@splinetool/runtime 1.9.31 → 1.9.32

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 CHANGED
@@ -3136,10 +3136,10 @@ 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 YG(n,t,e){let r=new up,i=new U,s=new U,o=new Ze,a=new hp({depthPacking:Tw}),l=new tw,c={},u=e.maxTextureSize,h={[Hn]:pi,[pi]:Hn,[fi]:fi},d=new it({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new U},radius:{value:4}},vertexShader:WG,fragmentShader:qG}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new _e;p.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Ut(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ay,this.render=function(S,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;let M=n.getRenderTarget(),b=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),C=n.state;C.setBlending(Jt),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let P=0,D=S.length;P<D;P++){let _=S[P],I=_.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",_,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;i.copy(I.mapSize);let L=I.getFrameExtents();if(i.multiply(L),s.copy(I.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/L.x),i.x=s.x*L.x,I.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/L.y),i.y=s.y*L.y,I.mapSize.y=s.y)),I.map===null){let V=this.type!==$f?{minFilter:Vt,magFilter:Vt}:{};I.map=new dt(i.x,i.y,V),I.map.texture.name=_.name+".shadowMap",I.camera.updateProjectionMatrix()}n.setRenderTarget(I.map),n.clear();let j=I.getViewportCount();for(let V=0;V<j;V++){let H=I.getViewport(V);o.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),C.viewport(o),I.updateMatrices(_,V),r=I.getFrustum(),x(w,A,I.camera,_,this.type)}I.isPointLightShadow!==!0&&this.type===$f&&y(I,A),I.needsUpdate=!1}g.needsUpdate=!1,n.setRenderTarget(M,b,T)};function y(S,w){let A=t.update(m);d.defines.VSM_SAMPLES!==S.blurSamples&&(d.defines.VSM_SAMPLES=S.blurSamples,f.defines.VSM_SAMPLES=S.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new dt(i.x,i.y)),d.uniforms.shadow_pass.value=S.map.texture,d.uniforms.resolution.value=S.mapSize,d.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(w,null,A,d,m,null),f.uniforms.shadow_pass.value=S.mapPass.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(w,null,A,f,m,null)}function v(S,w,A,M,b,T){let C=null,P=A.isPointLight===!0?S.customDistanceMaterial:S.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 D=C.uuid,_=w.uuid,I=c[D];I===void 0&&(I={},c[D]=I);let L=I[_];L===void 0&&(L=C.clone(),I[_]=L),C=L}return C.visible=w.visible,C.wireframe=w.wireframe,T===$f?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=M,C.farDistance=b),C}function x(S,w,A,M,b){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&b===$f)&&(!S.frustumCulled||r.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,S.matrixWorld);let P=t.update(S),D=S.material;if(Array.isArray(D)){let _=P.groups;for(let I=0,L=_.length;I<L;I++){let j=_[I],V=D[j.materialIndex];if(V&&V.visible){let H=v(S,V,M,A.near,A.far,b);n.renderBufferDirect(A,null,P,H,S,j)}}}else if(D.visible){let _=v(S,D,M,A.near,A.far,b);n.renderBufferDirect(A,null,P,_,S,null)}}let C=S.children;for(let P=0,D=C.length;P<D;P++)x(C[P],w,A,M,b)}}function XG(n,t,e){let r=e.isWebGL2;function i(){let Q=!1,ye=new Ze,Te=null,je=new Ze(0,0,0,0);return{setMask:function(He){Te!==He&&!Q&&(n.colorMask(He,He,He,He),Te=He)},setLocked:function(He){Q=He},setClear:function(He,_t,Fr,Vr,Zo){Zo===!0&&(He*=Vr,_t*=Vr,Fr*=Vr),ye.set(He,_t,Fr,Vr),je.equals(ye)===!1&&(n.clearColor(He,_t,Fr,Vr),je.copy(ye))},reset:function(){Q=!1,Te=null,je.set(-1,0,0,0)}}}function s(){let Q=!1,ye=null,Te=null,je=null;return{setTest:function(He){He?oe(2929):ie(2929)},setMask:function(He){ye!==He&&!Q&&(n.depthMask(He),ye=He)},setFunc:function(He){if(Te!==He){switch(He){case MF:n.depthFunc(512);break;case TF:n.depthFunc(519);break;case CF:n.depthFunc(513);break;case zS:n.depthFunc(515);break;case PF:n.depthFunc(514);break;case _F:n.depthFunc(518);break;case DF:n.depthFunc(516);break;case IF:n.depthFunc(517);break;default:n.depthFunc(515)}Te=He}},setLocked:function(He){Q=He},setClear:function(He){je!==He&&(n.clearDepth(He),je=He)},reset:function(){Q=!1,ye=null,Te=null,je=null}}}function o(){let Q=!1,ye=null,Te=null,je=null,He=null,_t=null,Fr=null,Vr=null,Zo=null;return{setTest:function(Tr){Q||(Tr?oe(2960):ie(2960))},setMask:function(Tr){ye!==Tr&&!Q&&(n.stencilMask(Tr),ye=Tr)},setFunc:function(Tr,es,Tn){(Te!==Tr||je!==es||He!==Tn)&&(n.stencilFunc(Tr,es,Tn),Te=Tr,je=es,He=Tn)},setOp:function(Tr,es,Tn){(_t!==Tr||Fr!==es||Vr!==Tn)&&(n.stencilOp(Tr,es,Tn),_t=Tr,Fr=es,Vr=Tn)},setLocked:function(Tr){Q=Tr},setClear:function(Tr){Zo!==Tr&&(n.clearStencil(Tr),Zo=Tr)},reset:function(){Q=!1,ye=null,Te=null,je=null,He=null,_t=null,Fr=null,Vr=null,Zo=null}}}let a=new i,l=new s,c=new o,u=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,S=null,w=null,A=null,M=null,b=null,T=!1,C=null,P=null,D=null,_=null,I=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 W=null,q={},K=n.getParameter(3088),G=n.getParameter(2978),Z=new Ze().fromArray(K),te=new Ze().fromArray(G);function $(Q,ye,Te){let je=new Uint8Array(4),He=n.createTexture();n.bindTexture(Q,He),n.texParameteri(Q,10241,9728),n.texParameteri(Q,10240,9728);for(let _t=0;_t<Te;_t++)n.texImage2D(ye+_t,0,6408,1,1,0,6408,5121,je);return He}let Y={};Y[3553]=$(3553,3553,1),Y[34067]=$(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),oe(2929),l.setFunc(zS),ke(!1),ze(dT),oe(2884),Ie(Jt);function oe(Q){d[Q]!==!0&&(n.enable(Q),d[Q]=!0)}function ie(Q){d[Q]!==!1&&(n.disable(Q),d[Q]=!1)}function re(Q,ye){return f[Q]!==ye?(n.bindFramebuffer(Q,ye),f[Q]=ye,r&&(Q===36009&&(f[36160]=ye),Q===36160&&(f[36009]=ye)),!0):!1}function J(Q,ye){let Te=m,je=!1;if(Q)if(Te=p.get(ye),Te===void 0&&(Te=[],p.set(ye,Te)),Q.isWebGLMultipleRenderTargets){let He=Q.texture;if(Te.length!==He.length||Te[0]!==36064){for(let _t=0,Fr=He.length;_t<Fr;_t++)Te[_t]=36064+_t;Te.length=He.length,je=!0}}else Te[0]!==36064&&(Te[0]=36064,je=!0);else Te[0]!==1029&&(Te[0]=1029,je=!0);je&&(e.isWebGL2?n.drawBuffers(Te):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Te))}function Ae(Q){return g!==Q?(n.useProgram(Q),g=Q,!0):!1}let xe={[Tu]:32774,[pF]:32778,[mF]:32779};if(r)xe[gT]=32775,xe[yT]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(xe[gT]=Q.MIN_EXT,xe[yT]=Q.MAX_EXT)}let de={[gF]:0,[yF]:1,[vF]:768,[HC]:770,[EF]:776,[wF]:774,[bF]:772,[xF]:769,[WC]:771,[AF]:775,[SF]:773};function Ie(Q,ye,Te,je,He,_t,Fr,Vr){if(Q===Jt){y===!0&&(ie(3042),y=!1);return}if(y===!1&&(oe(3042),y=!0),Q!==fF){if(Q!==v||Vr!==T){if((x!==Tu||A!==Tu)&&(n.blendEquation(32774),x=Tu,A=Tu),Vr)switch(Q){case Xa:n.blendFuncSeparate(1,771,1,771);break;case fT:n.blendFunc(1,1);break;case pT:n.blendFuncSeparate(0,769,0,1);break;case mT:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case Xa:n.blendFuncSeparate(770,771,1,771);break;case fT:n.blendFunc(770,1);break;case pT:n.blendFuncSeparate(0,769,0,1);break;case mT:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}S=null,w=null,M=null,b=null,v=Q,T=Vr}return}He=He||ye,_t=_t||Te,Fr=Fr||je,(ye!==x||He!==A)&&(n.blendEquationSeparate(xe[ye],xe[He]),x=ye,A=He),(Te!==S||je!==w||_t!==M||Fr!==b)&&(n.blendFuncSeparate(de[Te],de[je],de[_t],de[Fr]),S=Te,w=je,M=_t,b=Fr),v=Q,T=!1}function Ce(Q,ye){Q.side===fi?ie(2884):oe(2884);let Te=Q.side===pi;ye&&(Te=!Te),ke(Te),Q.blending===Xa&&Q.transparent===!1?Ie(Jt):Ie(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let je=Q.stencilWrite;c.setTest(je),je&&(c.setMask(Q.stencilWriteMask),c.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),c.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),Oe(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?oe(32926):ie(32926)}function ke(Q){C!==Q&&(Q?n.frontFace(2304):n.frontFace(2305),C=Q)}function ze(Q){Q!==uF?(oe(2884),Q!==P&&(Q===dT?n.cullFace(1029):Q===hF?n.cullFace(1028):n.cullFace(1032))):ie(2884),P=Q}function Ve(Q){Q!==D&&(j&&n.lineWidth(Q),D=Q)}function Oe(Q,ye,Te){Q?(oe(32823),(_!==ye||I!==Te)&&(n.polygonOffset(ye,Te),_=ye,I=Te)):ie(32823)}function Ye(Q){Q?oe(3089):ie(3089)}function F(Q){Q===void 0&&(Q=33984+L-1),W!==Q&&(n.activeTexture(Q),W=Q)}function N(Q,ye,Te){Te===void 0&&(W===null?Te=33984+L-1:Te=W);let je=q[Te];je===void 0&&(je={type:void 0,texture:void 0},q[Te]=je),(je.type!==Q||je.texture!==ye)&&(W!==Te&&(n.activeTexture(Te),W=Te),n.bindTexture(Q,ye||Y[Q]),je.type=Q,je.texture=ye)}function B(){let Q=q[W];Q!==void 0&&Q.type!==void 0&&(n.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ge(){try{n.compressedTexImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function me(){try{n.texSubImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Le(){try{n.texSubImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ne(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Re(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function nt(){try{n.texStorage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ge(){try{n.texImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Be(){try{n.texImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function et(Q){Z.equals(Q)===!1&&(n.scissor(Q.x,Q.y,Q.z,Q.w),Z.copy(Q))}function st(Q){te.equals(Q)===!1&&(n.viewport(Q.x,Q.y,Q.z,Q.w),te.copy(Q))}function Bt(Q,ye){let Te=h.get(ye);Te===void 0&&(Te=new WeakMap,h.set(ye,Te));let je=Te.get(Q);je===void 0&&(je=n.getUniformBlockIndex(ye,Q.name),Te.set(Q,je))}function dr(Q,ye){let je=h.get(ye).get(Q);u.get(ye)!==je&&(n.uniformBlockBinding(ye,je,Q.__bindingPointIndex),u.set(ye,je))}function Mr(){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={},W=null,q={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,S=null,w=null,A=null,M=null,b=null,T=!1,C=null,P=null,D=null,_=null,I=null,Z.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:Ae,setBlending:Ie,setMaterial:Ce,setFlipSided:ke,setCullFace:ze,setLineWidth:Ve,setPolygonOffset:Oe,setScissorTest:Ye,activeTexture:F,bindTexture:N,unbindTexture:B,compressedTexImage2D:ae,compressedTexImage3D:ge,texImage2D:Ge,texImage3D:Be,updateUBOMapping:Bt,uniformBlockBinding:dr,texStorage2D:pe,texStorage3D:nt,texSubImage2D:me,texSubImage3D:Le,compressedTexSubImage2D:Ne,compressedTexSubImage3D:Re,scissor:et,viewport:st,reset:Mr}}function QG(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),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(N,B){return y?new OffscreenCanvas(N,B):lp("canvas")}function x(N,B,ae,ge){let me=1;if((N.width>ge||N.height>ge)&&(me=ge/Math.max(N.width,N.height)),me<1||B===!0)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap){let Le=B?Zg:Math.floor,Ne=Le(me*N.width),Re=Le(me*N.height);m===void 0&&(m=v(Ne,Re));let pe=ae?v(Ne,Re):m;return pe.width=Ne,pe.height=Re,pe.getContext("2d").drawImage(N,0,0,Ne,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+Ne+"x"+Re+")."),pe}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),N;return N}function S(N){return qS(N.width)&&qS(N.height)}function w(N){return a?!1:N.wrapS!==Xt||N.wrapT!==Xt||N.minFilter!==Vt&&N.minFilter!==rt}function A(N,B){return N.generateMipmaps&&B&&N.minFilter!==Vt&&N.minFilter!==rt}function M(N){n.generateMipmap(N)}function b(N,B,ae,ge,me=!1){if(a===!1)return B;if(N!==null){if(n[N]!==void 0)return n[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let Le=B;return B===6403&&(ae===5126&&(Le=33326),ae===5131&&(Le=33325),ae===5121&&(Le=33321)),B===33319&&(ae===5126&&(Le=33328),ae===5131&&(Le=33327),ae===5121&&(Le=33323)),B===6408&&(ae===5126&&(Le=34836),ae===5131&&(Le=34842),ae===5121&&(Le=ge===at&&me===!1?35907:32856),ae===32819&&(Le=32854),ae===32820&&(Le=32855)),(Le===33325||Le===33326||Le===33327||Le===33328||Le===34842||Le===34836)&&t.get("EXT_color_buffer_float"),Le}function T(N,B,ae){return A(N,ae)===!0||N.isFramebufferTexture&&N.minFilter!==Vt&&N.minFilter!==rt?Math.log2(Math.max(B.width,B.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?B.mipmaps.length:1}function C(N){return N===Vt||N===vT||N===iS?9728:9729}function P(N){let B=N.target;B.removeEventListener("dispose",P),_(B),B.isVideoTexture&&p.delete(B)}function D(N){let B=N.target;B.removeEventListener("dispose",D),L(B)}function _(N){let B=r.get(N);if(B.__webglInit===void 0)return;let ae=N.source,ge=g.get(ae);if(ge){let me=ge[B.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(N),Object.keys(ge).length===0&&g.delete(ae)}r.remove(N)}function I(N){let B=r.get(N);n.deleteTexture(B.__webglTexture);let ae=N.source,ge=g.get(ae);delete ge[B.__cacheKey],o.memory.textures--}function L(N){let B=N.texture,ae=r.get(N),ge=r.get(B);if(ge.__webglTexture!==void 0&&(n.deleteTexture(ge.__webglTexture),o.memory.textures--),N.depthTexture&&N.depthTexture.dispose(),N.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(N.isWebGLMultipleRenderTargets)for(let me=0,Le=B.length;me<Le;me++){let Ne=r.get(B[me]);Ne.__webglTexture&&(n.deleteTexture(Ne.__webglTexture),o.memory.textures--),r.remove(B[me])}r.remove(B),r.remove(N)}let j=0;function V(){j=0}function H(){let N=j;return N>=l&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+l),j+=1,N}function W(N){let B=[];return B.push(N.wrapS),B.push(N.wrapT),B.push(N.wrapR||0),B.push(N.magFilter),B.push(N.minFilter),B.push(N.anisotropy),B.push(N.internalFormat),B.push(N.format),B.push(N.type),B.push(N.generateMipmaps),B.push(N.premultiplyAlpha),B.push(N.flipY),B.push(N.unpackAlignment),B.push(N.encoding),B.join()}function q(N,B){let ae=r.get(N);if(N.isVideoTexture&&Ye(N),N.isRenderTargetTexture===!1&&N.version>0&&ae.__version!==N.version){let ge=N.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ae,N,B);return}}e.bindTexture(3553,ae.__webglTexture,33984+B)}function K(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(35866,ae.__webglTexture,33984+B)}function G(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(32879,ae.__webglTexture,33984+B)}function Z(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){re(ae,N,B);return}e.bindTexture(34067,ae.__webglTexture,33984+B)}let te={[Os]:10497,[Xt]:33071,[jS]:33648},$={[Vt]:9728,[vT]:9984,[iS]:9986,[rt]:9729,[UF]:9985,[fc]:9987};function Y(N,B,ae){if(ae?(n.texParameteri(N,10242,te[B.wrapS]),n.texParameteri(N,10243,te[B.wrapT]),(N===32879||N===35866)&&n.texParameteri(N,32882,te[B.wrapR]),n.texParameteri(N,10240,$[B.magFilter]),n.texParameteri(N,10241,$[B.minFilter])):(n.texParameteri(N,10242,33071),n.texParameteri(N,10243,33071),(N===32879||N===35866)&&n.texParameteri(N,32882,33071),(B.wrapS!==Xt||B.wrapT!==Xt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(N,10240,C(B.magFilter)),n.texParameteri(N,10241,C(B.minFilter)),B.minFilter!==Vt&&B.minFilter!==rt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let ge=t.get("EXT_texture_filter_anisotropic");if(B.magFilter===Vt||B.minFilter!==iS&&B.minFilter!==fc||B.type===br&&t.has("OES_texture_float_linear")===!1||a===!1&&B.type===Wn&&t.has("OES_texture_half_float_linear")===!1)return;(B.anisotropy>1||r.get(B).__currentAnisotropy)&&(n.texParameterf(N,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(B.anisotropy,i.getMaxAnisotropy())),r.get(B).__currentAnisotropy=B.anisotropy)}}function oe(N,B){let ae=!1;N.__webglInit===void 0&&(N.__webglInit=!0,B.addEventListener("dispose",P));let ge=B.source,me=g.get(ge);me===void 0&&(me={},g.set(ge,me));let Le=W(B);if(Le!==N.__cacheKey){me[Le]===void 0&&(me[Le]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,ae=!0),me[Le].usedTimes++;let Ne=me[N.__cacheKey];Ne!==void 0&&(me[N.__cacheKey].usedTimes--,Ne.usedTimes===0&&I(B)),N.__cacheKey=Le,N.__webglTexture=me[Le].texture}return ae}function ie(N,B,ae){let ge=3553;(B.isDataArrayTexture||B.isCompressedArrayTexture)&&(ge=35866),B.isData3DTexture&&(ge=32879);let me=oe(N,B),Le=B.source;e.bindTexture(ge,N.__webglTexture,33984+ae);let Ne=r.get(Le);if(Le.version!==Ne.__version||me===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,B.flipY),n.pixelStorei(37441,B.premultiplyAlpha),n.pixelStorei(3317,B.unpackAlignment),n.pixelStorei(37443,0);let Re=w(B)&&S(B.image)===!1,pe=x(B.image,Re,!1,u);pe=F(B,pe);let nt=S(pe)||a,Ge=s.convert(B.format,B.encoding),Be=s.convert(B.type),et=b(B.internalFormat,Ge,Be,B.encoding,B.isVideoTexture);Y(ge,B,nt);let st,Bt=B.mipmaps,dr=a&&B.isVideoTexture!==!0,Mr=Ne.__version===void 0||me===!0,Q=T(B,pe,nt);if(B.isDepthTexture)et=6402,a?B.type===br?et=36012:B.type===Ds?et=33190:B.type===Qa?et=35056:et=33189:B.type===br&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),B.format===hc&&et===6402&&B.type!==XC&&B.type!==Ds&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),B.type=Ds,Be=s.convert(B.type)),B.format===Ja&&et===6402&&(et=34041,B.type!==Qa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),B.type=Qa,Be=s.convert(B.type))),Mr&&(dr?e.texStorage2D(3553,1,et,pe.width,pe.height):e.texImage2D(3553,0,et,pe.width,pe.height,0,Ge,Be,null));else if(B.isDataTexture)if(Bt.length>0&&nt){dr&&Mr&&e.texStorage2D(3553,Q,et,Bt[0].width,Bt[0].height);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],dr?e.texSubImage2D(3553,ye,0,0,st.width,st.height,Ge,Be,st.data):e.texImage2D(3553,ye,et,st.width,st.height,0,Ge,Be,st.data);B.generateMipmaps=!1}else dr?(Mr&&e.texStorage2D(3553,Q,et,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,pe.width,pe.height,Ge,Be,pe.data)):e.texImage2D(3553,0,et,pe.width,pe.height,0,Ge,Be,pe.data);else if(B.isCompressedTexture)if(B.isCompressedArrayTexture){dr&&Mr&&e.texStorage3D(35866,Q,et,Bt[0].width,Bt[0].height,pe.depth);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],B.format!==qr?Ge!==null?dr?e.compressedTexSubImage3D(35866,ye,0,0,0,st.width,st.height,pe.depth,Ge,st.data,0,0):e.compressedTexImage3D(35866,ye,et,st.width,st.height,pe.depth,0,st.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):dr?e.texSubImage3D(35866,ye,0,0,0,st.width,st.height,pe.depth,Ge,Be,st.data):e.texImage3D(35866,ye,et,st.width,st.height,pe.depth,0,Ge,Be,st.data)}else{dr&&Mr&&e.texStorage2D(3553,Q,et,Bt[0].width,Bt[0].height);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],B.format!==qr?Ge!==null?dr?e.compressedTexSubImage2D(3553,ye,0,0,st.width,st.height,Ge,st.data):e.compressedTexImage2D(3553,ye,et,st.width,st.height,0,st.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):dr?e.texSubImage2D(3553,ye,0,0,st.width,st.height,Ge,Be,st.data):e.texImage2D(3553,ye,et,st.width,st.height,0,Ge,Be,st.data)}else if(B.isDataArrayTexture)dr?(Mr&&e.texStorage3D(35866,Q,et,pe.width,pe.height,pe.depth),e.texSubImage3D(35866,0,0,0,0,pe.width,pe.height,pe.depth,Ge,Be,pe.data)):e.texImage3D(35866,0,et,pe.width,pe.height,pe.depth,0,Ge,Be,pe.data);else if(B.isData3DTexture)dr?(Mr&&e.texStorage3D(32879,Q,et,pe.width,pe.height,pe.depth),e.texSubImage3D(32879,0,0,0,0,pe.width,pe.height,pe.depth,Ge,Be,pe.data)):e.texImage3D(32879,0,et,pe.width,pe.height,pe.depth,0,Ge,Be,pe.data);else if(B.isFramebufferTexture){if(Mr)if(dr)e.texStorage2D(3553,Q,et,pe.width,pe.height);else{let ye=pe.width,Te=pe.height;for(let je=0;je<Q;je++)e.texImage2D(3553,je,et,ye,Te,0,Ge,Be,null),ye>>=1,Te>>=1}}else if(Bt.length>0&&nt){dr&&Mr&&e.texStorage2D(3553,Q,et,Bt[0].width,Bt[0].height);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],dr?e.texSubImage2D(3553,ye,0,0,Ge,Be,st):e.texImage2D(3553,ye,et,Ge,Be,st);B.generateMipmaps=!1}else dr?(Mr&&e.texStorage2D(3553,Q,et,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,Ge,Be,pe)):e.texImage2D(3553,0,et,Ge,Be,pe);A(B,nt)&&M(ge),Ne.__version=Le.version,B.onUpdate&&B.onUpdate(B)}N.__version=B.version}function re(N,B,ae){if(B.image.length!==6)return;let ge=oe(N,B),me=B.source;e.bindTexture(34067,N.__webglTexture,33984+ae);let Le=r.get(me);if(me.version!==Le.__version||ge===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,B.flipY),n.pixelStorei(37441,B.premultiplyAlpha),n.pixelStorei(3317,B.unpackAlignment),n.pixelStorei(37443,0);let Ne=B.isCompressedTexture||B.image[0].isCompressedTexture,Re=B.image[0]&&B.image[0].isDataTexture,pe=[];for(let ye=0;ye<6;ye++)!Ne&&!Re?pe[ye]=x(B.image[ye],!1,!0,c):pe[ye]=Re?B.image[ye].image:B.image[ye],pe[ye]=F(B,pe[ye]);let nt=pe[0],Ge=S(nt)||a,Be=s.convert(B.format,B.encoding),et=s.convert(B.type),st=b(B.internalFormat,Be,et,B.encoding),Bt=a&&B.isVideoTexture!==!0,dr=Le.__version===void 0||ge===!0,Mr=T(B,nt,Ge);Y(34067,B,Ge);let Q;if(Ne){Bt&&dr&&e.texStorage2D(34067,Mr,st,nt.width,nt.height);for(let ye=0;ye<6;ye++){Q=pe[ye].mipmaps;for(let Te=0;Te<Q.length;Te++){let je=Q[Te];B.format!==qr?Be!==null?Bt?e.compressedTexSubImage2D(34069+ye,Te,0,0,je.width,je.height,Be,je.data):e.compressedTexImage2D(34069+ye,Te,st,je.width,je.height,0,je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Bt?e.texSubImage2D(34069+ye,Te,0,0,je.width,je.height,Be,et,je.data):e.texImage2D(34069+ye,Te,st,je.width,je.height,0,Be,et,je.data)}}}else{Q=B.mipmaps,Bt&&dr&&(Q.length>0&&Mr++,e.texStorage2D(34067,Mr,st,pe[0].width,pe[0].height));for(let ye=0;ye<6;ye++)if(Re){Bt?e.texSubImage2D(34069+ye,0,0,0,pe[ye].width,pe[ye].height,Be,et,pe[ye].data):e.texImage2D(34069+ye,0,st,pe[ye].width,pe[ye].height,0,Be,et,pe[ye].data);for(let Te=0;Te<Q.length;Te++){let He=Q[Te].image[ye].image;Bt?e.texSubImage2D(34069+ye,Te+1,0,0,He.width,He.height,Be,et,He.data):e.texImage2D(34069+ye,Te+1,st,He.width,He.height,0,Be,et,He.data)}}else{Bt?e.texSubImage2D(34069+ye,0,0,0,Be,et,pe[ye]):e.texImage2D(34069+ye,0,st,Be,et,pe[ye]);for(let Te=0;Te<Q.length;Te++){let je=Q[Te];Bt?e.texSubImage2D(34069+ye,Te+1,0,0,Be,et,je.image[ye]):e.texImage2D(34069+ye,Te+1,st,Be,et,je.image[ye])}}}A(B,Ge)&&M(34067),Le.__version=me.version,B.onUpdate&&B.onUpdate(B)}N.__version=B.version}function J(N,B,ae,ge,me){let Le=s.convert(ae.format,ae.encoding),Ne=s.convert(ae.type),Re=b(ae.internalFormat,Le,Ne,ae.encoding);r.get(B).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Re,B.width,B.height,B.depth,0,Le,Ne,null):e.texImage2D(me,0,Re,B.width,B.height,0,Le,Ne,null)),e.bindFramebuffer(36160,N),Oe(B)?d.framebufferTexture2DMultisampleEXT(36160,ge,me,r.get(ae).__webglTexture,0,Ve(B)):(me===3553||me>=34069&&me<=34074)&&n.framebufferTexture2D(36160,ge,me,r.get(ae).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ae(N,B,ae){if(n.bindRenderbuffer(36161,N),B.depthBuffer&&!B.stencilBuffer){let ge=33189;if(ae||Oe(B)){let me=B.depthTexture;me&&me.isDepthTexture&&(me.type===br?ge=36012:me.type===Ds&&(ge=33190));let Le=Ve(B);Oe(B)?d.renderbufferStorageMultisampleEXT(36161,Le,ge,B.width,B.height):n.renderbufferStorageMultisample(36161,Le,ge,B.width,B.height)}else n.renderbufferStorage(36161,ge,B.width,B.height);n.framebufferRenderbuffer(36160,36096,36161,N)}else if(B.depthBuffer&&B.stencilBuffer){let ge=Ve(B);ae&&Oe(B)===!1?n.renderbufferStorageMultisample(36161,ge,35056,B.width,B.height):Oe(B)?d.renderbufferStorageMultisampleEXT(36161,ge,35056,B.width,B.height):n.renderbufferStorage(36161,34041,B.width,B.height),n.framebufferRenderbuffer(36160,33306,36161,N)}else{let ge=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let me=0;me<ge.length;me++){let Le=ge[me],Ne=s.convert(Le.format,Le.encoding),Re=s.convert(Le.type),pe=b(Le.internalFormat,Ne,Re,Le.encoding),nt=Ve(B);ae&&Oe(B)===!1?n.renderbufferStorageMultisample(36161,nt,pe,B.width,B.height):Oe(B)?d.renderbufferStorageMultisampleEXT(36161,nt,pe,B.width,B.height):n.renderbufferStorage(36161,pe,B.width,B.height)}}n.bindRenderbuffer(36161,null)}function xe(N,B){if(B&&B.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,N),!(B.depthTexture&&B.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(B.depthTexture).__webglTexture||B.depthTexture.image.width!==B.width||B.depthTexture.image.height!==B.height)&&(B.depthTexture.image.width=B.width,B.depthTexture.image.height=B.height,B.depthTexture.needsUpdate=!0),q(B.depthTexture,0);let ge=r.get(B.depthTexture).__webglTexture,me=Ve(B);if(B.depthTexture.format===hc)Oe(B)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ge,0,me):n.framebufferTexture2D(36160,36096,3553,ge,0);else if(B.depthTexture.format===Ja)Oe(B)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ge,0,me):n.framebufferTexture2D(36160,33306,3553,ge,0);else throw new Error("Unknown depthTexture format")}function de(N){let B=r.get(N),ae=N.isWebGLCubeRenderTarget===!0;if(N.depthTexture&&!B.__autoAllocateDepthBuffer){if(ae)throw new Error("target.depthTexture not supported in Cube render targets");xe(B.__webglFramebuffer,N)}else if(ae){B.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)e.bindFramebuffer(36160,B.__webglFramebuffer[ge]),B.__webglDepthbuffer[ge]=n.createRenderbuffer(),Ae(B.__webglDepthbuffer[ge],N,!1)}else e.bindFramebuffer(36160,B.__webglFramebuffer),B.__webglDepthbuffer=n.createRenderbuffer(),Ae(B.__webglDepthbuffer,N,!1);e.bindFramebuffer(36160,null)}function Ie(N,B,ae){let ge=r.get(N);B!==void 0&&J(ge.__webglFramebuffer,N,N.texture,36064,3553),ae!==void 0&&de(N)}function Ce(N){let B=N.texture,ae=r.get(N),ge=r.get(B);N.addEventListener("dispose",D),N.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=n.createTexture()),ge.__version=B.version,o.memory.textures++);let me=N.isWebGLCubeRenderTarget===!0,Le=N.isWebGLMultipleRenderTargets===!0,Ne=S(N)||a;if(me){ae.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)ae.__webglFramebuffer[Re]=n.createFramebuffer()}else{if(ae.__webglFramebuffer=n.createFramebuffer(),Le)if(i.drawBuffers){let Re=N.texture;for(let pe=0,nt=Re.length;pe<nt;pe++){let Ge=r.get(Re[pe]);Ge.__webglTexture===void 0&&(Ge.__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&&N.samples>0&&Oe(N)===!1){let Re=Le?B:[B];ae.__webglMultisampledFramebuffer=n.createFramebuffer(),ae.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ae.__webglMultisampledFramebuffer);for(let pe=0;pe<Re.length;pe++){let nt=Re[pe];ae.__webglColorRenderbuffer[pe]=n.createRenderbuffer(),n.bindRenderbuffer(36161,ae.__webglColorRenderbuffer[pe]);let Ge=s.convert(nt.format,nt.encoding),Be=s.convert(nt.type),et=b(nt.internalFormat,Ge,Be,nt.encoding,N.isXRRenderTarget===!0),st=Ve(N);n.renderbufferStorageMultisample(36161,st,et,N.width,N.height),n.framebufferRenderbuffer(36160,36064+pe,36161,ae.__webglColorRenderbuffer[pe])}n.bindRenderbuffer(36161,null),N.depthBuffer&&(ae.__webglDepthRenderbuffer=n.createRenderbuffer(),Ae(ae.__webglDepthRenderbuffer,N,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ge.__webglTexture),Y(34067,B,Ne);for(let Re=0;Re<6;Re++)J(ae.__webglFramebuffer[Re],N,B,36064,34069+Re);A(B,Ne)&&M(34067),e.unbindTexture()}else if(Le){let Re=N.texture;for(let pe=0,nt=Re.length;pe<nt;pe++){let Ge=Re[pe],Be=r.get(Ge);e.bindTexture(3553,Be.__webglTexture),Y(3553,Ge,Ne),J(ae.__webglFramebuffer,N,Ge,36064+pe,3553),A(Ge,Ne)&&M(3553)}e.unbindTexture()}else{let Re=3553;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(a?Re=N.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Re,ge.__webglTexture),Y(Re,B,Ne),J(ae.__webglFramebuffer,N,B,36064,Re),A(B,Ne)&&M(Re),e.unbindTexture()}N.depthBuffer&&de(N)}function ke(N){let B=S(N)||a,ae=N.isWebGLMultipleRenderTargets===!0?N.texture:[N.texture];for(let ge=0,me=ae.length;ge<me;ge++){let Le=ae[ge];if(A(Le,B)){let Ne=N.isWebGLCubeRenderTarget?34067:3553,Re=r.get(Le).__webglTexture;e.bindTexture(Ne,Re),M(Ne),e.unbindTexture()}}}function ze(N){if(a&&N.samples>0&&Oe(N)===!1){let B=N.isWebGLMultipleRenderTargets?N.texture:[N.texture],ae=N.width,ge=N.height,me=16384,Le=[],Ne=N.stencilBuffer?33306:36096,Re=r.get(N),pe=N.isWebGLMultipleRenderTargets===!0;if(pe)for(let nt=0;nt<B.length;nt++)e.bindFramebuffer(36160,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,null),e.bindFramebuffer(36160,Re.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,null,0);e.bindFramebuffer(36008,Re.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Re.__webglFramebuffer);for(let nt=0;nt<B.length;nt++){Le.push(36064+nt),N.depthBuffer&&Le.push(Ne);let Ge=Re.__ignoreDepthValues!==void 0?Re.__ignoreDepthValues:!1;if(Ge===!1&&(N.depthBuffer&&(me|=256),N.stencilBuffer&&(me|=1024)),pe&&n.framebufferRenderbuffer(36008,36064,36161,Re.__webglColorRenderbuffer[nt]),Ge===!0&&(n.invalidateFramebuffer(36008,[Ne]),n.invalidateFramebuffer(36009,[Ne])),pe){let Be=r.get(B[nt]).__webglTexture;n.framebufferTexture2D(36009,36064,3553,Be,0)}n.blitFramebuffer(0,0,ae,ge,0,0,ae,ge,me,9728),f&&n.invalidateFramebuffer(36008,Le)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),pe)for(let nt=0;nt<B.length;nt++){e.bindFramebuffer(36160,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,Re.__webglColorRenderbuffer[nt]);let Ge=r.get(B[nt]).__webglTexture;e.bindFramebuffer(36160,Re.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,Ge,0)}e.bindFramebuffer(36009,Re.__webglMultisampledFramebuffer)}}function Ve(N){return Math.min(h,N.samples)}function Oe(N){let B=r.get(N);return a&&N.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&B.__useRenderToTexture!==!1}function Ye(N){let B=o.render.frame;p.get(N)!==B&&(p.set(N,B),N.update())}function F(N,B){let ae=N.encoding,ge=N.format,me=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||N.format===WS||ae!==mn&&(ae===at?a===!1?t.has("EXT_sRGB")===!0&&ge===qr?(N.format=WS,N.minFilter=rt,N.generateMipmaps=!1):B=Jg.sRGBToLinear(B):(ge!==qr||me!==_r)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ae)),B}this.allocateTextureUnit=H,this.resetTextureUnits=V,this.setTexture2D=q,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=Z,this.rebindTextures=Ie,this.setupRenderTarget=Ce,this.updateRenderTargetMipmap=ke,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Oe}function KG(n,t,e){let r=e.isWebGL2;function i(s,o=null){let a;if(s===_r)return 5121;if(s===jF)return 32819;if(s===HF)return 32820;if(s===zF)return 5120;if(s===kF)return 5122;if(s===XC)return 5123;if(s===GF)return 5124;if(s===Ds)return 5125;if(s===br)return 5126;if(s===Wn)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===WF)return 6406;if(s===qr)return 6408;if(s===qF)return 6409;if(s===YF)return 6410;if(s===hc)return 6402;if(s===Ja)return 34041;if(s===WS)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===XF)return 6403;if(s===QF)return 36244;if(s===Ju)return 33319;if(s===KF)return 33320;if(s===ww)return 36249;if(s===nS||s===sS||s===oS||s===aS)if(o===at)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===nS)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===sS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===oS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===aS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===nS)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===sS)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===oS)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===aS)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===xT||s===bT||s===ST||s===wT)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===xT)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===bT)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===ST)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===wT)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===ZF)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===AT||s===ET)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===AT)return o===at?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===ET)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===MT||s===TT||s===CT||s===PT||s===_T||s===DT||s===IT||s===OT||s===RT||s===LT||s===BT||s===NT||s===FT||s===VT)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===MT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===TT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===CT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===PT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===_T)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===DT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===IT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===OT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===RT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===LT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===BT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===NT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===FT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===VT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===lS)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===lS)return o===at?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===JF||s===UT||s===zT||s===kT)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===lS)return a.COMPRESSED_RED_RGTC1_EXT;if(s===UT)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===zT)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===kT)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Qa?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 rw=class extends $r{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},sn=class extends Mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},ZG={type:"move"},ip=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sn,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 sn,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 sn,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 m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(c,m);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,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(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(ZG)))}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 sn;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},ns=class extends $t{constructor(t,e,r,i,s,o,a,l,c,u){if(u=u!==void 0?u:hc,u!==hc&&u!==Ja)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===hc&&(r=Ds),r===void 0&&u===Ja&&(r=Qa),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}},iw=class extends pr{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,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],S=new Set,w=new Map,A=new $r;A.layers.enable(1),A.viewport=new Ze;let M=new $r;M.layers.enable(2),M.viewport=new Ze;let b=[A,M],T=new rw;T.layers.enable(1),T.layers.enable(2);let C=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let Z=v[G];return Z===void 0&&(Z=new ip,v[G]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(G){let Z=v[G];return Z===void 0&&(Z=new ip,v[G]=Z),Z.getGripSpace()},this.getHand=function(G){let Z=v[G];return Z===void 0&&(Z=new ip,v[G]=Z),Z.getHandSpace()};function D(G){let Z=x.indexOf(G.inputSource);if(Z===-1)return;let te=v[Z];te!==void 0&&te.dispatchEvent({type:G.type,data:G.inputSource})}function _(){i.removeEventListener("select",D),i.removeEventListener("selectstart",D),i.removeEventListener("selectend",D),i.removeEventListener("squeeze",D),i.removeEventListener("squeezestart",D),i.removeEventListener("squeezeend",D),i.removeEventListener("end",_),i.removeEventListener("inputsourceschange",I);for(let G=0;G<v.length;G++){let Z=x[G];Z!==null&&(x[G]=null,v[G].disconnect(Z))}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(G){s=G,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(G){c=G},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(G){if(i=G,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",D),i.addEventListener("selectstart",D),i.addEventListener("selectend",D),i.addEventListener("squeeze",D),i.addEventListener("squeezestart",D),i.addEventListener("squeezeend",D),i.addEventListener("end",_),i.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Z={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,Z),i.updateRenderState({baseLayer:f}),y=new dt(f.framebufferWidth,f.framebufferHeight,{format:qr,type:_r,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let Z=null,te=null,$=null;m.depth&&($=m.stencil?35056:33190,Z=m.stencil?Ja:hc,te=m.stencil?Qa:Ds);let Y={colorFormat:32856,depthFormat:$,scaleFactor:s};h=new XRWebGLBinding(i,e),d=h.createProjectionLayer(Y),i.updateRenderState({layers:[d]}),y=new dt(d.textureWidth,d.textureHeight,{format:qr,type:_r,depthTexture:new ns(d.textureWidth,d.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.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 I(G){for(let Z=0;Z<G.removed.length;Z++){let te=G.removed[Z],$=x.indexOf(te);$>=0&&(x[$]=null,v[$].disconnect(te))}for(let Z=0;Z<G.added.length;Z++){let te=G.added[Z],$=x.indexOf(te);if($===-1){for(let oe=0;oe<v.length;oe++)if(oe>=x.length){x.push(te),$=oe;break}else if(x[oe]===null){x[oe]=te,$=oe;break}if($===-1)break}let Y=v[$];Y&&Y.connect(te)}}let L=new E,j=new E;function V(G,Z,te){L.setFromMatrixPosition(Z.matrixWorld),j.setFromMatrixPosition(te.matrixWorld);let $=L.distanceTo(j),Y=Z.projectionMatrix.elements,oe=te.projectionMatrix.elements,ie=Y[14]/(Y[10]-1),re=Y[14]/(Y[10]+1),J=(Y[9]+1)/Y[5],Ae=(Y[9]-1)/Y[5],xe=(Y[8]-1)/Y[0],de=(oe[8]+1)/oe[0],Ie=ie*xe,Ce=ie*de,ke=$/(-xe+de),ze=ke*-xe;Z.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(ze),G.translateZ(ke),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Ve=ie+ke,Oe=re+ke,Ye=Ie-ze,F=Ce+($-ze),N=J*re/Oe*Ve,B=Ae*re/Oe*Ve;G.projectionMatrix.makePerspective(Ye,F,N,B,Ve,Oe)}function H(G,Z){Z===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(Z.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(i===null)return;T.near=M.near=A.near=G.near,T.far=M.far=A.far=G.far,(C!==T.near||P!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),C=T.near,P=T.far);let Z=G.parent,te=T.cameras;H(T,Z);for(let Y=0;Y<te.length;Y++)H(te[Y],Z);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),G.matrix.copy(T.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let $=G.children;for(let Y=0,oe=$.length;Y<oe;Y++)$[Y].updateMatrixWorld(!0);te.length===2?V(T,A,M):T.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(G){l=G,d!==null&&(d.fixedFoveation=G),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=G)},this.getPlanes=function(){return S};let W=null;function q(G,Z){if(u=Z.getViewerPose(c||o),p=Z,u!==null){let te=u.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let $=!1;te.length!==T.cameras.length&&(T.cameras.length=0,$=!0);for(let Y=0;Y<te.length;Y++){let oe=te[Y],ie=null;if(f!==null)ie=f.getViewport(oe);else{let J=h.getViewSubImage(d,oe);ie=J.viewport,Y===0&&(t.setRenderTargetTextures(y,J.colorTexture,d.ignoreDepthValues?void 0:J.depthStencilTexture),t.setRenderTarget(y))}let re=b[Y];re===void 0&&(re=new $r,re.layers.enable(Y),re.viewport=new Ze,b[Y]=re),re.matrix.fromArray(oe.transform.matrix),re.projectionMatrix.fromArray(oe.projectionMatrix),re.viewport.set(ie.x,ie.y,ie.width,ie.height),Y===0&&T.matrix.copy(re.matrix),$===!0&&T.cameras.push(re)}}for(let te=0;te<v.length;te++){let $=x[te],Y=v[te];$!==null&&Y!==void 0&&Y.update($,Z,c||o)}if(W&&W(G,Z),Z.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:Z.detectedPlanes});let te=null;for(let $ of S)Z.detectedPlanes.has($)||(te===null&&(te=[]),te.push($));if(te!==null)for(let $ of te)S.delete($),w.delete($),r.dispatchEvent({type:"planeremoved",data:$});for(let $ of Z.detectedPlanes)if(!S.has($))S.add($),w.set($,Z.lastChangedTime),r.dispatchEvent({type:"planeadded",data:$});else{let Y=w.get($);$.lastChangedTime>Y&&(w.set($,$.lastChangedTime),r.dispatchEvent({type:"planechanged",data:$}))}}p=null}let K=new eP;K.setAnimationLoop(q),this.setAnimationLoop=function(G){W=G},this.dispose=function(){}}};function JG(n,t){function e(m,g){g.color.getRGB(m.fogColor.value,$C(n)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(m,g):g.isMeshToonMaterial?(i(m,g),u(m,g)):g.isMeshPhongMaterial?(i(m,g),c(m,g)):g.isMeshStandardMaterial?(i(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(i(m,g),f(m,g)):g.isMeshDepthMaterial?i(m,g):g.isMeshDistanceMaterial?(i(m,g),p(m,g)):g.isMeshNormalMaterial?i(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===pi&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===pi&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let S=n.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*S}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function c(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===pi&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function $G(n,t,e,r){let i={},s={},o=[],a=e.isWebGL2?n.getParameter(35375):0;function l(v,x){let S=x.program;r.uniformBlockBinding(v,S)}function c(v,x){let S=i[v.id];S===void 0&&(p(v),S=u(v),i[v.id]=S,v.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(v,w);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function u(v){let x=h();v.__bindingPointIndex=x;let S=n.createBuffer(),w=v.__size,A=v.usage;return n.bindBuffer(35345,S),n.bufferData(35345,w,A),n.bindBuffer(35345,null),n.bindBufferBase(35345,x,S),S}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=i[v.id],S=v.uniforms,w=v.__cache;n.bindBuffer(35345,x);for(let A=0,M=S.length;A<M;A++){let b=S[A];if(f(b,A,w)===!0){let T=b.__offset,C=Array.isArray(b.value)?b.value:[b.value],P=0;for(let D=0;D<C.length;D++){let _=C[D],I=m(_);typeof _=="number"?(b.__data[0]=_,n.bufferSubData(35345,T+P,b.__data)):_.isMatrix3?(b.__data[0]=_.elements[0],b.__data[1]=_.elements[1],b.__data[2]=_.elements[2],b.__data[3]=_.elements[0],b.__data[4]=_.elements[3],b.__data[5]=_.elements[4],b.__data[6]=_.elements[5],b.__data[7]=_.elements[0],b.__data[8]=_.elements[6],b.__data[9]=_.elements[7],b.__data[10]=_.elements[8],b.__data[11]=_.elements[0]):(_.toArray(b.__data,P),P+=I.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(35345,T,b.__data)}}n.bindBuffer(35345,null)}function f(v,x,S){let w=v.value;if(S[x]===void 0){if(typeof w=="number")S[x]=w;else{let A=Array.isArray(w)?w:[w],M=[];for(let b=0;b<A.length;b++)M.push(A[b].clone());S[x]=M}return!0}else if(typeof w=="number"){if(S[x]!==w)return S[x]=w,!0}else{let A=Array.isArray(S[x])?S[x]:[S[x]],M=Array.isArray(w)?w:[w];for(let b=0;b<A.length;b++){let T=A[b];if(T.equals(M[b])===!1)return T.copy(M[b]),!0}}return!1}function p(v){let x=v.uniforms,S=0,w=16,A=0;for(let M=0,b=x.length;M<b;M++){let T=x[M],C={boundary:0,storage:0},P=Array.isArray(T.value)?T.value:[T.value];for(let D=0,_=P.length;D<_;D++){let I=P[D],L=m(I);C.boundary+=L.boundary,C.storage+=L.storage}if(T.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=S,M>0){A=S%w;let D=w-A;A!==0&&D-C.boundary<0&&(S+=w-A,T.__offset=S)}S+=C.storage}return A=S%w,A>0&&(S+=w-A),v.__size=S,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),n.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)n.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:c,dispose:y}}function e4(){let n=lp("canvas");return n.style.display="block",n}function _w(n={}){this.isWebGLRenderer=!0;let t=n.canvas!==void 0?n.canvas:e4(),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=[],p=[];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=mn,this.physicallyCorrectLights=!1,this.toneMapping=Is,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,S=-1,w=null,A=new Ze,M=new Ze,b=null,T=t.width,C=t.height,P=1,D=null,_=null,I=new Ze(0,0,T,C),L=new Ze(0,0,T,C),j=!1,V=new up,H=!1,W=!1,q=null,K=new ue,G=new U,Z=new E,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function $(){return x===null?P:1}let Y=e;function oe(k,ce){for(let ve=0;ve<k.length;ve++){let se=k[ve],be=t.getContext(se,ce);if(be!==null)return be}return null}try{let k={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${ca}`),t.addEventListener("webglcontextlost",et,!1),t.addEventListener("webglcontextrestored",st,!1),t.addEventListener("webglcontextcreationerror",Bt,!1),Y===null){let ce=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ce.shift(),Y=oe(ce,k),Y===null)throw oe(ce)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}Y.getShaderPrecisionFormat===void 0&&(Y.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let ie,re,J,Ae,xe,de,Ie,Ce,ke,ze,Ve,Oe,Ye,F,N,B,ae,ge,me,Le,Ne,Re,pe,nt;function Ge(){ie=new Sk(Y),re=new mk(Y,ie,n),ie.init(re),Re=new KG(Y,ie,re),J=new XG(Y,ie,re),Ae=new Ek,xe=new NG,de=new QG(Y,ie,J,xe,re,Re,Ae),Ie=new yk(m),Ce=new bk(m),ke=new RV(Y,re),pe=new fk(Y,ie,ke,re),ze=new wk(Y,ke,Ae,pe),Ve=new Pk(Y,ze,ke,Ae),me=new Ck(Y,re,de),B=new gk(xe),Oe=new BG(m,Ie,Ce,ie,re,pe,B),Ye=new JG(m,xe),F=new VG,N=new HG(ie,re),ge=new dk(m,Ie,Ce,J,Ve,u,o),ae=new YG(m,Ve,re),nt=new $G(Y,Ae,re,J),Le=new pk(Y,ie,Ae,re),Ne=new Ak(Y,ie,Ae,re),Ae.programs=Oe.programs,m.capabilities=re,m.extensions=ie,m.properties=xe,m.renderLists=F,m.shadowMap=ae,m.state=J,m.info=Ae}Ge();let Be=new iw(m,Y);this.xr=Be,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){let k=ie.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){let k=ie.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(k){k!==void 0&&(P=k,this.setSize(T,C,!1))},this.getSize=function(k){return k.set(T,C)},this.setSize=function(k,ce,ve){if(Be.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=k,C=ce,t.width=Math.floor(k*P),t.height=Math.floor(ce*P),ve!==!1&&(t.style.width=k+"px",t.style.height=ce+"px"),this.setViewport(0,0,k,ce)},this.getDrawingBufferSize=function(k){return k.set(T*P,C*P).floor()},this.setDrawingBufferSize=function(k,ce,ve){T=k,C=ce,P=ve,t.width=Math.floor(k*ve),t.height=Math.floor(ce*ve),this.setViewport(0,0,k,ce)},this.getCurrentViewport=function(k){return k.copy(A)},this.getViewport=function(k){return k.copy(I)},this.setViewport=function(k,ce,ve,se){k.isVector4?I.set(k.x,k.y,k.z,k.w):I.set(k,ce,ve,se),J.viewport(A.copy(I).multiplyScalar(P).floor())},this.getScissor=function(k){return k.copy(L)},this.setScissor=function(k,ce,ve,se){k.isVector4?L.set(k.x,k.y,k.z,k.w):L.set(k,ce,ve,se),J.scissor(M.copy(L).multiplyScalar(P).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(k){J.setScissorTest(j=k)},this.setOpaqueSort=function(k){D=k},this.setTransparentSort=function(k){_=k},this.getClearColor=function(k){return k.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor.apply(ge,arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha.apply(ge,arguments)},this.clear=function(k=!0,ce=!0,ve=!0){let se=0;k&&(se|=16384),ce&&(se|=256),ve&&(se|=1024),Y.clear(se)},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",et,!1),t.removeEventListener("webglcontextrestored",st,!1),t.removeEventListener("webglcontextcreationerror",Bt,!1),F.dispose(),N.dispose(),xe.dispose(),Ie.dispose(),Ce.dispose(),Ve.dispose(),pe.dispose(),nt.dispose(),Oe.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",je),Be.removeEventListener("sessionend",He),q&&(q.dispose(),q=null),_t.stop()};function et(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function st(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let k=Ae.autoReset,ce=ae.enabled,ve=ae.autoUpdate,se=ae.needsUpdate,be=ae.type;Ge(),Ae.autoReset=k,ae.enabled=ce,ae.autoUpdate=ve,ae.needsUpdate=se,ae.type=be}function Bt(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function dr(k){let ce=k.target;ce.removeEventListener("dispose",dr),Mr(ce)}function Mr(k){Q(k),xe.remove(k)}function Q(k){let ce=xe.get(k).programs;ce!==void 0&&(ce.forEach(function(ve){Oe.releaseProgram(ve)}),k.isShaderMaterial&&Oe.releaseShaderCache(k))}this.renderBufferDirect=function(k,ce,ve,se,be,ct){ce===null&&(ce=te);let mt=be.isMesh&&be.matrixWorld.determinant()<0,At=Zb(k,ce,ve,se,be);J.setMaterial(se,mt);let Ct=ve.index,Gt=1;se.wireframe===!0&&(Ct=ze.getWireframeAttribute(ve),Gt=2);let Nt=ve.drawRange,Dt=ve.attributes.position,Ft=Nt.start*Gt,tn=(Nt.start+Nt.count)*Gt;ct!==null&&(Ft=Math.max(Ft,ct.start*Gt),tn=Math.min(tn,(ct.start+ct.count)*Gt)),Ct!==null?(Ft=Math.max(Ft,0),tn=Math.min(tn,Ct.count)):Dt!=null&&(Ft=Math.max(Ft,0),tn=Math.min(tn,Dt.count));let rn=tn-Ft;if(rn<0||rn===1/0)return;pe.setup(be,se,At,ve,Ct);let ao,gt=Le;if(Ct!==null&&(ao=ke.get(Ct),gt=Ne,gt.setIndex(ao)),be.isMesh)se.wireframe===!0?(J.setLineWidth(se.wireframeLinewidth*$()),gt.setMode(1)):gt.setMode(4);else if(be.isLine){let Rt=se.linewidth;Rt===void 0&&(Rt=1),J.setLineWidth(Rt*$()),be.isLineSegments?gt.setMode(1):be.isLineLoop?gt.setMode(2):gt.setMode(3)}else be.isPoints?gt.setMode(0):be.isSprite&&gt.setMode(4);if(be.isInstancedMesh)gt.renderInstances(Ft,rn,be.count);else if(ve.isInstancedBufferGeometry){let Rt=ve._maxInstanceCount!==void 0?ve._maxInstanceCount:1/0,lu=Math.min(ve.instanceCount,Rt);gt.renderInstances(Ft,rn,lu)}else gt.render(Ft,rn)},this.compile=function(k,ce){function ve(se,be,ct){se.transparent===!0&&se.side===fi&&se.forceSinglePass===!1?(se.side=pi,se.needsUpdate=!0,Tn(se,be,ct),se.side=Hn,se.needsUpdate=!0,Tn(se,be,ct),se.side=fi):Tn(se,be,ct)}d=N.get(k),d.init(),p.push(d),k.traverseVisible(function(se){se.isLight&&se.layers.test(ce.layers)&&(d.pushLight(se),se.castShadow&&d.pushShadow(se))}),d.setupLights(m.physicallyCorrectLights),k.traverse(function(se){let be=se.material;if(be)if(Array.isArray(be))for(let ct=0;ct<be.length;ct++){let mt=be[ct];ve(mt,k,se)}else ve(be,k,se)}),p.pop(),d=null};let ye=null;function Te(k){ye&&ye(k)}function je(){_t.stop()}function He(){_t.start()}let _t=new eP;_t.setAnimationLoop(Te),typeof self<"u"&&_t.setContext(self),this.setAnimationLoop=function(k){ye=k,Be.setAnimationLoop(k),k===null?_t.stop():_t.start()},Be.addEventListener("sessionstart",je),Be.addEventListener("sessionend",He),this.render=function(k,ce){if(ce!==void 0&&ce.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),ce.parent===null&&ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(ce),ce=Be.getCamera()),k.isScene===!0&&k.onBeforeRender(m,k,ce,x),d=N.get(k,p.length),d.init(),p.push(d),K.multiplyMatrices(ce.projectionMatrix,ce.matrixWorldInverse),V.setFromProjectionMatrix(K),W=this.localClippingEnabled,H=B.init(this.clippingPlanes,W),h=F.get(k,f.length),h.init(),f.push(h),Fr(k,ce,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(D,_),H===!0&&B.beginShadows();let ve=d.state.shadowsArray;if(ae.render(ve,k,ce),H===!0&&B.endShadows(),this.info.autoReset===!0&&this.info.reset(),ge.render(h,k),d.setupLights(m.physicallyCorrectLights),ce.isArrayCamera){let se=ce.cameras;for(let be=0,ct=se.length;be<ct;be++){let mt=se[be];Vr(h,k,mt,mt.viewport)}}else Vr(h,k,ce);x!==null&&(de.updateMultisampleRenderTarget(x),de.updateRenderTargetMipmap(x)),k.isScene===!0&&k.onAfterRender(m,k,ce),pe.resetDefaultState(),S=-1,w=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Fr(k,ce,ve,se){if(k.visible===!1)return;if(k.layers.test(ce.layers)){if(k.isGroup)ve=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(ce);else if(k.isLight)d.pushLight(k),k.castShadow&&d.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||V.intersectsSprite(k)){se&&Z.setFromMatrixPosition(k.matrixWorld).applyMatrix4(K);let mt=Ve.update(k),At=k.material;At.visible&&h.push(k,mt,At,ve,Z.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(k.isSkinnedMesh&&k.skeleton.frame!==Ae.render.frame&&(k.skeleton.update(),k.skeleton.frame=Ae.render.frame),!k.frustumCulled||V.intersectsObject(k))){se&&Z.setFromMatrixPosition(k.matrixWorld).applyMatrix4(K);let mt=Ve.update(k),At=k.material;if(Array.isArray(At)){let Ct=mt.groups;for(let Gt=0,Nt=Ct.length;Gt<Nt;Gt++){let Dt=Ct[Gt],Ft=At[Dt.materialIndex];Ft&&Ft.visible&&h.push(k,mt,Ft,ve,Z.z,Dt)}}else At.visible&&h.push(k,mt,At,ve,Z.z,null)}}let ct=k.children;for(let mt=0,At=ct.length;mt<At;mt++)Fr(ct[mt],ce,ve,se)}function Vr(k,ce,ve,se){let be=k.opaque,ct=k.transmissive,mt=k.transparent;d.setupLightsView(ve),H===!0&&B.setGlobalState(m.clippingPlanes,ve),ct.length>0&&Zo(be,ce,ve),se&&J.viewport(A.copy(se)),be.length>0&&Tr(be,ce,ve),ct.length>0&&Tr(ct,ce,ve),mt.length>0&&Tr(mt,ce,ve),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Zo(k,ce,ve){let se=re.isWebGL2;q===null&&(q=new dt(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?Wn:_r,minFilter:fc,samples:se&&s===!0?4:0})),m.getDrawingBufferSize(G),se?q.setSize(G.x,G.y):q.setSize(Zg(G.x),Zg(G.y));let be=m.getRenderTarget();m.setRenderTarget(q),m.clear();let ct=m.toneMapping;m.toneMapping=Is,Tr(k,ce,ve),m.toneMapping=ct,de.updateMultisampleRenderTarget(q),de.updateRenderTargetMipmap(q),m.setRenderTarget(be)}function Tr(k,ce,ve){let se=ce.isScene===!0?ce.overrideMaterial:null;for(let be=0,ct=k.length;be<ct;be++){let mt=k[be],At=mt.object,Ct=mt.geometry,Gt=se===null?mt.material:se,Nt=mt.group;At.layers.test(ve.layers)&&es(At,ce,ve,Ct,Gt,Nt)}}function es(k,ce,ve,se,be,ct){k.onBeforeRender(m,ce,ve,se,be,ct),k.modelViewMatrix.multiplyMatrices(ve.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),be.onBeforeRender(m,ce,ve,se,k,ct),be.transparent===!0&&be.side===fi&&be.forceSinglePass===!1?(be.side=pi,be.needsUpdate=!0,m.renderBufferDirect(ve,ce,se,be,k,ct),be.side=Hn,be.needsUpdate=!0,m.renderBufferDirect(ve,ce,se,be,k,ct),be.side=fi):m.renderBufferDirect(ve,ce,se,be,k,ct),k.onAfterRender(m,ce,ve,se,be,ct)}function Tn(k,ce,ve){ce.isScene!==!0&&(ce=te);let se=xe.get(k),be=d.state.lights,ct=d.state.shadowsArray,mt=be.state.version,At=Oe.getParameters(k,be.state,ct,ce,ve),Ct=Oe.getProgramCacheKey(At),Gt=se.programs;se.environment=k.isMeshStandardMaterial?ce.environment:null,se.fog=ce.fog,se.envMap=(k.isMeshStandardMaterial?Ce:Ie).get(k.envMap||se.environment),Gt===void 0&&(k.addEventListener("dispose",dr),Gt=new Map,se.programs=Gt);let Nt=Gt.get(Ct);if(Nt!==void 0){if(se.currentProgram===Nt&&se.lightsStateVersion===mt)return Gf(k,At),Nt}else At.uniforms=Oe.getUniforms(k),k.onBuild(ve,At,m),k.onBeforeCompile(At,m),Nt=Oe.acquireProgram(At,Ct),Gt.set(Ct,Nt),se.uniforms=At.uniforms;let Dt=se.uniforms;(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(Dt.clippingPlanes=B.uniform),Gf(k,At),se.needsLights=$b(k),se.lightsStateVersion=mt,se.needsLights&&(Dt.ambientLightColor.value=be.state.ambient,Dt.lightProbe.value=be.state.probe,Dt.directionalLights.value=be.state.directional,Dt.directionalLightShadows.value=be.state.directionalShadow,Dt.spotLights.value=be.state.spot,Dt.spotLightShadows.value=be.state.spotShadow,Dt.rectAreaLights.value=be.state.rectArea,Dt.ltc_1.value=be.state.rectAreaLTC1,Dt.ltc_2.value=be.state.rectAreaLTC2,Dt.pointLights.value=be.state.point,Dt.pointLightShadows.value=be.state.pointShadow,Dt.hemisphereLights.value=be.state.hemi,Dt.directionalShadowMap.value=be.state.directionalShadowMap,Dt.directionalShadowMatrix.value=be.state.directionalShadowMatrix,Dt.spotShadowMap.value=be.state.spotShadowMap,Dt.spotLightMatrix.value=be.state.spotLightMatrix,Dt.spotLightMap.value=be.state.spotLightMap,Dt.pointShadowMap.value=be.state.pointShadowMap,Dt.pointShadowMatrix.value=be.state.pointShadowMatrix);let Ft=Nt.getUniforms(),tn=Iu.seqWithValue(Ft.seq,Dt);return se.currentProgram=Nt,se.uniformsList=tn,Nt}function Gf(k,ce){let ve=xe.get(k);ve.outputEncoding=ce.outputEncoding,ve.instancing=ce.instancing,ve.skinning=ce.skinning,ve.morphTargets=ce.morphTargets,ve.morphNormals=ce.morphNormals,ve.morphColors=ce.morphColors,ve.morphTargetsCount=ce.morphTargetsCount,ve.numClippingPlanes=ce.numClippingPlanes,ve.numIntersection=ce.numClipIntersection,ve.vertexAlphas=ce.vertexAlphas,ve.vertexTangents=ce.vertexTangents,ve.toneMapping=ce.toneMapping}function Zb(k,ce,ve,se,be){ce.isScene!==!0&&(ce=te),de.resetTextureUnits();let ct=ce.fog,mt=se.isMeshStandardMaterial?ce.environment:null,At=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:mn,Ct=(se.isMeshStandardMaterial?Ce:Ie).get(se.envMap||mt),Gt=se.vertexColors===!0&&!!ve.attributes.color&&ve.attributes.color.itemSize===4,Nt=!!se.normalMap&&!!ve.attributes.tangent,Dt=!!ve.morphAttributes.position,Ft=!!ve.morphAttributes.normal,tn=!!ve.morphAttributes.color,rn=se.toneMapped?m.toneMapping:Is,ao=ve.morphAttributes.position||ve.morphAttributes.normal||ve.morphAttributes.color,gt=ao!==void 0?ao.length:0,Rt=xe.get(se),lu=d.state.lights;if(H===!0&&(W===!0||k!==w)){let ui=k===w&&se.id===S;B.setState(se,k,ui)}let ci=!1;se.version===Rt.__version?(Rt.needsLights&&Rt.lightsStateVersion!==lu.state.version||Rt.outputEncoding!==At||be.isInstancedMesh&&Rt.instancing===!1||!be.isInstancedMesh&&Rt.instancing===!0||be.isSkinnedMesh&&Rt.skinning===!1||!be.isSkinnedMesh&&Rt.skinning===!0||Rt.envMap!==Ct||se.fog===!0&&Rt.fog!==ct||Rt.numClippingPlanes!==void 0&&(Rt.numClippingPlanes!==B.numPlanes||Rt.numIntersection!==B.numIntersection)||Rt.vertexAlphas!==Gt||Rt.vertexTangents!==Nt||Rt.morphTargets!==Dt||Rt.morphNormals!==Ft||Rt.morphColors!==tn||Rt.toneMapping!==rn||re.isWebGL2===!0&&Rt.morphTargetsCount!==gt)&&(ci=!0):(ci=!0,Rt.__version=se.version);let lo=Rt.currentProgram;ci===!0&&(lo=Tn(se,ce,be));let cu=!1,kn=!1,Et=!1,Si=lo.getUniforms(),ts=Rt.uniforms;if(J.useProgram(lo.program)&&(cu=!0,kn=!0,Et=!0),se.id!==S&&(S=se.id,kn=!0),cu||w!==k){if(Si.setValue(Y,"projectionMatrix",k.projectionMatrix),re.logarithmicDepthBuffer&&Si.setValue(Y,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),w!==k&&(w=k,kn=!0,Et=!0),se.isShaderMaterial||se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshStandardMaterial||se.envMap){let ui=Si.map.cameraPosition;ui!==void 0&&ui.setValue(Y,Z.setFromMatrixPosition(k.matrixWorld))}(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial)&&Si.setValue(Y,"isOrthographic",k.isOrthographicCamera===!0),(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial||se.isShadowMaterial||be.isSkinnedMesh)&&Si.setValue(Y,"viewMatrix",k.matrixWorldInverse)}if(be.isSkinnedMesh){Si.setOptional(Y,be,"bindMatrix"),Si.setOptional(Y,be,"bindMatrixInverse");let ui=be.skeleton;ui&&(re.floatVertexTextures?(ui.boneTexture===null&&ui.computeBoneTexture(),Si.setValue(Y,"boneTexture",ui.boneTexture,de),Si.setValue(Y,"boneTextureSize",ui.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 uu=ve.morphAttributes;if((uu.position!==void 0||uu.normal!==void 0||uu.color!==void 0&&re.isWebGL2===!0)&&me.update(be,ve,se,lo),(kn||Rt.receiveShadow!==be.receiveShadow)&&(Rt.receiveShadow=be.receiveShadow,Si.setValue(Y,"receiveShadow",be.receiveShadow)),se.isMeshGouraudMaterial&&se.envMap!==null&&(ts.envMap.value=Ct,ts.flipEnvMap.value=Ct.isCubeTexture&&Ct.isRenderTargetTexture===!1?-1:1),kn&&(Si.setValue(Y,"toneMappingExposure",m.toneMappingExposure),Rt.needsLights&&Jb(ts,Et),ct&&se.fog===!0&&Ye.refreshFogUniforms(ts,ct),Ye.refreshMaterialUniforms(ts,se,P,C,q),Iu.upload(Y,Rt.uniformsList,ts,de)),se.isShaderMaterial&&se.uniformsNeedUpdate===!0&&(Iu.upload(Y,Rt.uniformsList,ts,de),se.uniformsNeedUpdate=!1),se.isSpriteMaterial&&Si.setValue(Y,"center",be.center),Si.setValue(Y,"modelViewMatrix",be.modelViewMatrix),Si.setValue(Y,"normalMatrix",be.normalMatrix),Si.setValue(Y,"modelMatrix",be.matrixWorld),be.previousModelViewMatrix&&Si.setValue(Y,"previousModelViewMatrix",be.previousModelViewMatrix),k.previousProjectionMatrix&&Si.setValue(Y,"previousProjectionMatrix",k.previousProjectionMatrix),se.isShaderMaterial||se.isRawShaderMaterial){let ui=se.uniformsGroups;for(let O=0,R=ui.length;O<R;O++)if(re.isWebGL2){let X=ui[O];nt.update(X,lo),nt.bind(X,lo)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return lo}function Jb(k,ce){k.ambientLightColor.needsUpdate=ce,k.lightProbe.needsUpdate=ce,k.directionalLights.needsUpdate=ce,k.directionalLightShadows.needsUpdate=ce,k.pointLights.needsUpdate=ce,k.pointLightShadows.needsUpdate=ce,k.spotLights.needsUpdate=ce,k.spotLightShadows.needsUpdate=ce,k.rectAreaLights.needsUpdate=ce,k.hemisphereLights.needsUpdate=ce}function $b(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(k,ce,ve){xe.get(k.texture).__webglTexture=ce,xe.get(k.depthTexture).__webglTexture=ve;let se=xe.get(k);se.__hasExternalTextures=!0,se.__hasExternalTextures&&(se.__autoAllocateDepthBuffer=ve===void 0,se.__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"),se.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(k,ce){let ve=xe.get(k);ve.__webglFramebuffer=ce,ve.__useDefaultFramebuffer=ce===void 0},this.setRenderTarget=function(k,ce=0,ve=0){x=k,y=ce,v=ve;let se=!0,be=null,ct=!1,mt=!1;if(k){let Ct=xe.get(k);Ct.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),se=!1):Ct.__webglFramebuffer===void 0?de.setupRenderTarget(k):Ct.__hasExternalTextures&&de.rebindTextures(k,xe.get(k.texture).__webglTexture,xe.get(k.depthTexture).__webglTexture);let Gt=k.texture;(Gt.isData3DTexture||Gt.isDataArrayTexture||Gt.isCompressedArrayTexture)&&(mt=!0);let Nt=xe.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(be=Nt[ce],ct=!0):re.isWebGL2&&k.samples>0&&de.useMultisampledRTT(k)===!1?be=xe.get(k).__webglMultisampledFramebuffer:be=Nt,A.copy(k.viewport),M.copy(k.scissor),b=k.scissorTest}else A.copy(I).multiplyScalar(P).floor(),M.copy(L).multiplyScalar(P).floor(),b=j;if(J.bindFramebuffer(36160,be)&&re.drawBuffers&&se&&J.drawBuffers(k,be),J.viewport(A),J.scissor(M),J.setScissorTest(b),ct){let Ct=xe.get(k.texture);Y.framebufferTexture2D(36160,36064,34069+ce,Ct.__webglTexture,ve)}else if(mt){let Ct=xe.get(k.texture),Gt=ce||0;Y.framebufferTextureLayer(36160,36064,Ct.__webglTexture,ve||0,Gt)}S=-1},this.readRenderTargetPixels=function(k,ce,ve,se,be,ct,mt){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=xe.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&mt!==void 0&&(At=At[mt]),At){J.bindFramebuffer(36160,At);try{let Ct=k.texture,Gt=Ct.format,Nt=Ct.type;if(Gt!==qr&&Re.convert(Gt)!==Y.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Dt=Nt===Wn&&(ie.has("EXT_color_buffer_half_float")||re.isWebGL2&&ie.has("EXT_color_buffer_float"));if(Nt!==_r&&Re.convert(Nt)!==Y.getParameter(35738)&&!(Nt===br&&(re.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!Dt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ce>=0&&ce<=k.width-se&&ve>=0&&ve<=k.height-be&&Y.readPixels(ce,ve,se,be,Re.convert(Gt),Re.convert(Nt),ct)}finally{let Ct=x!==null?xe.get(x).__webglFramebuffer:null;J.bindFramebuffer(36160,Ct)}}},this.copyFramebufferToTexture=function(k,ce,ve=0){let se=Math.pow(2,-ve),be=Math.floor(ce.image.width*se),ct=Math.floor(ce.image.height*se);de.setTexture2D(ce,0),Y.copyTexSubImage2D(3553,ve,0,0,k.x,k.y,be,ct),J.unbindTexture()},this.copyTextureToTexture=function(k,ce,ve,se=0){let be=ce.image.width,ct=ce.image.height,mt=Re.convert(ve.format),At=Re.convert(ve.type);de.setTexture2D(ve,0),Y.pixelStorei(37440,ve.flipY),Y.pixelStorei(37441,ve.premultiplyAlpha),Y.pixelStorei(3317,ve.unpackAlignment),ce.isDataTexture?Y.texSubImage2D(3553,se,k.x,k.y,be,ct,mt,At,ce.image.data):ce.isCompressedTexture?Y.compressedTexSubImage2D(3553,se,k.x,k.y,ce.mipmaps[0].width,ce.mipmaps[0].height,mt,ce.mipmaps[0].data):Y.texSubImage2D(3553,se,k.x,k.y,mt,At,ce.image),se===0&&ve.generateMipmaps&&Y.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(k,ce,ve,se,be=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ct=k.max.x-k.min.x+1,mt=k.max.y-k.min.y+1,At=k.max.z-k.min.z+1,Ct=Re.convert(se.format),Gt=Re.convert(se.type),Nt;if(se.isData3DTexture)de.setTexture3D(se,0),Nt=32879;else if(se.isDataArrayTexture)de.setTexture2DArray(se,0),Nt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(37440,se.flipY),Y.pixelStorei(37441,se.premultiplyAlpha),Y.pixelStorei(3317,se.unpackAlignment);let Dt=Y.getParameter(3314),Ft=Y.getParameter(32878),tn=Y.getParameter(3316),rn=Y.getParameter(3315),ao=Y.getParameter(32877),gt=ve.isCompressedTexture?ve.mipmaps[0]:ve.image;Y.pixelStorei(3314,gt.width),Y.pixelStorei(32878,gt.height),Y.pixelStorei(3316,k.min.x),Y.pixelStorei(3315,k.min.y),Y.pixelStorei(32877,k.min.z),ve.isDataTexture||ve.isData3DTexture?Y.texSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,Gt,gt.data):ve.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y.compressedTexSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,gt.data)):Y.texSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,Gt,gt),Y.pixelStorei(3314,Dt),Y.pixelStorei(32878,Ft),Y.pixelStorei(3316,tn),Y.pixelStorei(3315,rn),Y.pixelStorei(32877,ao),be===0&&se.generateMipmaps&&Y.generateMipmap(Nt),J.unbindTexture()},this.initTexture=function(k){k.isCubeTexture?de.setTextureCube(k,0):k.isData3DTexture?de.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?de.setTexture2DArray(k,0):de.setTexture2D(k,0),J.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,J.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var nw=class extends _w{};nw.prototype.isWebGL1Renderer=!0;var Lu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new We(t),this.near=e,this.far=r}clone(){return new Lu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ei=class extends Mt{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}},sy=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=HS,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=is()}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=is()),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=is()),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}}},fn=new E,mc=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++)fn.fromBufferAttribute(this,e),fn.applyMatrix4(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.applyNormalMatrix(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.transformDirection(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}setX(t,e){return this.normalized&&(e=xr(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=xr(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=xr(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=xr(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=aa(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=aa(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=aa(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=aa(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=xr(e,this.array),r=xr(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=xr(e,this.array),r=xr(r,this.array),i=xr(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=xr(e,this.array),r=xr(r,this.array),i=xr(i,this.array),s=xr(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 Xe(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 mc(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 dp=class extends Mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},gi=class extends $t{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}},SC=new ue,t4=new ue,el=class{constructor(t=[],e=[]){this.uuid=is(),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:t4;SC.multiplyMatrices(a,e[s]),SC.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new el(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=KC(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new gi(e,t,t,qr,br);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 dp),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}},fo=class extends Xe{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}},wC=new ue,AC=new ue,Vg=[],r4=new ue,Zf=new Ut,oy=class extends Ut{constructor(t,e,r){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new fo(new Float32Array(r*16),16),this.instanceColor=null,this.count=r,this.frustumCulled=!1;for(let i=0;i<r;i++)this.setMatrixAt(i,r4)}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(Zf.geometry=this.geometry,Zf.material=this.material,Zf.material!==void 0)for(let s=0;s<i;s++){this.getMatrixAt(s,wC),AC.multiplyMatrices(r,wC),Zf.matrixWorld=AC,Zf.raycast(t,Vg);for(let o=0,a=Vg.length;o<a;o++){let l=Vg[o];l.instanceId=s,l.object=this,e.push(l)}Vg.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new fo(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"})}},ss=class extends pc{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new We(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}},EC=new E,MC=new E,TC=new ue,LS=new Rs,Ug=new Or,gc=class extends Mt{constructor(t=new _e,e=new ss){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++)EC.fromBufferAttribute(e,i-1),MC.fromBufferAttribute(e,i),r[i]=r[i-1],r[i]+=EC.distanceTo(MC);t.setAttribute("lineDistance",new Me(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(),Ug.copy(r.boundingSphere),Ug.applyMatrix4(i),Ug.radius+=s,t.ray.intersectsSphere(Ug)===!1)return;TC.copy(i).invert(),LS.copy(t.ray).applyMatrix4(TC);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,p=r.index,g=r.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){let w=p.getX(x),A=p.getX(x+1);if(c.fromBufferAttribute(g,w),u.fromBufferAttribute(g,A),LS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){if(c.fromBufferAttribute(g,x),u.fromBufferAttribute(g,x+1),LS.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:x,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}}}}},CC=new E,PC=new E,tl=class extends gc{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)CC.fromBufferAttribute(e,i),PC.fromBufferAttribute(e,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+CC.distanceTo(PC);t.setAttribute("lineDistance",new Me(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var ay=class extends $t{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:rt,this.magFilter=s!==void 0?s:rt,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 ly=class extends $t{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}},os=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 p=f/t;i[f]=this.getTangentAt(p,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 p=Math.acos(di(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(di(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),o[p].crossVectors(i[p],s[p])}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}},yc=class extends os{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}},sw=class extends yc{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Dw(){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 zg=new E,BS=new Dw,NS=new Dw,FS=new Dw,ow=class extends os{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]:(zg.subVectors(i[0],i[1]).add(i[0]),c=zg);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(zg.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=zg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(c.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(u),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),BS.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,p,m,g),NS.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,p,m,g),FS.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,p,m,g)}else this.curveType==="catmullrom"&&(BS.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),NS.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),FS.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return r.set(BS.calc(l),NS.calc(l),FS.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 _C(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 i4(n,t){let e=1-n;return e*e*t}function n4(n,t){return 2*(1-n)*n*t}function s4(n,t){return n*n*t}function np(n,t,e,r){return i4(n,t)+n4(n,e)+s4(n,r)}function o4(n,t){let e=1-n;return e*e*e*t}function a4(n,t){let e=1-n;return 3*e*e*n*t}function l4(n,t){return 3*(1-n)*n*n*t}function c4(n,t){return n*n*n*t}function sp(n,t,e,r,i){return o4(n,t)+a4(n,e)+l4(n,r)+c4(n,i)}var an=class extends os{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(sp(t,i.x,s.x,o.x,a.x),sp(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}},vc=class extends os{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(sp(t,i.x,s.x,o.x,a.x),sp(t,i.y,s.y,o.y,a.y),sp(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}},ln=class extends os{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}},fp=class extends os{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}},Yn=class extends os{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(np(t,i.x,s.x,o.x),np(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}},aw=class extends os{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(np(t,i.x,s.x,o.x),np(t,i.y,s.y,o.y),np(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}},Bu=class extends os{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(_C(a,l.x,c.x,u.x,h.x),_C(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}},u4=Object.freeze({__proto__:null,ArcCurve:sw,CatmullRomCurve3:ow,CubicBezierCurve:an,CubicBezierCurve3:vc,EllipseCurve:yc,LineCurve:ln,LineCurve3:fp,QuadraticBezierCurve:Yn,QuadraticBezierCurve3:aw,SplineCurve:Bu}),pp=class extends os{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 ln(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 u4[i.type]().fromJSON(i))}return this}},xc=class extends pp{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 ln(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 Yn(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 an(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 Bu(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 yc(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}},Nu=class extends _e{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=di(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new E,d=new U,f=new E,p=new E,m=new E,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=r+v*u*i,S=Math.sin(x),w=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*S,h.y=t[A].y,h.z=t[A].x*w,o.push(h.x,h.y,h.z),d.x=v/e,d.y=A/(t.length-1),a.push(d.x,d.y);let M=l[3*A+0]*S,b=l[3*A+1],T=l[3*A+0]*w;c.push(M,b,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let S=x+v*t.length,w=S,A=S+t.length,M=S+t.length+1,b=S+1;s.push(w,A,b),s.push(M,b,A)}this.setIndex(s),this.setAttribute("position",new Me(o,3)),this.setAttribute("uv",new Me(a,2)),this.setAttribute("normal",new Me(c,3))}static fromJSON(t){return new Nu(t.points,t.segments,t.phiStart,t.phiLength)}};var bc=class extends _e{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=[],p=0,m=[],g=r/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Me(h,3)),this.setAttribute("normal",new Me(d,3)),this.setAttribute("uv",new Me(f,2));function v(){let S=new E,w=new E,A=0,M=(e-t)/r;for(let b=0;b<=s;b++){let T=[],C=b/s,P=C*(e-t)+t;for(let D=0;D<=i;D++){let _=D/i,I=_*l+a,L=Math.sin(I),j=Math.cos(I);w.x=P*L,w.y=-C*r+g,w.z=P*j,h.push(w.x,w.y,w.z),S.set(L,M,j).normalize(),d.push(S.x,S.y,S.z),f.push(_,1-C),T.push(p++)}m.push(T)}for(let b=0;b<i;b++)for(let T=0;T<s;T++){let C=m[T][b],P=m[T+1][b],D=m[T+1][b+1],_=m[T][b+1];u.push(C,P,_),u.push(P,D,_),A+=6}c.addGroup(y,A,0),y+=A}function x(S){let w=p,A=new U,M=new E,b=0,T=S===!0?t:e,C=S===!0?1:-1;for(let D=1;D<=i;D++)h.push(0,g*C,0),d.push(0,C,0),f.push(.5,.5),p++;let P=p;for(let D=0;D<=i;D++){let I=D/i*l+a,L=Math.cos(I),j=Math.sin(I);M.x=T*j,M.y=g*C,M.z=T*L,h.push(M.x,M.y,M.z),d.push(0,C,0),A.x=L*.5+.5,A.y=j*.5*C+.5,f.push(A.x,A.y),p++}for(let D=0;D<i;D++){let _=w+D,I=P+D;S===!0?u.push(I,I+1,_):u.push(I+1,I,_),b+=3}c.addGroup(y,b,S===!0?1:2),y+=b}}static fromJSON(t){return new bc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},rl=class extends bc{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 rl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Fu=class extends _e{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 Me(s,3)),this.setAttribute("normal",new Me(s.slice(),3)),this.setAttribute("uv",new Me(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new E,S=new E,w=new E;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],S),f(e[A+2],w),l(x,S,w,v)}function l(v,x,S,w){let A=w+1,M=[];for(let b=0;b<=A;b++){M[b]=[];let T=v.clone().lerp(S,b/A),C=x.clone().lerp(S,b/A),P=A-b;for(let D=0;D<=P;D++)D===0&&b===A?M[b][D]=T:M[b][D]=T.clone().lerp(C,D/P)}for(let b=0;b<A;b++)for(let T=0;T<2*(A-b)-1;T++){let C=Math.floor(T/2);T%2===0?(d(M[b][C+1]),d(M[b+1][C]),d(M[b][C])):(d(M[b][C+1]),d(M[b+1][C+1]),d(M[b+1][C]))}}function c(v){let x=new E;for(let S=0;S<s.length;S+=3)x.x=s[S+0],x.y=s[S+1],x.z=s[S+2],x.normalize().multiplyScalar(v),s[S+0]=x.x,s[S+1]=x.y,s[S+2]=x.z}function u(){let v=new E;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let S=g(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(S,1-w)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],S=o[v+2],w=o[v+4],A=Math.max(x,S,w),M=Math.min(x,S,w);A>.9&&M<.1&&(x<.2&&(o[v+0]+=1),S<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let S=v*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function p(){let v=new E,x=new E,S=new E,w=new E,A=new U,M=new U,b=new U;for(let T=0,C=0;T<s.length;T+=9,C+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),S.set(s[T+6],s[T+7],s[T+8]),A.set(o[C+0],o[C+1]),M.set(o[C+2],o[C+3]),b.set(o[C+4],o[C+5]),w.copy(v).add(x).add(S).divideScalar(3);let P=g(w);m(A,C+0,v,P),m(M,C+2,x,P),m(b,C+4,S,P)}}function m(v,x,S,w){w<0&&v.x===1&&(o[x]=v.x-1),S.x===0&&S.z===0&&(o[x]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new Fu(t.vertices,t.indices,t.radius,t.details)}},Vu=class extends Fu{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 Vu(t.radius,t.detail)}};var la=class extends xc{constructor(t){super(t),this.uuid=is(),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 xc().fromJSON(i))}return this}},h4={triangulate:function(n,t,e=2){let r=t&&t.length,i=r?t[0]*e:n.length,s=sP(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=g4(n,t,s,e)),n.length>80*e){a=c=n[0],l=u=n[1];for(let p=e;p<i;p+=e)h=n[p],d=n[p+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 mp(s,o,e,a,l,f,0),o}};function sP(n,t,e,r,i){let s,o;if(i===C4(n,t,e,r)>0)for(s=t;s<e;s+=r)o=DC(s,n[s],n[s+1],o);else for(s=e-r;s>=t;s-=r)o=DC(s,n[s],n[s+1],o);return o&&My(o,o.next)&&(yp(o),o=o.next),o}function Sc(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(My(e,e.next)||zr(e.prev,e,e.next)===0)){if(yp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function mp(n,t,e,r,i,s,o){if(!n)return;!o&&s&&S4(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?f4(n,r,i,s):d4(n)){t.push(l.i/e|0),t.push(n.i/e|0),t.push(c.i/e|0),yp(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=p4(Sc(n),t,e),mp(n,t,e,r,i,s,2)):o===2&&m4(n,t,e,r,i,s):mp(Sc(n),t,e,r,i,s,1);break}}}function d4(n){let t=n.prev,e=n,r=n.next;if(zr(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,p=r.next;for(;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Du(i,a,s,l,o,c,p.x,p.y)&&zr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function f4(n,t,e,r){let i=n.prev,s=n,o=n.next;if(zr(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,p=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=lw(f,p,t,e,r),v=lw(m,g,t,e,r),x=n.prevZ,S=n.nextZ;for(;x&&x.z>=y&&S&&S.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Du(a,u,l,h,c,d,x.x,x.y)&&zr(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Du(a,u,l,h,c,d,S.x,S.y)&&zr(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Du(a,u,l,h,c,d,x.x,x.y)&&zr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=v;){if(S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Du(a,u,l,h,c,d,S.x,S.y)&&zr(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function p4(n,t,e){let r=n;do{let i=r.prev,s=r.next.next;!My(i,s)&&oP(i,r,r.next,s)&&gp(i,s)&&gp(s,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),yp(r),yp(r.next),r=n=s),r=r.next}while(r!==n);return Sc(r)}function m4(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&E4(o,a)){let l=aP(o,a);o=Sc(o,o.next),l=Sc(l,l.next),mp(o,t,e,r,i,s,0),mp(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function g4(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=sP(n,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(A4(c));for(i.sort(y4),s=0;s<i.length;s++)e=v4(i[s],e);return e}function y4(n,t){return n.x-t.x}function v4(n,t){let e=x4(n,t);if(!e)return t;let r=aP(e,n);return Sc(r,r.next),Sc(e,e.next)}function x4(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&&Du(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),gp(e,n)&&(h<u||h===u&&(e.x>i.x||e.x===i.x&&b4(i,e)))&&(i=e,u=h)),e=e.next;while(e!==a);return i}function b4(n,t){return zr(n.prev,n,t.prev)<0&&zr(t.next,n,n.next)<0}function S4(n,t,e,r){let i=n;do i.z===0&&(i.z=lw(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,w4(i)}function w4(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 lw(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 A4(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 Du(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 E4(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!M4(n,t)&&(gp(n,t)&&gp(t,n)&&T4(n,t)&&(zr(n.prev,n,t.prev)||zr(n,t.prev,t))||My(n,t)&&zr(n.prev,n,n.next)>0&&zr(t.prev,t,t.next)>0)}function zr(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function My(n,t){return n.x===t.x&&n.y===t.y}function oP(n,t,e,r){let i=Gg(zr(n,t,e)),s=Gg(zr(n,t,r)),o=Gg(zr(e,r,n)),a=Gg(zr(e,r,t));return!!(i!==s&&o!==a||i===0&&kg(n,e,t)||s===0&&kg(n,r,t)||o===0&&kg(e,n,r)||a===0&&kg(e,t,r))}function kg(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 Gg(n){return n>0?1:n<0?-1:0}function M4(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&&oP(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function gp(n,t){return zr(n.prev,n,n.next)<0?zr(n,t,n.next)>=0&&zr(n,n.prev,t)>=0:zr(n,t,n.prev)<0||zr(n,n.next,t)<0}function T4(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 aP(n,t){let e=new cw(n.i,n.x,n.y),r=new cw(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 DC(n,t,e,r){let i=new cw(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 yp(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 cw(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 C4(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 Uu=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 Uu.area(t)<0}static triangulateShape(t,e){let r=[],i=[],s=[];IC(t),OC(r,t);let o=t.length;e.forEach(IC);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,OC(r,e[l]);let a=h4.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function IC(n){let t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function OC(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}var zu=class extends Fu{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 zu(t.radius,t.detail)}};var Ls=class extends _e{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=[],p=[],m=[],g=[];for(let y=0;y<=r;y++){let v=[],x=y/r,S=0;y==0&&o==0?S=.5/e:y==r&&l==Math.PI&&(S=-.5/e);for(let w=0;w<=e;w++){let A=w/e;h.x=-t*Math.cos(i+A*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(i+A*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(A+S,1-x),v.push(c++)}u.push(v)}for(let y=0;y<r;y++)for(let v=0;v<e;v++){let x=u[y][v+1],S=u[y][v],w=u[y+1][v],A=u[y+1][v+1];(y!==0||o>0)&&f.push(x,S,A),(y!==r-1||l<Math.PI)&&f.push(S,w,A)}this.setIndex(f),this.setAttribute("position",new Me(p,3)),this.setAttribute("normal",new Me(m,3)),this.setAttribute("uv",new Me(g,2))}static fromJSON(t){return new Ls(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var ku=class extends _e{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 p=0;p<=i;p++){let m=p/i*s,g=f/r*Math.PI*2;h.x=(t+e*Math.cos(g))*Math.cos(m),h.y=(t+e*Math.cos(g))*Math.sin(m),h.z=e*Math.sin(g),a.push(h.x,h.y,h.z),u.x=t*Math.cos(m),u.y=t*Math.sin(m),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(p/i),c.push(f/r)}for(let f=1;f<=r;f++)for(let p=1;p<=i;p++){let m=(i+1)*f+p-1,g=(i+1)*(f-1)+p-1,y=(i+1)*(f-1)+p,v=(i+1)*f+p;o.push(m,g,v),o.push(g,y,v)}this.setIndex(o),this.setAttribute("position",new Me(a,3)),this.setAttribute("normal",new Me(l,3)),this.setAttribute("uv",new Me(c,2))}static fromJSON(t){return new ku(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},Gu=class extends _e{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,p=new E,m=new E,g=new E,y=new E;for(let x=0;x<=r;++x){let S=x/r*s*Math.PI*2;v(S,s,o,t,f),v(S+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,M=-e*Math.cos(A),b=e*Math.sin(A);h.x=f.x+(M*y.x+b*m.x),h.y=f.y+(M*y.y+b*m.y),h.z=f.z+(M*y.z+b*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(x/r),u.push(w/i)}}for(let x=1;x<=r;x++)for(let S=1;S<=i;S++){let w=(i+1)*(x-1)+(S-1),A=(i+1)*x+(S-1),M=(i+1)*x+S,b=(i+1)*(x-1)+S;a.push(w,A,b),a.push(A,M,b)}this.setIndex(a),this.setAttribute("position",new Me(l,3)),this.setAttribute("normal",new Me(c,3)),this.setAttribute("uv",new Me(u,2));function v(x,S,w,A,M){let b=Math.cos(x),T=Math.sin(x),C=w/S*x,P=Math.cos(C);M.x=A*(2+P)*.5*b,M.y=A*(2+P)*T*.5,M.z=A*Math.sin(C)*.5}}static fromJSON(t){return new Gu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Ya(n,t,e){return lP(n)?new n.constructor(n.subarray(t,e!==void 0?e:n.length)):n.slice(t,e)}function jg(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 lP(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function P4(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 RC(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 cP(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 ju=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_(){}},uw=class extends ju{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:Cu,endingEnd:Cu}}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 Pu:s=t,a=2*e-r;break;case Kg: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 Pu:o=t,l=2*r-e;break;case Kg: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,p=(r-e)/(i-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,S=f*g-f*m;for(let w=0;w!==a;++w)s[w]=y*o[u+w]+v*o[c+w]+x*o[l+w]+S*o[h+w];return s}},cy=class extends ju{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}},hw=class extends ju{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t){return this.copySampleValue_(t-1)}},as=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=jg(e,this.TimeBufferType),this.values=jg(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:jg(t.times,Array),values:jg(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(r.interpolation=i)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new hw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new cy(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new uw(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Xg:e=this.InterpolantFactoryMethodDiscrete;break;case Qg:e=this.InterpolantFactoryMethodLinear;break;case cS: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 Xg;case this.InterpolantFactoryMethodLinear:return Qg;case this.InterpolantFactoryMethodSmooth:return cS}}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=Ya(r,s,o),this.values=Ya(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&&lP(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=Ya(this.times),e=Ya(this.values),r=this.getValueSize(),i=this.getInterpolation()===cS,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 p=0;p!==r;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){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=Ya(t,0,o),this.values=Ya(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Ya(this.times,0),e=Ya(this.values,0),r=this.constructor,i=new r(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};as.prototype.TimeBufferType=Float32Array;as.prototype.ValueBufferType=Float32Array;as.prototype.DefaultInterpolation=Qg;var il=class extends as{};il.prototype.ValueTypeName="bool";il.prototype.ValueBufferType=Array;il.prototype.DefaultInterpolation=Xg;il.prototype.InterpolantFactoryMethodLinear=void 0;il.prototype.InterpolantFactoryMethodSmooth=void 0;var uy=class extends as{};uy.prototype.ValueTypeName="color";var Hu=class extends as{};Hu.prototype.ValueTypeName="number";var dw=class extends ju{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)Qe.slerpFlat(s,0,o,c-a,o,c,l);return s}},wc=class extends as{InterpolantFactoryMethodLinear(t){return new dw(this.times,this.values,this.getValueSize(),t)}};wc.prototype.ValueTypeName="quaternion";wc.prototype.DefaultInterpolation=Qg;wc.prototype.InterpolantFactoryMethodSmooth=void 0;var nl=class extends as{};nl.prototype.ValueTypeName="string";nl.prototype.ValueBufferType=Array;nl.prototype.DefaultInterpolation=Xg;nl.prototype.InterpolantFactoryMethodLinear=void 0;nl.prototype.InterpolantFactoryMethodSmooth=void 0;var Wu=class extends as{};Wu.prototype.ValueTypeName="vector";var qu=class{constructor(t,e=-1,r,i=Mw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=i,this.uuid=is(),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(D4(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(as.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=P4(l);l=RC(l,1,u),c=RC(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Hu(".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,p,m){if(f.length!==0){let g=[],y=[];cP(f,g,y,p),g.length!==0&&m.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={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}i.push(new Hu(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(Wu,f+".position",d,"pos",i),r(wc,f+".quaternion",d,"rot",i),r(Wu,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 _4(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Hu;case"vector":case"vector2":case"vector3":case"vector4":return Wu;case"color":return uy;case"quaternion":return wc;case"bool":case"boolean":return il;case"string":return nl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function D4(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=_4(n.type);if(n.times===void 0){let e=[],r=[];cP(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 hy={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={}}},vp=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],p=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},I4=new vp,sl=class{constructor(t){this.manager=t!==void 0?t:I4,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}},sa={},fw=class extends Error{constructor(t,e){super(t),this.response=e}},Yu=class extends sl{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=hy.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(sa[t]!==void 0){sa[t].push({onLoad:e,onProgress:r,onError:i});return}sa[t]=[],sa[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=sa[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:S})=>{if(x)y.close();else{m+=S.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,M=u.length;A<M;A++){let b=u[A];b.onProgress&&b.onProgress(w)}y.enqueue(S),v()}})}}});return new Response(g)}else throw new fw(`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(p=>f.decode(p))}}}).then(c=>{hy.add(t,c);let u=sa[t];delete sa[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=sa[t];if(u===void 0)throw this.manager.itemError(t),c;delete sa[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 pw=class extends sl{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=hy.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=lp("img");function l(){u(),hy.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 dy=class extends sl{constructor(t){super(t)}load(t,e,r,i){let s=new $t,o=new pw(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}},ol=class extends Mt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new We(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}},fy=class extends ol{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new We(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},VS=new ue,LC=new E,BC=new E,xp=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 up,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;LC.setFromMatrixPosition(t.matrixWorld),e.position.copy(LC),BC.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(BC),e.updateMatrixWorld(),VS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(VS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(VS)}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}},mw=class extends xp{constructor(){super(new $r(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=ap*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}},py=class extends ol{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(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new mw}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}},NC=new ue,Jf=new E,US=new E,gw=class extends xp{constructor(){super(new $r(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()),Jf.setFromMatrixPosition(t.matrixWorld),r.position.copy(Jf),US.copy(r.position),US.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(US),r.updateMatrixWorld(),i.makeTranslation(-Jf.x,-Jf.y,-Jf.z),NC.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(NC)}},my=class extends ol{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 gw}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}},yw=class extends xp{constructor(){super(new $a(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},gy=class extends ol{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.shadow=new yw}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var bp=class extends _e{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}},Xu=class extends sl{constructor(t){super(t)}load(t,e,r,i){let s=this,o=new Yu(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,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=xg(g.type,y),x=new sy(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return r[p]=y,y}let o=t.isInstancedBufferGeometry?new bp:new _e,a=t.data.index;if(a!==void 0){let f=xg(a.type,a.array);o.setIndex(new Xe(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=i(t.data,p.data);m=new mc(g,p.itemSize,p.offset,p.normalized)}else{let g=xg(p.type,p.array),y=p.isInstancedBufferAttribute?fo:Xe;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let c=t.data.morphAttributes;if(c)for(let f in c){let p=c[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let S=i(t.data,v.data);x=new mc(S,v.itemSize,v.offset,v.normalized)}else{let S=xg(v.type,v.array);x=new Xe(S,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}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,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.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 Or(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var yy=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=FC(),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=FC();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function FC(){return(typeof performance>"u"?Date:performance).now()}var vw=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){Qe.slerpFlat(t,e,t,e,t,r,i)}_slerpAdditive(t,e,r,i,s){let o=this._workIndex*s;Qe.multiplyQuaternionsFlat(t,o,t,e,t,r),Qe.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}}},Iw="\\[\\]\\.:\\/",O4=new RegExp("["+Iw+"]","g"),Ow="[^"+Iw+"]",R4="[^"+Iw.replace("\\.","")+"]",L4=/((?:WC+[\/:])*)/.source.replace("WC",Ow),B4=/(WCOD+)?/.source.replace("WCOD",R4),N4=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ow),F4=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ow),V4=new RegExp("^"+L4+B4+N4+F4+"$"),U4=["material","materials","bones","map"],xw=class{constructor(t,e,r){let i=r||Zt.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()}},Zt=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Zt.parseTrackName(e),this.node=Zt.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 Zt.Composite(t,e,r):new Zt(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(O4,"")}static parseTrackName(t){let e=V4.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);U4.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=Zt.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}};Zt.Composite=xw;Zt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Zt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Zt.prototype.GetterByBindingType=[Zt.prototype._getValue_direct,Zt.prototype._getValue_array,Zt.prototype._getValue_arrayElement,Zt.prototype._getValue_toArray];Zt.prototype.SetterByBindingTypeAndVersioning=[[Zt.prototype._setValue_direct,Zt.prototype._setValue_direct_setNeedsUpdate,Zt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_array,Zt.prototype._setValue_array_setNeedsUpdate,Zt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_arrayElement,Zt.prototype._setValue_arrayElement_setNeedsUpdate,Zt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_fromArray,Zt.prototype._setValue_fromArray_setNeedsUpdate,Zt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var bw=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:Cu,endingEnd:Cu};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=Ew,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 $F:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Mw: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===wp;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(r===Aw){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=Pu,i.endingEnd=Pu):(t?i.endingStart=this.zeroSlopeAtStart?Pu:Cu:i.endingStart=Kg,e?i.endingEnd=this.zeroSlopeAtEnd?Pu:Cu:i.endingEnd=Kg)}_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}},z4=new Float32Array(1),vy=class extends pr{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,p=u[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new vw(Zt.create(r,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.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 cy(new Float32Array(2),new Float32Array(2),1,z4),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"?qu.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=Mw),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 bw(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"?qu.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))}},le=class{constructor(t){this.value=t}clone(){return new le(this.value.clone===void 0?this.value:this.value.clone())}};var Qu=class{constructor(t,e,r=0,i=1/0){this.ray=new Rs(t,e),this.near=r,this.far=i,this.camera=null,this.layers=new cp,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 Sw(t,this,r,e),r.sort(VC),r}intersectObjects(t,e=!0,r=[]){for(let i=0,s=t.length;i<s;i++)Sw(t[i],this,r,e);return r.sort(VC),r}};function VC(n,t){return n.distance-t.distance}function Sw(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++)Sw(i[s],t,e,!0)}}var Sp=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(di(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var UC=new U,Ku=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=UC.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 UC.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)}},zC=new E,Hg=new E,Mi=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){zC.subVectors(t,this.start),Hg.subVectors(this.end,this.start);let r=Hg.dot(Hg),s=Hg.dot(zC)/r;return e&&(s=di(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)}},kC=new E,xy=class extends Mt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new _e,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 Me(i,3));let s=new ss({fog:!1,toneMapped:!1});this.cone=new tl(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),kC.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(kC),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var by=class extends Ut{constructor(t,e,r){let i=new Ls(e,4,2),s=new on({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 GC=new E,Wg=new E,jC=new E,Sy=class extends Mt{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 _e;i.setAttribute("position",new Me([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new ss({fog:!1,toneMapped:!1});this.lightPlane=new gc(i,s),this.add(this.lightPlane),i=new _e,i.setAttribute("position",new Me([0,0,0,0,0,1],3)),this.targetLine=new gc(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),GC.setFromMatrixPosition(this.light.matrixWorld),Wg.setFromMatrixPosition(this.light.target.matrixWorld),jC.subVectors(Wg,GC),this.lightPlane.lookAt(Wg),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(Wg),this.targetLine.scale.z=jC.length()}},qg=new E,Wr=new qn,al=class extends tl{constructor(t){let e=new _e,r=new ss({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(p,m){l(p),l(m)}function l(p){i.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(i.length/3-1)}e.setAttribute("position",new Me(i,3)),e.setAttribute("color",new Me(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 We(16755200),u=new We(16711680),h=new We(43775),d=new We(16777215),f=new We(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;Wr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Jr("c",e,t,Wr,0,0,-1),Jr("t",e,t,Wr,0,0,1),Jr("n1",e,t,Wr,-r,-i,-1),Jr("n2",e,t,Wr,r,-i,-1),Jr("n3",e,t,Wr,-r,i,-1),Jr("n4",e,t,Wr,r,i,-1),Jr("f1",e,t,Wr,-r,-i,1),Jr("f2",e,t,Wr,r,-i,1),Jr("f3",e,t,Wr,-r,i,1),Jr("f4",e,t,Wr,r,i,1),Jr("u1",e,t,Wr,r*.7,i*1.1,-1),Jr("u2",e,t,Wr,-r*.7,i*1.1,-1),Jr("u3",e,t,Wr,0,i*2,-1),Jr("cf1",e,t,Wr,-r,0,1),Jr("cf2",e,t,Wr,r,0,1),Jr("cf3",e,t,Wr,0,-i,1),Jr("cf4",e,t,Wr,0,i,1),Jr("cn1",e,t,Wr,-r,0,-1),Jr("cn2",e,t,Wr,r,0,-1),Jr("cn3",e,t,Wr,0,-i,-1),Jr("cn4",e,t,Wr,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Jr(n,t,e,r,i,s,o){qg.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],qg.x,qg.y,qg.z)}}var ll=class extends tl{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 _e;s.setIndex(new Xe(r,1)),s.setAttribute("position",new Me(i,3)),super(s,new ss({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 wy=class extends tl{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 _e;i.setAttribute("position",new Me(e,3)),i.setAttribute("color",new Me(r,3));let s=new ss({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,r){let i=new We,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 oa=k4();function k4(){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 G4(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=di(n,-65504,65504),oa.floatView[0]=n;let t=oa.uint32View[0],e=t>>23&511;return oa.baseTable[e]+((t&8388607)>>oa.shiftTable[e])}function j4(n){let t=n>>10;return oa.uint32View[0]=oa.mantissaTable[oa.offsetTable[t]+(n&1023)]+oa.exponentTable[t],oa.floatView[0]}var uP=Object.freeze({__proto__:null,fromHalfFloat:j4,toHalfFloat:G4});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ca}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ca);var eh=".",Ap=Symbol("target"),Rw=Symbol("unsubscribe");function Ep(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function hP(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var Qn=Array.isArray;function Ac(n){return typeof n=="symbol"}var H4={after:(n,t)=>Qn(n)?n.slice(t.length):t===""?n:n.slice(t.length+1),concat:(n,t)=>Qn(n)?(n=[...n],t&&n.push(t),n):t&&t.toString!==void 0?(n!==""&&(n+=eh),Ac(t)?n+t.toString():n+t):n,initial:n=>{if(Qn(n))return n.slice(0,-1);if(n==="")return n;let t=n.lastIndexOf(eh);return t===-1?"":n.slice(0,t)},last:n=>{if(Qn(n))return n[n.length-1]||"";if(n==="")return n;let t=n.lastIndexOf(eh);return t===-1?n:n.slice(t+1)},walk:(n,t)=>{if(Qn(n))for(let e of n)t(e);else if(n!==""){let e=0,r=n.indexOf(eh);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(eh,e)}},get(n,t){return this.walk(t,e=>{n&&(n=n[e])}),n}},gn=H4;function Lw(n){return typeof n=="object"&&typeof n.next=="function"}function Bw(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[Ap].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 Ty(n,t,e){return n.isUnsubscribed||t.ignoreSymbols&&Ac(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Mp=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,gn.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 th(n){return toString.call(n)==="[object Object]"}function rh(){return!0}function cl(n,t){return n.length!==t.length||n.some((e,r)=>t[r]!==e)}var Cy=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var W4=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Nw={push:rh,pop:rh,shift:rh,unshift:rh,copyWithin:cl,reverse:cl,sort:cl,splice:cl,flat:cl,fill:cl},dP=new Set([...Cy,...W4,...Object.keys(Nw)]);function ih(n,t){if(n.size!==t.size)return!0;for(let e of n)if(!t.has(e))return!0;return!1}var Fw=["keys","values","entries"],Vw=new Set(["has","toString"]),Uw={add:ih,clear:ih,delete:ih,forEach:ih},fP=new Set([...Vw,...Object.keys(Uw),...Fw]);function nh(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 q4=new Set([...Vw,"get"]),zw={set:nh,clear:nh,delete:nh,forEach:nh},pP=new Set([...q4,...Object.keys(zw),...Fw]);var Ni=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 Cy.has(t)}_shallowClone(t){let e=t;if(th(t))e={...t};else if(Qn(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?(Qn(i)?this._onIsChanged=Nw[e]:i instanceof Set?this._onIsChanged=Uw[e]:i instanceof Map&&(this._onIsChanged=zw[e]),i):r}update(t,e,r){let i=gn.after(t,this._path);if(e!=="length"){let s=this.clone;gn.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],gn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var sh=class extends Ni{static isHandledMethod(t){return dP.has(t)}};var Tp=class extends Ni{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var oh=class extends Ni{static isHandledMethod(t){return fP.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 ah=class extends Ni{static isHandledMethod(t){return pP.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 Cp=class extends Ni{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 Pp=class extends Ni{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 Ns=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return th(t)||Qn(t)||Ep(t)}static isHandledMethod(t,e){return th(t)?Ni.isHandledMethod(e):Qn(t)?sh.isHandledMethod(e):t instanceof Set?oh.isHandledMethod(e):t instanceof Map?ah.isHandledMethod(e):Ep(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let i=Ni;Qn(t)?i=sh:t instanceof Date?i=Tp:t instanceof Set?i=oh:t instanceof Map?i=ah:t instanceof WeakSet?i=Cp:t instanceof WeakMap&&(i=Pp),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=Ns.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 Y4={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},kw=(n,t,e={})=>{e={...Y4,...e};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new Mp(i),c=typeof e.onValidate=="function",u=new Ns(c),h=(v,x,S,w,A)=>!c||u.isCloning||e.onValidate(gn.concat(l.getPath(v),x),S,w,A)===!0,d=(v,x,S,w)=>{!Ty(l,e,x)&&!(o&&l.isDetached(v,n))&&f(l.getPath(v),x,S,w)},f=(v,x,S,w,A)=>{u.isCloning?u.update(v,x,w):t(gn.concat(v,x),S,w,A)},p=v=>v&&(v[r]||v),m=(v,x,S,w)=>hP(v)||S==="constructor"||s&&!Ns.isHandledMethod(x,S)||Ty(l,e,S)||l.isGetInvariant(x,S)||o&&l.isDetached(x,n)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,gn.concat(w,S),g,r)),g={get(v,x,S){if(Ac(x)){if(x===r||x===Ap)return v;if(x===Rw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=Ep(v)?Reflect.get(v,x):Reflect.get(v,x,S);return m(w,v,x)},set(v,x,S,w){S=p(S);let A=v[r]||v,M=A[x];if(i(M,S)&&x in v)return!0;let b=h(v,x,S,M);return b&&l.setProperty(A,x,S,w,M)?(d(v,x,v[x],M),!0):!b},defineProperty(v,x,S){if(!l.isSameDescriptor(S,v,x)){let w=v[x];h(v,x,S.value,w)&&l.defineProperty(v,x,S,w)&&d(v,x,S.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let S=Reflect.get(v,x),w=h(v,x,void 0,S);return w&&l.deleteProperty(v,x,S)?(d(v,x,void 0,S),!0):!w},apply(v,x,S){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,S);if((a===!1||a!==!0&&!a.includes(v.name))&&Ns.isHandledType(w)){let A=gn.initial(l.getPath(v)),M=Ns.isHandledMethod(w,v.name);u.start(w,A,S);let b=Reflect.apply(v,u.preferredThisArg(v,x,w),M?S.map(P=>p(P)):S),T=u.isChanged(w,i),C=u.stop();if(Ns.isHandledType(b)&&M&&(x instanceof Map&&v.name==="get"&&(A=gn.concat(A,S[0])),b=l.getProxy(b,A,g)),T){let P={name:v.name,args:S,result:b},D=u.isCloning?gn.initial(A):A,_=u.isCloning?gn.last(A):"";h(gn.get(n,D),_,w,C,P)?f(D,_,w,C,P):u.undo(w)}return(x instanceof Map||x instanceof Set)&&Lw(b)?Bw(b,v,x,A,m):b}return Reflect.apply(v,x,S)}},y=l.getProxy(n,e.pathAsArray?[]:"",g);return t=t.bind(y),c&&(e.onValidate=e.onValidate.bind(y)),y};kw.target=n=>n&&n[Ap]||n;kw.unsubscribe=n=>n[Rw]||n;var Gw=kw;var X4=typeof global=="object"&&global&&global.Object===Object&&global,Py=X4;var Q4=typeof self=="object"&&self&&self.Object===Object&&self,K4=Py||Q4||Function("return this")(),Yr=K4;var Z4=Yr.Symbol,Fi=Z4;var mP=Object.prototype,J4=mP.hasOwnProperty,$4=mP.toString,_p=Fi?Fi.toStringTag:void 0;function ej(n){var t=J4.call(n,_p),e=n[_p];try{n[_p]=void 0;var r=!0}catch{}var i=$4.call(n);return r&&(t?n[_p]=e:delete n[_p]),i}var gP=ej;var tj=Object.prototype,rj=tj.toString;function ij(n){return rj.call(n)}var yP=ij;var nj="[object Null]",sj="[object Undefined]",vP=Fi?Fi.toStringTag:void 0;function oj(n){return n==null?n===void 0?sj:nj:vP&&vP in Object(n)?gP(n):yP(n)}var Kn=oj;function aj(n){return n!=null&&typeof n=="object"}var Wi=aj;var lj="[object Symbol]";function cj(n){return typeof n=="symbol"||Wi(n)&&Kn(n)==lj}var po=cj;function uj(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 _y=uj;var hj=Array.isArray,Ti=hj;var dj=1/0,xP=Fi?Fi.prototype:void 0,bP=xP?xP.toString:void 0;function SP(n){if(typeof n=="string")return n;if(Ti(n))return _y(n,SP)+"";if(po(n))return bP?bP.call(n):"";var t=n+"";return t=="0"&&1/n==-dj?"-0":t}var wP=SP;var fj=/\s/;function pj(n){for(var t=n.length;t--&&fj.test(n.charAt(t)););return t}var AP=pj;var mj=/^\s+/;function gj(n){return n&&n.slice(0,AP(n)+1).replace(mj,"")}var EP=gj;function yj(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var yi=yj;var MP=0/0,vj=/^[-+]0x[0-9a-f]+$/i,xj=/^0b[01]+$/i,bj=/^0o[0-7]+$/i,Sj=parseInt;function wj(n){if(typeof n=="number")return n;if(po(n))return MP;if(yi(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=yi(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=EP(n);var e=xj.test(n);return e||bj.test(n)?Sj(n.slice(2),e?2:8):vj.test(n)?MP:+n}var jw=wj;function Aj(n){return n}var Dy=Aj;var Ej="[object AsyncFunction]",Mj="[object Function]",Tj="[object GeneratorFunction]",Cj="[object Proxy]";function Pj(n){if(!yi(n))return!1;var t=Kn(n);return t==Mj||t==Tj||t==Ej||t==Cj}var Iy=Pj;var _j=Yr["__core-js_shared__"],Oy=_j;var TP=function(){var n=/[^.]+$/.exec(Oy&&Oy.keys&&Oy.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Dj(n){return!!TP&&TP in n}var CP=Dj;var Ij=Function.prototype,Oj=Ij.toString;function Rj(n){if(n!=null){try{return Oj.call(n)}catch{}try{return n+""}catch{}}return""}var ua=Rj;var Lj=/[\\^$.*+?()[\]{}|]/g,Bj=/^\[object .+?Constructor\]$/,Nj=Function.prototype,Fj=Object.prototype,Vj=Nj.toString,Uj=Fj.hasOwnProperty,zj=RegExp("^"+Vj.call(Uj).replace(Lj,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function kj(n){if(!yi(n)||CP(n))return!1;var t=Iy(n)?zj:Bj;return t.test(ua(n))}var PP=kj;function Gj(n,t){return n?.[t]}var _P=Gj;function jj(n,t){var e=_P(n,t);return PP(e)?e:void 0}var Cn=jj;var Hj=Cn(Yr,"WeakMap"),Ry=Hj;var DP=Object.create,Wj=function(){function n(){}return function(t){if(!yi(t))return{};if(DP)return DP(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),IP=Wj;function qj(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 OP=qj;function Yj(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var RP=Yj;var Xj=800,Qj=16,Kj=Date.now;function Zj(n){var t=0,e=0;return function(){var r=Kj(),i=Qj-(r-e);if(e=r,i>0){if(++t>=Xj)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var LP=Zj;function Jj(n){return function(){return n}}var BP=Jj;var $j=function(){try{var n=Cn(Object,"defineProperty");return n({},"",{}),n}catch{}}(),lh=$j;var eH=lh?function(n,t){return lh(n,"toString",{configurable:!0,enumerable:!1,value:BP(t),writable:!0})}:Dy,NP=eH;var tH=LP(NP),FP=tH;function rH(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var VP=rH;var iH=9007199254740991,nH=/^(?:0|[1-9]\d*)$/;function sH(n,t){var e=typeof n;return t=t??iH,!!t&&(e=="number"||e!="symbol"&&nH.test(n))&&n>-1&&n%1==0&&n<t}var ch=sH;function oH(n,t,e){t=="__proto__"&&lh?lh(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Ly=oH;function aH(n,t){return n===t||n!==n&&t!==t}var uh=aH;var lH=Object.prototype,cH=lH.hasOwnProperty;function uH(n,t,e){var r=n[t];(!(cH.call(n,t)&&uh(r,e))||e===void 0&&!(t in n))&&Ly(n,t,e)}var hh=uH;function hH(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?Ly(e,a,l):hh(e,a,l)}return e}var mo=hH;var UP=Math.max;function dH(n,t,e){return t=UP(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,s=UP(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),OP(n,this,a)}}var zP=dH;var fH=9007199254740991;function pH(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=fH}var dh=pH;function mH(n){return n!=null&&dh(n.length)&&!Iy(n)}var By=mH;var gH=Object.prototype;function yH(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||gH;return n===e}var fh=yH;function vH(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var kP=vH;var xH="[object Arguments]";function bH(n){return Wi(n)&&Kn(n)==xH}var Hw=bH;var GP=Object.prototype,SH=GP.hasOwnProperty,wH=GP.propertyIsEnumerable,AH=Hw(function(){return arguments}())?Hw:function(n){return Wi(n)&&SH.call(n,"callee")&&!wH.call(n,"callee")},ph=AH;function EH(){return!1}var jP=EH;var qP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,HP=qP&&typeof module=="object"&&module&&!module.nodeType&&module,MH=HP&&HP.exports===qP,WP=MH?Yr.Buffer:void 0,TH=WP?WP.isBuffer:void 0,CH=TH||jP,Ec=CH;var PH="[object Arguments]",_H="[object Array]",DH="[object Boolean]",IH="[object Date]",OH="[object Error]",RH="[object Function]",LH="[object Map]",BH="[object Number]",NH="[object Object]",FH="[object RegExp]",VH="[object Set]",UH="[object String]",zH="[object WeakMap]",kH="[object ArrayBuffer]",GH="[object DataView]",jH="[object Float32Array]",HH="[object Float64Array]",WH="[object Int8Array]",qH="[object Int16Array]",YH="[object Int32Array]",XH="[object Uint8Array]",QH="[object Uint8ClampedArray]",KH="[object Uint16Array]",ZH="[object Uint32Array]",Dr={};Dr[jH]=Dr[HH]=Dr[WH]=Dr[qH]=Dr[YH]=Dr[XH]=Dr[QH]=Dr[KH]=Dr[ZH]=!0;Dr[PH]=Dr[_H]=Dr[kH]=Dr[DH]=Dr[GH]=Dr[IH]=Dr[OH]=Dr[RH]=Dr[LH]=Dr[BH]=Dr[NH]=Dr[FH]=Dr[VH]=Dr[UH]=Dr[zH]=!1;function JH(n){return Wi(n)&&dh(n.length)&&!!Dr[Kn(n)]}var YP=JH;function $H(n){return function(t){return n(t)}}var mh=$H;var XP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dp=XP&&typeof module=="object"&&module&&!module.nodeType&&module,e5=Dp&&Dp.exports===XP,Ww=e5&&Py.process,t5=function(){try{var n=Dp&&Dp.require&&Dp.require("util").types;return n||Ww&&Ww.binding&&Ww.binding("util")}catch{}}(),ha=t5;var QP=ha&&ha.isTypedArray,r5=QP?mh(QP):YP,Ny=r5;var i5=Object.prototype,n5=i5.hasOwnProperty;function s5(n,t){var e=Ti(n),r=!e&&ph(n),i=!e&&!r&&Ec(n),s=!e&&!r&&!i&&Ny(n),o=e||r||i||s,a=o?kP(n.length,String):[],l=a.length;for(var c in n)(t||n5.call(n,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ch(c,l)))&&a.push(c);return a}var Fy=s5;function o5(n,t){return function(e){return n(t(e))}}var Vy=o5;var a5=Vy(Object.keys,Object),KP=a5;var l5=Object.prototype,c5=l5.hasOwnProperty;function u5(n){if(!fh(n))return KP(n);var t=[];for(var e in Object(n))c5.call(n,e)&&e!="constructor"&&t.push(e);return t}var ZP=u5;function h5(n){return By(n)?Fy(n):ZP(n)}var gh=h5;function d5(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var JP=d5;var f5=Object.prototype,p5=f5.hasOwnProperty;function m5(n){if(!yi(n))return JP(n);var t=fh(n),e=[];for(var r in n)r=="constructor"&&(t||!p5.call(n,r))||e.push(r);return e}var $P=m5;function g5(n){return By(n)?Fy(n,!0):$P(n)}var ls=g5;var y5=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,v5=/^\w*$/;function x5(n,t){if(Ti(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||po(n)?!0:v5.test(n)||!y5.test(n)||t!=null&&n in Object(t)}var e_=x5;var b5=Cn(Object,"create"),da=b5;function S5(){this.__data__=da?da(null):{},this.size=0}var t_=S5;function w5(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var r_=w5;var A5="__lodash_hash_undefined__",E5=Object.prototype,M5=E5.hasOwnProperty;function T5(n){var t=this.__data__;if(da){var e=t[n];return e===A5?void 0:e}return M5.call(t,n)?t[n]:void 0}var i_=T5;var C5=Object.prototype,P5=C5.hasOwnProperty;function _5(n){var t=this.__data__;return da?t[n]!==void 0:P5.call(t,n)}var n_=_5;var D5="__lodash_hash_undefined__";function I5(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=da&&t===void 0?D5:t,this}var s_=I5;function yh(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])}}yh.prototype.clear=t_;yh.prototype.delete=r_;yh.prototype.get=i_;yh.prototype.has=n_;yh.prototype.set=s_;var qw=yh;function O5(){this.__data__=[],this.size=0}var o_=O5;function R5(n,t){for(var e=n.length;e--;)if(uh(n[e][0],t))return e;return-1}var ul=R5;var L5=Array.prototype,B5=L5.splice;function N5(n){var t=this.__data__,e=ul(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():B5.call(t,e,1),--this.size,!0}var a_=N5;function F5(n){var t=this.__data__,e=ul(t,n);return e<0?void 0:t[e][1]}var l_=F5;function V5(n){return ul(this.__data__,n)>-1}var c_=V5;function U5(n,t){var e=this.__data__,r=ul(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var u_=U5;function vh(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])}}vh.prototype.clear=o_;vh.prototype.delete=a_;vh.prototype.get=l_;vh.prototype.has=c_;vh.prototype.set=u_;var hl=vh;var z5=Cn(Yr,"Map"),dl=z5;function k5(){this.size=0,this.__data__={hash:new qw,map:new(dl||hl),string:new qw}}var h_=k5;function G5(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var d_=G5;function j5(n,t){var e=n.__data__;return d_(t)?e[typeof t=="string"?"string":"hash"]:e.map}var fl=j5;function H5(n){var t=fl(this,n).delete(n);return this.size-=t?1:0,t}var f_=H5;function W5(n){return fl(this,n).get(n)}var p_=W5;function q5(n){return fl(this,n).has(n)}var m_=q5;function Y5(n,t){var e=fl(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var g_=Y5;function xh(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])}}xh.prototype.clear=h_;xh.prototype.delete=f_;xh.prototype.get=p_;xh.prototype.has=m_;xh.prototype.set=g_;var Mc=xh;var X5="Expected a function";function Yw(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(X5);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(Yw.Cache||Mc),e}Yw.Cache=Mc;var y_=Yw;var Q5=500;function K5(n){var t=y_(n,function(r){return e.size===Q5&&e.clear(),r}),e=t.cache;return t}var v_=K5;var Z5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,J5=/\\(\\)?/g,$5=v_(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(Z5,function(e,r,i,s){t.push(i?s.replace(J5,"$1"):r||e)}),t}),x_=$5;function eW(n){return n==null?"":wP(n)}var b_=eW;function tW(n,t){return Ti(n)?n:e_(n,t)?[n]:x_(b_(n))}var cs=tW;var rW=1/0;function iW(n){if(typeof n=="string"||po(n))return n;var t=n+"";return t=="0"&&1/n==-rW?"-0":t}var pl=iW;function nW(n,t){t=cs(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[pl(t[e++])];return e&&e==r?n:void 0}var Uy=nW;function sW(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var bh=sW;var S_=Fi?Fi.isConcatSpreadable:void 0;function oW(n){return Ti(n)||ph(n)||!!(S_&&n&&n[S_])}var w_=oW;function A_(n,t,e,r,i){var s=-1,o=n.length;for(e||(e=w_),i||(i=[]);++s<o;){var a=n[s];t>0&&e(a)?t>1?A_(a,t-1,e,r,i):bh(i,a):r||(i[i.length]=a)}return i}var E_=A_;function aW(n){var t=n==null?0:n.length;return t?E_(n,1):[]}var M_=aW;function lW(n){return FP(zP(n,void 0,M_),n+"")}var zy=lW;var cW=Vy(Object.getPrototypeOf,Object),Sh=cW;var uW="[object Object]",hW=Function.prototype,dW=Object.prototype,T_=hW.toString,fW=dW.hasOwnProperty,pW=T_.call(Object);function mW(n){if(!Wi(n)||Kn(n)!=uW)return!1;var t=Sh(n);if(t===null)return!0;var e=fW.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&T_.call(e)==pW}var C_=mW;function gW(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 P_=gW;function yW(){this.__data__=new hl,this.size=0}var __=yW;function vW(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var D_=vW;function xW(n){return this.__data__.get(n)}var I_=xW;function bW(n){return this.__data__.has(n)}var O_=bW;var SW=200;function wW(n,t){var e=this.__data__;if(e instanceof hl){var r=e.__data__;if(!dl||r.length<SW-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Mc(r)}return e.set(n,t),this.size=e.size,this}var R_=wW;function wh(n){var t=this.__data__=new hl(n);this.size=t.size}wh.prototype.clear=__;wh.prototype.delete=D_;wh.prototype.get=I_;wh.prototype.has=O_;wh.prototype.set=R_;var Ah=wh;function AW(n,t){return n&&mo(t,gh(t),n)}var L_=AW;function EW(n,t){return n&&mo(t,ls(t),n)}var B_=EW;var U_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,N_=U_&&typeof module=="object"&&module&&!module.nodeType&&module,MW=N_&&N_.exports===U_,F_=MW?Yr.Buffer:void 0,V_=F_?F_.allocUnsafe:void 0;function TW(n,t){if(t)return n.slice();var e=n.length,r=V_?V_(e):new n.constructor(e);return n.copy(r),r}var z_=TW;function CW(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 k_=CW;function PW(){return[]}var ky=PW;var _W=Object.prototype,DW=_W.propertyIsEnumerable,G_=Object.getOwnPropertySymbols,IW=G_?function(n){return n==null?[]:(n=Object(n),k_(G_(n),function(t){return DW.call(n,t)}))}:ky,Eh=IW;function OW(n,t){return mo(n,Eh(n),t)}var j_=OW;var RW=Object.getOwnPropertySymbols,LW=RW?function(n){for(var t=[];n;)bh(t,Eh(n)),n=Sh(n);return t}:ky,Gy=LW;function BW(n,t){return mo(n,Gy(n),t)}var H_=BW;function NW(n,t,e){var r=t(n);return Ti(n)?r:bh(r,e(n))}var jy=NW;function FW(n){return jy(n,gh,Eh)}var Ip=FW;function VW(n){return jy(n,ls,Gy)}var Hy=VW;var UW=Cn(Yr,"DataView"),Wy=UW;var zW=Cn(Yr,"Promise"),qy=zW;var kW=Cn(Yr,"Set"),Yy=kW;var W_="[object Map]",GW="[object Object]",q_="[object Promise]",Y_="[object Set]",X_="[object WeakMap]",Q_="[object DataView]",jW=ua(Wy),HW=ua(dl),WW=ua(qy),qW=ua(Yy),YW=ua(Ry),Tc=Kn;(Wy&&Tc(new Wy(new ArrayBuffer(1)))!=Q_||dl&&Tc(new dl)!=W_||qy&&Tc(qy.resolve())!=q_||Yy&&Tc(new Yy)!=Y_||Ry&&Tc(new Ry)!=X_)&&(Tc=function(n){var t=Kn(n),e=t==GW?n.constructor:void 0,r=e?ua(e):"";if(r)switch(r){case jW:return Q_;case HW:return W_;case WW:return q_;case qW:return Y_;case YW:return X_}return t});var fa=Tc;var XW=Object.prototype,QW=XW.hasOwnProperty;function KW(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&QW.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var K_=KW;var ZW=Yr.Uint8Array,Mh=ZW;function JW(n){var t=new n.constructor(n.byteLength);return new Mh(t).set(new Mh(n)),t}var Th=JW;function $W(n,t){var e=t?Th(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Z_=$W;var e6=/\w*$/;function t6(n){var t=new n.constructor(n.source,e6.exec(n));return t.lastIndex=n.lastIndex,t}var J_=t6;var $_=Fi?Fi.prototype:void 0,e2=$_?$_.valueOf:void 0;function r6(n){return e2?Object(e2.call(n)):{}}var t2=r6;function i6(n,t){var e=t?Th(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var r2=i6;var n6="[object Boolean]",s6="[object Date]",o6="[object Map]",a6="[object Number]",l6="[object RegExp]",c6="[object Set]",u6="[object String]",h6="[object Symbol]",d6="[object ArrayBuffer]",f6="[object DataView]",p6="[object Float32Array]",m6="[object Float64Array]",g6="[object Int8Array]",y6="[object Int16Array]",v6="[object Int32Array]",x6="[object Uint8Array]",b6="[object Uint8ClampedArray]",S6="[object Uint16Array]",w6="[object Uint32Array]";function A6(n,t,e){var r=n.constructor;switch(t){case d6:return Th(n);case n6:case s6:return new r(+n);case f6:return Z_(n,e);case p6:case m6:case g6:case y6:case v6:case x6:case b6:case S6:case w6:return r2(n,e);case o6:return new r;case a6:case u6:return new r(n);case l6:return J_(n);case c6:return new r;case h6:return t2(n)}}var i2=A6;function E6(n){return typeof n.constructor=="function"&&!fh(n)?IP(Sh(n)):{}}var n2=E6;var M6="[object Map]";function T6(n){return Wi(n)&&fa(n)==M6}var s2=T6;var o2=ha&&ha.isMap,C6=o2?mh(o2):s2,a2=C6;var P6="[object Set]";function _6(n){return Wi(n)&&fa(n)==P6}var l2=_6;var c2=ha&&ha.isSet,D6=c2?mh(c2):l2,u2=D6;var I6=1,O6=2,R6=4,h2="[object Arguments]",L6="[object Array]",B6="[object Boolean]",N6="[object Date]",F6="[object Error]",d2="[object Function]",V6="[object GeneratorFunction]",U6="[object Map]",z6="[object Number]",f2="[object Object]",k6="[object RegExp]",G6="[object Set]",j6="[object String]",H6="[object Symbol]",W6="[object WeakMap]",q6="[object ArrayBuffer]",Y6="[object DataView]",X6="[object Float32Array]",Q6="[object Float64Array]",K6="[object Int8Array]",Z6="[object Int16Array]",J6="[object Int32Array]",$6="[object Uint8Array]",e8="[object Uint8ClampedArray]",t8="[object Uint16Array]",r8="[object Uint32Array]",Pr={};Pr[h2]=Pr[L6]=Pr[q6]=Pr[Y6]=Pr[B6]=Pr[N6]=Pr[X6]=Pr[Q6]=Pr[K6]=Pr[Z6]=Pr[J6]=Pr[U6]=Pr[z6]=Pr[f2]=Pr[k6]=Pr[G6]=Pr[j6]=Pr[H6]=Pr[$6]=Pr[e8]=Pr[t8]=Pr[r8]=!0;Pr[F6]=Pr[d2]=Pr[W6]=!1;function Xy(n,t,e,r,i,s){var o,a=t&I6,l=t&O6,c=t&R6;if(e&&(o=i?e(n,r,i,s):e(n)),o!==void 0)return o;if(!yi(n))return n;var u=Ti(n);if(u){if(o=K_(n),!a)return RP(n,o)}else{var h=fa(n),d=h==d2||h==V6;if(Ec(n))return z_(n,a);if(h==f2||h==h2||d&&!i){if(o=l||d?{}:n2(n),!a)return l?H_(n,B_(o,n)):j_(n,L_(o,n))}else{if(!Pr[h])return i?n:{};o=i2(n,h,a)}}s||(s=new Ah);var f=s.get(n);if(f)return f;s.set(n,o),u2(n)?n.forEach(function(g){o.add(Xy(g,t,e,g,n,s))}):a2(n)&&n.forEach(function(g,y){o.set(y,Xy(g,t,e,y,n,s))});var p=c?l?Hy:Ip:l?ls:gh,m=u?void 0:p(n);return VP(m||n,function(g,y){m&&(y=g,g=n[y]),hh(o,y,Xy(g,t,e,y,n,s))}),o}var Qy=Xy;var i8=1,n8=4;function s8(n){return Qy(n,i8|n8)}var pa=s8;var o8="__lodash_hash_undefined__";function a8(n){return this.__data__.set(n,o8),this}var p2=a8;function l8(n){return this.__data__.has(n)}var m2=l8;function Ky(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Mc;++t<e;)this.add(n[t])}Ky.prototype.add=Ky.prototype.push=p2;Ky.prototype.has=m2;var g2=Ky;function c8(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 y2=c8;function u8(n,t){return n.has(t)}var v2=u8;var h8=1,d8=2;function f8(n,t,e,r,i,s){var o=e&h8,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&d8?new g2:void 0;for(s.set(n,t),s.set(t,n);++h<a;){var p=n[h],m=t[h];if(r)var g=o?r(m,p,h,t,n,s):r(p,m,h,n,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!y2(t,function(y,v){if(!v2(f,v)&&(p===y||i(p,y,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||i(p,m,e,r,s))){d=!1;break}}return s.delete(n),s.delete(t),d}var Zy=f8;function p8(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var x2=p8;function m8(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var b2=m8;var g8=1,y8=2,v8="[object Boolean]",x8="[object Date]",b8="[object Error]",S8="[object Map]",w8="[object Number]",A8="[object RegExp]",E8="[object Set]",M8="[object String]",T8="[object Symbol]",C8="[object ArrayBuffer]",P8="[object DataView]",S2=Fi?Fi.prototype:void 0,Xw=S2?S2.valueOf:void 0;function _8(n,t,e,r,i,s,o){switch(e){case P8:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case C8:return!(n.byteLength!=t.byteLength||!s(new Mh(n),new Mh(t)));case v8:case x8:case w8:return uh(+n,+t);case b8:return n.name==t.name&&n.message==t.message;case A8:case M8:return n==t+"";case S8:var a=x2;case E8:var l=r&g8;if(a||(a=b2),n.size!=t.size&&!l)return!1;var c=o.get(n);if(c)return c==t;r|=y8,o.set(n,t);var u=Zy(a(n),a(t),r,i,s,o);return o.delete(n),u;case T8:if(Xw)return Xw.call(n)==Xw.call(t)}return!1}var w2=_8;var D8=1,I8=Object.prototype,O8=I8.hasOwnProperty;function R8(n,t,e,r,i,s){var o=e&D8,a=Ip(n),l=a.length,c=Ip(t),u=c.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:O8.call(t,d)))return!1}var f=s.get(n),p=s.get(t);if(f&&p)return f==t&&p==n;var m=!0;s.set(n,t),s.set(t,n);for(var g=o;++h<l;){d=a[h];var y=n[d],v=t[d];if(r)var x=o?r(v,y,d,t,n,s):r(y,v,d,n,t,s);if(!(x===void 0?y===v||i(y,v,e,r,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var S=n.constructor,w=t.constructor;S!=w&&"constructor"in n&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof w=="function"&&w instanceof w)&&(m=!1)}return s.delete(n),s.delete(t),m}var A2=R8;var L8=1,E2="[object Arguments]",M2="[object Array]",Jy="[object Object]",B8=Object.prototype,T2=B8.hasOwnProperty;function N8(n,t,e,r,i,s){var o=Ti(n),a=Ti(t),l=o?M2:fa(n),c=a?M2:fa(t);l=l==E2?Jy:l,c=c==E2?Jy:c;var u=l==Jy,h=c==Jy,d=l==c;if(d&&Ec(n)){if(!Ec(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new Ah),o||Ny(n)?Zy(n,t,e,r,i,s):w2(n,t,l,e,r,i,s);if(!(e&L8)){var f=u&&T2.call(n,"__wrapped__"),p=h&&T2.call(t,"__wrapped__");if(f||p){var m=f?n.value():n,g=p?t.value():t;return s||(s=new Ah),i(m,g,e,r,s)}}return d?(s||(s=new Ah),A2(n,t,e,r,i,s)):!1}var C2=N8;function P2(n,t,e,r,i){return n===t?!0:n==null||t==null||!Wi(n)&&!Wi(t)?n!==n&&t!==t:C2(n,t,e,r,P2,i)}var _2=P2;function F8(n,t){return n!=null&&t in Object(n)}var D2=F8;function V8(n,t,e){t=cs(t,n);for(var r=-1,i=t.length,s=!1;++r<i;){var o=pl(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&&dh(i)&&ch(o,i)&&(Ti(n)||ph(n)))}var I2=V8;function U8(n,t){return n!=null&&I2(n,t,D2)}var O2=U8;var z8=function(){return Yr.Date.now()},$y=z8;var k8="Expected a function",G8=Math.max,j8=Math.min;function H8(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(k8);t=jw(t)||0,yi(e)&&(u=!!e.leading,h="maxWait"in e,s=h?G8(jw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var M=r,b=i;return r=i=void 0,c=A,o=n.apply(b,M),o}function p(A){return c=A,a=setTimeout(y,t),u?f(A):o}function m(A){var M=A-l,b=A-c,T=t-M;return h?j8(T,s-b):T}function g(A){var M=A-l,b=A-c;return l===void 0||M>=t||M<0||h&&b>=s}function y(){var A=$y();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function S(){return a===void 0?o:v($y())}function w(){var A=$y(),M=g(A);if(r=arguments,i=this,l=A,M){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=S,w}var go=H8;function W8(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var R2=W8;function q8(n,t){return n>t}var L2=q8;function Y8(n,t){return t.length<2?n:Uy(n,P_(t,0,-1))}var B2=Y8;function X8(n,t){return _2(n,t)}var Cc=X8;function Q8(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&&!po(o):e(o,a)))var a=o,l=s}return l}var N2=Q8;function K8(n){return n&&n.length?N2(n,Dy,L2):void 0}var Qw=K8;function Z8(n,t){return t=cs(t,n),n=B2(n,t),n==null||delete n[pl(R2(t))]}var F2=Z8;function J8(n){return C_(n)?void 0:n}var V2=J8;var $8=1,eq=2,tq=4,rq=zy(function(n,t){var e={};if(n==null)return e;var r=!1;t=_y(t,function(s){return s=cs(s,n),r||(r=s.length>1),s}),mo(n,Hy(n),e),r&&(e=Qy(e,$8|eq|tq,V2));for(var i=t.length;i--;)F2(e,t[i]);return e}),Ch=rq;function iq(n,t,e,r){if(!yi(n))return n;t=cs(t,n);for(var i=-1,s=t.length,o=s-1,a=n;a!=null&&++i<s;){var l=pl(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=yi(u)?u:ch(t[i+1])?[]:{})}hh(a,l,c),a=a[l]}return n}var U2=iq;function nq(n,t,e){for(var r=-1,i=t.length,s={};++r<i;){var o=t[r],a=Uy(n,o);e(a,o)&&U2(s,cs(o,n),a)}return s}var z2=nq;function sq(n,t){return z2(n,t,function(e,r){return O2(n,r)})}var k2=sq;var oq=zy(function(n,t){return n==null?{}:k2(n,t)}),Pn=oq;var aq="Expected a function";function lq(n,t,e){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(aq);return yi(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),go(n,t,{leading:r,maxWait:t,trailing:i})}var Kw=lq;function ev(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function qi(n,t){return Object.setPrototypeOf(n,t),n}var cq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),uq=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),hq=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ph&&"ontouchend"in document,dq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,fq=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,pq=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},mq=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},gq=()=>{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"},Zw=cq(),mce=Zw?gq():void 0,Ph=uq(),yo=hq(),G2=dq(),Ci=fq(),Jw=pq(),j2=Number(mq());function tv(n){return Array.isArray(n)?n:[n]}function rv(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 Op(n){return Ph?n.metaKey:n.ctrlKey}function H2(n){return n.wheelDeltaY===0||n.deltaY===0?Ph&&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 Je=[],nv={},Rp={},iv={};function W2(n){Je.includes(n)||Je.push(n)}function _h(n){delete nv[n.pointerId];for(let t=0;t<Je.length;t++)if(Je[t].pointerId===n.pointerId){Je.splice(t,1);break}}function q2(){Je.splice(0,Je.length)}function sv(n){if(n.pointerType!=="touch")return;let t=nv[n.pointerId];t===void 0&&(t={x:0,y:0},nv[n.pointerId]=t),t.x=n.pageX,t.y=n.pageY}function ov(n){let t=n.pointerId===Je[0].pointerId?Je[1]:Je[0];return nv[t.pointerId]}function Y2(n){Rp[n.key]=!0,iv[n.key]=iv[n.key]===void 0?1:iv[n.key]+1}function X2(n){if(Ph&&Rp.Meta)for(let t in Rp)Rp[t]=!1;else Rp[n.key]=!1;iv={}}function Q2(n){n.addEventListener("pointerdown",W2,!0),n.addEventListener("pointerdown",sv,!0),n.addEventListener("pointermove",sv,!0),n.addEventListener("pointerup",_h,!0),n.addEventListener("pointercancel",_h,!0),n.addEventListener("pointerleave",_h,!0),window.addEventListener("keydown",Y2,!0),window.addEventListener("keyup",X2,!0)}function K2(n){n.removeEventListener("pointerdown",W2,!0),n.removeEventListener("pointerdown",sv,!0),n.removeEventListener("pointermove",sv,!0),n.removeEventListener("pointerup",_h,!0),n.removeEventListener("pointercancel",_h,!0),n.removeEventListener("pointerleave",_h,!0),window.removeEventListener("keydown",Y2,!0),window.removeEventListener("keyup",X2,!0)}var Z2,J2=new Promise(n=>{Z2=n});var av;function $2(){if(av)return av;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.9.31/build",i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});Z2(l)}return av=n(),av}var eD,tD=new Promise(n=>{eD=n});var lv;function rD(){if(lv)return lv;async function n(){let e=await import("./physics.js");await e.init(),eD(e)}return lv=n(),lv}var Ke=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,Ke.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,Ke.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,Ke.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:i}}}}return null}};function Lp(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"&&Lp(r)}return Object.freeze(n)}function iD(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 Dh=class extends Error{};function cv(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function vo(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 Ih(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 nD(){return typeof process<"u"}function sD(n,t){for(let e of n)t(e.id,e.data)!==!0&&sD(e.children,t)}function oD(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)oD(e,t)}var gr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,gr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lp(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&&oD(i,r)}}traverse(e){sD(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,gr.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 Dh("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,p)=>f.fi-p.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)=>iD(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 vo(0,i,i);{let o=s[0].fi;return vo(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 vo(l,l+i,i)}else return vo(o.fi,a.fi,i)}}};var Oh;(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})(Oh||(Oh={}));var Ue=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ue.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lp(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,Ue.prototype);let r=e;return nD()||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 vo(0,r,r);{let s=i[0].fi;return vo(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 vo(a,a+r,r)}else return vo(s.fi,o.fi,r)}}};function Rh(n){return n&&typeof n=="object"&&n instanceof yr}var yr=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&&!Rh(r))return null;i+=1}r=r?cv(r):new yr;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=cv(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=cv(l);c[t.path[i-1]]=r,r=c}else{let c=new yr;c[t.path[i-1]]=r,r=c}}i-=1}let o=Object.setPrototypeOf(r,yr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},xo;(r=>{function n(i,s){return Bp(i,s)??i}r.apply=n;function t(i,s){return e1(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=Sr.zoomOnce(l,a[o]),l===void 0)return s;if(!Rh(l))return;o+=1}if(l===void 0)return s;if(!!Rh(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=$w([s],l);return c?(console.log(c),c):s}else return s}r.filterOp=e})(xo||(xo={}));function $w(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=Bp(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=$w(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 yq(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=Bp(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 Bp(n,t){if(!Rh(t))return t;if(n instanceof gr){let e=$w(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Ue)return yq(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,s)=>{let o=Bp(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 yr)return e1(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,s]of Object.entries(n)){let o=Bp(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 e1(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!Rh(t))return t;if(!Rh(n))return xo.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 yr;for(let i of e){let s=e1(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=s}return r}function aD(n,t){let e={cur:[],result:[],len:0};return n=Np(n,t,e)??n,[n,e.result]}function uv(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function hv(n){n&&(n.len-=1)}function vq(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function lD(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=Np(s.data,t,uv(e,o));hv(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=lD(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 xq(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=Np(s.data,t,uv(e,o));return hv(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 Np(n,t,e){if(n instanceof gr){let r=lD(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof Ue)return xq(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((s,o)=>{let a=Np(s,t,uv(e,o));return hv(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"&&!Ih(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=Np(o,t,uv(e,s));hv(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&&vq(e),r}else return}}var Lh;(t=>{function n(e,r){let i=Sr.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})(Lh||(Lh={}));var Lr;(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 yr&&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 gr||l instanceof Ue||l instanceof Ke?d=l.runOp(c):d=Oh.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=u[g],v=h[g];if(v instanceof gr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Ue){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Ke){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof yr){let x={...v,[y]:m};m=Object.setPrototypeOf(x,yr.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],p;if(l instanceof gr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Ue){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;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})(Lr||(Lr={}));var Fp;(l=>{function n(){return[]}l.empty=n;function t(c,u){let h=[];for(let d of c){let[f,...p]=d.path;f===u&&h.push({...d,path:p})}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=>Lr.subsumed(d,f))),...u]}l.compress=i;function s(c,u){return c.every(h=>u.every(d=>Lr.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 p of u)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Sr.zoom(h,[...p.path,p.id]),y=Lr.apply(h,{...p,type:2})):(m=Sr.zoom(h,[...p.path,p.id,"value"]),y=Lr.apply(h,p)),y!==null){h=y.data;let[v,x]=aD(h,{[p.id]:m});h=v;for(let S=0;S<x.length;S++){let w=x[S],A=w.pop();if(typeof A=="number"){let M=[A];for(let T=S+1;T<x.length;T++){let C=x[T],P=C[C.length-1];if(typeof P=="number"&&Sr.equal(w,C.slice(0,C.length-1)))M.push(P),x.splice(T,1);else break}let b=Sr.zoom(h,w);g=b.map((T,C)=>M.includes(C)?p.id:T),m=b,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let M=m,b=Sr.zoom(h,w.slice(0,w.length-2)),T=b.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:M}}:C);Object.setPrototypeOf(T,Object.getPrototypeOf(b.layers)),b.layers=T}g=p.id}d.push({type:0,path:w,props:{[A]:m}}),f.push({type:0,path:w,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Lr.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Dh)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(Fp||(Fp={}));var cD=Symbol(),bq=Symbol(),fv=Symbol(),Pc=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let s=r;for(;!(i instanceof dv);){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[fv];r&&r(),delete this._children[t]}}}},r1=class extends Pc{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 this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Oh.runOp(this._current,t),t.path)}},i1=class extends Pc{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,Ke.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},uD={get(n,t){if(t===fv)return()=>{n._parent=null};if(t===cD)return n._current;if(t===bq)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=pv(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]}}},Sq={...uD,set(n,t,e){let r={type:0,props:{[t]:kr(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}},wq={...uD,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}},Bh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fv]=()=>{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=pv(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)}},Nh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fv]=()=>{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=pv(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 t1(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Sr.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var dv=class extends Pc{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){t1(this.ts,e,t),t1(this.actual,r,t),t1(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function pv(n,t,e){return e instanceof gr?new Bh(n,t,e):e instanceof Ue?new Nh(n,t,e):e instanceof Ke?new Proxy(new i1(n,t,e),wq):e!==null&&typeof e=="object"?Ih(e)?e:new Proxy(new r1(n,t,e),Sq):e}function n1(n){let t=new dv(n);return[pv(t,"",n),t]}function ml(n,t){let[e,r]=n1(n);return t(e),r.result()}function kr(n){return n instanceof Bh||n instanceof Nh?n._current:n!==null&&typeof n=="object"?n[cD]:n}var Sr;(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 gr||s instanceof Bh)&&typeof o=="string")return s.data(o);if((s instanceof Ue||s instanceof Nh)&&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})(Sr||(Sr={}));function hD(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 Lt(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 mv=class{},Vp=class extends mv{constructor(e){super();this.id=e}},Up=class extends mv{constructor(e){super();this.data=e}};var o1;try{o1=new TextDecoder}catch{}var qe,yl,ne=0;var xD=[],a1=xD,l1=0,_n={},Qt,gl,us=0,bo=0,Zn,ma,yn=[],nr,dD={useRecords:!1,mapsAsObjects:!0},zp=class{},u1=new zp;u1.name="MessagePack 0xC1";var Fh=!1,So=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(qe)return ED(()=>(yv(),this?this.unpack(t,e):So.prototype.unpack.call(dD,t,e)));yl=e>-1?e:t.length,ne=0,l1=0,bo=0,gl=null,a1=xD,Zn=null,qe=t;try{nr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw qe=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 So){if(_n=this,this.structures)return Qt=this.structures,gv();(!Qt||Qt.length>0)&&(Qt=[])}else _n=dD,(!Qt||Qt.length>0)&&(Qt=[]);return gv()}unpackMultiple(t,e){let r,i=0;try{Fh=!0;let s=t.length,o=this?this.unpack(t,s):bv.unpack(t,s);if(e){for(e(o);ne<s;)if(i=ne,e(gv())===!1)return}else{for(r=[o];ne<s;)i=ne,r.push(gv());return r}}catch(s){throw s.lastPosition=i,s.values=r,s}finally{Fh=!1,yv()}}_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 gv(){try{if(!_n.trusted&&!Fh){let t=Qt.sharedLength||0;t<Qt.length&&(Qt.length=t)}let n=Xr();if(ne==yl)Qt.restoreStructures&&fD(),Qt=null,qe=null,ma&&(ma=null);else if(ne>yl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Fh)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Qt.restoreStructures&&fD(),yv(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function fD(){for(let n in Qt.restoreStructures)Qt[n]=Qt.restoreStructures[n];Qt.restoreStructures=null}function Xr(){let n=qe[ne++];if(n<160)if(n<128){if(n<64)return n;{let t=Qt[n&63]||_n.getStructures&&bD()[n&63];return t?(t.read||(t.read=h1(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,_n.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[wD()]=Xr();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Xr(),Xr());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=Xr();return t}else if(n<192){let t=n-160;if(bo>=ne)return gl.slice(ne-us,(ne+=t)-us);if(bo==0&&yl<140){let e=t<16?d1(t):SD(t);if(e!=null)return e}return c1(t)}else{let t;switch(n){case 192:return null;case 193:return Zn?(t=Xr(),t>0?Zn[1].slice(Zn.position1,Zn.position1+=t):Zn[0].slice(Zn.position0,Zn.position0-=t)):u1;case 194:return!1;case 195:return!0;case 196:return s1(qe[ne++]);case 197:return t=nr.getUint16(ne),ne+=2,s1(t);case 198:return t=nr.getUint32(ne),ne+=4,s1(t);case 199:return _c(qe[ne++]);case 200:return t=nr.getUint16(ne),ne+=2,_c(t);case 201:return t=nr.getUint32(ne),ne+=4,_c(t);case 202:if(t=nr.getFloat32(ne),_n.useFloat32>2){let e=xv[(qe[ne]&127)<<1|qe[ne+1]>>7];return ne+=4,(e*t+(t>0?.5:-.5)>>0)/e}return ne+=4,t;case 203:return t=nr.getFloat64(ne),ne+=8,t;case 204:return qe[ne++];case 205:return t=nr.getUint16(ne),ne+=2,t;case 206:return t=nr.getUint32(ne),ne+=4,t;case 207:return _n.int64AsNumber?(t=nr.getUint32(ne)*4294967296,t+=nr.getUint32(ne+4)):t=nr.getBigUint64(ne),ne+=8,t;case 208:return nr.getInt8(ne++);case 209:return t=nr.getInt16(ne),ne+=2,t;case 210:return t=nr.getInt32(ne),ne+=4,t;case 211:return _n.int64AsNumber?(t=nr.getInt32(ne)*4294967296,t+=nr.getUint32(ne+4)):t=nr.getBigInt64(ne),ne+=8,t;case 212:if(t=qe[ne++],t==114)return vD(qe[ne++]&63);{let e=yn[t];if(e)return e.read?(ne++,e.read(Xr())):e.noBuffer?(ne++,e()):e(qe.subarray(ne,++ne));throw new Error("Unknown extension "+t)}case 213:return t=qe[ne],t==114?(ne++,vD(qe[ne++]&63,qe[ne++])):_c(2);case 214:return _c(4);case 215:return _c(8);case 216:return _c(16);case 217:return t=qe[ne++],bo>=ne?gl.slice(ne-us,(ne+=t)-us):Eq(t);case 218:return t=nr.getUint16(ne),ne+=2,bo>=ne?gl.slice(ne-us,(ne+=t)-us):Mq(t);case 219:return t=nr.getUint32(ne),ne+=4,bo>=ne?gl.slice(ne-us,(ne+=t)-us):Tq(t);case 220:return t=nr.getUint16(ne),ne+=2,mD(t);case 221:return t=nr.getUint32(ne),ne+=4,mD(t);case 222:return t=nr.getUint16(ne),ne+=2,gD(t);case 223:return t=nr.getUint32(ne),ne+=4,gD(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 Aq=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function h1(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>Aq.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Xr);return n.highByte===0&&(n.read=pD(t,n.read)),i()}let r={};for(let i=0,s=n.length;i<s;i++){let o=n[i];r[o]=Xr()}return r}return e.count=0,n.highByte===0?pD(t,e):e}var pD=(n,t)=>function(){let e=qe[ne++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Qt[r]||bD()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=h1(i,n)),i.read()};function bD(){let n=ED(()=>(qe=null,_n.getStructures()));return Qt=_n._mergeStructures(n,Qt)}var c1=vv,Eq=vv,Mq=vv,Tq=vv;function vv(n){let t;if(n<16&&(t=d1(n)))return t;if(n>64&&o1)return o1.decode(qe.subarray(ne,ne+=n));let e=ne+n,r=[];for(t="";ne<e;){let i=qe[ne++];if((i&128)===0)r.push(i);else if((i&224)===192){let s=qe[ne++]&63;r.push((i&31)<<6|s)}else if((i&240)===224){let s=qe[ne++]&63,o=qe[ne++]&63;r.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=qe[ne++]&63,o=qe[ne++]&63,a=qe[ne++]&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+=Vi.apply(String,r),r.length=0)}return r.length>0&&(t+=Vi.apply(String,r)),t}function mD(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=Xr();return t}function gD(n){if(_n.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[wD()]=Xr();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Xr(),Xr());return t}}var Vi=String.fromCharCode;function SD(n){let t=ne,e=new Array(n);for(let r=0;r<n;r++){let i=qe[ne++];if((i&128)>0){ne=t;return}e[r]=i}return Vi.apply(String,e)}function d1(n){if(n<4)if(n<2){if(n===0)return"";{let t=qe[ne++];if((t&128)>1){ne-=1;return}return Vi(t)}}else{let t=qe[ne++],e=qe[ne++];if((t&128)>0||(e&128)>0){ne-=2;return}if(n<3)return Vi(t,e);let r=qe[ne++];if((r&128)>0){ne-=3;return}return Vi(t,e,r)}else{let t=qe[ne++],e=qe[ne++],r=qe[ne++],i=qe[ne++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){ne-=4;return}if(n<6){if(n===4)return Vi(t,e,r,i);{let s=qe[ne++];if((s&128)>0){ne-=5;return}return Vi(t,e,r,i,s)}}else if(n<8){let s=qe[ne++],o=qe[ne++];if((s&128)>0||(o&128)>0){ne-=6;return}if(n<7)return Vi(t,e,r,i,s,o);let a=qe[ne++];if((a&128)>0){ne-=7;return}return Vi(t,e,r,i,s,o,a)}else{let s=qe[ne++],o=qe[ne++],a=qe[ne++],l=qe[ne++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){ne-=8;return}if(n<10){if(n===8)return Vi(t,e,r,i,s,o,a,l);{let c=qe[ne++];if((c&128)>0){ne-=9;return}return Vi(t,e,r,i,s,o,a,l,c)}}else if(n<12){let c=qe[ne++],u=qe[ne++];if((c&128)>0||(u&128)>0){ne-=10;return}if(n<11)return Vi(t,e,r,i,s,o,a,l,c,u);let h=qe[ne++];if((h&128)>0){ne-=11;return}return Vi(t,e,r,i,s,o,a,l,c,u,h)}else{let c=qe[ne++],u=qe[ne++],h=qe[ne++],d=qe[ne++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){ne-=12;return}if(n<14){if(n===12)return Vi(t,e,r,i,s,o,a,l,c,u,h,d);{let f=qe[ne++];if((f&128)>0){ne-=13;return}return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f)}}else{let f=qe[ne++],p=qe[ne++];if((f&128)>0||(p&128)>0){ne-=14;return}if(n<15)return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f,p);let m=qe[ne++];if((m&128)>0){ne-=15;return}return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f,p,m)}}}}}function s1(n){return _n.copyBuffers?Uint8Array.prototype.slice.call(qe,ne,ne+=n):qe.subarray(ne,ne+=n)}function _c(n){let t=qe[ne++];if(yn[t])return yn[t](qe.subarray(ne,ne+=n));throw new Error("Unknown extension type "+t)}var yD=new Array(4096);function wD(){let n=qe[ne++];if(n>=160&&n<192){if(n=n-160,bo>=ne)return gl.slice(ne-us,(ne+=n)-us);if(!(bo==0&&yl<180))return c1(n)}else return ne--,Xr();let t=(n<<5^(n>1?nr.getUint16(ne):n>0?qe[ne]:0))&4095,e=yD[t],r=ne,i=ne+n-3,s,o=0;if(e&&e.bytes==n){for(;r<i;){if(s=nr.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(s=qe[r++],s!=e[o++]){r=1879048192;break}if(r===i)return ne=r,e.string;i-=3,r=ne}for(e=[],yD[t]=e,e.bytes=n;r<i;)s=nr.getUint32(r),e.push(s),r+=4;for(i+=3;r<i;)s=qe[r++],e.push(s);let a=n<16?d1(n):SD(n);return a!=null?e.string=a:e.string=c1(n)}var vD=(n,t)=>{var e=Xr();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Qt[n];return i&&i.isShared&&((Qt.restoreStructures||(Qt.restoreStructures=[]))[n]=i),Qt[n]=e,e.read=h1(e,r),e.read()},AD=typeof self=="object"?self:global;yn[0]=()=>{};yn[0].noBuffer=!0;yn[101]=()=>{let n=Xr();return(AD[n[0]]||Error)(n[1])};yn[105]=n=>{let t=nr.getUint32(ne-4);ma||(ma=new Map);let e=qe[ne],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};ma.set(t,i);let s=Xr();return i.used?Object.assign(r,s):(i.target=s,s)};yn[112]=n=>{let t=nr.getUint32(ne-4),e=ma.get(t);return e.used=!0,e.target};yn[115]=()=>new Set(Xr());var f1=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");yn[116]=n=>{let t=n[0],e=f1[t];if(!e)throw new Error("Could not find typed array for code "+t);return new AD[e](Uint8Array.prototype.slice.call(n,1).buffer)};yn[120]=()=>{let n=Xr();return new RegExp(n[0],n[1])};yn[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=ne;ne+=t-4,Zn=[Xr(),Xr()],Zn.position0=0,Zn.position1=0;let r=ne;ne=e;try{return Xr()}finally{ne=r}};yn[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 ED(n){let t=yl,e=ne,r=l1,i=us,s=bo,o=gl,a=a1,l=ma,c=Zn,u=new Uint8Array(qe.slice(0,yl)),h=Qt,d=Qt.slice(0,Qt.length),f=_n,p=Fh,m=n();return yl=t,ne=e,l1=r,us=i,bo=s,gl=o,a1=a,ma=l,Zn=c,qe=u,Fh=p,Qt=h,Qt.splice(0,Qt.length,...d),_n=f,nr=new DataView(qe.buffer,qe.byteOffset,qe.byteLength),m}function yv(){qe=null,ma=null,Qt=null}function MD(n){n.unpack?yn[n.type]=n.unpack:yn[n.type]=n}var xv=new Array(147);for(let n=0;n<256;n++)xv[n]=+("1e"+Math.floor(45.15-n*.30103));var bv=new So({useRecords:!1}),Cq=bv.unpack,Pq=bv.unpackMultiple,_q=bv.unpack,Sv={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Dq=new Float32Array(1),Tue=new Uint8Array(Dq.buffer,0,4);var wv;try{wv=new TextEncoder}catch{}var Av,m1,Ev=typeof Buffer<"u",p1=Ev?Buffer.allocUnsafeSlow:Uint8Array,_D=Ev?Buffer:Uint8Array,TD=Ev?4294967296:2144337920,Se,ti,he=0,wo,Ao=null,Iq=/[\u0080-\uFFFF]/,kp=Symbol("record-id"),Dc=class extends So{constructor(t){super(t),this.offset=0;let e,r,i,s,o,a,l=0,c=_D.prototype.utf8Write?function(b,T,C){return Se.utf8Write(b,T,C)}:wv&&wv.encodeInto?function(b,T){return wv.encodeInto(b,Se.subarray(T)).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 p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,S=0;this.pack=this.encode=function(b,T){if(Se||(Se=new p1(8192),ti=new DataView(Se.buffer,0,8192),he=0),wo=Se.length-10,wo-he<2048?(Se=new p1(Se.length),ti=new DataView(Se.buffer,0,Se.length),wo=Se.length-10,he=0):he=he+7&2147483640,r=he,a=u.structuredClone?new Map:null,u.bundleStrings?(Ao=["",""],Se[he++]=214,Se[he++]=98,Ao.position=he-r,he+=4):Ao=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 D=i[P];if(!D)continue;let _,I=i.transitions;for(let L=0,j=D.length;L<j;L++){let V=D[L];_=I[V],_||(_=I[V]=Object.create(null)),I=_}I[kp]=P+64}l=C}h||(i.nextId=C+64)}s&&(s=!1),o=i||[];try{if(w(b),Ao){ti.setUint32(Ao.position+r,he-Ao.position-r);let C=Ao;Ao=null,w(C[0]),w(C[1])}if(u.offset=he,a&&a.idsToInsert){he+=a.idsToInsert.length*6,he>wo&&M(he),u.offset=he;let C=Rq(Se.subarray(r,he),a.idsToInsert);return a=null,C}return T&ID?(Se.start=r,Se.end=he,Se):Se.subarray(r,he)}finally{if(i){if(S<10&&S++,x>1e4)i.transitions=null,S=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let C=0,P=v.length;C<P;C++)v[C][kp]=0;v=[]}if(s&&u.saveStructures){let C=i.sharedLength||f;i.length>C&&(i=i.slice(0,C));let P=Se.subarray(r,he);return u.saveStructures(i,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(b)):(l=C,P)}}T&zq&&(he=r)}};let w=b=>{he>wo&&(Se=M(he));var T=typeof b,C;if(T==="string"){let P=b.length;if(Ao&&P>=8&&P<4096){let I=Iq.test(b);Ao[I?0:1]+=b,Se[he++]=193,w(I?-P:P);return}let D;P<32?D=1:P<256?D=2:P<65536?D=3:D=5;let _=P*3;if(he+_>wo&&(Se=M(he+_)),P<64||!c){let I,L,j,V=he+D;for(I=0;I<P;I++)L=b.charCodeAt(I),L<128?Se[V++]=L:L<2048?(Se[V++]=L>>6|192,Se[V++]=L&63|128):(L&64512)===55296&&((j=b.charCodeAt(I+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),I++,Se[V++]=L>>18|240,Se[V++]=L>>12&63|128,Se[V++]=L>>6&63|128,Se[V++]=L&63|128):(Se[V++]=L>>12|224,Se[V++]=L>>6&63|128,Se[V++]=L&63|128);C=V-he-D}else C=c(b,he+D,_);C<32?Se[he++]=160|C:C<256?(D<2&&Se.copyWithin(he+2,he+1,he+1+C),Se[he++]=217,Se[he++]=C):C<65536?(D<3&&Se.copyWithin(he+3,he+2,he+2+C),Se[he++]=218,Se[he++]=C>>8,Se[he++]=C&255):(D<5&&Se.copyWithin(he+5,he+3,he+3+C),Se[he++]=219,ti.setUint32(he,C),he+=4),he+=C}else if(T==="number")if(b>>>0===b)b<64?Se[he++]=b:b<256?(Se[he++]=204,Se[he++]=b):b<65536?(Se[he++]=205,Se[he++]=b>>8,Se[he++]=b&255):(Se[he++]=206,ti.setUint32(he,b),he+=4);else if(b>>0===b)b>=-32?Se[he++]=256+b:b>=-128?(Se[he++]=208,Se[he++]=b+256):b>=-32768?(Se[he++]=209,ti.setInt16(he,b),he+=2):(Se[he++]=210,ti.setInt32(he,b),he+=4);else{let P;if((P=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Se[he++]=202,ti.setFloat32(he,b);let D;if(P<4||(D=b*xv[(Se[he]&127)<<1|Se[he+1]>>7])>>0===D){he+=4;return}else he--}Se[he++]=203,ti.setFloat64(he,b),he+=8}else if(T==="object")if(!b)Se[he++]=192;else{if(a){let D=a.get(b);if(D){if(!D.id){let _=a.idsToInsert||(a.idsToInsert=[]);D.id=_.push(D)}Se[he++]=214,Se[he++]=112,ti.setUint32(he,D.id),he+=4;return}else a.set(b,{offset:he-r})}let P=b.constructor;if(P===Object)A(b,!0);else if(P===Array){C=b.length,C<16?Se[he++]=144|C:C<65536?(Se[he++]=220,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=221,ti.setUint32(he,C),he+=4);for(let D=0;D<C;D++)w(b[D])}else if(P===Map){C=b.size,C<16?Se[he++]=128|C:C<65536?(Se[he++]=222,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=223,ti.setUint32(he,C),he+=4);for(let[D,_]of b)w(D),w(_)}else{for(let D=0,_=Av.length;D<_;D++){let I=m1[D];if(b instanceof I){let L=Av[D];if(L.write){L.type&&(Se[he++]=212,Se[he++]=L.type,Se[he++]=0),w(L.write.call(this,b));return}let j=Se,V=ti,H=he;Se=null;let W;try{W=L.pack.call(this,b,q=>(Se=j,j=null,he+=q,he>wo&&M(he),{target:Se,targetView:ti,position:he-q}),w)}finally{j&&(Se=j,ti=V,he=H,wo=Se.length-10)}W&&(W.length+he>wo&&M(W.length+he),he=Oq(W,Se,he,L.type));return}}A(b,!b.hasOwnProperty)}}else if(T==="boolean")Se[he++]=b?195:194;else if(T==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))Se[he++]=211,ti.setBigInt64(he,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)Se[he++]=207,ti.setBigUint64(he,b);else if(this.largeBigIntToFloat)Se[he++]=203,ti.setFloat64(he,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");he+=8}else if(T==="undefined")this.encodeUndefinedAsNil?Se[he++]=192:(Se[he++]=212,Se[he++]=0,Se[he++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},A=this.useRecords===!1?this.variableMapSize?b=>{let T=Object.keys(b),C=T.length;C<16?Se[he++]=128|C:C<65536?(Se[he++]=222,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=223,ti.setUint32(he,C),he+=4);let P;for(let D=0;D<C;D++)w(P=T[D]),w(b[P])}:(b,T)=>{Se[he++]=222;let C=he-r;he+=2;let P=0;for(let D in b)(T||b.hasOwnProperty(D))&&(w(D),w(b[D]),P++);Se[C+++r]=P>>8,Se[C+r]=P&255}:b=>{let T=Object.keys(b),C,P=o.transitions||(o.transitions=Object.create(null)),D=0;for(let I=0,L=T.length;I<L;I++){let j=T[I];C=P[j],C||(C=P[j]=Object.create(null),D++),P=C}let _=P[kp];if(_)_>=96&&m?(Se[he++]=((_-=96)&31)+96,Se[he++]=_>>5):Se[he++]=_;else{_=o.nextId,_||(_=64),_<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(_=o.nextOwnId,_<y||(_=g),o.nextOwnId=_+1):(_>=y&&(_=g),o.nextId=_+1);let I=T.highByte=_>=96&&m?_-96>>5:-1;P[kp]=_,o[_-64]=T,_<g?(T.isShared=!0,o.sharedLength=_-63,s=!0,I>=0?(Se[he++]=(_&31)+96,Se[he++]=I):Se[he++]=_):(I>=0?(Se[he++]=213,Se[he++]=114,Se[he++]=(_&31)+96,Se[he++]=I):(Se[he++]=212,Se[he++]=114,Se[he++]=_),D&&(x+=S*D),v.length>=p&&(v.shift()[kp]=0),v.push(P),w(T))}for(let I=0,L=T.length;I<L;I++)w(b[T[I]])},M=b=>{let T;if(b>16777216){if(b-r>TD)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(TD,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(b-r<<2,Se.length-1)>>12)+1<<12;let C=new p1(T);return ti=new DataView(C.buffer,0,T),Se.copy?Se.copy(C,0,r,b):C.set(Se.slice(r,b)),he-=r,r=0,wo=C.length-10,Se=C}}useBuffer(t){Se=t,ti=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),he=0}};m1=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,zp];Av=[{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?CD(n,16,t):PD(Ev?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==_D&&this.structuredClone?CD(n,f1.indexOf(e.name),t):PD(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function CD(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 PD(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 Oq(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 Rq(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 vl(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)");m1.unshift(n.Class),Av.unshift(n)}MD(n)}var DD=new Dc({useRecords:!1}),Lq=DD.pack,Bq=DD.pack;var{NEVER:Nq,ALWAYS:Fq,DECIMAL_ROUND:Vq,DECIMAL_FIT:Uq}=Sv,ID=512,zq=1024;var OD=new Dc({structuredClone:!0});vl({Class:Ke.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ke.prototype),n}});vl({Class:Ue.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Ue.prototype),n}});vl({Class:gr.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,gr.prototype),n}});vl({Class:Vp.prototype.constructor,type:4,write(n){return n.id},read(n){return new Vp(n)}});vl({Class:Up.prototype.constructor,type:5,write(n){return n.data},read(n){return new Up(n)}});vl({Class:yr.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,yr.prototype),n}});function kq(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 g1(n){if(Ih(n))return n;if(Array.isArray(n))return n.map(g1);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=g1(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var Mv;(r=>{function n(i){return OD.pack(i)}r.serialize=n;function t(i){return OD.unpack(i)}r.deserialize=t;function e(i){return kq(n(g1(i))).toString()}r.checksum=e})(Mv||(Mv={}));var RD;(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})(RD||(RD={}));function v1(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var Yi={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseHover"]:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Start"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Conditional"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseUp"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MousePress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyUp"]:["Transition","Animation","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","Audio","Particles","Create","Conditional"],["Collision"]:["Transition","Animation","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"]},LD;(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,actions:new Ue}:{type:r,disabled:!1,key:void 0,actions:new Ue}}e.defaultData=t})(LD||(LD={}));var Tv;(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(Tv||(Tv={}));var y1;(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:Tv.propertyDefaultData(i),rOperand:{...Tv.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})(y1||(y1={}));var BD;(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(BD||(BD={}));var ND;(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,inActions:new Ue,outActions:new Ue,condition:y1.distanceDefaultData(r)}}e.defaultData=t})(ND||(ND={}));var FD;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Ue,drop:new Ue}})(FD||(FD={}));var Cv;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Ue})(Cv||(Cv={}));var Pv;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Pv||(Pv={}));var VD;(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,actions:new Ue}}e.defaultData=t})(VD||(VD={}));var UD;(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Ue}}e.defaultData=t})(UD||(UD={}));var zD;(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,actions:new Ue}}e.defaultData=t})(zD||(zD={}));var kD;(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,target:"character",actions:new Ue}}e.defaultData=t})(kD||(kD={}));var GD;(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new Ue,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(GD||(GD={}));var _v;(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 Ue},l={size:"tablet",operator:"<",actions:new Ue},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new Ue},u=new Ue;return u.push({id:we.generateUUID(),fi:0,data:a},{id:we.generateUUID(),fi:1,data:l},{id:we.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:u}}o.defaultData=i;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Ue}}o.defaultBreakpointData=s})(_v||(_v={}));var Dv;(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",actions:new Ue,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(Dv||(Dv={}));var jD;(e=>{function n(r){return r.type==="API"}e.is=n;function t(){return{disabled:!1,type:"API",successActions:new Ue,errorActions:new Ue,userAPIId:""}}e.defaultData=t})(jD||(jD={}));var HD;(e=>{function n(r){return r.type==="WEBHOOK"}e.is=n;function t(){return{disabled:!1,type:"WEBHOOK",actions:new Ue,userWebhookId:""}}e.defaultData=t})(HD||(HD={}));var hs="personal camera",bl="a218fcc3-276b-49b9-b485-49037fd14f5f",XD=2960946,ii=5526619;var Fs;(f=>{function n(p,m){return p[0]===m[0]&&p[1]===m[1]}f.isEqual=n;function t(p,m,g){return[p[0]+(m[0]-p[0])*g,p[1]+(m[1]-p[1])*g]}f.lerp=t;function e(p,m){return[p[0]+m[0],p[1]+m[1]]}f.add=e;function r(p,m){return[p[0]-m[0],p[1]-m[1]]}f.sub=r;function i(p,m){return[p[0]*m[0],p[1]*m[1]]}f.multiply=i;function s(p,m){return[p[0]/m[0],p[1]/m[1]]}f.divide=s;function o(p,m){return Math.pow(m[0]-p[0],2)+Math.pow(m[1]-p[1],2)}f.distanceSquared=o;function a(p,m){return Math.sqrt(o(p,m))}f.distance=a;function l(p,m){return p[0]*m[0]+p[1]*m[1]}f.dot=l;function c(p,m){return[p[0]*m,p[1]*m]}f.scalarMultiply=c;function u(p,m,g){let y=f.sub(m,p),v=f.sub(g,p),x=f.dot(y,v)/f.dot(y,y),S=f.scalarMultiply(y,x);return f.add(p,S)}f.projectionOnto=u;function h(p,m,g){return a(p,u(p,m,g))}f.projectionOntoDistance=h;function d(p,m){return[(p[0]+m[0])*.5,(p[1]+m[1])*.5]}f.center=d})(Fs||(Fs={}));var Eo;(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})(Eo||(Eo={}));var Gp;(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})(Gp||(Gp={}));var WD;(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})(WD||(WD={}));var xl;(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})(xl||(xl={}));var ri;(h=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}h.isRGB=n,h.white={r:1,g:1,b:1},h.red={r:1,g:0,b:0},h.black={r:0,g:0,b:0};function i(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}h.toRgb255a1=i;function s(d){return{r:d.r,g:d.g,b:d.b}}h.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}h.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}h.toHex=a;function l(d,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}h.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}h.equalsFixed=c;function u(d,f,p){return{r:d.r+(f.r-d.r)*p,g:d.g+(f.g-d.g)*p,b:d.b+(f.b-d.b)*p}}h.lerp=u})(ri||(ri={}));var bt;(c=>{c.white={...ri.white,a:1},c.transparent={...ri.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function r(u,h){return{...ri.fromHex(u),a:h}}c.fromHexAndA=r;function i(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=i;function s(u,h){return ri.equals(u,h)&&u.a===h.a}c.equals=s;function o(u,h){return ri.equalsFixed(u,h)&&u.a.toFixed(2)===h.a.toFixed(2)}c.equalsFixed=o;function a(u,h,d){return{r:u.r+(h.r-u.r)*d,g:u.g+(h.g-u.g)*d,b:u.b+(h.b-u.b)*d,a:u.a+(h.a-u.a)*d}}c.lerp=a;function l({r:u,g:h,b:d,a:f}=c.white){return`rgba(${u*255}, ${h*255}, ${d*255}, ${f})`}c.toStyle=l})(bt||(bt={}));var Iv;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Iv||(Iv={}));var qD;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(qD||(qD={}));var YD;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(YD||(YD={}));var ga;(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]))(ga||(ga={}));function x1(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 Vs;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Vs||(Vs={}));var Sl;(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})(Sl||(Sl={}));var Mo;(e=>{function n(r,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*i,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function t(r,i){let s={...r};if(b1.forEach(o=>{Object.assign(s,{[o]:i[o]??r[o]})}),s.radial={...r.radial},i.radial){let o=r.radial,a=i.radial;S1.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},i.linear){let o=r.linear,a=i.linear;w1.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},i.grid){let o=r.grid,a=i.grid;A1.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},i.toObject){let o=r.toObject,a=i.toObject;E1.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},i.randomnessObject){let o=r.randomnessObject,a=i.randomnessObject;M1.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Mo||(Mo={}));var Ov;(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})(Ov||(Ov={}));var b1=["count"],S1=["radius","start","end","position","scale","rotation"],w1=["position","scale","rotation"],A1=["count","size"],E1=["count","position","scale","rotation"],M1=["strength","scale","rotation","position","movement","seed","freqScale"];var Rv;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Rv||(Rv={}));var Lv;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:bt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:bt.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:bt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Lv||(Lv={}));var Vh;(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}))(Vh||(Vh={}));var wl;(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]})(wl||(wl={}));var T1;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(T1||(T1={}));var C1;(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})(C1||(C1={}));var Bv;(t=>t.defaultData={...C1.defaultData,...T1.defaultData})(Bv||(Bv={}));var QD;(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})(QD||(QD={}));var Uh;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Uh||(Uh={}));var KD;(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})(KD||(KD={}));function JD(n){return n.type!=="displace"}var ZD;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(ZD||(ZD={}));var Nv=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],$D=["wrapping","image","video","name","minFilter","magFilter"],Gr;(i=>{function n(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let c=s.texture;c&&Object.assign(c,a)}}i.patch=n;function t(s,o){return s==="light"&&o?e(o):r(s)}i.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,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{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Uh.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...o,type:"color",color:ri.fromHex(ii)};case"depth":return{...o,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{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,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{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ri.fromHex(6710886),a:1},colorB:{...ri.fromHex(6710886),a:1},colorC:{...ri.fromHex(16777215),a:1},colorD:{...ri.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{...o,type:"fresnel",color:bt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,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:bt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:bt.fromHexAndA(0,1),contourColor:bt.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{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...o,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{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ri.fromHex(0),a:1},colorB:{...ri.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}}}})(Gr||(Gr={}));var Qr;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function t(u){let h="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,p])=>{h+=`${f}${p}`,Array.isArray(p)?p.forEach(m=>h+=`${m}`):typeof p=="object"?Object.values(p).forEach(m=>{typeof m=="number"?h+=`${m.toFixed(4)}`:h+=`${m}`}):h+=`${p}`})}),h}c.getHash=t;function e(){return{layers:new Ue}}c.defaultEmptyData=e;function r(u="layer1",h="layer2"){return s("phong",u,h)}c.defaultData=r;function i(u,h){return{...u,name:h}}c.withName=i;function s(u,h="layer1",d="layer2"){let f=new Ue;return f.push({fi:0,data:Gr.defaultData("light",u),id:h}),f.push({fi:1,data:Gr.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=s;function o(u){let h=Gr.defaultData("texture");u&&Object.assign(h.texture,{image:u});let d=new Ue;return d.push({fi:0,data:h,id:"layer1"}),d.push({fi:1,data:{...Gr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Gr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=o;function a(u,h="phong",d="layer1",f="layer2"){let p=Gr.defaultData("texture");Object.assign(p.texture,{image:u});let m=new Ue;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:Gr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerTextureData=a;function l(u,h="phong",d="layer1",f="layer2"){let p=Gr.defaultData("video");Object.assign(p.texture,{video:u});let m=new Ue;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:Gr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Qr||(Qr={}));var zh;(t=>{function n(){return{points:new Ue,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(zh||(zh={}));var kh;(t=>{function n(){return{points:new Ue,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(kh||(kh={}));var P1={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Fv;(t=>{function n(e,r){let i={...e};return _1.forEach(s=>{Object.assign(i,{[s]:r[s]??e[s]})}),i}t.merge=n})(Fv||(Fv={}));var Vv={shape:P1,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},_1=["depth","offset","angle","twist","startScale","endScale"];var jp;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"||r==="InputGeometry"}e.isParametricMesh=t})(jp||(jp={}));var Uv;(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,Fv.merge(i.extrusion,r.extrusion))),i}t.merge=n})(Uv||(Uv={}));var ya;(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:kh.defaultData(),extrusion:Vv};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:zh.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==="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})(ya||(ya={}));var zv=["width","height","depth"];var kv;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:ri.white,near:.1,far:2e3})(kv||(kv={}));var Gh;(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}}})(Gh||(Gh={}));var D1;(t=>t.defaultData={softShadowQuality:"low"})(D1||(D1={}));var I1;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(I1||(I1={}));var O1;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(O1||(O1={}));var Al;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Al||(Al={}));var R1;(t=>t.defaultData={playCamera:hs,gameControlObject:null})(R1||(R1={}));var Gv;(t=>t.defaultData={backgroundColor:bt.fromHexAndA(XD,1),postprocessing:Gh.defaultData,fog:kv.defaultData,globalPhysics:Al.defaultData,ambient:I1.defaultData,ao:O1.defaultData,shadow:D1.defaultData,publish:R1.defaultData})(Gv||(Gv={}));var jv;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(jv||(jv={}));var eI;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(eI||(eI={}));var jh;(i=>{i.identity={...Iv.identity,hiddenMatrix:xl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function r(s,o){return ev({position:Eo.isEqual(s.position,o.position)?void 0:o.position,rotation:Eo.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Eo.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:xl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=r})(jh||(jh={}));var vi;(t=>t.defaultData={states:new Ue,events:new Ue,visible:!0,raycastLock:!1,physics:wl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...jh.identity,cloner:null})(vi||(vi={}));var Hv;(t=>t.defaultData={type:"Empty",...vi.defaultData})(Hv||(Hv={}));var tI;(t=>t.defaultData={type:"ParticleCollider",...jv.defaultData,...vi.defaultData})(tI||(tI={}));var rI;(t=>t.defaultData={type:"Component",...vi.defaultData})(rI||(rI={}));var iI;(t=>t.defaultData={type:"Particle",...vi.defaultData,...Vh.defaultData})(iI||(iI={}));var El;(t=>t.defaultData={type:"Mesh",...vi.defaultData,...Bv.defaultData})(El||(El={}));var Ic;(t=>t.defaultData={...vi.defaultData,...jh.identity,position:[0,0,Sl.DefaultTargetOffset],...Sl.defaultData})(Ic||(Ic={}));var Wv;(e=>{function n(r){return{...vi.defaultData,...Lv.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Wv||(Wv={}));var Hh;(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})(Hh||(Hh={}));var To;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...vi.defaultData,...a,component:o,overrides:new yr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function i(o){let a=jh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=i})(To||(To={}));var va;(e=>{e.defaultData={type:"Page",...vi.defaultData,physics:{...wl.defaultData,fusedBody:!1},...Gv.defaultData,camera:Ic.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(va||(va={}));var qv;(o=>(o.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:xl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:wl.defaultData,states:new Ue,events:new Ue,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Sl.defaultData},o.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"]},o.defaultMeshObject={name:"Rectangle",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("RectangleGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultBooleanObject={name:"Boolean",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("BooleanGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultTextObject={name:"Text",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("TextGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultInputObject={name:"Input",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("InputGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")}))(qv||(qv={}));var xa;(i=>{function n(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new yr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new yr})))):Vs.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=ml(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&Gr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=ml(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&&Gr.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,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,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(...Ov.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,p]of Object.entries(d))u(["materials",f],p);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,jh.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})}),Vs.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:Uv.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Mo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Mo.merge(a.cloner,o.cloner)});else if(Rv.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=ri.clone(l.color))}return a}i.patch=r})(xa||(xa={}));var Wh;(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,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})(Wh||(Wh={}));var Us;(t=>t.defaultData={orbitControls:Wh.defaultData,playPage:bl,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},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70}},stopRaycast:!0,hdTransmission:!1})(Us||(Us={}));var L1;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(L1||(L1={}));var B1;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(B1||(B1={}));var ba;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...L1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:B1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ba||(ba={}));var Ml;(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=qh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Ml||(Ml={}));var Sa;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:Wv.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,h=[]){let d=[],f=qv.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...h);let p=new gr;return p.push({fi:1,id:bl,data:{...va.defaultData,name:"Scene 1"},children:d}),p}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Us.defaultData,styles:ba.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new gr,publish:Us.defaultData,styles:ba.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Us.defaultData,styles:ba.defaultData()}},c.emptyData=function(){return{objects:new gr,publish:{...Us.defaultData},styles:ba.defaultData()}};function a(u){return{...c.defaultData,objects:qi(u,gr.prototype)}}c.withObjs=a;function l(u,h){return a([{id:u,data:h,children:[],fi:0}])}c.withObj=l})(Sa||(Sa={}));var Yh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Yh||(Yh={}));var Yv;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new Ue}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(Yv||(Yv={}));var nI;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new Ue,queries:new Ue,autoStart:!0}))(nI||(nI={}));var Br;(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})(Br||(Br={}));var N1;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(N1||(N1={}));var sI;(t=>t.all=[...N1.all,"components"])(sI||(sI={}));var oI;(t=>{function n(){return{images:new Ke,videos:new Ke,colors:new Ke,audios:new Ke,particles:new Ke,fonts:new Ke,materials:new Ke,components:new Ke,variables:new Ke,userAPIs:new Ke,userWebhooks:new Ke}}t.defaultData=n})(oI||(oI={}));var zs;(t=>{function n(){return{images:new Ke,videos:new Ke,colors:new Ke,audios:new Ke,particles:new Ke,fonts:new Ke,materials:new Ke,components:new Ke,variables:new Ke,userAPIs:new Ke,userWebhooks:new Ke}}t.defaultData=n})(zs||(zs={}));var vn;(s=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},qi(o,Ke.prototype)}s.defaultColors=n;function t(){return qi({},Ke.prototype)}s.defaultImages=t;function e(){return{catelogs:new Ke,materials:new Ke,images:new Ke,videos:new Ke,colors:new Ke,audios:new Ke,particles:new Ke,fonts:new Ke,variables:new Ue,userAPIs:new Ke,userWebhooks:new Ke,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})(vn||(vn={}));var Xh;(t=>t.list=["idle","move","jump","run"])(Xh||(Xh={}));var Qh;(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 Ue,move:new Ue,jump:new Ue,run:new Ue},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:bt.fromHexAndA(3728051,1)}}))(Qh||(Qh={}));function aI(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={...Pn(kr(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={...kr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function wa(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Aa(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,s)=>{i===void 0&&(r.materials[s]=Qr.defaultData(),i=r.materials[s]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Qr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Qr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==yr.prototype&&t(i.material)})})}function jq(n){Object.assign(n.scene.publish,{orbitControls:{...Wh.defaultData,...kr(n.scene.publish.orbitControls)}})}function Hq(n){Object.assign(n.scene.publish.settings,{video:{...Us.defaultData.settings.video,...kr(n.scene.publish.settings.video)}})}function Wq(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((Nv.includes(i)||typeof s=="boolean")&&delete r[i],i==="texture")for(let[o,a]of Object.entries(s))($D.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 qq(n){n.scene.publish.withBackground=!0}function Yq(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Xq(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 Qq(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 Kq(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=kr(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=kr(e).booleanExclude!==!0)}})}function Zq(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 Jq(n){function t(r){Object.setPrototypeOf(r,yr.prototype),r.texture&&Object.setPrototypeOf(r.texture,yr.prototype)}function e(r){Object.setPrototypeOf(r,yr.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=kr(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=kr(l).layers;e(c),l.layers=c}})})}function lI(n){n.layers===void 0&&Object.assign(n,Qr.defaultTwoLayerData("lambert"))}function F1(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={...kr(t),colors:e,steps:r};Object.assign(t,i)}})}function $q(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function cI(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&F1(r)}):"material"in e&&typeof e.material!="string"&&F1(e.material)}),Object.values(n.shared.materials).forEach(t=>F1(t))}function e9(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 t9(n){n.shared.audios=qi({},Ke.prototype)}function r9(n){n.shared.videos=qi({},Ke.prototype)}function i9(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 n9(n){Object.entries(kr(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(kr(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function s9(n){n.scene.publish.settings.web.preload=!1}function uI(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 hI(n){n.layers&&n.layers.forEach(t=>{JD(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 o9(n){n.shared.fonts=qi({},Ke.prototype)}function a9(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 l9(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let s=Qr.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=a9(i.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let l={name:i.name,...vi.defaultData,...El.defaultData,flatShading:!1,wireframe:!1,geometry:{...ya.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:kr(i.states),events:kr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=kr(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 c9(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 Ue,move:new Ue,jump:new Ue}});else{let s=new Ue;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:we.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,Pn(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 Ue({fi:0,id:we.generateUUID(),data:c},{fi:1,id:we.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function u9(n){n.scene.objects.traverse((t,e)=>{function r(i,s){let o=new Ue,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Pn(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={...Pn(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:we.generateUUID(),data:{type:i,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function dI(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Gr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function fI(n){wa(n,dI),Aa(n,dI)}function h9(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function d9(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 f9(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Qr.defaultTwoLayerData("phong"))})}function p9(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 m9(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 g9(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 y9(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function v9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function x9(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function b9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Qh.defaultDataThirdPerson.navmesh)})})}function S9(n){n.scene.styles||(n.scene.styles=ba.defaultData())}function pI(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function w9(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}),Aa(n,pI),wa(n,pI)}function A9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Ue})})})}function E9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function mI(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function gI(n,t){if(t<1&&(Aa(n,aI),wa(n,aI),n.schema=1),t<2&&(jq(n),n.schema=2),t<3&&(Wq(n),n.schema=3),t<4&&(qq(n),n.schema=4),t<5&&(Yq(n),n.schema=5),t<6&&(Xq(n),n.schema=6),t<7&&(Qq(n),n.schema=7),t<8&&(n.schema=8),t<9&&(cI(n),n.schema=9),t<10&&($q(n),n.schema=10),t<11&&(e9(n),n.schema=11),t<12&&(cI(n),n.schema=12),t<13&&(t9(n),n.schema=13),t<14&&(i9(n),n.schema=14),t<15&&(n9(n),n.schema=15),t<16&&(s9(n),n.schema=16),t<17&&(Aa(n,uI),wa(n,uI),n.schema=17),t<18&&(Aa(n,lI),wa(n,lI),n.schema=18),t<19&&(Hq(n),n.schema=19),t<20&&(o9(n),l9(n),n.schema=20),t<21&&(c9(n),u9(n),n.schema=21),t<22&&(fI(n),n.schema=22),t<23&&(h9(n),n.schema=23),t<24&&(d9(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(r9(n),t<25&&(n.schema=25)),t<26&&(Kq(n),n.schema=26),t<27&&(Zq(n),n.schema=27),t<28&&(fI(n),n.schema=28),t<29&&(Jq(n),n.schema=29),t<30&&(f9(n),n.schema=30),t<31&&(p9(n),n.schema=31),t<33&&(m9(n),n.schema=33),t<34&&(g9(n),n.schema=34),t<35&&(y9(n),n.schema=35),t<36&&(v9(n),n.schema=36),t<37&&(x9(n),n.schema=37),t<38&&(Aa(n,hI),wa(n,hI),n.schema=38),t<39&&(b9(n),n.schema=39),t<40&&(S9(n),n.schema=40),t<41&&(w9(n),n.schema=41),t<42&&(A9(n),n.schema=42),t<43&&(E9(n),n.schema=43),t<99){Aa(n,mI),wa(n,mI),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=hs);let e=kr(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=bl,r.insertBefore(null,null,[{id:bl,data:{...va.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Pn(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Pn(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Al.defaultData,...Pn(n.scene.environment,"usePhysics","gravity")},camera:kr(n.scene.ownerCamera)??va.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Sa.TRASH_CAN_ID&&r.move(bl,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,wl.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function yI(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function M9(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 T9(n){Array.isArray(kr(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 Kh=180/Math.PI;function vI(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Kh)}function xI(n){vI(n),n.type==="Page"&&vI(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Kh))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Kh),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Kh),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Kh,t.extrusion.twist*=Kh),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(kr(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 C9(n){n.shared.variables=qi({},Ke.prototype)}function P9(n){let t=kr(n.shared.variables);n.shared.variables=qi(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),Ue.prototype)}var Co=115;function bI(n,t){t(n.data);for(let e of n.children)bI(e,t)}function _9(n){let t=n.schema??104;t!==Co&&t<105&&(bI(n.asset,xI),n.schema=105)}function D9(n){n.shared.particles=qi({},Ke.prototype),n.shared.lib&&(n.shared.lib.particles=zs.defaultData().particles)}function I9(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 O9(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 R9(n){n.scene.objects.traverse((t,e)=>{Array.isArray(kr(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 L9(n){n.shared.userAPIs=qi({},Ke.prototype),n.shared.userWebhooks=qi({},Ke.prototype),n.shared.lib&&(n.shared.lib.userAPIs=zs.defaultData().userAPIs,n.shared.lib.userWebhooks=zs.defaultData().userWebhooks)}function Xv(n){let t=n.schema??0;if(t!==Co){console.warn("updating from ",t,"to ",Co),gI(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Us.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Aa(n,yI),wa(n,yI),n.schema=101),t<102&&(M9(n),n.schema=102),t<104&&(n.shared.catelogs=new Ke,n.shared.lib=zs.defaultData(),n.schema=104),t<105&&(C9(n),n.scene.objects.traverse((e,r)=>{xI(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))_9(e);t<106&&(P9(n),n.schema=106),t<107&&(n.shared.lib.variables=zs.defaultData().variables,n.schema=107),t<109&&(D9(n),n.schema=109),t<110&&(I9(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{T9(r)}),n.schema=111),t<112&&(O9(n),n.schema=112),t<113&&(R9(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&&(L9(n),n.schema=115)}}var qh;(c=>{c.defaultData={schema:Co,scene:Sa.defaultData,frames:new Ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Yh.defaultData),shared:{...vn.emptyData(),colors:vn.defaultColors()}},c.emptyDataForImports=function(){let u=Sa.emptyDataWithPage();return{schema:Co,scene:u,frames:new Ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Yh.defaultData),shared:{...vn.emptyData(),colors:vn.defaultColors(),images:vn.defaultImages()}}},c.emptyData=function(){return{schema:Co,scene:Sa.emptyDataWithPage(),frames:new Ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Yh.defaultData),shared:vn.emptyData()}},c.clipboard2dData=function(){return{schema:Co,scene:Sa.emptyData(),frames:new Ke,shared:vn.emptyData()}},c.collabHelper={...Fp,updateSchema(u){return(u.schema??0)<Co?ml(u,Xv):(u.schema??0)-Co}};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}}c.getComponentData=a;function l(u){let h=Object.values(u.shared.userAPIs);for(let d of h){let f=d.headers;for(let p of f)if(p.data.key.toLowerCase()==="authorization"&&p.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(qh||(qh={}));var Qv;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Qv||(Qv={}));var SI;(t=>{function n(e){return!0}t.is=n})(SI||(SI={}));var Kv;(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 ev({position:Fs.isEqual(i.position,s.position)?void 0:s.position,rotation:i.rotation===s.rotation?void 0:s.rotation,scale:Fs.isEqual(i.scale,s.scale)?void 0:s.scale,shear:i.shear&&s.shear&&Fs.isEqual(i.shear,s.shear)?void 0:s.shear})}r.diff=e})(Kv||(Kv={}));var V1;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(V1||(V1={}));var wI;(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})(wI||(wI={}));var Zv;(t=>t.defaultData={opacity:1,fill:{color:bt.fromHexAndA(ii,1),enabled:!0},stroke:{color:bt.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:bt.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:bt.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Zv||(Zv={}));var Ea;(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,Kv.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})(Ea||(Ea={}));var Hp;(t=>t.defaultData={...Kv.defaultData,...V1.defaultData,states:new Ue,events:new Ue,visible:!0,raycastLock:!1})(Hp||(Hp={}));var Zh;(t=>t.defaultData={...Hp.defaultData,...Zv.defaultData})(Zh||(Zh={}));var Jv;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(Jv||(Jv={}));var U1;(t=>t.defaultData={...Zh.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(U1||(U1={}));var Jh;(t=>t.defaultData={...Zh.defaultData,...Jv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Jh||(Jh={}));var z1;(t=>t.defaultData={...Zh.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"})(z1||(z1={}));var k1;(t=>t.defaultData={...Zh.defaultData,type:"path2d",path:"",name:"Path"})(k1||(k1={}));var AI;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(AI||(AI={}));var Wp;(t=>t.defaultData={...Hp.defaultData,name:"Group",type:"group2d"})(Wp||(Wp={}));var G1;(t=>t.defaultData=()=>({...Hp.defaultData,...Jv.defaultData,...Zv.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:bt.fromHexAndA(4737101,1),enabled:!0},stroke:{color:bt.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(G1||(G1={}));var Ma;(s=>{function n(o){switch(o){case"rectangle2d":return{...Jh.defaultData};case"ellipse2d":return{...U1.defaultData};case"text2d":return{...z1.defaultData};case"vector2d":return{...Jh.defaultData};case"path2d":return{...k1.defaultData};case"frame2d":return{...G1.defaultData()};case"group2d":return{...Wp.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})(Ma||(Ma={}));var $v;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new gr},e.emptyData=function(){return{type:"scene2d",objects:new gr}}))($v||($v={}));function ks(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 _e,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 p=0;p<f.count;++p)h.push(f.getX(p)+u);u+=n[d].attributes.position.count}l.setIndex(h)}for(let u in s){let h=EI(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 m=0;m<o[u].length;++m)f.push(o[u][m][d]);let p=EI(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(p)}}return l}function EI(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 Xe(s,e,r)}var MI=Math.pow(2,-24);var Oc=class{constructor(){}};function fs(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 j1(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 H1(n,t){t.set(n)}function W1(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 qp(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 $h(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 F9(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 Xe(i,1));for(let s=0;s<e;s++)i[s]=s}}function V9(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 Y1(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,p=-1/0,m=-1/0,g=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let S=n[v+0],w=n[v+1],A=S-w,M=S+w;A<s&&(s=A),M>l&&(l=M),y&&S<h&&(h=S),y&&S>p&&(p=S);let b=n[v+2],T=n[v+3],C=b-T,P=b+T;C<o&&(o=C),P>c&&(c=P),y&&b<d&&(d=b),y&&b>m&&(m=b);let D=n[v+4],_=n[v+5],I=D-_,L=D+_;I<a&&(a=I),L>u&&(u=L),y&&D<f&&(f=D),y&&D>g&&(g=D)}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]=p,i[4]=m,i[5]=g)}function U9(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 p=n[u+4];p<o&&(o=p),p>c&&(c=p)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function z9(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 Ta=32,k9=(n,t)=>n.candidate-t.candidate,Tl=new Array(Ta).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),e0=new Float32Array(6);function G9(n,t,e,r,i,s){let o=-1,a=0;if(s===0)o=j1(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=j1(n),o!==-1&&(a=j9(e,r,i,o));else if(s===2){let l=$h(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)/Ta;if(i<Ta/4){let y=[...Tl];y.length=i;let v=0;for(let S=u;S<h;S+=6,v++){let w=y[v];w.candidate=e[S+2*d],w.count=0;let{bounds:A,leftCacheBounds:M,rightCacheBounds:b}=w;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0,M[T]=1/0,M[T+3]=-1/0,A[T]=1/0,A[T+3]=-1/0;qp(S,e,A)}y.sort(k9);let x=i;for(let S=0;S<x;S++){let w=y[S];for(;S+1<x&&y[S+1].candidate===w.candidate;)y.splice(S+1,1),x--}for(let S=u;S<h;S+=6){let w=e[S+2*d];for(let A=0;A<x;A++){let M=y[A];w>=M.candidate?qp(S,e,M.rightCacheBounds):(qp(S,e,M.leftCacheBounds),M.count++)}}for(let S=0;S<x;S++){let w=y[S],A=w.count,M=i-w.count,b=w.leftCacheBounds,T=w.rightCacheBounds,C=0;A!==0&&(C=$h(b)/l);let P=0;M!==0&&(P=$h(T)/l);let D=1+1.25*(C*A+P*M);D<c&&(o=d,c=D,a=w.candidate)}}else{for(let x=0;x<Ta;x++){let S=Tl[x];S.count=0,S.candidate=f+g+x*g;let w=S.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let x=u;x<h;x+=6){let A=~~((e[x+2*d]-f)/g);A>=Ta&&(A=Ta-1);let M=Tl[A];M.count++,qp(x,e,M.bounds)}let y=Tl[Ta-1];H1(y.bounds,y.rightCacheBounds);for(let x=Ta-2;x>=0;x--){let S=Tl[x],w=Tl[x+1];W1(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let x=0;x<Ta-1;x++){let S=Tl[x],w=S.count,A=S.bounds,b=Tl[x+1].rightCacheBounds;w!==0&&(v===0?H1(A,e0):W1(A,e0,e0)),v+=w;let T=0,C=0;v!==0&&(T=$h(e0)/l);let P=i-v;P!==0&&(C=$h(b)/l);let D=1+1.25*(T*v+C*P);D<c&&(o=d,c=D,a=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function j9(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 H9(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,p,m,g;o?(p=r[d+0],m=r[d+1],g=r[d+2]):(p=r[d+0]*c+l,m=r[d+1]*c+l,g=r[d+2]*c+l);for(let y=0;y<3;y++){let v,x,S;o?(v=e[u[y]](p),x=e[u[y]](m),S=e[u[y]](g)):(v=a[p+y],x=a[m+y],S=a[g+y]);let w=v;x<w&&(w=x),S<w&&(w=S);let A=v;x>A&&(A=x),S>A&&(A=S);let M=(A-w)/2,b=y*2;s[f+b+0]=w+M,s[f+b+1]=M+(Math.abs(w)+M)*MI,w<t[y]&&(t[y]=w),A>t[y+3]&&(t[y+3]=A)}}return s}function W9(n,t){function e(y){d&&d(y/f)}function r(y,v,x,S=null,w=0){if(!p&&w>=l&&(p=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),x<=u||w>=l)return e(v+x),y.offset=v,y.count=x,y;let A=G9(y.boundingData,S,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=z9(a,o,v,x,A);if(M===v||M===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new Oc,T=v,C=M-v;y.left=b,b.boundingData=new Float32Array(6),Y1(o,T,C,b.boundingData,s),r(b,T,C,s,w+1);let P=new Oc,D=M,_=x-C;y.right=P,P.boundingData=new Float32Array(6),Y1(o,D,_,P.boundingData,s),r(P,D,_,s,w+1)}return y}F9(n,t);let i=new Float32Array(6),s=new Float32Array(6),o=H9(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,p=!1,m=[],g=V9(n);if(g.length===1){let y=g[0],v=new Oc;v.boundingData=i,U9(o,y.offset,y.count,s),r(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new Oc;v.boundingData=new Float32Array(6),Y1(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function PI(n,t){let e=W9(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,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(p){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,v=h.splitAxis,x;if(x=c(u+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=x/4,x=c(x,y),i[d+7]=v,x}}}var Dn=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}};Dn.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 Ipe=function(){let n=new Dn;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 q9=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),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),Yp=function(){let n=new U,t=new E,e=new E;return function(i,s,o,a){q9(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}}}}(),_I=function(){let n=new E,t=new E,e=new Ur,r=new Mi;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 m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var Y9=1e-15;function ed(n){return Math.abs(n)<Y9}var In=class extends Cr{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Dn),this.points=[this.a,this.b,this.c],this.sphere=new Or,this.plane=new Ur,this.needsUpdate=!0}intersectsSphere(t){return _I(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],p=o[3];f.subVectors(r,t),p.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};In.prototype.closestPointToSegment=function(){let n=new E,t=new E,e=new Mi;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]),Yp(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)}}();In.prototype.intersectsTriangle=function(){let n=new In,t=new Array(3),e=new Array(3),r=new Dn,i=new Dn,s=new E,o=new E,a=new E,l=new E,c=new Mi,u=new Mi,h=new Mi;return function(f,p=null,m=!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 v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let M=v[A],b=x[A];if(r.setFromPoints(b,e),M.isSeparated(r))return!1}let S=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 M=S[A],b=w[A];if(r.setFromPoints(b,t),M.isSeparated(r))return!1}for(let A=0;A<4;A++){let M=x[A];for(let b=0;b<4;b++){let T=w[b];if(s.crossVectors(M,T),r.setFromPoints(s,t),i.setFromPoints(s,e),r.isSeparated(i))return!1}}return p&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,x=!1,S=0;for(let I=0;I<3;I++){let L=v[I],j=v[(I+1)%3];c.start.copy(L),c.end.copy(j),c.delta(o);let V=x?u.start:u.end,H=ed(y.distanceToPoint(L));if(ed(y.normal.dot(o))&&H){u.copy(c),S=2;break}if((y.intersectLine(c,V)||H)&&!ed(V.distanceTo(j))){if(S++,x)break;x=!0}}if(S===1&&f.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(S!==2)return!1;let w=f.points,A=!1,M=0;for(let I=0;I<3;I++){let L=w[I],j=w[(I+1)%3];c.start.copy(L),c.end.copy(j),c.delta(a);let V=A?h.start:h.end,H=ed(g.distanceToPoint(L));if(ed(g.normal.dot(a))&&H){h.copy(c),M=2;break}if((g.intersectLine(c,V)||H)&&!ed(V.distanceTo(j))){if(M++,A)break;A=!0}}if(M===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(M!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let b=u.start.dot(o),T=u.end.dot(o),C=h.start.dot(o),P=h.end.dot(o),D=T<C,_=b<P;return b!==P&&C!==T&&D===_?!1:(p&&(l.subVectors(u.start,h.start),l.dot(o)>0?p.start.copy(u.start):p.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?p.end.copy(u.end):p.end.copy(h.end)),!0)}}}();In.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();In.prototype.distanceToTriangle=function(){let n=new E,t=new E,e=["a","b","c"],r=new Mi,i=new Mi;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],p=o[f];this.closestPointToPoint(p,n),d=p.distanceToSquared(n),d<u&&(u=d,a&&a.copy(n),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,n),d=m.distanceToSquared(n),d<u&&(u=d,a&&a.copy(m),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 p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];i.set(o[m],o[g]),Yp(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 On=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 Dn),this.alignedSatBounds=new Array(3).fill().map(()=>new Dn),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}};On.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}}();On.prototype.intersectsBox=function(){let n=new Dn;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}}();On.prototype.intersectsTriangle=function(){let n=new In,t=new Array(3),e=new Dn,r=new Dn,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],p=l[d];if(e.setFromPoints(p,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],p=u[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=u[p];if(i.crossVectors(f,m),e.setFromPoints(i,t),r.setFromPoints(i,h),e.isSeparated(r))return!1}}return!0}}();On.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}}();On.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();On.prototype.distanceToBox=function(){let n=["x","y","z"],t=new Array(12).fill().map(()=>new Mi),e=new Array(12).fill().map(()=>new Mi),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,p=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(h,d);let v=y.distanceToSquared(i);if(v<p&&(p=v,l&&l.copy(y),c&&c.copy(i),v<u))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,S=(g+2)%3,w=y<<x|v<<S,A=1<<g|y<<x|v<<S,M=f[w],b=f[A];t[m].set(M,b);let C=n[g],P=n[x],D=n[S],_=e[m],I=_.start,L=_.end;I[C]=h[C],I[P]=y?h[P]:d[P],I[D]=v?h[D]:d[P],L[C]=d[C],L[P]=y?h[P]:d[P],L[D]=v?h[D]:d[P],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?d.x:h.x,i.y=y?d.y:h.y,i.z=v?d.z:h.z,this.closestPointToPoint(i,r);let x=i.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),c&&c.copy(i),x<u))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Yp(y,x,r,i);let S=r.distanceToSquared(i);if(S<p&&(p=S,l&&l.copy(r),c&&c.copy(i),S<u))return Math.sqrt(S)}}return Math.sqrt(p)}}();var td=new E,rd=new E,id=new E,r0=new U,i0=new U,n0=new U,DI=new E,II=new E,OI=new E,s0=new E;function X9(n,t,e,r,i,s){let o;return s===pi?o=n.intersectTriangle(r,e,t,!0,i):o=n.intersectTriangle(t,e,r,s!==fi,i),o===null?null:{distance:n.origin.distanceTo(i),point:i.clone()}}function Q9(n,t,e,r,i,s,o,a,l){td.fromBufferAttribute(t,s),rd.fromBufferAttribute(t,o),id.fromBufferAttribute(t,a);let c=X9(n,td,rd,id,s0,l);if(c){r&&(r0.fromBufferAttribute(r,s),i0.fromBufferAttribute(r,o),n0.fromBufferAttribute(r,a),c.uv=Cr.getInterpolation(s0,td,rd,id,r0,i0,n0,new U)),i&&(r0.fromBufferAttribute(i,s),i0.fromBufferAttribute(i,o),n0.fromBufferAttribute(i,a),c.uv1=Cr.getInterpolation(s0,td,rd,id,r0,i0,n0,new U)),e&&(DI.fromBufferAttribute(e,s),II.fromBufferAttribute(e,o),OI.fromBufferAttribute(e,a),c.normal=Cr.getInterpolation(s0,td,rd,id,DI,II,OI,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};Cr.getNormal(td,rd,id,u.normal),c.face=u,c.faceIndex=s}return c}function Q1(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=Q9(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,i&&i.push(f),f):null}function RI(n,t,e,r,i,s){for(let o=r,a=r+i;o<a;o++)Q1(n,t,e,o,s)}function LI(n,t,e,r,i){let s=1/0,o=null;for(let a=r,l=r+i;a<l;a++){let c=Q1(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 K1(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 nd=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 Ca(n,t){return t[n+15]===65535}function Rc(n,t){return t[n+6]}function sd(n,t){return t[n+14]}function od(n){return n+8}function ad(n,t){return t[n+6]}function BI(n,t){return t[n+7]}var ld=new jt,a0=new E,Z9=["x","y","z"];function l0(n,t,e,r,i){let s=n*2,o=cd,a=Cl,l=Pl;if(Ca(s,a)){let u=Rc(n,l),h=sd(s,a);RI(t,e,r,u,h,i)}else{let u=od(n);u0(u,o,r,a0)&&l0(u,t,e,r,i);let h=ad(n,l);u0(h,o,r,a0)&&l0(h,t,e,r,i)}}function c0(n,t,e,r){let i=n*2,s=cd,o=Cl,a=Pl;if(Ca(i,o)){let c=Rc(n,a),u=sd(i,o);return LI(t,e,r,c,u)}else{let c=BI(n,a),u=Z9[c],d=r.direction[u]>=0,f,p;d?(f=od(n),p=ad(n,a)):(f=ad(n,a),p=od(n));let g=u0(f,s,r,a0)?c0(f,t,e,r):null;if(g){let x=g.point[u];if(d?x<=s[p+c]:x>=s[p+c+3])return g}let v=u0(p,s,r,a0)?c0(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var NI=function(){let n,t,e=[],r=new nd(()=>new jt);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(x){let S=x*2,w=Cl,A=Pl;for(;!Ca(S,w);)x=od(x),S=x*2;return Rc(x,A)}function f(x){let S=x*2,w=Cl,A=Pl;for(;!Ca(S,w);)x=ad(x,A),S=x*2;return Rc(x,A)+sd(S,w)}let p=s*2,m=cd,g=Cl,y=Pl;if(Ca(p,g)){let x=Rc(s,y),S=sd(p,g);return fs(s,m,n),l(x,S,!1,h,u+s,n)}else{let x=od(s),S=ad(s,y),w=x,A=S,M,b,T,C;if(c&&(T=n,C=t,fs(w,m,T),fs(A,m,C),M=c(T),b=c(C),b<M)){w=S,A=x;let V=M;M=b,b=V,T=C}T||(T=n,fs(w,m,T));let P=Ca(w*2,g),D=a(T,P,M,h+1,u+w),_;if(D===2){let V=d(w),W=f(w)-V;_=l(V,W,!0,h+1,u+w,T)}else _=D&&i(w,o,a,l,c,u,h+1);if(_)return!0;C=t,fs(A,m,C);let I=Ca(A*2,g),L=a(C,I,b,h+1,u+A),j;if(L===2){let V=d(A),W=f(A)-V;j=l(V,W,!0,h+1,u+A,C)}else j=L&&i(A,o,a,l,c,u,h+1);return!!j}}}(),FI=function(){let n=new In,t=new In,e=new ue,r=new On,i=new On;return function s(o,a,l,c,u=null){let h=o*2,d=cd,f=Cl,p=Pl;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,c),u=r),Ca(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,S=l.attributes.position,w=Rc(o,p),A=sd(h,f);if(e.copy(c).invert(),l.boundsTree)return fs(o,d,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>i.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(c),b.b.applyMatrix4(c),b.c.applyMatrix4(c),b.needsUpdate=!0;for(let T=w*3,C=(A+w)*3;T<C;T+=3)if(ps(t,T,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let M=w*3,b=A+w*3;M<b;M+=3){ps(n,M,y,v),n.a.applyMatrix4(e),n.b.applyMatrix4(e),n.c.applyMatrix4(e),n.needsUpdate=!0;for(let T=0,C=x.count;T<C;T+=3)if(ps(t,T,x,S),t.needsUpdate=!0,n.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return fs(g,d,ld),!!(u.intersectsBox(ld)&&s(g,a,l,c,u)||(fs(y,d,ld),u.intersectsBox(ld)&&s(y,a,l,c,u)))}}}();function u0(n,t,e,r){return fs(n,t,ld),e.intersectBox(ld,r)}var Z1=[],o0,cd,Cl,Pl;function ud(n){o0&&Z1.push(o0),o0=n,cd=new Float32Array(n),Cl=new Uint16Array(n),Pl=new Uint32Array(n)}function Xp(){o0=null,cd=null,Cl=null,Pl=null,Z1.length&&ud(Z1.pop())}var J1=Symbol("skip tree generation"),$1=new jt,eA=new jt,hd=new ue,Lc=new On,Qp=new On,Kp=new E,h0=new E,J9=new E,$9=new E,e7=new E,VI=new jt,Po=new nd(()=>new In),_o=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."),_o.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."),_o.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 _o(e,{...r,[J1]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Xe(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,[J1]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[J1]||(this._roots=PI(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new jt))),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,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,S=1/0,w=1/0,A=-1/0,M=-1/0,b=-1/0;for(let T=3*y,C=3*(y+v);T<C;T++){let P=r[T],D=i.getX(P),_=i.getY(P),I=i.getZ(P);D<x&&(x=D),D>A&&(A=D),_<S&&(S=_),_>M&&(M=_),I<w&&(w=I),I>b&&(b=I)}return l[d+0]!==x||l[d+1]!==S||l[d+2]!==w||l[d+3]!==A||l[d+4]!==M||l[d+5]!==b?(l[d+0]=x,l[d+1]=S,l[d+2]=w,l[d+3]=A,l[d+4]=M,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,S=v+f,w=p,A=!1,M=!1;t?w||(A=t.has(x),M=t.has(S),w=!A&&!M):(A=!0,M=!0);let b=w||A,T=w||M,C=!1;b&&(C=h(y,f,w));let P=!1;T&&(P=h(v,f,w));let D=C||P;if(D)for(let _=0;_<3;_++){let I=y+_,L=v+_,j=l[I],V=l[I+3],H=l[L],W=l[L+3];l[d+_]=j<H?j:H,l[d+_+3]=V>W?V:W}return D}}}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=Hn){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(ud(r[u]),l0(0,i,d,t,s),Xp(),a){let p=l[u].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=Hn){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;ud(r[u]);let f=c0(0,i,d,t);Xp(),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(ud(s),i=FI(0,r,t,e),Xp(),i)break;return i}shapecast(t,e,r){let i=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,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=Po.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:K1(f,p,i,c,m,g,s)}else l||(c?l=(d,f,p,m)=>K1(d,f,i,c,p,m,s):l=(d,f,p)=>p);let u=!1,h=0;for(let d of this._roots){if(ud(d),u=NI(0,i,a,l,o,h),Xp(),u)break;h+=d.byteLength}return Po.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;hd.copy(e).invert();let u=Po.getPrimitive(),h=Po.getPrimitive();if(s){let f=function(p,m,g,y,v,x,S,w){for(let A=g,M=g+y;A<M;A++){ps(h,A*3,l,c),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let b=p,T=p+m;b<T;b++)if(ps(u,b*3,o,a),u.needsUpdate=!0,s(u,h,b,A,v,x,S,w))return!0}return!1};if(i){let p=i;i=function(m,g,y,v,x,S,w,A){return p(m,g,y,v,x,S,w,A)?!0:f(m,g,y,v,x,S,w,A)}}else i=f}t.getBoundingBox(eA),eA.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>eA.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>($1.copy(v),$1.applyMatrix4(hd),t.shapecast({intersectsBounds:x=>$1.intersectsBox(x),intersectsRange:(x,S,w,A,M)=>i(f,p,x,S,g,y,A,M)}))});return Po.releasePrimitive(u),Po.releasePrimitive(h),d}intersectsBox(t,e){return Lc.set(t.min,t.max,e),Lc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Lc.intersectsBox(r),intersectsTriangle:r=>Lc.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(),Lc.set(t.boundingBox.min,t.boundingBox.max,e),Lc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=Po.getPrimitive(),f=Po.getPrimitive(),p=h0,m=J9,g=null,y=null;i&&(g=$9,y=e7);let v=1/0,x=null,S=null;return hd.copy(e).invert(),Qp.matrix.copy(hd),this.shapecast({boundsTraverseOrder:w=>Lc.distanceToBox(w),intersectsBounds:(w,A,M)=>M<v&&M<o?(A&&(Qp.min.copy(w.min),Qp.max.copy(w.max),Qp.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>Qp.distanceToBox(M),intersectsBounds:(M,b,T)=>T<v&&T<o,intersectsRange:(M,b)=>{for(let T=M*3,C=(M+b)*3;T<C;T+=3){ps(f,T,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let P=w*3,D=(w+A)*3;P<D;P+=3){ps(d,P,c,l),d.needsUpdate=!0;let _=d.distanceToTriangle(f,p,g);if(_<v&&(m.copy(p),y&&y.copy(g),v=_,x=P/3,S=T/3),_<s)return!0}}}});{let M=h?h.count:u.count;for(let b=0,T=M;b<T;b+=3){ps(f,b,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=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=C/3,S=b/3),D<s)return!0}}}}}),Po.releasePrimitive(d),Po.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=v,r.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(hd),m.applyMatrix4(hd),i.distance=m.sub(i.point).length(),i.faceIndex=S),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=>(Kp.copy(t).clamp(u.min,u.max),Kp.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d<a&&d<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,Kp);let d=t.distanceToSquared(Kp);return d<a&&(h0.copy(Kp),a=d,l=h),d<s}}),a===1/0)return null;let c=Math.sqrt(a);return e.point?e.point.copy(h0):e.point=h0.clone(),e.distance=c,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{fs(0,new Float32Array(r),VI),t.union(VI)}),t}};var tf=$o(zI());var t7=.5*(Math.sqrt(3)-1),Zp=(3-Math.sqrt(3))/6,r7=1/3,Do=1/6,Eme=(Math.sqrt(5)-1)/4,Mme=(5-Math.sqrt(5))/20,Jp=n=>Math.floor(n)|0,kI=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]),rA=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 d0(n=Math.random){let t=jI(n),e=new Float64Array(t).map(i=>kI[i%12*2]),r=new Float64Array(t).map(i=>kI[i%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*t7,h=Jp(s+u),d=Jp(o+u),f=(h+d)*Zp,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let S=g-v+Zp,w=y-x+Zp,A=g-1+2*Zp,M=y-1+2*Zp,b=h&255,T=d&255,C=.5-g*g-y*y;if(C>=0){let _=b+t[T],I=e[_],L=r[_];C*=C,a=C*C*(I*g+L*y)}let P=.5-S*S-w*w;if(P>=0){let _=b+v+t[T+x],I=e[_],L=r[_];P*=P,l=P*P*(I*S+L*w)}let D=.5-A*A-M*M;if(D>=0){let _=b+1+t[T+1],I=e[_],L=r[_];D*=D,c=D*D*(I*A+L*M)}return 70*(a+l+c)}}function GI(n=Math.random){let t=jI(n),e=new Float64Array(t).map(s=>rA[s%12*3]),r=new Float64Array(t).map(s=>rA[s%12*3+1]),i=new Float64Array(t).map(s=>rA[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*r7,p=Jp(o+f),m=Jp(a+f),g=Jp(l+f),y=(p+m+g)*Do,v=p-y,x=m-y,S=g-y,w=o-v,A=a-x,M=l-S,b,T,C,P,D,_;w>=A?A>=M?(b=1,T=0,C=0,P=1,D=1,_=0):w>=M?(b=1,T=0,C=0,P=1,D=0,_=1):(b=0,T=0,C=1,P=1,D=0,_=1):A<M?(b=0,T=0,C=1,P=0,D=1,_=1):w<M?(b=0,T=1,C=0,P=0,D=1,_=1):(b=0,T=1,C=0,P=1,D=1,_=0);let I=w-b+Do,L=A-T+Do,j=M-C+Do,V=w-P+2*Do,H=A-D+2*Do,W=M-_+2*Do,q=w-1+3*Do,K=A-1+3*Do,G=M-1+3*Do,Z=p&255,te=m&255,$=g&255,Y=.6-w*w-A*A-M*M;if(Y<0)c=0;else{let J=Z+t[te+t[$]];Y*=Y,c=Y*Y*(e[J]*w+r[J]*A+i[J]*M)}let oe=.6-I*I-L*L-j*j;if(oe<0)u=0;else{let J=Z+b+t[te+T+t[$+C]];oe*=oe,u=oe*oe*(e[J]*I+r[J]*L+i[J]*j)}let ie=.6-V*V-H*H-W*W;if(ie<0)h=0;else{let J=Z+P+t[te+D+t[$+_]];ie*=ie,h=ie*ie*(e[J]*V+r[J]*H+i[J]*W)}let re=.6-q*q-K*K-G*G;if(re<0)d=0;else{let J=Z+1+t[te+1+t[$+1]];re*=re,d=re*re*(e[J]*q+r[J]*K+i[J]*G)}return 32*(c+u+h+d)}}function jI(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 Gs=new Cr,f0=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;Gs.a.fromBufferAttribute(t,i),Gs.b.fromBufferAttribute(t,i+1),Gs.c.fromBufferAttribute(t,i+2),s*=Gs.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),Gs.a.fromBufferAttribute(this.positionAttribute,t*3),Gs.b.fromBufferAttribute(this.positionAttribute,t*3+1),Gs.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Gs.a,i).addScaledVector(Gs.b,s).addScaledVector(Gs.c,1-(i+s)),Gs.getNormal(r),this}};var WI=$o(iA()),i7=new ue,n7=new ue,s7=new ue,dd;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(dd||(dd={}));var fd=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new ue;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ue;this.matrixWorldRigid=new ue;this.shearScale=new ue;this.shearScaleInv=new ue}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Mt&&(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.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)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,i=0){for(let s of this.children)dd.is(s)&&s.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let o of this.children)dd.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,WI.SVD)(i),l=i7.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=n7.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=s7.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 nA=class extends fd(Mt){},o7=n=>n.type==="Mesh",Nr=class extends nA{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 Nr(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.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return o7(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}};var Bc=new E,Nc=new E,pd=new ue,YI=[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)],a7=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],l7=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],qI=(n,t,e)=>{n.updateEntityBoxSize(Bc,Nc),pd.copy(t).multiply(n.matrixWorld),Nc.x===0&&Nc.y===0&&Nc.z===0?e.push(new E(Bc.x,Bc.y,Bc.z).applyMatrix4(pd)):YI.forEach(r=>{e.push(r.clone().multiply(Nc).add(Bc).applyMatrix4(pd))})},$p=class extends jt{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}qI(o,r,s)}}):qI(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(pd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Nc).multiplyScalar(.5),this.getCenter(Bc),pd.copy(this.matrix).setPosition(Bc),this.vertices=YI.map(e=>e.clone().multiply(Nc).applyMatrix4(pd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=a7.map(([e,r])=>new Mi(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=l7.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var js={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var oA=class extends pp{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 p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var aA=.001;function lA(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=aA}function sA(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 lA(e,r,s)&&lA(e,i,s)}function m0(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++)lA(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),p=new E(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!n.isClosed&&(u===0||u===o-1)){a[u]={...m,removedLength:0};continue}let g=i&&u==0?o-1:u-1,y=i&&u==o-1?0:u+1,v=e[g].data,x=e[y].data,S=new E(...v.position),w=new E(...x.position),A=S.clone().sub(d).normalize(),M=w.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:M});let b=sA(v,h),T=sA(h,x);if(!b||!T)a[u]={...m,removedLength:0};else{let C=A.clone().add(M).normalize(),P=C.clone().cross(A).length()/A.dot(C);a[u]={...m,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],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],p=a[d],m=null;if(!sA(e[h].data,e[d].data))f.position.distanceTo(p.position)>aA&&(m=new vc(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>aA&&(m=new vc(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*u+1]=m}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),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),S=g.clone().multiplyScalar(-m).add(x),w=d.distanceTo(S)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(w*d.distanceTo(f)).add(d),M=A.clone().lerp(S,2),b=f.clone().lerp(A,4/3),T=p.clone().lerp(M,4/3);l[2*u]=new vc(f,b,T,p)}let c=new oA;return l.forEach(u=>{u&&c.add(u)}),c}var yt;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(yt||(yt={}));var Io=n=>yt.is(n),c7={type:"completeState",isfromEntity:!0},u7=["x","y","z"],cA=new E,h7=new E().set(0,1,0),md=n=>class extends fd(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.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new $p;this._recursiveBBox=new $p;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(yt.is(i))return i}entityChildrenCount(){let r=this.children.length;for(;r--;)if(yt.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(yt.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)xa.toOps(this.data,o.data).forEach(l=>{let c=Lh.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=xa.patch(this.data,o),xa.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=>{Io(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(yt.is(i[s]))return i[s];if(yt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&yt.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)Io(i)&&r(i)}traverseEntityAncestors(r){this.traverseAncestors(i=>{yt.is(i)&&r(i)})}traverseConcreteEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Io(o)&&o.isConcreteEntity&&o.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Io(o)&&o.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Io(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=>Io(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*we.RAD2DEG,this.rotation.y*we.RAD2DEG,this.rotation.z*we.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ch(i,r)}getTransformValues(r,i,s){return i[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,u7[a]])??o)}updateTransformState(r,i){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),s=!0),r.rotation&&(cA.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(we.DEG2RAD),this.rotation.setFromVector3(cA),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??xl.identity)),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)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)yt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{yt.is(r)&&r.disposeRecursively()})}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Ch(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=Lt(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=Sr.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}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=Sr.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,xa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Lt(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(xo.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Sr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[m,g]of Object.entries(r.props))g===void 0&&(p===r.props&&(p={...r.props}),p[m]=f[m]);r={...r,props:p}}d.overrideData=Hh.resolve(i.overrides,u),d.updateByOp(r,Lr.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 To.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of To.rootOverrideProps)if(Lt(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=xo.filterOp(h.overrideData,u);d&&h.updateByOp(d,Lr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=xo.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=i:f=Lr.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&&!Vs.is(r.props.type)&&js.changeEntityProptotype(this,i,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){js.changeEntityProptotype(this,i,s);for(let o of this.children)yt.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),Lt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Lt(r.path,["cloner"])!==null){let o=Lr.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.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),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=m0(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 p=new ue().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let g=new ue().extractRotation(l.matrixWorld),y=u.getTangentAt(h).applyMatrix4(g).add(d),v=new ue().lookAt(d,y,h7),x=cA.setFromEuler(new ir().setFromRotationMatrix(v)).multiplyScalar(we.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(c7)})}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 js.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 js.Cloner(this,r),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,i.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var g0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=we.clamp(e.thetaLength,0,360);let r=e.width/2,i=e.radiusTop??r,s=e.radiusBottom??r;return i===s?(i=r,s=r):i>s?(i=r,s=s*r/i):(i=i*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}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,p;return l===0?(p=new _e,p.setAttribute("position",new Me([],3))):h||f?p=new em(c,u,r,i,s,o,a,l*Math.PI/180,h,h,d,f):p=new bc(c,u,r,i,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"CylinderGeometry"}})}};function _l(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function XI(n){return new U(n.y,-n.x)}var em=class extends _e{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 p=[],m=[],g=[],y=[],v=0,x=r/2,S=new E,w=new E;f&&t==0&&(t=c),f&&e==0&&(e=u);let A=new U(t,x),M=new U(e,-x),b=null,T=null,C=null,P=null,D=A.clone().sub(M),_=0,I=0,L=0;d>0&&(_=Math.min(t,e)*(1-d),I=t-_,L=e-_);let j=A.clone();j.x-=_;let V=Math.PI-D.angle(),H=D.angle(),W=Math.tan(H/2),q=Math.tan(V/2),K=W+q,G=d?K:q,Z=d?K:W;if(c=Math.min(c,(t-I)/G,D.length()/K),u=Math.min(u,(e-L)/Z,D.length()/K),c>0){let re=c/W;b=A.clone().sub(new U(re,c)),d&&(C=b.clone(),C.x-=_-K*c),A.sub(D.clone().setLength(re))}if(u>0){let re=u/q;T=M.clone().sub(new U(re,-u)),M.add(D.clone().setLength(re)),d&&(P=T.clone(),P.x-=_-K*u,j.sub(D.clone().setLength(re)))}D=A.clone().sub(M);let te=D.length()<.5,$=[];for(let re=0;re<=i;re++){let J=[],Ae=re/i,xe=Ae*l+a,de=new U(Math.sin(xe),Math.cos(xe));P&&T?(Y(J,Ae,de,V,u,P,-1,!0),Y(J,Ae,de,H,u,T,-1,!1)):T?(oe(J,de,T.x,0,-1),Y(J,Ae,de,H,u,T,-1,!1)):o||oe(J,de,e,L,-1);let Ie=XI(D).normalize();if(_l(Ie,de,S),!te)for(let Ce=0;Ce<=s;Ce++){let ke=Ce/s,ze=D.clone().multiplyScalar(ke).add(M);_l(ze,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}if(C&&b?(Y(J,Ae,de,V,c,b,1,!1),Y(J,Ae,de,H,c,C,1,!0)):b?(Y(J,Ae,de,V,c,b,1,!1),oe(J,de,b.x,0,1)):o||oe(J,de,t,I,1),d&&!te){let Ce=XI(D).multiplyScalar(-1).normalize();_l(Ce,de,S);for(let ke=0;ke<=s;ke++){let ze=ke/s,Ve=D.clone().multiplyScalar(-ze).add(j);_l(Ve,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}}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 Ae=$[re][J],xe=$[re+1][J],de=$[re+1][J+1],Ie=$[re][J+1],Ce=m[de*3+0],ke=m[de*3+2];p.push(Ae,xe,Ie),(Ce!=0||ke!=0)&&p.push(xe,de,Ie)}l<Math.PI*2&&(ie(-1,$[0],a),ie(1,$[$.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new Me(m,3)),this.setAttribute("normal",new Me(g,3)),this.setAttribute("uv",new Me(y,2));function Y(re,J,Ae,xe,de,Ie,Ce,ke){for(let ze=0;ze<h+1;ze++){let Ve=ze/h,Oe=Ce<0?Ve:1-Ve;ke&&(Oe-=1),Oe*=xe;let Ye=new U(Math.sin(Oe),Math.cos(Oe)*Ce),F=Ye.clone().multiplyScalar(de).add(Ie);_l(F,Ae,w),m.push(w.x,w.y,w.z),_l(Ye,Ae,S),g.push(S.x,S.y,S.z),y.push(J,.5+w.y/r),re.push(v++)}}function oe(re,J,Ae,xe,de){let Ie=new E,Ce=new U,ke=[Ae,xe];de<0&&ke.reverse();for(let ze of ke)Ce.set(ze,x*de),_l(Ce,J,Ie),m.push(Ie.x,Ie.y,Ie.z),g.push(0,de,0),y.push(.5,.5),re.push(v++)}function ie(re,J,Ae){let xe=new U(Math.sin(Ae),Math.cos(Ae)),de=new U(-Math.cos(Ae),Math.sin(Ae)),Ie=new E,Ce=re<0?(Ve,Oe,Ye)=>p.push(Ve,Oe,Ye):(Ve,Oe,Ye)=>p.push(Ve,Ye,Oe),ke=new U((t+e+I+L)/4,0);_l(ke,xe,Ie),m.push(Ie.x,Ie.y,Ie.z),g.push(de.x,0,de.y),y.push(.5,.5);let ze=v++;for(let Ve of J){let Oe=m.slice(Ve*3,Ve*3+3);m.push(...Oe),g.push(de.x,0,de.y);let Ye=y.slice(Ve*2,Ve*2+2);y.push(...Ye),v++}for(let Ve=ze+1;Ve<v-1;Ve++)Ce(ze,Ve,Ve+1);Ce(ze,v-1,ze+1)}}};var QI=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=we.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 _e,d.setAttribute("position",new Me([],3))):c>0||u>0||l<360?d=new em(0,t/2,r,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new rl(t/2,r,i,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var KI=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 mi(t,e,r,i,s,o):c=new hA(t,e,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},uA=Math.PI/2,hA=class extends _e{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;p("z","y","x",-1,-1,r,e,t,o,s),p("z","y","x",1,-1,r,e,-t,o,s),p("x","z","y",1,1,t,r,e,i,o),p("x","z","y",1,-1,t,r,-e,i,o),p("x","y","z",1,-1,t,e,r,i,s),p("x","y","z",-1,-1,t,e,-r,i,s),a>0&&(m("z","y","x",-1,-1,1,r,e,t,o),m("z","y","x",1,-1,-1,r,e,t,o),m("z","y","x",-1,1,-1,r,e,t,o),m("z","y","x",1,1,1,r,e,t,o),m("x","y","z",-1,-1,-1,t,e,r,i),m("x","y","z",1,-1,1,t,e,r,i),m("x","y","z",-1,1,1,t,e,r,i),m("x","y","z",1,1,-1,t,e,r,i),m("y","x","z",-1,-1,1,e,t,r,s),m("y","x","z",1,-1,-1,e,t,r,s),m("y","x","z",1,1,1,e,t,r,s),m("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 Me(u,3)),this.setAttribute("normal",new Me(h,3)),this.setAttribute("uv",new Me(d,2));function p(y,v,x,S,w,A,M,b,T,C){let P=(A-2*a)/T,D=(M-2*a)/C,_=A/2-a,I=M/2-a,L=b/2,j=T+1,V=C+1,H=0,W=new E;for(let q=0;q<V;q++){let K=q*D-I;for(let G=0;G<j;G++){let Z=G*P-_;W[y]=Z*S,W[v]=K*w,W[x]=L,u.push(W.x,W.y,W.z),W[y]=0,W[v]=0,W[x]=b>0?1:-1,h.push(W.x,W.y,W.z),d.push(G/T),d.push(1-q/C),H+=1}}for(let q=0;q<C;q++)for(let K=0;K<T;K++){let G=f+K+j*q,Z=f+K+j*(q+1),te=f+(K+1)+j*(q+1),$=f+(K+1)+j*q;c.push(G,Z,$),c.push(Z,te,$)}f+=H}function m(y,v,x,S,w,A,M,b,T,C){let P=(M-2*a)/C,D=M/2-a,_=b/2-a,I=T/2,L=C+1,j=0,V=new E,H=new E;for(let W=0;W<l+1;W++){let q=W/l*uA,K=Math.sin(q)*a,G=(1-Math.cos(q))*a,Z=Math.sin(q),te=Math.cos(q);V[v]=(_+K)*w,V[x]=(I-G)*A,H[y]=0,H[v]=Z*Math.sign(V[v]),H[x]=te*Math.sign(V[x]);for(let $=0;$<L;$++){let Y=$*P-D;V[y]=Y*S,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 W=0;W<l;W++)for(let q=0;q<C;q++){let K=f+q+L*W,G=f+q+L*(W+1),Z=f+(q+1)+L*(W+1),te=f+(q+1)+L*W;c.push(K,G,te),c.push(G,Z,te)}f+=j}function g(y,v,x){let S=new E,w=new E(t/2,e/2,r/2);w.subScalar(a);let A=[],M=y*v*x>0?(T,C,P)=>c.push(T,C,P):(T,C,P)=>c.push(T,P,C);for(let T=0;T<=l;T++){let C=[],P=uA*(1-T/l),D=Math.cos(P),_=Math.sin(P),I=0;for(let L=0;L<=T;L++){let j=Math.cos(I),V=Math.sin(I);S.x=D*j,S.y=_,S.z=D*V;let H=w.clone().addScaledVector(S,a);u.push(y*H.x,v*H.y,x*H.z),h.push(y*S.x,v*S.y,x*S.z),d.push(0,0),C.push(f++),I+=uA/T}A.push(C)}let b=A.length-1;for(let T=0;T<b;T++){let C=A[T],P=A[T+1],D=C.length-1;M(C[0],P[1],P[0]);for(let _=1;_<=D;_++)M(C[_-1],C[_],P[_]),M(C[_],P[_+1],P[_])}}}};var Dl=class extends _e{constructor(t=[],e=[],r="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),h(),this.setAttribute("position",new Me(a,3)),this.setAttribute("normal",new Me(c,3)),this.setAttribute("uv",new Me(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],p=new E,m=p.clone(),g=new Cr,y=s*i,v=i-y,x=o+1,S=new E,w=(W,q)=>S.subVectors(W,q).normalize(),A=(W,q)=>Array(W).fill(void 0).map(q),M=A(t.length/3,(W,q)=>new E().fromArray(t,q*3).setLength(i)),b=[],T=1e6;for(let W=0;W<M.length;W++){let q=M[W],K=[],G,Z,te,$=1e10,Y=-1;for(;(Y=e.indexOf(W,Y+1))!=-1;){let J=Y-Y%3;G=e[J+(Y+1)%3],Z=e[J+(Y+2)%3],te=q.distanceToSquared(M[G]),$=Math.min($,te),K.push([G,Z,te])}$+=1e-6;let oe=[],ie=0,re=K.length;for(let J=0;J<re;J++){[G,Z,te]=K[ie];let Ae=b[G]?.includes(W)==!0;te<=$&&oe.push(G+ +Ae*T),ie=K.findIndex(xe=>xe[0]==Z)}b.push(oe)}let C=[];{let W=0,q=0,K,G,Z=f==3;for(let te=0;te<=o;te++){K=te*(te+1)/2,G=(te+1)*(te+2)/2;for(let $=0;$<o-te;$++)[W,q]=[K+$+te+2,G+$+te+3],C.push(K,G,...Z?[q,K]:[W,G],q,W),[K,G]=[W,q];C.push(K,G,K+o+2)}}let P=p.clone(),D=p.clone(),_=p.clone(),I=p.clone(),L=p.clone(),j=[],V=A(M.length,()=>A(f,()=>p.clone()));for(let W=0;W<M.length;W++){p.copy(M[W]).normalize(),P.copy(p).multiplyScalar(v);let q=b[W];for(let oe=0;oe<q.length;oe++){let ie=q[oe],re=q[(oe+1)%f];g.setFromPointsAndIndices(M,W,ie%T,re%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(P,V[W][oe])}let K=[],G=[],Z=[],te=new E;o==0&&[...V[W]].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[W][re],Ae=V[W][oe];p.copy(J).sub(P),m.copy(Ae).sub(P);let xe=P.angleTo(p),de=p.angleTo(m),Ie=Math.cos(xe)*y;o==0?D.copy(te):D.copy(P).setLength(v+Ie),G.push(Ie);let Ce=[D,J,Ae];for(let ke=0;ke<2;ke++){let ze=Ce[ke],Ve=Ce[ke+1];I.subVectors(ze,P),L.subVectors(Ve,P),_.crossVectors(I,L).normalize();for(let Oe=0;Oe<x;Oe++){let Ye=[xe,de][ke]*Oe/x;p.copy(I).applyAxisAngle(_,Ye).add(P),K.push(p.clone()),ke&&(w(p,P),ie.push([Oe==0?ze:p.clone(),S.clone()]))}ke&&(w(Ve,P),ie.push([Ve,S.clone()]))}Z.push(ie)}j.push(Z);let $=2*x,Y=2;for(let oe=0;oe<f;oe++){let ie=$*oe,re=$*((oe+1)%f),J=[K[ie]];for(let xe=1;xe<x;xe++){I=K[ie+xe],L=K[re+xe],J.push(I);for(let de=1,Ie=xe-Y+1;de<=Ie;de++)p.lerpVectors(I,L,de/(Ie+1)),p.sub(P).setLength(G[oe]).add(P),J.push(p.clone());J.push(L)}for(let xe=0;xe<x;xe++)J.push(K[xe+x+ie]);J.push(K[re+x]);let Ae=C.map(xe=>J[xe]);a.push(...Ae.map(xe=>[xe.x,xe.y,xe.z]).flat()),c.push(...Ae.map(xe=>(w(xe,P),[S.x,S.y,S.z])).flat())}}let H=[];for(let W=0;W<b.length;W++)for(let q=0;q<f;q++){let K=b[W][q];if(K<T){let G=b[K].findIndex($=>$%T==W),Z=j[W][q],te=j[K][G];for(let $=0;$<x;$++){let Y=Z[$],oe=te[x-$],ie=Z[$+1],re=te[x-($+1)];[Y,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(Z[0][0],te[x][0],Z[x][0],te[0][0])}}for(;H.length;){let W,q,K,G;[W,q]=H.splice(0,2);let Z=[W];for(;W!=q;)Z.push(q),K=H.indexOf(q),G=K%2,q=H.splice(K-G,2)[1-G];S.subVectors(Z[0],Z[1]).cross(p.subVectors(Z[0],Z[2])).normalize();let te=S.dot(Z[0])<0;te&&S.negate();for(let $=1;$<=Z.length-2;$++)[Z[$+ +te],Z[$+1-+te],Z[0]].forEach(Y=>{a.push(Y.x,Y.y,Y.z),c.push(S.x,S.y,S.z)})}}function h(){let d=new E;for(let M=0;M<a.length;M+=3){d.x=a[M+0],d.y=a[M+1],d.z=a[M+2];let b=w(d)/2/Math.PI+.5,T=A(d)/Math.PI+.5;l.push(b,1-T)}let f=new E,p=new E,m=new E,g=new E,y=new U,v=new U,x=new U,S=(M,b,T,C)=>{C<0&&M.x===1&&(l[b]=M.x-1),T.x===0&&T.z===0&&(l[b]=C/2/Math.PI+.5)};for(let M=0,b=0;M<a.length;M+=9,b+=6){f.set(a[M+0],a[M+1],a[M+2]),p.set(a[M+3],a[M+4],a[M+5]),m.set(a[M+6],a[M+7],a[M+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(p).add(m).divideScalar(3);let T=w(g);S(y,b+0,f,T),S(v,b+2,p,T),S(x,b+4,m,T)}for(let M=0;M<l.length;M+=6){let b=l[M+0],T=l[M+2],C=l[M+4],P=Math.max(b,T,C),D=Math.min(b,T,C);P>.9&&D<.1&&(b<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),C<.2&&(l[M+4]+=1))}function w(M){return Math.atan2(M.z,-M.x)}function A(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new Dl(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var ZI=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 tm(t*.5,s,o):new Vu(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},tm=class extends Dl{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 tm(t.radius,t.corner,t.cornerSides)}};var rm=1e-12,gd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=we.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]}},yd=class extends gd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new yd(this.parent).copy(this)}},Hs=class extends gd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new yd(this),new yd(this))}static create(e,r){let i=new Hs(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 Hs(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&&(JI(i,e),JI(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 JI(n,t=new U){let e=n.length();return t.set(-n.y/e,n.x/e)}var fA=n=>n,vd=new U,y0=new U,d7=new U,f7=new U,p7=new U,m7=new U,eO=new E,tO=new E;function rO(n){let t=new U;t.addVectors(n.v0,vd.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new U;return e.addVectors(n.v2,y0.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new an(n.v0,t,e,n.v2)}function im(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function g7(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function y7(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function pA(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 iO(n,t,e){return $I(n,t)&&$I(t,e)&&dA(n.position,t.position,e.position)}function dA(n,t,e){return vd.copy(t).sub(n).cross(y0.copy(e).sub(n))===0}function nO(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 sO(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function oO(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 pA(t,n,e)>Math.PI&&(u*=-1),im(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 mA(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function $I(n,t){return dA(n.position,n.controls[1].position,t.position)&&dA(n.position,t.controls[0].position,t.position)}function aO(n,t,e,r,i=.5){let s=vd.subVectors(t,n).multiplyScalar(i).add(n),o=y0.subVectors(e,t).multiplyScalar(i).add(t),a=d7.subVectors(r,e).multiplyScalar(i).add(e),l=s,c=f7.subVectors(o,s).multiplyScalar(i).add(s),u=p7.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=m7.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 lO(n,t,e=12,r=!0){let i=tO.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let c=fA(t[l]),u=vd,h=Il(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof an||c instanceof Yn||c instanceof ln){if(c.getPoint(d/h,u),i.set(u.x,u.y,0),s!==void 0&&y7(s,i))continue;s===void 0&&(s=eO),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 cO(n,t,e,r=12,i=!0){let s=tO.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=fA(t[l]),h=vd,d=Il(u,r);a.push(d);for(let f=0;f<=d;f++)if(u instanceof an||u instanceof Yn||u instanceof ln){if(u.getPoint(f/d,h),s.set(h.x,h.y,0),c?.equals(s))continue;c===void 0?c=eO:(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 gA(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=Il(o.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Il(o.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Il(n[0].roundedCurveCorner,t)*.5),r}function Il(n,t=12){return n&&n instanceof yc?t*2:n&&(n instanceof ln||n instanceof fp)?1:n&&n instanceof Bu?t*n.points.length:t}function uO(n,t,e=12,r=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=fA(t[o]),l=Il(a,e),c=vd;for(let u=0;u<=l;u++)if(a instanceof an||a instanceof Yn||a instanceof ln){if(a.getPoint(u/l,c),i!==void 0&&g7(i,c,rm))continue;i===void 0&&(i=y0),i.copy(c),n.push(c.x,c.y),s++}}return im(n[0],n[n.length-2],rm)&&im(n[1],n[n.length-1],rm)&&(n.pop(),n.pop()),r&&s>1&&!(im(n[s-1],n[1],rm)&&im(n[s-2],n[0],rm))&&(n.push(n[0],n[1]),s++),n}var yA=new U,v7=new U,x7=new U,b7=new U,S7=new U,w7=new U,qt=class extends la{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ur(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=we.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let s=new qt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Hs.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>qt.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=yA.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=we.generateUUID()){let s;e instanceof U?s=e:s=new U(e,r);let o=new Hs(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 lO(e,i?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=gA(this.points,e,!1),this.roundedCurveDivisions=gA(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return cO(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),uO(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=Il(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(mA(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(yA.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){mA(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&&iO(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,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(c,m*.499),v=Math.min(c,g*.499),x=Math.min(y,v),S=1-x/m,w=x/g,A=h.getPointAt(S,yA),M=d.getPointAt(w,v7);this._subSplitCurve(h,f,S,A,void 0),this._subSplitCurve(d,p,w,void 0,M);let b;if(this.useCubicForRoundedCorners){let T=pA(A,o.position,M)/2,C=Math.tan(T)*A.distanceTo(o.position),[P,D]=nO(A,M,C,x7,b7),_=sO(P,D,o.position),[I,L]=oO(_,A,M,C,S7,w7);b=new an(A.clone(),I.clone(),L.clone(),M.clone())}else b=new Yn(A.clone(),o.position.clone(),M.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+r,0,b),r++}}}}_subSplitCurve(e,r,i,s,o){if(e instanceof ln)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=aO(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 qt(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 Hs(we.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 qt;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 an&&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 Yn&&(o[l]=rO(o[l]));for(l=0,c=o.length;l<c;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof an?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof ln&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&i(p,f),a.push(p))}let u=o[o.length-1],h=!1;return u instanceof an?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof ln&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof la&&(this.shapeHoles=e.holes.map(o=>{let a=new qt;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 xA=Math.PI*2;function vA({x:n,y:t},e,r,i,s){return{x:n*e+i,y:t*r+s}}function A7(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 hO(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 E7(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),p=u*h-u*f-h*d;p<0&&(p=0),p/=u*f+h*d,p=Math.sqrt(p)*(l===c?-1:1);let m=p*i/s*a,g=p*-s/i*o,y=m+(n+e)/2,v=g+(t+r)/2,x=(o-m)/i,S=(a-g)/s,w=(-o-m)/i,A=(-a-g)/s,M=hO(1,0,x,S),b=hO(x,S,w,A);return!c&&b>0&&(b-=xA),c&&b<0&&(b+=xA),{centerx:y,centery:v,ang1:M,ang2:b}}function dO({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=E7(n,t,e,r,i,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(xA/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(A7(f,p)),f+=p;return l.map(x=>{let{x:S,y:w}=vA(x[0],i,s,m,g),{x:A,y:M}=vA(x[1],i,s,m,g),{x:b,y:T}=vA(x[2],i,s,m,g);return{x1:S,y1:w,x2:A,y2:M,x:b,y:T}})}var zt;(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"})(zt||(zt={}));var jr;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(jr||(jr={}));function ut(n,t){if(!n)throw t||"Assertion Failed!"}var ot=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){ut(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){ut(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){ut(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){ut(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}(),nm=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}(),v0=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}(),xd=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}(),fO=function(){function n(){var t=new xd,e=new nm,r=new v0(0),i=new v0(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 v0(0),r=new v0(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;ut(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;ut(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 xd,e=new xd,r=new nm,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 xd;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new nm;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 nm;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 xd;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 nm;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&&ot.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&ot.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){ut(i.prev===s),l=i.anEdge;do ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l),ut(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(ut(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){ut(o.prev===a),l=o.anEdge;do ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l),ut(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(ut(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ut(l.Sym.next===c.Sym),ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Org!==null),ut(l.Dst!==null),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l);ut(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}(),pO=function(){function n(){this.handle=null}return n}(),mO=function(){function n(){this.key=null,this.node=0}return n}(),M7=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 pO,this.handles[r]=new mO;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,ut(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 pO;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new mO}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;ut(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}(),bA=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}(),gO=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),T7=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new gO,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 gO;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}(),C7=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?ot.vertLeq(s.Org,o.Org)?ot.edgeSign(o.Dst,s.Org,o.Org)<=0:ot.edgeSign(s.Dst,o.Org,s.Org)>=0:ot.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ot.edgeSign(s.Dst,i,s.Org)>=0;var a=ot.edgeEval(s.Dst,i,s.Org),l=ot.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ut(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ut(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 bA;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 zt.ODD:return(e&1)!==0;case zt.NONZERO:return e!==0;case zt.POSITIVE:return e>0;case zt.NEGATIVE:return e<0;case zt.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 ut(ot.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,ut(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=ot.vertL1dist(e,t),s=ot.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(ot.vertLeq(i.Org,s.Org)){if(ot.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ot.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(ot.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(ut(!ot.vertEq(i.Dst,s.Dst)),ot.vertLeq(i.Dst,s.Dst)){if(ot.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(ot.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 xd,f,p;if(ut(!ot.vertEq(c,l)),ut(ot.edgeSign(l,t.event,o)<=0),ut(ot.edgeSign(c,t.event,a)>=0),ut(o!==t.event&&a!==t.event),ut(!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(ot.vertLeq(o,a)){if(ot.edgeSign(c,o,a)>0)return!1}else if(ot.edgeSign(l,a,o)<0)return!1;return n.debugEvent(t),ot.intersect(l,o,c,a,d),ut(Math.min(o.t,l.t)<=d.t),ut(d.t<=Math.max(a.t,c.t)),ut(Math.min(c.s,l.s)<=d.s),ut(d.s<=Math.max(a.s,o.s)),ot.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=ot.vertLeq(o,a)?o:a,ot.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ot.vertEq(d,o)||ot.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!ot.vertEq(l,t.event)&&ot.edgeSign(l,t.event,d)>=0||!ot.vertEq(c,t.event)&&ot.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),p=n.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,s.Onext,i.Rprev,p,!0),!0):(ot.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),ot.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),ot.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),ot.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}ot.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,ot.vertEq(i.Org,r)){ut(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!ot.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}ut(!1),e=n.topRightRegion(e),l=n.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(ut(s!==o),n.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),ot.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 bA;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,ot.edgeSign(o.Dst,e,o.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(s=ot.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);ut(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 bA,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 T7(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||(ut(e.fixUpperEdge),ut(++r===1)),ut(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,ot.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 M7(s,ot.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,ut(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||!ot.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}(),P7=function(){function n(){this.mesh=new fO,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=zt.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],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],c[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<c[y]&&(c[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],i=f[v],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=m.next;e!==m;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(;ot.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ot.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(ot.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ot.edgeGoesLeft(i.Lnext)||ot.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&&(ot.edgeGoesRight(r.Lprev)||ot.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===jr.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===jr.CONNECTED_POLYGONS){s=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==u.anEdge);for(var p=l;p<r;++p)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 fO),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=zt.ODD),e===void 0&&(e=jr.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_(),C7.computeInterior(this,o);var a=this.mesh;return e===jr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===jr.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function Ws(n){var t=n.windingRule,e=t===void 0?zt.ODD:t,r=n.elementType,i=r===void 0?jr.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,p=f===void 0?!0:f,m=n.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new P7;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,i,o,l,u,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var $ge=zt.ODD,eye=zt.NONZERO,tye=zt.POSITIVE,rye=zt.NEGATIVE,iye=zt.ABS_GEQ_TWO,nye=jr.POLYGONS,sye=jr.CONNECTED_POLYGONS,oye=jr.BOUNDARY_CONTOURS;var x0=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*x0.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*x0.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)}},sm=x0;sm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var bO=$o(xO()),om={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},MA={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},TA={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},EA=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Rl=class extends _e{constructor(e,r,i=0,s=12,o=3,a=zt.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 D=P.extractShapePointsToFlatArray([],s),_=[];for(let I=D.length-1;I>=1;I-=2){let L=D[I-1],j=D[I-0];_.push(L,j)}return _}),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 D=u[P],_=[];for(let I=0;I<D.length;I+=2)_.push([D[I],D[I+1]]);h.push(_)}let f;e.isText?f=new Ku().setFromPoints(e.points.map(D=>D.position)).getSize(new U).length()*.1:h[0].length===0?f=i:f=(0,bO.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=Ws({windingRule:a,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{p=om}let m;try{m=Ws({windingRule:zt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=MA}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let P=0;P<m.elements.length;P++){let D=m.elements[P],_=P%2===0?p.vertexCount:0;p.elements.push(D+_)}for(let P=0;P<m.vertexIndices.length;P++){let D=m.vertexIndices[P],_=p.vertexCount;p.vertexIndices.push(D+_)}for(let P=0;P<m.vertices.length;P++){let D=m.vertices[P];p.vertices.push(D)}}let y=1/0,v=-1/0,x=1/0,S=-1/0;for(let P=0,D=p.vertexCount;P<D;P++){let _=P*2,I=p.vertices[_+0],L=p.vertices[_+1];I<y&&(y=I),I>v&&(v=I),L<x&&(x=L),L>S&&(S=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=S-x,this._buffer=new sm(this._computeBufferEstimatedSize(p));let w=[],A=[];for(let P=p.elementCount-1;P>=0;P--){let D=P>=g,_=P*2,I=p.elements[_+0],L=p.elements[_+1],j=I+L,V={start:I,count:L,normals:[],continuous:[],concave:[]},H=I,W=j-1,q=I+1,K=this._shape.roundedCurves.length;do{let Y=H-I,oe=p.vertices[W*2+0],ie=p.vertices[W*2+1],re=p.vertices[H*2+0],J=p.vertices[H*2+1],Ae=p.vertices[q*2+0],xe=p.vertices[q*2+1],de=re-oe,Ie=J-ie,Ce=Math.sqrt(de*de+Ie*Ie);de/=Ce,Ie/=Ce;let ke=re-Ae,ze=J-xe,Ve=Math.sqrt(ke*ke+ze*ze);ke/=Ve,ze/=Ve,V.normals[Y*2+0]=-ze,V.normals[Y*2+1]=ke,V.concave[Y]=de*ze-Ie*ke>0;let Oe=p.vertexIndices[H];if(Array.isArray(Oe))V.continuous[Y]=!1;else{let[Ye,F]=this._shape.getCurveIndexFromVertexId(Oe-1,!0);if(F>0&&F<1)V.continuous[Y]=!0;else{let N=F===1?Ye+1:Ye-1;N=(N+K)%K;let B=F===1?0:1,ae=this._shape.roundedCurves[Ye].getTangent(F),ge=this._shape.roundedCurves[N].getTangent(B);V.continuous[Y]=ae.dot(ge)>.95}}D&&(V.normals[Y*2+0]*=-1,V.normals[Y*2+1]*=-1),[W,H,q]=[H,q,q+1],q>=j&&(q-=L)}while(q!==I+1);let G=[];G.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,j*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((Y,oe)=>[oe,oe]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,j*2)});let Z=0;for(let Y=1;Y<=this._bevelSegments;Y++){let oe=Y/this._bevelSegments*Math.PI/2,ie=(1-Math.cos(oe))*this._bevel,re=[],J=[],Ae=[],xe=[],de=0;for(let Ce=0;Ce<L;Ce++){let ke=Ce*2,ze=(Ce-1+L)%L*2,Ve=p.vertices[V.start*2+ke+0],Oe=p.vertices[V.start*2+ke+1],Ye=-V.normals[ze+0]*ie,F=-V.normals[ze+1]*ie,N=-V.normals[ke+0]*ie,B=-V.normals[ke+1]*ie;if(V.concave[Ce]||!V.concave[Ce]&&D){let ae=Math.atan2(F,Ye),ge=Math.atan2(B,N);ge>ae&&(ge-=Math.PI*2);let me=ge-ae;if(V.continuous[Ce]||D){let Le=ae+me/2,Ne=Math.cos(Le)*ie,Re=Math.sin(Le)*ie;re[2*de+0]=Ve+Ne*(D?-1:1),re[2*de+1]=Oe+Re*(D?-1:1),xe[de]=Ce,de++}else{let Le=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Ne=0;Ne<=Le;Ne++){let Re=ae+me*(Ne/Le),pe=Math.cos(Re)*ie,nt=Math.sin(Re)*ie;re[2*de+0]=Ve+pe,re[2*de+1]=Oe+nt,xe[de]=Ce,de++}}}else re[2*de+0]=Ve+Ye,re[2*de+1]=Oe+F,xe[de]=Ce,J[Ce]=de,de++,re[2*de+0]=Ve,re[2*de+1]=Oe,xe[de]=Ce,de++,re[2*de+0]=Ve+N,re[2*de+1]=Oe+B,xe[de]=Ce,Ae[Ce]=de,de++}let Ie=Ws({windingRule:zt.POSITIVE,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[re],edgeCreateCallback:Ce=>{let ze=Ce.Org.idx,Ve=xe[ze],Oe=xe[(ze+1)%xe.length];Ce.idx=[Ve,Oe],Ce.Sym.idx=[Oe,Ve]},vertexIdCallback:Ce=>{let ke=Ce.Lprev.idx;return[ke?ke[1]:0,Ce.idx?Ce.idx[0]:0]}});if(!Ie)throw console.log("Error"),new Error(`error generating bevel geometry for ${Y}'th loop`);if(!Ie.vertexCount){let Ce=(Y-1)/this._bevelSegments*Math.PI/2;Z=(1-Math.sin(Ce))*this._bevel;break}for(let Ce=0;Ce<Ie.vertexIndices.length;Ce++){let[ke,ze]=Ie.vertexIndices[Ce];if(ke===ze)continue;let Ve=ze;ze<ke&&(Ve+=L);for(let Oe=ke;Oe<Ve;Oe++){let Ye=Oe%L,F=(Oe+1)%L;if(!V.continuous[Ye]||!V.continuous[F]){Ie.vertexIndices[Ce]=[ke,Ye],Ie.vertexIndices.splice(Ce+1,0,[F,ze]),Ie.vertices.splice((Ce+1)*2,0,Ie.vertices[Ce*2],Ie.vertices[Ce*2+1]);break}}}G.push({bevelI:Y,angle:oe,size:ie,boundary:Ie,reverseMap:xe,insetPoints:re})}let te=(Y,oe,ie)=>{let re=0,J=Y.boundary.vertexIndices.length;for(;re<J&&ie(Y.boundary.vertexIndices[oe]);)oe=(oe+1)%J,re++;return re},$=w.length;for(let Y=1;Y<G.length;Y++){let oe=G[Y-1],ie=G[Y],re=oe.boundary.vertexIndices.length,J=ie.boundary.vertexIndices.length;if(!re||!J)break;let Ae=V.concave.length,xe=0,de=EA(xe,L);for(;!oe.boundary.vertexIndices.filter(de).length||!ie.boundary.vertexIndices.filter(de).length;)xe++,de=EA(xe,L);let Ie=oe.boundary.vertexIndices.findIndex(de),Ce=ie.boundary.vertexIndices.findIndex(de);do Ie=(Ie+1)%re;while(de(oe.boundary.vertexIndices[Ie]));do Ce=(Ce+1)%J;while(de(ie.boundary.vertexIndices[Ce]));xe=(xe+1)%L;let ke=xe,ze=0,Ve=this._buildBevelVert(V,oe,(Ie-1+re)%re,void 0,ze),Oe=this._buildBevelVert(V,ie,(Ce-1+J)%J,void 0,ze),Ye=Ve,F=Oe,N,B,ae=!1;do{ze=(xe||Ae)/Ae,de=EA(xe,L);let ge=te(oe,Ie,de),me=te(ie,Ce,de),Le=ae;if(ae=!1,ge&&!me){for(let Ne=0;Ne<ge;Ne++)N=this._buildBevelVert(V,oe,(Ie+Ne)%re,Ne/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N;ae=!0}else if(!ge&&me)for(let Ne=0;Ne<me;Ne++)B=this._buildBevelVert(V,ie,(Ce+Ne)%J,Ne/(me-1),ze),w.push(F.topN,Ye.topP,B.topP),l===!1&&w.push(Ye.bottomP,F.bottomN,B.bottomP),F=B;else if(ge&&me)if(N=this._buildBevelVert(V,oe,Ie,0,ze),B=this._buildBevelVert(V,ie,Ce,0,ze),Le?(w.push(Ye.topN,B.topP,F.topN),w.push(Ye.topN,N.topP,B.topP),l===!1&&(w.push(B.bottomP,Ye.bottomN,F.bottomN),w.push(B.bottomP,N.bottomP,Ye.bottomN))):(w.push(F.topN,Ye.topN,N.topP),w.push(F.topN,N.topP,B.topP),l===!1&&(w.push(N.bottomP,Ye.bottomN,F.bottomN),w.push(N.bottomP,F.bottomN,B.bottomP))),Ye=N,F=B,ge===me)for(let Ne=1;Ne<ge;Ne++)N=this._buildBevelVert(V,oe,(Ie+Ne)%re,Ne/(ge-1),ze),B=this._buildBevelVert(V,ie,(Ce+Ne)%J,Ne/(me-1),ze),w.push(Ye.topN,N.topP,F.topN),w.push(F.topN,N.topP,B.topP),l===!1&&(w.push(N.bottomP,Ye.bottomN,F.bottomN),w.push(N.bottomP,F.bottomN,B.bottomP)),Ye=N,F=B;else if(ge>me){let Ne=ge/me,Re=0;for(let pe=1;pe<ge;pe++)N=this._buildBevelVert(V,oe,(Ie+pe)%re,pe/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N,pe>(Re+1)*Ne&&(Re++,B=this._buildBevelVert(V,ie,(Ce+Re)%J,Re/(me-1),ze),w.push(F.topN,N.topP,B.topP),l===!1&&w.push(N.bottomP,F.bottomN,B.bottomP),F=B)}else{let Ne=me/ge,Re=0;for(let pe=1;pe<me;pe++)B=this._buildBevelVert(V,ie,(Ce+pe)%J,pe/(me-1),ze),w.push(F.topN,N.topP,B.topP),l===!1&&w.push(N.bottomP,F.bottomN,B.bottomP),F=B,pe>(Re+1)*Ne&&(Re++,N=this._buildBevelVert(V,oe,(Ie+Re)%re,Re/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N)}Ie=(Ie+ge)%re,Ce=(Ce+me)%J,xe=(xe+1)%Ae}while(xe!==ke)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(G,V,w),D){let Y=[];for(let oe=w.length-1;oe>=$+2;oe-=3){let ie=w[oe-2],re=w[oe-1],J=w[oe-0];Y.push(J,re,ie)}w.splice($,w.length-$,...Y)}if(D){let Y=[];for(let oe=G[G.length-1].boundary.vertices.length-1;oe>=1;oe-=2){let ie=G[G.length-1].boundary.vertices[oe-1],re=G[G.length-1].boundary.vertices[oe-0];Y.push(ie,re)}A.push(Y)}if(!D){let Y=G[G.length-1],oe;try{oe=Ws({windingRule:G.length>1?zt.POSITIVE:zt.ODD,elementType:jr.POLYGONS,vertexSize:2,strict:!0,contours:[Y.insetPoints,...A]})}catch{oe=TA}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],Z),J=this._buildSurfaceVert(oe,oe.elements[ie+1],Z),Ae=this._buildSurfaceVert(oe,oe.elements[ie+2],Z);w.push(re.top,J.top,Ae.top),l===!1&&w.push(Ae.bottom,J.bottom,re.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new Xe(Uint32Array.from(w),1),b=new Xe(this._buffer.positions,3),T=new Xe(this._buffer.normals,3),C=new Xe(this._buffer.uvs,2);b.needsUpdate=!0,T.needsUpdate=!0,C.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",T),this.setAttribute("uv",C),this.setIndex(M)}_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 p=Math.cos(r.angle),m=Math.sin(r.angle),g=i*2,y=u*2,v=h*2,x=r.boundary.vertices[g+0],S=r.boundary.vertices[g+1],w=(1-m)*this._bevel,A=(x-this._minX)/this._width,M=(S-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),M=1);let b=e.normals[y+0],T=e.normals[y+1],C=e.normals[v+0],P=e.normals[v+1];if(f){let j=C-b,V=P-T;b=b+j*(1-s),T=T+V*(1-s);let H=Math.sqrt(b*b+T*T);b/=H,T/=H}let D=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=D*3,I=D*2,L={i,fi:u,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:o};return this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=b*p,this._buffer.normals[_+1]=T*p,this._buffer.normals[_+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=b*p,this._buffer.normals[_+4]=T*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[I+2]=M,this._buffer.uvs[I+3]=A),d||(this.forPathBevel?(D+=1,_+=3,I+=2):(D+=2,_+=6,I+=4),L.topP=D+0,L.bottomP=D+1,this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=C*p,this._buffer.normals[_+1]=P*p,this._buffer.normals[_+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=C*p,this._buffer.normals[_+4]=P*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[I+2]=M,this._buffer.uvs[I+3]=A)),this.vertexCache[a]=L,L}clone(){let e=new Rl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=pa(this.userData),e}};var bd=class extends _e{constructor(e,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=zt.ODD;this.elementType=jr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:zt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(u!==void 0&&y!==u&&(l=!1),h!==void 0&&v!==h&&(c=!1),u=y,h=v,!l&&!c)break}if(!l&&!c)try{a=Ws({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=om}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(d*3),3),this._normalAttribute=new Xe(new Float32Array(d*3),3),this._uvAttribute=new Xe(new Float32Array(d*2),2),this._indexAttribute=new Xe(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let S=0,w=d;S<w;S++){let A=S*2,M=a.vertices[A+0],b=a.vertices[A+1];M<p&&(p=M),M>m&&(m=M),b<g&&(g=b),b>y&&(y=b)}let v=m-p,x=y-g;for(let S=0,w=d;S<w;S++){let A=S*2,M=a.vertices[A+0],b=a.vertices[A+1],T=(M-p)/v,C=(b-g)/x;this._positionAttribute.setXYZ(S,M,b,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,T,C)}for(let S=0,w=f;S<w;S++){let A=S*3,M=a.elements[A+0],b=a.elements[A+1],T=a.elements[A+2];this._indexAttribute.setX(A+0,M),this._indexAttribute.setX(A+1,b),this._indexAttribute.setX(A+2,T)}}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 bd(this._shape,this._curveSegments);return e.userData=pa(this.userData),e}};var Sd=class extends Rl{constructor(e,r,i=0,s=12,o=3,a=zt.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 Sd(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=pa(this.userData),e}};var Rn=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:zt.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 qt?(o.width!==r||o.height!==i)&&o.applySize(r,i):o=new qt(r,i).fromJSON(o),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&o.update());let l=o??new qt(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 bd(n.shape,i,{windingRule:o}):a=new Sd(n.shape,t,e,i,r,o),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};var wO=Math.PI*2,Ad=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=we.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof qt?n.shape:new qt,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=R7(c,u,h,i*Math.PI/180,r,s);c.isClosed=!0,c.update();let f;return i===0?(f=new _e,f.setAttribute("position",new Me([],3))):f=Rn.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function R7(n,t,e,r,i,s){if(r>=wO)return i>30||i%4===0?(B7(n,t,e,s),Math.round(i/4)):SO(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=dO({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?L7(n,o.x,o.y,c,i,t,e,s):SO(n,r,i,t,e,s)}function L7(n,t,e,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(wd(t,e));for(let c=0,u=r.length;c<u;c++){let h=r[c],d=n.points[c],f=wd(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?AO(n,s,o,a):n.addPoint(wd(0,0)),l}function SO(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(wd(c,u))}return t<wO?s>0?AO(n,r,i,s):n.addPoint(wd(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&EO(n,r,i,s)),1}function B7(n,t,e,r=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;n.addPoint(S0(i-t,s,i-t,s-l,i-t,s+l)),n.addPoint(S0(i,s+e,i-a,s+e,i+a,s+e)),n.addPoint(S0(i+t,s,i+t,s+l,i+t,s-l)),n.addPoint(S0(i,s-e,i+a,s-e,i-a,s-e)),r>0&&EO(n,t,e,r)}function wd(n,t){return new Hs(we.generateUUID(),new U(n,t))}function S0(n,t,e,r,i,s){let o=wd(n,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(i,s),o}function AO(n,t,e,r){MO(n,t,e,r).forEach(s=>n.addPoint(s))}function EO(n,t,e,r){let i=MO(n,t,e,r),s=new qt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function MO(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=we.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 TO=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 am(!1,t,e,r,i,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},CA=new ho([0,0,0],1),am=class extends _e{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 p=()=>new E,m=new E,g=p(),y=p(),v=p(),x,S,w,A,M,b,T,C,P=p(),D=p(),_=p(),I=p(),L=p(),j=p(),V=p(),H=p(),W=r-2*l+.001,q=W/o,K=Math.ceil(a*o),G=K+1,Z=W/K,te=-W/2,$=u+1,Y=2*Math.PI/u,oe=Math.PI/2/d,ie=.01,re=Math.min((1-h/100)*l,l-ie),J=l-re,Ae=0,xe=2,de=d*xe+xe,Ie=$*de/xe,Ce=Ie+$*G,ke=Math.max(0,$*(G+de)),[ze,Ve,Oe]=[3,3,2].map(Ge=>Array(ke*Ge).fill(0)),Ye=[],F=s-l;function N(Ge,Be){let et=Math.PI/2;b=Be*Z,C=2*Math.PI*(b%q)/q+et,b+=te,T=Math.sin(C)*F,M=Math.cos(C)*F,t?Ge.set(M,T,b):Ge.set(M,b,T)}N(m,-1e-10),N(g,0),P.copy(m),N(m,1);let B=m.distanceTo(g),ae=f?0:J+re,ge=B*K+2*ae,me=re,Le=ge-ae;for(let Ge=0;Ge<=K;Ge++){N(y,Ge),H.subVectors(y,P).normalize(),P.copy(y),j.copy(y).setComponent(+t+1,0).normalize(),V.crossVectors(H,j).normalize();let Be=Ge===0,et=Ge===K,st=Be?3*Math.PI/2:oe,Bt=Be?me:Le,dr=Be?$:Ce,Mr=Be?0:ke-$,Q=H.clone().multiplyScalar(Be?-J:J).add(y),ye=H.clone().multiplyScalar(Be?-1:1).normalize();for(let Te=0;Te<$;Te++){let je=Te*Y;if(D.addVectors(m.copy(j).multiplyScalar(l*Math.cos(je)),g.copy(V).multiplyScalar(l*Math.sin(je))),_.copy(D).normalize(),Be||et){f||(Ae=Mr+Te,[0,1,2].forEach(He=>{ze[Ae*3+He]=Q.getComponent(He),Ve[Ae*3+He]=ye.getComponent(He)}),Oe[Ae*2]=+et,Oe[Ae*2+1]=Te/u),g.copy(_).multiplyScalar(re),v.addVectors(y,g);for(let He=0;He<d;He++){let _t=He*oe+st;I.addVectors(m.copy(H).multiplyScalar(J*Math.sin(_t)),g.copy(_).multiplyScalar(J*Math.cos(_t))),L.copy(I).normalize(),g.addVectors(v,I),I.normalize(),Ae=dr+He*$+Te,[0,1,2].forEach(Vr=>{ze[Ae*3+Vr]=g.getComponent(Vr),Ve[Ae*3+Vr]=L.getComponent(Vr)});let Fr=+Be+Math.sin(_t);Oe[Ae*2]=(Bt+J*Fr)/ge,Oe[Ae*2+1]=Te/u}}g.addVectors(y,D),Ae=Ie+Ge*$+Te,[0,1,2].forEach(He=>{ze[Ae*3+He]=g.getComponent(He),Ve[Ae*3+He]=_.getComponent(He)}),Oe[Ae*2]=(ae+Ge*B)/ge,Oe[Ae*2+1]=Te/u}}let Ne=G+2*d+xe,Re=1,[pe,nt]=[+f,Ne-1];for(let Ge=pe;Ge<=nt-1;Ge++){let Be=f&&Ge===nt-1;for(let et=0;et<$-1;et++)x=Ge*$+et,S=x+1,w=(Be?et:x)+$,A=(Be?et+1:S)+$,Ge===0?Ye.push(S,A,w):Ge===Ne-2?Ye.push(x,S,w):Ye.push(x,S,w,S,A,w)}this.setIndex(Ye),this.setAttribute("position",new Me(ze,3)),this.setAttribute("normal",new Me(Ve,3)),this.setAttribute("uv",new Me(Oe,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,CA.array=i,CA.count=i.length,CA}};var CO=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 lm(t*.5,s,o):new zu(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},lm=class extends Dl{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 lm(t.radius,t.corner,t.cornerSides)}};var PO=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 la;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 Nu(i.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var Oo=new ue,PA=new Mt,w0=new E,Ll=class extends pr{constructor(){super(),this.uuid=we.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 fr().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 Oo.makeRotationX(t),this.applyMatrix4(Oo),this}rotateY(t){return Oo.makeRotationY(t),this.applyMatrix4(Oo),this}rotateZ(t){return Oo.makeRotationZ(t),this.applyMatrix4(Oo),this}translate(t,e,r){return Oo.makeTranslation(t,e,r),this.applyMatrix4(Oo),this}scale(t,e,r){return Oo.makeScale(t,e,r),this.applyMatrix4(Oo),this}lookAt(t){return PA.lookAt(t),PA.updateMatrix(),this.applyMatrix4(PA.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 We().fromBufferAttribute(a,d));function u(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new E().fromBufferAttribute(o,d),new E().fromBufferAttribute(o,f),new E().fromBufferAttribute(o,p)],v=new Ed(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new U().fromBufferAttribute(l,d),new U().fromBufferAttribute(l,f),new U().fromBufferAttribute(l,p)]),c!==void 0&&e.faceVertexUvs[1].push([new U().fromBufferAttribute(c,d),new U().fromBufferAttribute(c,f),new U().fromBufferAttribute(c,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;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(w0).negate(),this.translate(w0.x,w0.y,w0.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 Ll;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 jt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Or),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 fr().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}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 p=c[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new Ed(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let S=0,w=y.length;S<w;S++)m=y[S].clone(),i!==void 0&&m.applyMatrix3(i).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let S=0,w=v.length;S<w;S++)g=v[S],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,S=y.length;x<S;x++)v.push(y[x].clone());this.faceVertexUvs[d].push(v)}}}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 p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let r=[],i=[],s={},o=[],a={},l=[],c={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,S=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,M=0;if(M=u(M,0,0),M=u(M,1,g),M=u(M,2,y),M=u(M,3,v),M=u(M,4,x),M=u(M,5,S),M=u(M,6,w),M=u(M,7,A),r.push(M),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let b=this.faceVertexUvs[0][p];r.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&r.push(h(m.normal)),S){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(w&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function u(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=i.length/3,i.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(p.x,p.y)),c[m]}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 Ll().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 p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,S=y.length;x<S;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}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 _A().fromGeometry(this),e=new _e,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",A0.call(new Xe(r,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",A0.call(new Xe(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",_O.call(new Xe(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",DO.call(new Xe(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",DO.call(new Xe(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 Me(c.data.length*3,3);u.name=c.name,s.push(A0.call(u,c.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new Me(t.skinIndices.length*4,4);e.setAttribute("skinIndex",IO.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Me(t.skinWeights.length*4,4);e.setAttribute("skinWeight",IO.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 _e,r=t.geometry;if(t.isPoints||t.isLine){let i=new Me(r.vertices.length*3,3),s=new Me(r.colors.length*3,3);if(e.setAttribute("position",A0.call(i,r.vertices)),e.setAttribute("color",_O.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Me(r.lineDistances.length,1);e.setAttribute("lineDistance",N7.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}};Ll.prototype.isGeometry=!0;var _A=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,p=t.skinWeights,m=f.length===r.length,g=p.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 v=e[y];this.vertices.push(r[v.a],r[v.b],r[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let w=v.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[v.a],A[v.b],A[v.c])}for(let w=0;w<h;w++){let A=u[w].vertexNormals[y];d[w].data.push(A.a,A.b,A.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.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}},Ed=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 We,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 N7(n){return this.array.set(n),this}function _O(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 We),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function DO(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 A0(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 IO(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 F7=["a","b","c"];function V7(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function DA(n,t,e){let r=Math.min(n,t),i=Math.max(n,t),s=r+"_"+i;return e.get(s)}function IA(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 U7(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],IA(o.a,o.b,n,r,o,e),IA(o.b,o.c,n,r,o,e),IA(o.c,o.a,n,r,o,e)}function E0(n,t,e,r,i){n.push(new Ed(t,e,r,void 0,void 0,i))}function Md(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function M0(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var T0=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof _e?t=new Ll().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;U7(l,c,d,f);let p=[],m,g,y,v,x,S,w;for(let ie of Array.from(f.keys())){for(g=f.get(ie),y=new E,x=3/8,S=1/8,w=g.faces.length,w!=2&&(x=.5,S=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=g.faces[o],a=0;a<3&&(m=l[V7(v,F7[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(S),y.add(e),g.newEdge=p.length,p.push(y)}let A,M,b,T,C,P,D,_=[];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)),M=1-r*Number(A),b=A,r<=2&&(r==2?(M=3/4,b=1/8):r==1||r==0),D=P.clone().multiplyScalar(M),e.set(0,0,0),o=0;o<r;o++)T=C[o],m=T.a!==P?T.a:T.b,e.add(m);e.multiplyScalar(Number(b)),D.add(e),_.push(D)}let I=_.concat(p),L=_.length,j,V,H,W=[],q=[],K,G,Z,te,$=new U,Y=new U,oe=new U;for(i=0,s=c.length;i<s;i++)v=c[i],j=Number(DA(v.a,v.b,f).newEdge)+L,V=Number(DA(v.b,v.c,f).newEdge)+L,H=Number(DA(v.c,v.a,f).newEdge)+L,E0(W,j,V,H,v.materialIndex),E0(W,v.a,j,H,v.materialIndex),E0(W,v.b,V,j,v.materialIndex),E0(W,v.c,H,V,v.materialIndex),h&&(K=u[i],G=K[0],Z=K[1],te=K[2],$.set(Md(G.x,Z.x),Md(G.y,Z.y)),Y.set(Md(Z.x,te.x),Md(Z.y,te.y)),oe.set(Md(G.x,te.x),Md(G.y,te.y)),M0(q,$,Y,oe),M0(q,G,$,oe),M0(q,Z,Y,$),M0(q,te,oe,Y));t.vertices=I,t.faces=W,h&&(t.faceVertexUvs[0]=q)}};var Pi=new E,OO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new _e().copy(new mi(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Pi),r={width:Pi.x,height:Pi.y,depth:Pi.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 _e().copy(new mi(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Pi)):Pi.set(o.width,o.height,o.depth),(t!==Pi.x||e!==Pi.y||r!==Pi.z)&&s.scale(Pi.x===0?1:t/Pi.x,Pi.y===0?1:e/Pi.y,Pi.z===0?1:r/Pi.z);let a=s.originalGeometry;try{i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new T0(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 Xu(e).load(n,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Pi);let o=100/Pi.x;Object.assign(s.parameters,{width:100,height:Pi.y*o,depth:Pi.z*o}),t(this.build(s))})}};var C0=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 qt?n.shape:new qt,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 m=0;m<r;m++){let g=f*m,y=h+Math.sin(g)*c,v=d+Math.cos(g)*u;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=i;l.roundness=i,l.update();let p=Rn.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...n,type:"PolygonGeometry"}})}};var RO=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 RA(t*.5,e,i,s,o,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function cm(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function OA(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 z7(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var RA=class extends _e{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,p=Math.PI/r,m=t*Math.cos(Math.PI/r),g=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,x=new E(0,-f,0),S=new E(0,f,0),w=new U(t,-f),A=new U(m,-f),M=new U(0,S.y).sub(A),b=new U(0,S.y).sub(w),T=new U(M.y,-M.x).normalize(),C=new U(b.y,-b.x).normalize(),D=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,D);let _;{let q=new E(T.x,T.y,0),K=new E(Math.cos(g)*q.x,q.y,Math.sin(g)*q.x);_=q.angleTo(K)}let I=o/Math.tan((Math.PI-M.angle())/2),L=o/Math.tan((Math.PI-_)/2),j=new E;if(!s){c.push(x.x,x.y,x.z),u.push(0,-1,0),h.push(0,0);let q=d++,K=[],G=w.clone(),Z=I/Math.cos(Math.PI/r);G.x-=Z;for(let te=0;te<r;te++){let $=te/r*Math.PI*2+p,Y=new U(Math.sin($),Math.cos($));cm(G,Y,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],q,K[(te+1)%K.length])}let V=[];{let q=new E,K=new E,G=new E,Z=new E,te=new E,$=new E;for(let Y=0;Y<r;Y++){let oe=Y/r*Math.PI*2+p,ie=(Y+.5)/r*Math.PI*2+p,re=(Y+1)/r*Math.PI*2+p,J=new U(Math.sin(oe),Math.cos(oe)),Ae=new U(Math.sin(ie),Math.cos(ie)),xe=new U(Math.sin(re),Math.cos(re));cm(w,J,K),cm(w,xe,G),cm(T,Ae,q),OA(S,K,G,L,L,Z),c.push(Z.x,Z.y,Z.z),OA(K,S,G,L,I,te),c.push(te.x,te.y,te.z),OA(G,K,S,I,L,$),c.push($.x,$.y,$.z),u.push(q.x,q.y,q.z),u.push(q.x,q.y,q.z),u.push(q.x,q.y,q.z),h.push(0,0),h.push(0,0),h.push(0,0);let de=d++,Ie=d++,Ce=d++;if(l.push(de,Ie,Ce),o>0){{let Ve=K.clone().add(G).multiplyScalar(.5),Oe=S.clone().sub(Ve).normalize(),F=x.clone().sub(Ve).normalize().add(Oe).normalize().multiplyScalar(-1),N=$.clone().sub(te);H(Ve,N,F,M.angle())}let ke,ze;{let Ve=new E;cm(C,xe,Ve);let Oe=$.clone().add(Z).multiplyScalar(.5);Oe=z7(Oe,G,S);let Ye=$.clone().sub(Z);[ke,ze]=H(Oe,Ye,Ve,_,Z.y)}{let Ve=ke,Oe=Ve.clone().setY(0).normalize(),Ye=new E(0,-1,0),F=Oe.clone().cross(Ye);W(Ve,Oe,Ye,F)}V.concat(ze);{let Ve=M.angle(),Oe=Math.PI-Ve,Ye=S.clone();Ye.y-=o/Math.sin(Ve-Math.PI/2);let F=new E,N=[];for(let ae=0;ae<a;ae++){let ge=[],me=Math.PI/2-Oe*ae/a,Le=Math.cos(me),Ne=Math.sin(me),Re=ie;for(let pe=0;pe<=ae;pe++){let nt=Math.cos(Re),Ge=Math.sin(Re);q.x=Le*Ge,q.y=Ne,q.z=Le*nt,F.copy(Ye).addScaledVector(q,o),c.push(F.x,F.y,F.z),u.push(q.x,q.y,q.z),h.push(0,0),ge.push(d++),Re+=Math.PI*2/ae/r}N.push(ge)}ze.reverse(),N.push(ze);let B=N.length-1;for(let ae=0;ae<B;ae++){let ge=N[ae],me=N[ae+1],Le=ge.length-1;l.push(me[1],ge[0],me[0]);for(let Ne=1;Ne<=Le;Ne++)l.push(ge[Ne],ge[Ne-1],me[Ne]),l.push(me[Ne+1],ge[Ne],me[Ne])}}}}}this.setIndex(l),this.setAttribute("position",new Me(c,3)),this.setAttribute("normal",new Me(u,3)),this.setAttribute("uv",new Me(h,2));function H(q,K,G,Z,te){let $=-Z/2,Y=(Math.PI-Z)/2,oe=K.clone().normalize().cross(G);q.addScaledVector(G,-o/Math.sin(Y));let ie=new E,re=new E,J=1,Ae=d,xe=[];for(let de=0;de<=a;de++){let Ie=$+de/a*Z;re.set(0,0,0),re.addScaledVector(oe,Math.sin(Ie)),re.addScaledVector(G,Math.cos(Ie));for(let Ce=0;Ce<=J;Ce++){let ke=Ce/J-.5;if(ie.copy(q),ie.addScaledVector(K,ke),ie.addScaledVector(re,o),te!=null){let ze=Math.max(0,ie.y-te);ie.addScaledVector(K,-ze/K.y)}c.push(ie.x,ie.y,ie.z),u.push(re.x,re.y,re.z),h.push(0,0),Ce===0&&xe.push(d),d++}}for(let de=0;de<a;de++)for(let Ie=0;Ie<J;Ie++){let Ce=Ae+Ie+(J+1)*de,ke=Ce+(J+1),ze=ke+1,Ve=Ce+1;l.push(Ce,ke,Ve),l.push(ke,ze,Ve)}return[q.clone().addScaledVector(K,.5),xe]}function W(q,K,G,Z){let te=Math.PI/2,$=b.angle()-te,Y=[],oe=new E,ie=new E;for(let J=0;J<=a;J++){let Ae=[],xe=J/a;for(let de=0;de<=J;de++){let Ce=((J?de/J:0)-.5)*v,ke=Math.cos(Ce),ze=Math.sin(Ce),Ve=Math.atan(Math.tan($)*ke),Oe=(te+Ve)*xe,Ye=Math.cos(Oe),F=Math.sin(Oe);oe.set(0,0,0),oe.addScaledVector(K,F*ke),oe.addScaledVector(G,Ye),oe.addScaledVector(Z,F*ze),ie.copy(q).addScaledVector(oe,o),c.push(ie.x,ie.y,ie.z),u.push(oe.x,oe.y,oe.z),h.push(0,0),Ae.push(d++)}Y.push(Ae)}let re=Y.length-1;for(let J=0;J<re;J++){let Ae=Y[J],xe=Y[J+1],de=Ae.length-1;l.push(Ae[0],xe[1],xe[0]);for(let Ie=1;Ie<=de;Ie++)l.push(Ae[Ie-1],Ae[Ie],xe[Ie]),l.push(Ae[Ie],xe[Ie+1],xe[Ie])}}}};var Td=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 qt?n.shape:new qt,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(S,w,A){return w>e&&A>r?Math.min(S*e/w,S*r/A):w>e?S*e/w:A>r?S*r/A:S}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 p=u.x,m=h.x,g=h.y,y=u.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let S=0,w=t.points.length;S<w;S++)t.points[S].roundness=f[S],S>0&&f[S]!==f[S-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Rn.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...n,type:"RectangleGeometry"}})}};var LO=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=we.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 _e,u.setAttribute("position",new Me([],3))):u=new Ls(.5*t,i,s,o,a,l,c*we.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var BO=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 Li(t,e,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var NO=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 LA(t,e,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},LA=class extends _e{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),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,S=+y,[w,A,M]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(ie,re=!1)=>Math.sin(ie-Math.PI/(1+ +re)),T=(ie,re=!1)=>Math.cos(ie-Math.PI/(1+ +re));M.y=Math.sin(i)*e-g;let C=Math.cos(i)*e-v,P=w.z-u;i<=d?(M.z=Math.min(C,P),M.z==P&&(M.y-=(C-P)/Math.tan(d-i))):A.z=Math.min(A.z-C-v,w.z-u),p.subVectors(w,A),m.subVectors(M,A);let D=Math.min(p.length(),m.length())*s/100,_=D*Math.tan(i/2),I=D/Math.cos(i/2),L=p.clone().normalize().add(m.normalize()).setLength(I).add(A);p.set(0,b(i,!0),T(i,!0)),h.push([M,p.clone()]);let j=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let re=d+i+ie*j;p.set(0,Math.sin(re)*_,Math.cos(re)*_),p.add(L),m.set(0,b(re),T(re)),h.push([p.clone(),m.clone()])}h.push([w,f(0,1,0)]);let V=Math.sin(j/2)*_*2,H=h.length-1,W=h[0][0].distanceTo(h[1][0]),q=h[H-1][0].distanceTo(h[H][0]),K=W+V*o+q;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(W+ie*V)/K);h[H].push(0);let[G,Z,te]=h[0],$,Y,oe;for(let ie=1;ie<h.length;ie++)[$,Y,oe]=h[ie],a.push(x,G.y,G.z,x,$.y,$.z,S,G.y,G.z,S,G.y,G.z,x,$.y,$.z,S,$.y,$.z),l.push(0,Z.y,Z.z,0,Y.y,Y.z,0,Z.y,Z.z,0,Z.y,Z.z,0,Y.y,Y.z,0,Y.y,Y.z),c.push(0,te,0,oe,1,te,1,te,0,oe,1,oe),[G,Z,te]=[$,Y,oe];this.setAttribute("position",new Me(a,3)),this.setAttribute("normal",new Me(l,3)),this.setAttribute("uv",new Me(c,2))}};var P0=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 qt?n.shape:new qt,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,p=0,m=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=h*r/100,v=d*r/100;if(i===3&&r===50){m=2*Math.PI/i;for(let S=0;S<i;S++){let w=m*S,A=f+Math.sin(w)*h,M=p+Math.cos(w)*d;u.addPoint(u.createPoint(A,M))}}else for(let S=0;S<i;S++){let w=f+Math.cos(g)*h,A=p+Math.sin(g)*d;u.addPoint(u.createPoint(w,A)),g+=m,w=f+Math.cos(g)*y,A=p+Math.sin(g)*v,S<=i,u.addPoint(u.createPoint(w,A)),g+=m}u.isClosed=!0;for(let S=0,w=u.points.length;S<w;S++)u.points[S].roundness=s;u.roundness=s,u.update();let x=Rn.create({shape:u,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(x,{userData:{...n,type:"StarGeometry"}})}};var FO=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 Li(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var VO=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),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=k7(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 k7(n,t,e,r,i,s,o,a,l,c,u){[t,e]=[e,t],o=t/2;let h=we.clamp(i/360,0,1);if(h===0){let d=new _e;return d.setAttribute("position",new Me([],3)),d}return h===1&&(c=0),new am(!0,n,t,e,r,h,s,o,a,l,c,u)}var UO=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 Gu(a,e,r,i,s,o);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var zO=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 qt?n.shape:new qt,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=Rn.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...n,type:"TriangleGeometry"}})}};function kO(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var BA=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)})}},NA=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+=`
3139
+ }`;function YG(n,t,e){let r=new up,i=new U,s=new U,o=new Ze,a=new hp({depthPacking:Tw}),l=new tw,c={},u=e.maxTextureSize,h={[Hn]:pi,[pi]:Hn,[fi]:fi},d=new it({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new U},radius:{value:4}},vertexShader:WG,fragmentShader:qG}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new _e;p.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Ut(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ay,this.render=function(S,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;let M=n.getRenderTarget(),b=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),C=n.state;C.setBlending(Jt),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let P=0,D=S.length;P<D;P++){let _=S[P],I=_.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",_,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;i.copy(I.mapSize);let L=I.getFrameExtents();if(i.multiply(L),s.copy(I.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/L.x),i.x=s.x*L.x,I.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/L.y),i.y=s.y*L.y,I.mapSize.y=s.y)),I.map===null){let V=this.type!==$f?{minFilter:Vt,magFilter:Vt}:{};I.map=new dt(i.x,i.y,V),I.map.texture.name=_.name+".shadowMap",I.camera.updateProjectionMatrix()}n.setRenderTarget(I.map),n.clear();let j=I.getViewportCount();for(let V=0;V<j;V++){let H=I.getViewport(V);o.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),C.viewport(o),I.updateMatrices(_,V),r=I.getFrustum(),x(w,A,I.camera,_,this.type)}I.isPointLightShadow!==!0&&this.type===$f&&y(I,A),I.needsUpdate=!1}g.needsUpdate=!1,n.setRenderTarget(M,b,T)};function y(S,w){let A=t.update(m);d.defines.VSM_SAMPLES!==S.blurSamples&&(d.defines.VSM_SAMPLES=S.blurSamples,f.defines.VSM_SAMPLES=S.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new dt(i.x,i.y)),d.uniforms.shadow_pass.value=S.map.texture,d.uniforms.resolution.value=S.mapSize,d.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(w,null,A,d,m,null),f.uniforms.shadow_pass.value=S.mapPass.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(w,null,A,f,m,null)}function v(S,w,A,M,b,T){let C=null,P=A.isPointLight===!0?S.customDistanceMaterial:S.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 D=C.uuid,_=w.uuid,I=c[D];I===void 0&&(I={},c[D]=I);let L=I[_];L===void 0&&(L=C.clone(),I[_]=L),C=L}return C.visible=w.visible,C.wireframe=w.wireframe,T===$f?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=M,C.farDistance=b),C}function x(S,w,A,M,b){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&b===$f)&&(!S.frustumCulled||r.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,S.matrixWorld);let P=t.update(S),D=S.material;if(Array.isArray(D)){let _=P.groups;for(let I=0,L=_.length;I<L;I++){let j=_[I],V=D[j.materialIndex];if(V&&V.visible){let H=v(S,V,M,A.near,A.far,b);n.renderBufferDirect(A,null,P,H,S,j)}}}else if(D.visible){let _=v(S,D,M,A.near,A.far,b);n.renderBufferDirect(A,null,P,_,S,null)}}let C=S.children;for(let P=0,D=C.length;P<D;P++)x(C[P],w,A,M,b)}}function XG(n,t,e){let r=e.isWebGL2;function i(){let Q=!1,ye=new Ze,Te=null,je=new Ze(0,0,0,0);return{setMask:function(He){Te!==He&&!Q&&(n.colorMask(He,He,He,He),Te=He)},setLocked:function(He){Q=He},setClear:function(He,_t,Fr,Vr,Zo){Zo===!0&&(He*=Vr,_t*=Vr,Fr*=Vr),ye.set(He,_t,Fr,Vr),je.equals(ye)===!1&&(n.clearColor(He,_t,Fr,Vr),je.copy(ye))},reset:function(){Q=!1,Te=null,je.set(-1,0,0,0)}}}function s(){let Q=!1,ye=null,Te=null,je=null;return{setTest:function(He){He?oe(2929):ie(2929)},setMask:function(He){ye!==He&&!Q&&(n.depthMask(He),ye=He)},setFunc:function(He){if(Te!==He){switch(He){case MF:n.depthFunc(512);break;case TF:n.depthFunc(519);break;case CF:n.depthFunc(513);break;case zS:n.depthFunc(515);break;case PF:n.depthFunc(514);break;case _F:n.depthFunc(518);break;case DF:n.depthFunc(516);break;case IF:n.depthFunc(517);break;default:n.depthFunc(515)}Te=He}},setLocked:function(He){Q=He},setClear:function(He){je!==He&&(n.clearDepth(He),je=He)},reset:function(){Q=!1,ye=null,Te=null,je=null}}}function o(){let Q=!1,ye=null,Te=null,je=null,He=null,_t=null,Fr=null,Vr=null,Zo=null;return{setTest:function(Tr){Q||(Tr?oe(2960):ie(2960))},setMask:function(Tr){ye!==Tr&&!Q&&(n.stencilMask(Tr),ye=Tr)},setFunc:function(Tr,es,Tn){(Te!==Tr||je!==es||He!==Tn)&&(n.stencilFunc(Tr,es,Tn),Te=Tr,je=es,He=Tn)},setOp:function(Tr,es,Tn){(_t!==Tr||Fr!==es||Vr!==Tn)&&(n.stencilOp(Tr,es,Tn),_t=Tr,Fr=es,Vr=Tn)},setLocked:function(Tr){Q=Tr},setClear:function(Tr){Zo!==Tr&&(n.clearStencil(Tr),Zo=Tr)},reset:function(){Q=!1,ye=null,Te=null,je=null,He=null,_t=null,Fr=null,Vr=null,Zo=null}}}let a=new i,l=new s,c=new o,u=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,S=null,w=null,A=null,M=null,b=null,T=!1,C=null,P=null,D=null,_=null,I=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 W=null,q={},K=n.getParameter(3088),G=n.getParameter(2978),Z=new Ze().fromArray(K),te=new Ze().fromArray(G);function $(Q,ye,Te){let je=new Uint8Array(4),He=n.createTexture();n.bindTexture(Q,He),n.texParameteri(Q,10241,9728),n.texParameteri(Q,10240,9728);for(let _t=0;_t<Te;_t++)n.texImage2D(ye+_t,0,6408,1,1,0,6408,5121,je);return He}let Y={};Y[3553]=$(3553,3553,1),Y[34067]=$(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),oe(2929),l.setFunc(zS),ke(!1),ze(dT),oe(2884),Ie(Jt);function oe(Q){d[Q]!==!0&&(n.enable(Q),d[Q]=!0)}function ie(Q){d[Q]!==!1&&(n.disable(Q),d[Q]=!1)}function re(Q,ye){return f[Q]!==ye?(n.bindFramebuffer(Q,ye),f[Q]=ye,r&&(Q===36009&&(f[36160]=ye),Q===36160&&(f[36009]=ye)),!0):!1}function J(Q,ye){let Te=m,je=!1;if(Q)if(Te=p.get(ye),Te===void 0&&(Te=[],p.set(ye,Te)),Q.isWebGLMultipleRenderTargets){let He=Q.texture;if(Te.length!==He.length||Te[0]!==36064){for(let _t=0,Fr=He.length;_t<Fr;_t++)Te[_t]=36064+_t;Te.length=He.length,je=!0}}else Te[0]!==36064&&(Te[0]=36064,je=!0);else Te[0]!==1029&&(Te[0]=1029,je=!0);je&&(e.isWebGL2?n.drawBuffers(Te):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Te))}function Ae(Q){return g!==Q?(n.useProgram(Q),g=Q,!0):!1}let xe={[Tu]:32774,[pF]:32778,[mF]:32779};if(r)xe[gT]=32775,xe[yT]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(xe[gT]=Q.MIN_EXT,xe[yT]=Q.MAX_EXT)}let de={[gF]:0,[yF]:1,[vF]:768,[HC]:770,[EF]:776,[wF]:774,[bF]:772,[xF]:769,[WC]:771,[AF]:775,[SF]:773};function Ie(Q,ye,Te,je,He,_t,Fr,Vr){if(Q===Jt){y===!0&&(ie(3042),y=!1);return}if(y===!1&&(oe(3042),y=!0),Q!==fF){if(Q!==v||Vr!==T){if((x!==Tu||A!==Tu)&&(n.blendEquation(32774),x=Tu,A=Tu),Vr)switch(Q){case Xa:n.blendFuncSeparate(1,771,1,771);break;case fT:n.blendFunc(1,1);break;case pT:n.blendFuncSeparate(0,769,0,1);break;case mT:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case Xa:n.blendFuncSeparate(770,771,1,771);break;case fT:n.blendFunc(770,1);break;case pT:n.blendFuncSeparate(0,769,0,1);break;case mT:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}S=null,w=null,M=null,b=null,v=Q,T=Vr}return}He=He||ye,_t=_t||Te,Fr=Fr||je,(ye!==x||He!==A)&&(n.blendEquationSeparate(xe[ye],xe[He]),x=ye,A=He),(Te!==S||je!==w||_t!==M||Fr!==b)&&(n.blendFuncSeparate(de[Te],de[je],de[_t],de[Fr]),S=Te,w=je,M=_t,b=Fr),v=Q,T=!1}function Ce(Q,ye){Q.side===fi?ie(2884):oe(2884);let Te=Q.side===pi;ye&&(Te=!Te),ke(Te),Q.blending===Xa&&Q.transparent===!1?Ie(Jt):Ie(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let je=Q.stencilWrite;c.setTest(je),je&&(c.setMask(Q.stencilWriteMask),c.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),c.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),Oe(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?oe(32926):ie(32926)}function ke(Q){C!==Q&&(Q?n.frontFace(2304):n.frontFace(2305),C=Q)}function ze(Q){Q!==uF?(oe(2884),Q!==P&&(Q===dT?n.cullFace(1029):Q===hF?n.cullFace(1028):n.cullFace(1032))):ie(2884),P=Q}function Ve(Q){Q!==D&&(j&&n.lineWidth(Q),D=Q)}function Oe(Q,ye,Te){Q?(oe(32823),(_!==ye||I!==Te)&&(n.polygonOffset(ye,Te),_=ye,I=Te)):ie(32823)}function Ye(Q){Q?oe(3089):ie(3089)}function F(Q){Q===void 0&&(Q=33984+L-1),W!==Q&&(n.activeTexture(Q),W=Q)}function N(Q,ye,Te){Te===void 0&&(W===null?Te=33984+L-1:Te=W);let je=q[Te];je===void 0&&(je={type:void 0,texture:void 0},q[Te]=je),(je.type!==Q||je.texture!==ye)&&(W!==Te&&(n.activeTexture(Te),W=Te),n.bindTexture(Q,ye||Y[Q]),je.type=Q,je.texture=ye)}function B(){let Q=q[W];Q!==void 0&&Q.type!==void 0&&(n.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ge(){try{n.compressedTexImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function me(){try{n.texSubImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Le(){try{n.texSubImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ne(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Re(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function nt(){try{n.texStorage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ge(){try{n.texImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Be(){try{n.texImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function et(Q){Z.equals(Q)===!1&&(n.scissor(Q.x,Q.y,Q.z,Q.w),Z.copy(Q))}function st(Q){te.equals(Q)===!1&&(n.viewport(Q.x,Q.y,Q.z,Q.w),te.copy(Q))}function Bt(Q,ye){let Te=h.get(ye);Te===void 0&&(Te=new WeakMap,h.set(ye,Te));let je=Te.get(Q);je===void 0&&(je=n.getUniformBlockIndex(ye,Q.name),Te.set(Q,je))}function dr(Q,ye){let je=h.get(ye).get(Q);u.get(ye)!==je&&(n.uniformBlockBinding(ye,je,Q.__bindingPointIndex),u.set(ye,je))}function Mr(){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={},W=null,q={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,S=null,w=null,A=null,M=null,b=null,T=!1,C=null,P=null,D=null,_=null,I=null,Z.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:Ae,setBlending:Ie,setMaterial:Ce,setFlipSided:ke,setCullFace:ze,setLineWidth:Ve,setPolygonOffset:Oe,setScissorTest:Ye,activeTexture:F,bindTexture:N,unbindTexture:B,compressedTexImage2D:ae,compressedTexImage3D:ge,texImage2D:Ge,texImage3D:Be,updateUBOMapping:Bt,uniformBlockBinding:dr,texStorage2D:pe,texStorage3D:nt,texSubImage2D:me,texSubImage3D:Le,compressedTexSubImage2D:Ne,compressedTexSubImage3D:Re,scissor:et,viewport:st,reset:Mr}}function QG(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),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(N,B){return y?new OffscreenCanvas(N,B):lp("canvas")}function x(N,B,ae,ge){let me=1;if((N.width>ge||N.height>ge)&&(me=ge/Math.max(N.width,N.height)),me<1||B===!0)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap){let Le=B?Zg:Math.floor,Ne=Le(me*N.width),Re=Le(me*N.height);m===void 0&&(m=v(Ne,Re));let pe=ae?v(Ne,Re):m;return pe.width=Ne,pe.height=Re,pe.getContext("2d").drawImage(N,0,0,Ne,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+Ne+"x"+Re+")."),pe}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),N;return N}function S(N){return qS(N.width)&&qS(N.height)}function w(N){return a?!1:N.wrapS!==Xt||N.wrapT!==Xt||N.minFilter!==Vt&&N.minFilter!==rt}function A(N,B){return N.generateMipmaps&&B&&N.minFilter!==Vt&&N.minFilter!==rt}function M(N){n.generateMipmap(N)}function b(N,B,ae,ge,me=!1){if(a===!1)return B;if(N!==null){if(n[N]!==void 0)return n[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let Le=B;return B===6403&&(ae===5126&&(Le=33326),ae===5131&&(Le=33325),ae===5121&&(Le=33321)),B===33319&&(ae===5126&&(Le=33328),ae===5131&&(Le=33327),ae===5121&&(Le=33323)),B===6408&&(ae===5126&&(Le=34836),ae===5131&&(Le=34842),ae===5121&&(Le=ge===at&&me===!1?35907:32856),ae===32819&&(Le=32854),ae===32820&&(Le=32855)),(Le===33325||Le===33326||Le===33327||Le===33328||Le===34842||Le===34836)&&t.get("EXT_color_buffer_float"),Le}function T(N,B,ae){return A(N,ae)===!0||N.isFramebufferTexture&&N.minFilter!==Vt&&N.minFilter!==rt?Math.log2(Math.max(B.width,B.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?B.mipmaps.length:1}function C(N){return N===Vt||N===vT||N===iS?9728:9729}function P(N){let B=N.target;B.removeEventListener("dispose",P),_(B),B.isVideoTexture&&p.delete(B)}function D(N){let B=N.target;B.removeEventListener("dispose",D),L(B)}function _(N){let B=r.get(N);if(B.__webglInit===void 0)return;let ae=N.source,ge=g.get(ae);if(ge){let me=ge[B.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(N),Object.keys(ge).length===0&&g.delete(ae)}r.remove(N)}function I(N){let B=r.get(N);n.deleteTexture(B.__webglTexture);let ae=N.source,ge=g.get(ae);delete ge[B.__cacheKey],o.memory.textures--}function L(N){let B=N.texture,ae=r.get(N),ge=r.get(B);if(ge.__webglTexture!==void 0&&(n.deleteTexture(ge.__webglTexture),o.memory.textures--),N.depthTexture&&N.depthTexture.dispose(),N.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(N.isWebGLMultipleRenderTargets)for(let me=0,Le=B.length;me<Le;me++){let Ne=r.get(B[me]);Ne.__webglTexture&&(n.deleteTexture(Ne.__webglTexture),o.memory.textures--),r.remove(B[me])}r.remove(B),r.remove(N)}let j=0;function V(){j=0}function H(){let N=j;return N>=l&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+l),j+=1,N}function W(N){let B=[];return B.push(N.wrapS),B.push(N.wrapT),B.push(N.wrapR||0),B.push(N.magFilter),B.push(N.minFilter),B.push(N.anisotropy),B.push(N.internalFormat),B.push(N.format),B.push(N.type),B.push(N.generateMipmaps),B.push(N.premultiplyAlpha),B.push(N.flipY),B.push(N.unpackAlignment),B.push(N.encoding),B.join()}function q(N,B){let ae=r.get(N);if(N.isVideoTexture&&Ye(N),N.isRenderTargetTexture===!1&&N.version>0&&ae.__version!==N.version){let ge=N.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ae,N,B);return}}e.bindTexture(3553,ae.__webglTexture,33984+B)}function K(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(35866,ae.__webglTexture,33984+B)}function G(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(32879,ae.__webglTexture,33984+B)}function Z(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){re(ae,N,B);return}e.bindTexture(34067,ae.__webglTexture,33984+B)}let te={[Os]:10497,[Xt]:33071,[jS]:33648},$={[Vt]:9728,[vT]:9984,[iS]:9986,[rt]:9729,[UF]:9985,[fc]:9987};function Y(N,B,ae){if(ae?(n.texParameteri(N,10242,te[B.wrapS]),n.texParameteri(N,10243,te[B.wrapT]),(N===32879||N===35866)&&n.texParameteri(N,32882,te[B.wrapR]),n.texParameteri(N,10240,$[B.magFilter]),n.texParameteri(N,10241,$[B.minFilter])):(n.texParameteri(N,10242,33071),n.texParameteri(N,10243,33071),(N===32879||N===35866)&&n.texParameteri(N,32882,33071),(B.wrapS!==Xt||B.wrapT!==Xt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(N,10240,C(B.magFilter)),n.texParameteri(N,10241,C(B.minFilter)),B.minFilter!==Vt&&B.minFilter!==rt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let ge=t.get("EXT_texture_filter_anisotropic");if(B.magFilter===Vt||B.minFilter!==iS&&B.minFilter!==fc||B.type===br&&t.has("OES_texture_float_linear")===!1||a===!1&&B.type===Wn&&t.has("OES_texture_half_float_linear")===!1)return;(B.anisotropy>1||r.get(B).__currentAnisotropy)&&(n.texParameterf(N,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(B.anisotropy,i.getMaxAnisotropy())),r.get(B).__currentAnisotropy=B.anisotropy)}}function oe(N,B){let ae=!1;N.__webglInit===void 0&&(N.__webglInit=!0,B.addEventListener("dispose",P));let ge=B.source,me=g.get(ge);me===void 0&&(me={},g.set(ge,me));let Le=W(B);if(Le!==N.__cacheKey){me[Le]===void 0&&(me[Le]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,ae=!0),me[Le].usedTimes++;let Ne=me[N.__cacheKey];Ne!==void 0&&(me[N.__cacheKey].usedTimes--,Ne.usedTimes===0&&I(B)),N.__cacheKey=Le,N.__webglTexture=me[Le].texture}return ae}function ie(N,B,ae){let ge=3553;(B.isDataArrayTexture||B.isCompressedArrayTexture)&&(ge=35866),B.isData3DTexture&&(ge=32879);let me=oe(N,B),Le=B.source;e.bindTexture(ge,N.__webglTexture,33984+ae);let Ne=r.get(Le);if(Le.version!==Ne.__version||me===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,B.flipY),n.pixelStorei(37441,B.premultiplyAlpha),n.pixelStorei(3317,B.unpackAlignment),n.pixelStorei(37443,0);let Re=w(B)&&S(B.image)===!1,pe=x(B.image,Re,!1,u);pe=F(B,pe);let nt=S(pe)||a,Ge=s.convert(B.format,B.encoding),Be=s.convert(B.type),et=b(B.internalFormat,Ge,Be,B.encoding,B.isVideoTexture);Y(ge,B,nt);let st,Bt=B.mipmaps,dr=a&&B.isVideoTexture!==!0,Mr=Ne.__version===void 0||me===!0,Q=T(B,pe,nt);if(B.isDepthTexture)et=6402,a?B.type===br?et=36012:B.type===Ds?et=33190:B.type===Qa?et=35056:et=33189:B.type===br&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),B.format===hc&&et===6402&&B.type!==XC&&B.type!==Ds&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),B.type=Ds,Be=s.convert(B.type)),B.format===Ja&&et===6402&&(et=34041,B.type!==Qa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),B.type=Qa,Be=s.convert(B.type))),Mr&&(dr?e.texStorage2D(3553,1,et,pe.width,pe.height):e.texImage2D(3553,0,et,pe.width,pe.height,0,Ge,Be,null));else if(B.isDataTexture)if(Bt.length>0&&nt){dr&&Mr&&e.texStorage2D(3553,Q,et,Bt[0].width,Bt[0].height);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],dr?e.texSubImage2D(3553,ye,0,0,st.width,st.height,Ge,Be,st.data):e.texImage2D(3553,ye,et,st.width,st.height,0,Ge,Be,st.data);B.generateMipmaps=!1}else dr?(Mr&&e.texStorage2D(3553,Q,et,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,pe.width,pe.height,Ge,Be,pe.data)):e.texImage2D(3553,0,et,pe.width,pe.height,0,Ge,Be,pe.data);else if(B.isCompressedTexture)if(B.isCompressedArrayTexture){dr&&Mr&&e.texStorage3D(35866,Q,et,Bt[0].width,Bt[0].height,pe.depth);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],B.format!==qr?Ge!==null?dr?e.compressedTexSubImage3D(35866,ye,0,0,0,st.width,st.height,pe.depth,Ge,st.data,0,0):e.compressedTexImage3D(35866,ye,et,st.width,st.height,pe.depth,0,st.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):dr?e.texSubImage3D(35866,ye,0,0,0,st.width,st.height,pe.depth,Ge,Be,st.data):e.texImage3D(35866,ye,et,st.width,st.height,pe.depth,0,Ge,Be,st.data)}else{dr&&Mr&&e.texStorage2D(3553,Q,et,Bt[0].width,Bt[0].height);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],B.format!==qr?Ge!==null?dr?e.compressedTexSubImage2D(3553,ye,0,0,st.width,st.height,Ge,st.data):e.compressedTexImage2D(3553,ye,et,st.width,st.height,0,st.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):dr?e.texSubImage2D(3553,ye,0,0,st.width,st.height,Ge,Be,st.data):e.texImage2D(3553,ye,et,st.width,st.height,0,Ge,Be,st.data)}else if(B.isDataArrayTexture)dr?(Mr&&e.texStorage3D(35866,Q,et,pe.width,pe.height,pe.depth),e.texSubImage3D(35866,0,0,0,0,pe.width,pe.height,pe.depth,Ge,Be,pe.data)):e.texImage3D(35866,0,et,pe.width,pe.height,pe.depth,0,Ge,Be,pe.data);else if(B.isData3DTexture)dr?(Mr&&e.texStorage3D(32879,Q,et,pe.width,pe.height,pe.depth),e.texSubImage3D(32879,0,0,0,0,pe.width,pe.height,pe.depth,Ge,Be,pe.data)):e.texImage3D(32879,0,et,pe.width,pe.height,pe.depth,0,Ge,Be,pe.data);else if(B.isFramebufferTexture){if(Mr)if(dr)e.texStorage2D(3553,Q,et,pe.width,pe.height);else{let ye=pe.width,Te=pe.height;for(let je=0;je<Q;je++)e.texImage2D(3553,je,et,ye,Te,0,Ge,Be,null),ye>>=1,Te>>=1}}else if(Bt.length>0&&nt){dr&&Mr&&e.texStorage2D(3553,Q,et,Bt[0].width,Bt[0].height);for(let ye=0,Te=Bt.length;ye<Te;ye++)st=Bt[ye],dr?e.texSubImage2D(3553,ye,0,0,Ge,Be,st):e.texImage2D(3553,ye,et,Ge,Be,st);B.generateMipmaps=!1}else dr?(Mr&&e.texStorage2D(3553,Q,et,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,Ge,Be,pe)):e.texImage2D(3553,0,et,Ge,Be,pe);A(B,nt)&&M(ge),Ne.__version=Le.version,B.onUpdate&&B.onUpdate(B)}N.__version=B.version}function re(N,B,ae){if(B.image.length!==6)return;let ge=oe(N,B),me=B.source;e.bindTexture(34067,N.__webglTexture,33984+ae);let Le=r.get(me);if(me.version!==Le.__version||ge===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,B.flipY),n.pixelStorei(37441,B.premultiplyAlpha),n.pixelStorei(3317,B.unpackAlignment),n.pixelStorei(37443,0);let Ne=B.isCompressedTexture||B.image[0].isCompressedTexture,Re=B.image[0]&&B.image[0].isDataTexture,pe=[];for(let ye=0;ye<6;ye++)!Ne&&!Re?pe[ye]=x(B.image[ye],!1,!0,c):pe[ye]=Re?B.image[ye].image:B.image[ye],pe[ye]=F(B,pe[ye]);let nt=pe[0],Ge=S(nt)||a,Be=s.convert(B.format,B.encoding),et=s.convert(B.type),st=b(B.internalFormat,Be,et,B.encoding),Bt=a&&B.isVideoTexture!==!0,dr=Le.__version===void 0||ge===!0,Mr=T(B,nt,Ge);Y(34067,B,Ge);let Q;if(Ne){Bt&&dr&&e.texStorage2D(34067,Mr,st,nt.width,nt.height);for(let ye=0;ye<6;ye++){Q=pe[ye].mipmaps;for(let Te=0;Te<Q.length;Te++){let je=Q[Te];B.format!==qr?Be!==null?Bt?e.compressedTexSubImage2D(34069+ye,Te,0,0,je.width,je.height,Be,je.data):e.compressedTexImage2D(34069+ye,Te,st,je.width,je.height,0,je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Bt?e.texSubImage2D(34069+ye,Te,0,0,je.width,je.height,Be,et,je.data):e.texImage2D(34069+ye,Te,st,je.width,je.height,0,Be,et,je.data)}}}else{Q=B.mipmaps,Bt&&dr&&(Q.length>0&&Mr++,e.texStorage2D(34067,Mr,st,pe[0].width,pe[0].height));for(let ye=0;ye<6;ye++)if(Re){Bt?e.texSubImage2D(34069+ye,0,0,0,pe[ye].width,pe[ye].height,Be,et,pe[ye].data):e.texImage2D(34069+ye,0,st,pe[ye].width,pe[ye].height,0,Be,et,pe[ye].data);for(let Te=0;Te<Q.length;Te++){let He=Q[Te].image[ye].image;Bt?e.texSubImage2D(34069+ye,Te+1,0,0,He.width,He.height,Be,et,He.data):e.texImage2D(34069+ye,Te+1,st,He.width,He.height,0,Be,et,He.data)}}else{Bt?e.texSubImage2D(34069+ye,0,0,0,Be,et,pe[ye]):e.texImage2D(34069+ye,0,st,Be,et,pe[ye]);for(let Te=0;Te<Q.length;Te++){let je=Q[Te];Bt?e.texSubImage2D(34069+ye,Te+1,0,0,Be,et,je.image[ye]):e.texImage2D(34069+ye,Te+1,st,Be,et,je.image[ye])}}}A(B,Ge)&&M(34067),Le.__version=me.version,B.onUpdate&&B.onUpdate(B)}N.__version=B.version}function J(N,B,ae,ge,me){let Le=s.convert(ae.format,ae.encoding),Ne=s.convert(ae.type),Re=b(ae.internalFormat,Le,Ne,ae.encoding);r.get(B).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Re,B.width,B.height,B.depth,0,Le,Ne,null):e.texImage2D(me,0,Re,B.width,B.height,0,Le,Ne,null)),e.bindFramebuffer(36160,N),Oe(B)?d.framebufferTexture2DMultisampleEXT(36160,ge,me,r.get(ae).__webglTexture,0,Ve(B)):(me===3553||me>=34069&&me<=34074)&&n.framebufferTexture2D(36160,ge,me,r.get(ae).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ae(N,B,ae){if(n.bindRenderbuffer(36161,N),B.depthBuffer&&!B.stencilBuffer){let ge=33189;if(ae||Oe(B)){let me=B.depthTexture;me&&me.isDepthTexture&&(me.type===br?ge=36012:me.type===Ds&&(ge=33190));let Le=Ve(B);Oe(B)?d.renderbufferStorageMultisampleEXT(36161,Le,ge,B.width,B.height):n.renderbufferStorageMultisample(36161,Le,ge,B.width,B.height)}else n.renderbufferStorage(36161,ge,B.width,B.height);n.framebufferRenderbuffer(36160,36096,36161,N)}else if(B.depthBuffer&&B.stencilBuffer){let ge=Ve(B);ae&&Oe(B)===!1?n.renderbufferStorageMultisample(36161,ge,35056,B.width,B.height):Oe(B)?d.renderbufferStorageMultisampleEXT(36161,ge,35056,B.width,B.height):n.renderbufferStorage(36161,34041,B.width,B.height),n.framebufferRenderbuffer(36160,33306,36161,N)}else{let ge=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let me=0;me<ge.length;me++){let Le=ge[me],Ne=s.convert(Le.format,Le.encoding),Re=s.convert(Le.type),pe=b(Le.internalFormat,Ne,Re,Le.encoding),nt=Ve(B);ae&&Oe(B)===!1?n.renderbufferStorageMultisample(36161,nt,pe,B.width,B.height):Oe(B)?d.renderbufferStorageMultisampleEXT(36161,nt,pe,B.width,B.height):n.renderbufferStorage(36161,pe,B.width,B.height)}}n.bindRenderbuffer(36161,null)}function xe(N,B){if(B&&B.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,N),!(B.depthTexture&&B.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(B.depthTexture).__webglTexture||B.depthTexture.image.width!==B.width||B.depthTexture.image.height!==B.height)&&(B.depthTexture.image.width=B.width,B.depthTexture.image.height=B.height,B.depthTexture.needsUpdate=!0),q(B.depthTexture,0);let ge=r.get(B.depthTexture).__webglTexture,me=Ve(B);if(B.depthTexture.format===hc)Oe(B)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ge,0,me):n.framebufferTexture2D(36160,36096,3553,ge,0);else if(B.depthTexture.format===Ja)Oe(B)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ge,0,me):n.framebufferTexture2D(36160,33306,3553,ge,0);else throw new Error("Unknown depthTexture format")}function de(N){let B=r.get(N),ae=N.isWebGLCubeRenderTarget===!0;if(N.depthTexture&&!B.__autoAllocateDepthBuffer){if(ae)throw new Error("target.depthTexture not supported in Cube render targets");xe(B.__webglFramebuffer,N)}else if(ae){B.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)e.bindFramebuffer(36160,B.__webglFramebuffer[ge]),B.__webglDepthbuffer[ge]=n.createRenderbuffer(),Ae(B.__webglDepthbuffer[ge],N,!1)}else e.bindFramebuffer(36160,B.__webglFramebuffer),B.__webglDepthbuffer=n.createRenderbuffer(),Ae(B.__webglDepthbuffer,N,!1);e.bindFramebuffer(36160,null)}function Ie(N,B,ae){let ge=r.get(N);B!==void 0&&J(ge.__webglFramebuffer,N,N.texture,36064,3553),ae!==void 0&&de(N)}function Ce(N){let B=N.texture,ae=r.get(N),ge=r.get(B);N.addEventListener("dispose",D),N.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=n.createTexture()),ge.__version=B.version,o.memory.textures++);let me=N.isWebGLCubeRenderTarget===!0,Le=N.isWebGLMultipleRenderTargets===!0,Ne=S(N)||a;if(me){ae.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)ae.__webglFramebuffer[Re]=n.createFramebuffer()}else{if(ae.__webglFramebuffer=n.createFramebuffer(),Le)if(i.drawBuffers){let Re=N.texture;for(let pe=0,nt=Re.length;pe<nt;pe++){let Ge=r.get(Re[pe]);Ge.__webglTexture===void 0&&(Ge.__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&&N.samples>0&&Oe(N)===!1){let Re=Le?B:[B];ae.__webglMultisampledFramebuffer=n.createFramebuffer(),ae.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ae.__webglMultisampledFramebuffer);for(let pe=0;pe<Re.length;pe++){let nt=Re[pe];ae.__webglColorRenderbuffer[pe]=n.createRenderbuffer(),n.bindRenderbuffer(36161,ae.__webglColorRenderbuffer[pe]);let Ge=s.convert(nt.format,nt.encoding),Be=s.convert(nt.type),et=b(nt.internalFormat,Ge,Be,nt.encoding,N.isXRRenderTarget===!0),st=Ve(N);n.renderbufferStorageMultisample(36161,st,et,N.width,N.height),n.framebufferRenderbuffer(36160,36064+pe,36161,ae.__webglColorRenderbuffer[pe])}n.bindRenderbuffer(36161,null),N.depthBuffer&&(ae.__webglDepthRenderbuffer=n.createRenderbuffer(),Ae(ae.__webglDepthRenderbuffer,N,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ge.__webglTexture),Y(34067,B,Ne);for(let Re=0;Re<6;Re++)J(ae.__webglFramebuffer[Re],N,B,36064,34069+Re);A(B,Ne)&&M(34067),e.unbindTexture()}else if(Le){let Re=N.texture;for(let pe=0,nt=Re.length;pe<nt;pe++){let Ge=Re[pe],Be=r.get(Ge);e.bindTexture(3553,Be.__webglTexture),Y(3553,Ge,Ne),J(ae.__webglFramebuffer,N,Ge,36064+pe,3553),A(Ge,Ne)&&M(3553)}e.unbindTexture()}else{let Re=3553;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(a?Re=N.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Re,ge.__webglTexture),Y(Re,B,Ne),J(ae.__webglFramebuffer,N,B,36064,Re),A(B,Ne)&&M(Re),e.unbindTexture()}N.depthBuffer&&de(N)}function ke(N){let B=S(N)||a,ae=N.isWebGLMultipleRenderTargets===!0?N.texture:[N.texture];for(let ge=0,me=ae.length;ge<me;ge++){let Le=ae[ge];if(A(Le,B)){let Ne=N.isWebGLCubeRenderTarget?34067:3553,Re=r.get(Le).__webglTexture;e.bindTexture(Ne,Re),M(Ne),e.unbindTexture()}}}function ze(N){if(a&&N.samples>0&&Oe(N)===!1){let B=N.isWebGLMultipleRenderTargets?N.texture:[N.texture],ae=N.width,ge=N.height,me=16384,Le=[],Ne=N.stencilBuffer?33306:36096,Re=r.get(N),pe=N.isWebGLMultipleRenderTargets===!0;if(pe)for(let nt=0;nt<B.length;nt++)e.bindFramebuffer(36160,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,null),e.bindFramebuffer(36160,Re.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,null,0);e.bindFramebuffer(36008,Re.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Re.__webglFramebuffer);for(let nt=0;nt<B.length;nt++){Le.push(36064+nt),N.depthBuffer&&Le.push(Ne);let Ge=Re.__ignoreDepthValues!==void 0?Re.__ignoreDepthValues:!1;if(Ge===!1&&(N.depthBuffer&&(me|=256),N.stencilBuffer&&(me|=1024)),pe&&n.framebufferRenderbuffer(36008,36064,36161,Re.__webglColorRenderbuffer[nt]),Ge===!0&&(n.invalidateFramebuffer(36008,[Ne]),n.invalidateFramebuffer(36009,[Ne])),pe){let Be=r.get(B[nt]).__webglTexture;n.framebufferTexture2D(36009,36064,3553,Be,0)}n.blitFramebuffer(0,0,ae,ge,0,0,ae,ge,me,9728),f&&n.invalidateFramebuffer(36008,Le)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),pe)for(let nt=0;nt<B.length;nt++){e.bindFramebuffer(36160,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+nt,36161,Re.__webglColorRenderbuffer[nt]);let Ge=r.get(B[nt]).__webglTexture;e.bindFramebuffer(36160,Re.__webglFramebuffer),n.framebufferTexture2D(36009,36064+nt,3553,Ge,0)}e.bindFramebuffer(36009,Re.__webglMultisampledFramebuffer)}}function Ve(N){return Math.min(h,N.samples)}function Oe(N){let B=r.get(N);return a&&N.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&B.__useRenderToTexture!==!1}function Ye(N){let B=o.render.frame;p.get(N)!==B&&(p.set(N,B),N.update())}function F(N,B){let ae=N.encoding,ge=N.format,me=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||N.format===WS||ae!==mn&&(ae===at?a===!1?t.has("EXT_sRGB")===!0&&ge===qr?(N.format=WS,N.minFilter=rt,N.generateMipmaps=!1):B=Jg.sRGBToLinear(B):(ge!==qr||me!==_r)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ae)),B}this.allocateTextureUnit=H,this.resetTextureUnits=V,this.setTexture2D=q,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=Z,this.rebindTextures=Ie,this.setupRenderTarget=Ce,this.updateRenderTargetMipmap=ke,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Oe}function KG(n,t,e){let r=e.isWebGL2;function i(s,o=null){let a;if(s===_r)return 5121;if(s===jF)return 32819;if(s===HF)return 32820;if(s===zF)return 5120;if(s===kF)return 5122;if(s===XC)return 5123;if(s===GF)return 5124;if(s===Ds)return 5125;if(s===br)return 5126;if(s===Wn)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===WF)return 6406;if(s===qr)return 6408;if(s===qF)return 6409;if(s===YF)return 6410;if(s===hc)return 6402;if(s===Ja)return 34041;if(s===WS)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===XF)return 6403;if(s===QF)return 36244;if(s===Ju)return 33319;if(s===KF)return 33320;if(s===ww)return 36249;if(s===nS||s===sS||s===oS||s===aS)if(o===at)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===nS)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===sS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===oS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===aS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===nS)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===sS)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===oS)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===aS)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===xT||s===bT||s===ST||s===wT)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===xT)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===bT)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===ST)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===wT)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===ZF)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===AT||s===ET)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===AT)return o===at?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===ET)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===MT||s===TT||s===CT||s===PT||s===_T||s===DT||s===IT||s===OT||s===RT||s===LT||s===BT||s===NT||s===FT||s===VT)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===MT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===TT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===CT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===PT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===_T)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===DT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===IT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===OT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===RT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===LT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===BT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===NT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===FT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===VT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===lS)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===lS)return o===at?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===JF||s===UT||s===zT||s===kT)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===lS)return a.COMPRESSED_RED_RGTC1_EXT;if(s===UT)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===zT)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===kT)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Qa?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 rw=class extends $r{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},sn=class extends Mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},ZG={type:"move"},ip=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sn,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 sn,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 sn,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 m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(c,m);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,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(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(ZG)))}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 sn;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},ns=class extends $t{constructor(t,e,r,i,s,o,a,l,c,u){if(u=u!==void 0?u:hc,u!==hc&&u!==Ja)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===hc&&(r=Ds),r===void 0&&u===Ja&&(r=Qa),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}},iw=class extends pr{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,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],S=new Set,w=new Map,A=new $r;A.layers.enable(1),A.viewport=new Ze;let M=new $r;M.layers.enable(2),M.viewport=new Ze;let b=[A,M],T=new rw;T.layers.enable(1),T.layers.enable(2);let C=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let Z=v[G];return Z===void 0&&(Z=new ip,v[G]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(G){let Z=v[G];return Z===void 0&&(Z=new ip,v[G]=Z),Z.getGripSpace()},this.getHand=function(G){let Z=v[G];return Z===void 0&&(Z=new ip,v[G]=Z),Z.getHandSpace()};function D(G){let Z=x.indexOf(G.inputSource);if(Z===-1)return;let te=v[Z];te!==void 0&&te.dispatchEvent({type:G.type,data:G.inputSource})}function _(){i.removeEventListener("select",D),i.removeEventListener("selectstart",D),i.removeEventListener("selectend",D),i.removeEventListener("squeeze",D),i.removeEventListener("squeezestart",D),i.removeEventListener("squeezeend",D),i.removeEventListener("end",_),i.removeEventListener("inputsourceschange",I);for(let G=0;G<v.length;G++){let Z=x[G];Z!==null&&(x[G]=null,v[G].disconnect(Z))}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(G){s=G,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(G){c=G},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(G){if(i=G,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",D),i.addEventListener("selectstart",D),i.addEventListener("selectend",D),i.addEventListener("squeeze",D),i.addEventListener("squeezestart",D),i.addEventListener("squeezeend",D),i.addEventListener("end",_),i.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Z={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,Z),i.updateRenderState({baseLayer:f}),y=new dt(f.framebufferWidth,f.framebufferHeight,{format:qr,type:_r,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let Z=null,te=null,$=null;m.depth&&($=m.stencil?35056:33190,Z=m.stencil?Ja:hc,te=m.stencil?Qa:Ds);let Y={colorFormat:32856,depthFormat:$,scaleFactor:s};h=new XRWebGLBinding(i,e),d=h.createProjectionLayer(Y),i.updateRenderState({layers:[d]}),y=new dt(d.textureWidth,d.textureHeight,{format:qr,type:_r,depthTexture:new ns(d.textureWidth,d.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.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 I(G){for(let Z=0;Z<G.removed.length;Z++){let te=G.removed[Z],$=x.indexOf(te);$>=0&&(x[$]=null,v[$].disconnect(te))}for(let Z=0;Z<G.added.length;Z++){let te=G.added[Z],$=x.indexOf(te);if($===-1){for(let oe=0;oe<v.length;oe++)if(oe>=x.length){x.push(te),$=oe;break}else if(x[oe]===null){x[oe]=te,$=oe;break}if($===-1)break}let Y=v[$];Y&&Y.connect(te)}}let L=new E,j=new E;function V(G,Z,te){L.setFromMatrixPosition(Z.matrixWorld),j.setFromMatrixPosition(te.matrixWorld);let $=L.distanceTo(j),Y=Z.projectionMatrix.elements,oe=te.projectionMatrix.elements,ie=Y[14]/(Y[10]-1),re=Y[14]/(Y[10]+1),J=(Y[9]+1)/Y[5],Ae=(Y[9]-1)/Y[5],xe=(Y[8]-1)/Y[0],de=(oe[8]+1)/oe[0],Ie=ie*xe,Ce=ie*de,ke=$/(-xe+de),ze=ke*-xe;Z.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(ze),G.translateZ(ke),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Ve=ie+ke,Oe=re+ke,Ye=Ie-ze,F=Ce+($-ze),N=J*re/Oe*Ve,B=Ae*re/Oe*Ve;G.projectionMatrix.makePerspective(Ye,F,N,B,Ve,Oe)}function H(G,Z){Z===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(Z.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(i===null)return;T.near=M.near=A.near=G.near,T.far=M.far=A.far=G.far,(C!==T.near||P!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),C=T.near,P=T.far);let Z=G.parent,te=T.cameras;H(T,Z);for(let Y=0;Y<te.length;Y++)H(te[Y],Z);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),G.matrix.copy(T.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let $=G.children;for(let Y=0,oe=$.length;Y<oe;Y++)$[Y].updateMatrixWorld(!0);te.length===2?V(T,A,M):T.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(G){l=G,d!==null&&(d.fixedFoveation=G),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=G)},this.getPlanes=function(){return S};let W=null;function q(G,Z){if(u=Z.getViewerPose(c||o),p=Z,u!==null){let te=u.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let $=!1;te.length!==T.cameras.length&&(T.cameras.length=0,$=!0);for(let Y=0;Y<te.length;Y++){let oe=te[Y],ie=null;if(f!==null)ie=f.getViewport(oe);else{let J=h.getViewSubImage(d,oe);ie=J.viewport,Y===0&&(t.setRenderTargetTextures(y,J.colorTexture,d.ignoreDepthValues?void 0:J.depthStencilTexture),t.setRenderTarget(y))}let re=b[Y];re===void 0&&(re=new $r,re.layers.enable(Y),re.viewport=new Ze,b[Y]=re),re.matrix.fromArray(oe.transform.matrix),re.projectionMatrix.fromArray(oe.projectionMatrix),re.viewport.set(ie.x,ie.y,ie.width,ie.height),Y===0&&T.matrix.copy(re.matrix),$===!0&&T.cameras.push(re)}}for(let te=0;te<v.length;te++){let $=x[te],Y=v[te];$!==null&&Y!==void 0&&Y.update($,Z,c||o)}if(W&&W(G,Z),Z.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:Z.detectedPlanes});let te=null;for(let $ of S)Z.detectedPlanes.has($)||(te===null&&(te=[]),te.push($));if(te!==null)for(let $ of te)S.delete($),w.delete($),r.dispatchEvent({type:"planeremoved",data:$});for(let $ of Z.detectedPlanes)if(!S.has($))S.add($),w.set($,Z.lastChangedTime),r.dispatchEvent({type:"planeadded",data:$});else{let Y=w.get($);$.lastChangedTime>Y&&(w.set($,$.lastChangedTime),r.dispatchEvent({type:"planechanged",data:$}))}}p=null}let K=new eP;K.setAnimationLoop(q),this.setAnimationLoop=function(G){W=G},this.dispose=function(){}}};function JG(n,t){function e(m,g){g.color.getRGB(m.fogColor.value,$C(n)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(m,g):g.isMeshToonMaterial?(i(m,g),u(m,g)):g.isMeshPhongMaterial?(i(m,g),c(m,g)):g.isMeshStandardMaterial?(i(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(i(m,g),f(m,g)):g.isMeshDepthMaterial?i(m,g):g.isMeshDistanceMaterial?(i(m,g),p(m,g)):g.isMeshNormalMaterial?i(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===pi&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===pi&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let S=n.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*S}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function c(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===pi&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function $G(n,t,e,r){let i={},s={},o=[],a=e.isWebGL2?n.getParameter(35375):0;function l(v,x){let S=x.program;r.uniformBlockBinding(v,S)}function c(v,x){let S=i[v.id];S===void 0&&(p(v),S=u(v),i[v.id]=S,v.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(v,w);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function u(v){let x=h();v.__bindingPointIndex=x;let S=n.createBuffer(),w=v.__size,A=v.usage;return n.bindBuffer(35345,S),n.bufferData(35345,w,A),n.bindBuffer(35345,null),n.bindBufferBase(35345,x,S),S}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=i[v.id],S=v.uniforms,w=v.__cache;n.bindBuffer(35345,x);for(let A=0,M=S.length;A<M;A++){let b=S[A];if(f(b,A,w)===!0){let T=b.__offset,C=Array.isArray(b.value)?b.value:[b.value],P=0;for(let D=0;D<C.length;D++){let _=C[D],I=m(_);typeof _=="number"?(b.__data[0]=_,n.bufferSubData(35345,T+P,b.__data)):_.isMatrix3?(b.__data[0]=_.elements[0],b.__data[1]=_.elements[1],b.__data[2]=_.elements[2],b.__data[3]=_.elements[0],b.__data[4]=_.elements[3],b.__data[5]=_.elements[4],b.__data[6]=_.elements[5],b.__data[7]=_.elements[0],b.__data[8]=_.elements[6],b.__data[9]=_.elements[7],b.__data[10]=_.elements[8],b.__data[11]=_.elements[0]):(_.toArray(b.__data,P),P+=I.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(35345,T,b.__data)}}n.bindBuffer(35345,null)}function f(v,x,S){let w=v.value;if(S[x]===void 0){if(typeof w=="number")S[x]=w;else{let A=Array.isArray(w)?w:[w],M=[];for(let b=0;b<A.length;b++)M.push(A[b].clone());S[x]=M}return!0}else if(typeof w=="number"){if(S[x]!==w)return S[x]=w,!0}else{let A=Array.isArray(S[x])?S[x]:[S[x]],M=Array.isArray(w)?w:[w];for(let b=0;b<A.length;b++){let T=A[b];if(T.equals(M[b])===!1)return T.copy(M[b]),!0}}return!1}function p(v){let x=v.uniforms,S=0,w=16,A=0;for(let M=0,b=x.length;M<b;M++){let T=x[M],C={boundary:0,storage:0},P=Array.isArray(T.value)?T.value:[T.value];for(let D=0,_=P.length;D<_;D++){let I=P[D],L=m(I);C.boundary+=L.boundary,C.storage+=L.storage}if(T.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=S,M>0){A=S%w;let D=w-A;A!==0&&D-C.boundary<0&&(S+=w-A,T.__offset=S)}S+=C.storage}return A=S%w,A>0&&(S+=w-A),v.__size=S,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),n.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)n.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:c,dispose:y}}function e4(){let n=lp("canvas");return n.style.display="block",n}function _w(n={}){this.isWebGLRenderer=!0;let t=n.canvas!==void 0?n.canvas:e4(),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=[],p=[];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=mn,this.physicallyCorrectLights=!1,this.toneMapping=Is,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,S=-1,w=null,A=new Ze,M=new Ze,b=null,T=t.width,C=t.height,P=1,D=null,_=null,I=new Ze(0,0,T,C),L=new Ze(0,0,T,C),j=!1,V=new up,H=!1,W=!1,q=null,K=new ue,G=new U,Z=new E,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function $(){return x===null?P:1}let Y=e;function oe(k,ce){for(let ve=0;ve<k.length;ve++){let se=k[ve],be=t.getContext(se,ce);if(be!==null)return be}return null}try{let k={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${ca}`),t.addEventListener("webglcontextlost",et,!1),t.addEventListener("webglcontextrestored",st,!1),t.addEventListener("webglcontextcreationerror",Bt,!1),Y===null){let ce=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ce.shift(),Y=oe(ce,k),Y===null)throw oe(ce)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}Y.getShaderPrecisionFormat===void 0&&(Y.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let ie,re,J,Ae,xe,de,Ie,Ce,ke,ze,Ve,Oe,Ye,F,N,B,ae,ge,me,Le,Ne,Re,pe,nt;function Ge(){ie=new Sk(Y),re=new mk(Y,ie,n),ie.init(re),Re=new KG(Y,ie,re),J=new XG(Y,ie,re),Ae=new Ek,xe=new NG,de=new QG(Y,ie,J,xe,re,Re,Ae),Ie=new yk(m),Ce=new bk(m),ke=new RV(Y,re),pe=new fk(Y,ie,ke,re),ze=new wk(Y,ke,Ae,pe),Ve=new Pk(Y,ze,ke,Ae),me=new Ck(Y,re,de),B=new gk(xe),Oe=new BG(m,Ie,Ce,ie,re,pe,B),Ye=new JG(m,xe),F=new VG,N=new HG(ie,re),ge=new dk(m,Ie,Ce,J,Ve,u,o),ae=new YG(m,Ve,re),nt=new $G(Y,Ae,re,J),Le=new pk(Y,ie,Ae,re),Ne=new Ak(Y,ie,Ae,re),Ae.programs=Oe.programs,m.capabilities=re,m.extensions=ie,m.properties=xe,m.renderLists=F,m.shadowMap=ae,m.state=J,m.info=Ae}Ge();let Be=new iw(m,Y);this.xr=Be,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){let k=ie.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){let k=ie.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(k){k!==void 0&&(P=k,this.setSize(T,C,!1))},this.getSize=function(k){return k.set(T,C)},this.setSize=function(k,ce,ve){if(Be.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=k,C=ce,t.width=Math.floor(k*P),t.height=Math.floor(ce*P),ve!==!1&&(t.style.width=k+"px",t.style.height=ce+"px"),this.setViewport(0,0,k,ce)},this.getDrawingBufferSize=function(k){return k.set(T*P,C*P).floor()},this.setDrawingBufferSize=function(k,ce,ve){T=k,C=ce,P=ve,t.width=Math.floor(k*ve),t.height=Math.floor(ce*ve),this.setViewport(0,0,k,ce)},this.getCurrentViewport=function(k){return k.copy(A)},this.getViewport=function(k){return k.copy(I)},this.setViewport=function(k,ce,ve,se){k.isVector4?I.set(k.x,k.y,k.z,k.w):I.set(k,ce,ve,se),J.viewport(A.copy(I).multiplyScalar(P).floor())},this.getScissor=function(k){return k.copy(L)},this.setScissor=function(k,ce,ve,se){k.isVector4?L.set(k.x,k.y,k.z,k.w):L.set(k,ce,ve,se),J.scissor(M.copy(L).multiplyScalar(P).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(k){J.setScissorTest(j=k)},this.setOpaqueSort=function(k){D=k},this.setTransparentSort=function(k){_=k},this.getClearColor=function(k){return k.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor.apply(ge,arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha.apply(ge,arguments)},this.clear=function(k=!0,ce=!0,ve=!0){let se=0;k&&(se|=16384),ce&&(se|=256),ve&&(se|=1024),Y.clear(se)},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",et,!1),t.removeEventListener("webglcontextrestored",st,!1),t.removeEventListener("webglcontextcreationerror",Bt,!1),F.dispose(),N.dispose(),xe.dispose(),Ie.dispose(),Ce.dispose(),Ve.dispose(),pe.dispose(),nt.dispose(),Oe.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",je),Be.removeEventListener("sessionend",He),q&&(q.dispose(),q=null),_t.stop()};function et(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function st(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let k=Ae.autoReset,ce=ae.enabled,ve=ae.autoUpdate,se=ae.needsUpdate,be=ae.type;Ge(),Ae.autoReset=k,ae.enabled=ce,ae.autoUpdate=ve,ae.needsUpdate=se,ae.type=be}function Bt(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function dr(k){let ce=k.target;ce.removeEventListener("dispose",dr),Mr(ce)}function Mr(k){Q(k),xe.remove(k)}function Q(k){let ce=xe.get(k).programs;ce!==void 0&&(ce.forEach(function(ve){Oe.releaseProgram(ve)}),k.isShaderMaterial&&Oe.releaseShaderCache(k))}this.renderBufferDirect=function(k,ce,ve,se,be,ct){ce===null&&(ce=te);let mt=be.isMesh&&be.matrixWorld.determinant()<0,At=Zb(k,ce,ve,se,be);J.setMaterial(se,mt);let Ct=ve.index,Gt=1;se.wireframe===!0&&(Ct=ze.getWireframeAttribute(ve),Gt=2);let Nt=ve.drawRange,Dt=ve.attributes.position,Ft=Nt.start*Gt,tn=(Nt.start+Nt.count)*Gt;ct!==null&&(Ft=Math.max(Ft,ct.start*Gt),tn=Math.min(tn,(ct.start+ct.count)*Gt)),Ct!==null?(Ft=Math.max(Ft,0),tn=Math.min(tn,Ct.count)):Dt!=null&&(Ft=Math.max(Ft,0),tn=Math.min(tn,Dt.count));let rn=tn-Ft;if(rn<0||rn===1/0)return;pe.setup(be,se,At,ve,Ct);let ao,gt=Le;if(Ct!==null&&(ao=ke.get(Ct),gt=Ne,gt.setIndex(ao)),be.isMesh)se.wireframe===!0?(J.setLineWidth(se.wireframeLinewidth*$()),gt.setMode(1)):gt.setMode(4);else if(be.isLine){let Rt=se.linewidth;Rt===void 0&&(Rt=1),J.setLineWidth(Rt*$()),be.isLineSegments?gt.setMode(1):be.isLineLoop?gt.setMode(2):gt.setMode(3)}else be.isPoints?gt.setMode(0):be.isSprite&&gt.setMode(4);if(be.isInstancedMesh)gt.renderInstances(Ft,rn,be.count);else if(ve.isInstancedBufferGeometry){let Rt=ve._maxInstanceCount!==void 0?ve._maxInstanceCount:1/0,lu=Math.min(ve.instanceCount,Rt);gt.renderInstances(Ft,rn,lu)}else gt.render(Ft,rn)},this.compile=function(k,ce){function ve(se,be,ct){se.transparent===!0&&se.side===fi&&se.forceSinglePass===!1?(se.side=pi,se.needsUpdate=!0,Tn(se,be,ct),se.side=Hn,se.needsUpdate=!0,Tn(se,be,ct),se.side=fi):Tn(se,be,ct)}d=N.get(k),d.init(),p.push(d),k.traverseVisible(function(se){se.isLight&&se.layers.test(ce.layers)&&(d.pushLight(se),se.castShadow&&d.pushShadow(se))}),d.setupLights(m.physicallyCorrectLights),k.traverse(function(se){let be=se.material;if(be)if(Array.isArray(be))for(let ct=0;ct<be.length;ct++){let mt=be[ct];ve(mt,k,se)}else ve(be,k,se)}),p.pop(),d=null};let ye=null;function Te(k){ye&&ye(k)}function je(){_t.stop()}function He(){_t.start()}let _t=new eP;_t.setAnimationLoop(Te),typeof self<"u"&&_t.setContext(self),this.setAnimationLoop=function(k){ye=k,Be.setAnimationLoop(k),k===null?_t.stop():_t.start()},Be.addEventListener("sessionstart",je),Be.addEventListener("sessionend",He),this.render=function(k,ce){if(ce!==void 0&&ce.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),ce.parent===null&&ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(ce),ce=Be.getCamera()),k.isScene===!0&&k.onBeforeRender(m,k,ce,x),d=N.get(k,p.length),d.init(),p.push(d),K.multiplyMatrices(ce.projectionMatrix,ce.matrixWorldInverse),V.setFromProjectionMatrix(K),W=this.localClippingEnabled,H=B.init(this.clippingPlanes,W),h=F.get(k,f.length),h.init(),f.push(h),Fr(k,ce,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(D,_),H===!0&&B.beginShadows();let ve=d.state.shadowsArray;if(ae.render(ve,k,ce),H===!0&&B.endShadows(),this.info.autoReset===!0&&this.info.reset(),ge.render(h,k),d.setupLights(m.physicallyCorrectLights),ce.isArrayCamera){let se=ce.cameras;for(let be=0,ct=se.length;be<ct;be++){let mt=se[be];Vr(h,k,mt,mt.viewport)}}else Vr(h,k,ce);x!==null&&(de.updateMultisampleRenderTarget(x),de.updateRenderTargetMipmap(x)),k.isScene===!0&&k.onAfterRender(m,k,ce),pe.resetDefaultState(),S=-1,w=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Fr(k,ce,ve,se){if(k.visible===!1)return;if(k.layers.test(ce.layers)){if(k.isGroup)ve=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(ce);else if(k.isLight)d.pushLight(k),k.castShadow&&d.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||V.intersectsSprite(k)){se&&Z.setFromMatrixPosition(k.matrixWorld).applyMatrix4(K);let mt=Ve.update(k),At=k.material;At.visible&&h.push(k,mt,At,ve,Z.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(k.isSkinnedMesh&&k.skeleton.frame!==Ae.render.frame&&(k.skeleton.update(),k.skeleton.frame=Ae.render.frame),!k.frustumCulled||V.intersectsObject(k))){se&&Z.setFromMatrixPosition(k.matrixWorld).applyMatrix4(K);let mt=Ve.update(k),At=k.material;if(Array.isArray(At)){let Ct=mt.groups;for(let Gt=0,Nt=Ct.length;Gt<Nt;Gt++){let Dt=Ct[Gt],Ft=At[Dt.materialIndex];Ft&&Ft.visible&&h.push(k,mt,Ft,ve,Z.z,Dt)}}else At.visible&&h.push(k,mt,At,ve,Z.z,null)}}let ct=k.children;for(let mt=0,At=ct.length;mt<At;mt++)Fr(ct[mt],ce,ve,se)}function Vr(k,ce,ve,se){let be=k.opaque,ct=k.transmissive,mt=k.transparent;d.setupLightsView(ve),H===!0&&B.setGlobalState(m.clippingPlanes,ve),ct.length>0&&Zo(be,ce,ve),se&&J.viewport(A.copy(se)),be.length>0&&Tr(be,ce,ve),ct.length>0&&Tr(ct,ce,ve),mt.length>0&&Tr(mt,ce,ve),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Zo(k,ce,ve){let se=re.isWebGL2;q===null&&(q=new dt(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?Wn:_r,minFilter:fc,samples:se&&s===!0?4:0})),m.getDrawingBufferSize(G),se?q.setSize(G.x,G.y):q.setSize(Zg(G.x),Zg(G.y));let be=m.getRenderTarget();m.setRenderTarget(q),m.clear();let ct=m.toneMapping;m.toneMapping=Is,Tr(k,ce,ve),m.toneMapping=ct,de.updateMultisampleRenderTarget(q),de.updateRenderTargetMipmap(q),m.setRenderTarget(be)}function Tr(k,ce,ve){let se=ce.isScene===!0?ce.overrideMaterial:null;for(let be=0,ct=k.length;be<ct;be++){let mt=k[be],At=mt.object,Ct=mt.geometry,Gt=se===null?mt.material:se,Nt=mt.group;At.layers.test(ve.layers)&&es(At,ce,ve,Ct,Gt,Nt)}}function es(k,ce,ve,se,be,ct){k.onBeforeRender(m,ce,ve,se,be,ct),k.modelViewMatrix.multiplyMatrices(ve.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),be.onBeforeRender(m,ce,ve,se,k,ct),be.transparent===!0&&be.side===fi&&be.forceSinglePass===!1?(be.side=pi,be.needsUpdate=!0,m.renderBufferDirect(ve,ce,se,be,k,ct),be.side=Hn,be.needsUpdate=!0,m.renderBufferDirect(ve,ce,se,be,k,ct),be.side=fi):m.renderBufferDirect(ve,ce,se,be,k,ct),k.onAfterRender(m,ce,ve,se,be,ct)}function Tn(k,ce,ve){ce.isScene!==!0&&(ce=te);let se=xe.get(k),be=d.state.lights,ct=d.state.shadowsArray,mt=be.state.version,At=Oe.getParameters(k,be.state,ct,ce,ve),Ct=Oe.getProgramCacheKey(At),Gt=se.programs;se.environment=k.isMeshStandardMaterial?ce.environment:null,se.fog=ce.fog,se.envMap=(k.isMeshStandardMaterial?Ce:Ie).get(k.envMap||se.environment),Gt===void 0&&(k.addEventListener("dispose",dr),Gt=new Map,se.programs=Gt);let Nt=Gt.get(Ct);if(Nt!==void 0){if(se.currentProgram===Nt&&se.lightsStateVersion===mt)return Gf(k,At),Nt}else At.uniforms=Oe.getUniforms(k),k.onBuild(ve,At,m),k.onBeforeCompile(At,m),Nt=Oe.acquireProgram(At,Ct),Gt.set(Ct,Nt),se.uniforms=At.uniforms;let Dt=se.uniforms;(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(Dt.clippingPlanes=B.uniform),Gf(k,At),se.needsLights=$b(k),se.lightsStateVersion=mt,se.needsLights&&(Dt.ambientLightColor.value=be.state.ambient,Dt.lightProbe.value=be.state.probe,Dt.directionalLights.value=be.state.directional,Dt.directionalLightShadows.value=be.state.directionalShadow,Dt.spotLights.value=be.state.spot,Dt.spotLightShadows.value=be.state.spotShadow,Dt.rectAreaLights.value=be.state.rectArea,Dt.ltc_1.value=be.state.rectAreaLTC1,Dt.ltc_2.value=be.state.rectAreaLTC2,Dt.pointLights.value=be.state.point,Dt.pointLightShadows.value=be.state.pointShadow,Dt.hemisphereLights.value=be.state.hemi,Dt.directionalShadowMap.value=be.state.directionalShadowMap,Dt.directionalShadowMatrix.value=be.state.directionalShadowMatrix,Dt.spotShadowMap.value=be.state.spotShadowMap,Dt.spotLightMatrix.value=be.state.spotLightMatrix,Dt.spotLightMap.value=be.state.spotLightMap,Dt.pointShadowMap.value=be.state.pointShadowMap,Dt.pointShadowMatrix.value=be.state.pointShadowMatrix);let Ft=Nt.getUniforms(),tn=Iu.seqWithValue(Ft.seq,Dt);return se.currentProgram=Nt,se.uniformsList=tn,Nt}function Gf(k,ce){let ve=xe.get(k);ve.outputEncoding=ce.outputEncoding,ve.instancing=ce.instancing,ve.skinning=ce.skinning,ve.morphTargets=ce.morphTargets,ve.morphNormals=ce.morphNormals,ve.morphColors=ce.morphColors,ve.morphTargetsCount=ce.morphTargetsCount,ve.numClippingPlanes=ce.numClippingPlanes,ve.numIntersection=ce.numClipIntersection,ve.vertexAlphas=ce.vertexAlphas,ve.vertexTangents=ce.vertexTangents,ve.toneMapping=ce.toneMapping}function Zb(k,ce,ve,se,be){ce.isScene!==!0&&(ce=te),de.resetTextureUnits();let ct=ce.fog,mt=se.isMeshStandardMaterial?ce.environment:null,At=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:mn,Ct=(se.isMeshStandardMaterial?Ce:Ie).get(se.envMap||mt),Gt=se.vertexColors===!0&&!!ve.attributes.color&&ve.attributes.color.itemSize===4,Nt=!!se.normalMap&&!!ve.attributes.tangent,Dt=!!ve.morphAttributes.position,Ft=!!ve.morphAttributes.normal,tn=!!ve.morphAttributes.color,rn=se.toneMapped?m.toneMapping:Is,ao=ve.morphAttributes.position||ve.morphAttributes.normal||ve.morphAttributes.color,gt=ao!==void 0?ao.length:0,Rt=xe.get(se),lu=d.state.lights;if(H===!0&&(W===!0||k!==w)){let ui=k===w&&se.id===S;B.setState(se,k,ui)}let ci=!1;se.version===Rt.__version?(Rt.needsLights&&Rt.lightsStateVersion!==lu.state.version||Rt.outputEncoding!==At||be.isInstancedMesh&&Rt.instancing===!1||!be.isInstancedMesh&&Rt.instancing===!0||be.isSkinnedMesh&&Rt.skinning===!1||!be.isSkinnedMesh&&Rt.skinning===!0||Rt.envMap!==Ct||se.fog===!0&&Rt.fog!==ct||Rt.numClippingPlanes!==void 0&&(Rt.numClippingPlanes!==B.numPlanes||Rt.numIntersection!==B.numIntersection)||Rt.vertexAlphas!==Gt||Rt.vertexTangents!==Nt||Rt.morphTargets!==Dt||Rt.morphNormals!==Ft||Rt.morphColors!==tn||Rt.toneMapping!==rn||re.isWebGL2===!0&&Rt.morphTargetsCount!==gt)&&(ci=!0):(ci=!0,Rt.__version=se.version);let lo=Rt.currentProgram;ci===!0&&(lo=Tn(se,ce,be));let cu=!1,kn=!1,Et=!1,Si=lo.getUniforms(),ts=Rt.uniforms;if(J.useProgram(lo.program)&&(cu=!0,kn=!0,Et=!0),se.id!==S&&(S=se.id,kn=!0),cu||w!==k){if(Si.setValue(Y,"projectionMatrix",k.projectionMatrix),re.logarithmicDepthBuffer&&Si.setValue(Y,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),w!==k&&(w=k,kn=!0,Et=!0),se.isShaderMaterial||se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshStandardMaterial||se.envMap){let ui=Si.map.cameraPosition;ui!==void 0&&ui.setValue(Y,Z.setFromMatrixPosition(k.matrixWorld))}(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial)&&Si.setValue(Y,"isOrthographic",k.isOrthographicCamera===!0),(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial||se.isShadowMaterial||be.isSkinnedMesh)&&Si.setValue(Y,"viewMatrix",k.matrixWorldInverse)}if(be.isSkinnedMesh){Si.setOptional(Y,be,"bindMatrix"),Si.setOptional(Y,be,"bindMatrixInverse");let ui=be.skeleton;ui&&(re.floatVertexTextures?(ui.boneTexture===null&&ui.computeBoneTexture(),Si.setValue(Y,"boneTexture",ui.boneTexture,de),Si.setValue(Y,"boneTextureSize",ui.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 uu=ve.morphAttributes;if((uu.position!==void 0||uu.normal!==void 0||uu.color!==void 0&&re.isWebGL2===!0)&&me.update(be,ve,se,lo),(kn||Rt.receiveShadow!==be.receiveShadow)&&(Rt.receiveShadow=be.receiveShadow,Si.setValue(Y,"receiveShadow",be.receiveShadow)),se.isMeshGouraudMaterial&&se.envMap!==null&&(ts.envMap.value=Ct,ts.flipEnvMap.value=Ct.isCubeTexture&&Ct.isRenderTargetTexture===!1?-1:1),kn&&(Si.setValue(Y,"toneMappingExposure",m.toneMappingExposure),Rt.needsLights&&Jb(ts,Et),ct&&se.fog===!0&&Ye.refreshFogUniforms(ts,ct),Ye.refreshMaterialUniforms(ts,se,P,C,q),Iu.upload(Y,Rt.uniformsList,ts,de)),se.isShaderMaterial&&se.uniformsNeedUpdate===!0&&(Iu.upload(Y,Rt.uniformsList,ts,de),se.uniformsNeedUpdate=!1),se.isSpriteMaterial&&Si.setValue(Y,"center",be.center),Si.setValue(Y,"modelViewMatrix",be.modelViewMatrix),Si.setValue(Y,"normalMatrix",be.normalMatrix),Si.setValue(Y,"modelMatrix",be.matrixWorld),be.previousModelViewMatrix&&Si.setValue(Y,"previousModelViewMatrix",be.previousModelViewMatrix),k.previousProjectionMatrix&&Si.setValue(Y,"previousProjectionMatrix",k.previousProjectionMatrix),se.isShaderMaterial||se.isRawShaderMaterial){let ui=se.uniformsGroups;for(let O=0,R=ui.length;O<R;O++)if(re.isWebGL2){let X=ui[O];nt.update(X,lo),nt.bind(X,lo)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return lo}function Jb(k,ce){k.ambientLightColor.needsUpdate=ce,k.lightProbe.needsUpdate=ce,k.directionalLights.needsUpdate=ce,k.directionalLightShadows.needsUpdate=ce,k.pointLights.needsUpdate=ce,k.pointLightShadows.needsUpdate=ce,k.spotLights.needsUpdate=ce,k.spotLightShadows.needsUpdate=ce,k.rectAreaLights.needsUpdate=ce,k.hemisphereLights.needsUpdate=ce}function $b(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(k,ce,ve){xe.get(k.texture).__webglTexture=ce,xe.get(k.depthTexture).__webglTexture=ve;let se=xe.get(k);se.__hasExternalTextures=!0,se.__hasExternalTextures&&(se.__autoAllocateDepthBuffer=ve===void 0,se.__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"),se.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(k,ce){let ve=xe.get(k);ve.__webglFramebuffer=ce,ve.__useDefaultFramebuffer=ce===void 0},this.setRenderTarget=function(k,ce=0,ve=0){x=k,y=ce,v=ve;let se=!0,be=null,ct=!1,mt=!1;if(k){let Ct=xe.get(k);Ct.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),se=!1):Ct.__webglFramebuffer===void 0?de.setupRenderTarget(k):Ct.__hasExternalTextures&&de.rebindTextures(k,xe.get(k.texture).__webglTexture,xe.get(k.depthTexture).__webglTexture);let Gt=k.texture;(Gt.isData3DTexture||Gt.isDataArrayTexture||Gt.isCompressedArrayTexture)&&(mt=!0);let Nt=xe.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(be=Nt[ce],ct=!0):re.isWebGL2&&k.samples>0&&de.useMultisampledRTT(k)===!1?be=xe.get(k).__webglMultisampledFramebuffer:be=Nt,A.copy(k.viewport),M.copy(k.scissor),b=k.scissorTest}else A.copy(I).multiplyScalar(P).floor(),M.copy(L).multiplyScalar(P).floor(),b=j;if(J.bindFramebuffer(36160,be)&&re.drawBuffers&&se&&J.drawBuffers(k,be),J.viewport(A),J.scissor(M),J.setScissorTest(b),ct){let Ct=xe.get(k.texture);Y.framebufferTexture2D(36160,36064,34069+ce,Ct.__webglTexture,ve)}else if(mt){let Ct=xe.get(k.texture),Gt=ce||0;Y.framebufferTextureLayer(36160,36064,Ct.__webglTexture,ve||0,Gt)}S=-1},this.readRenderTargetPixels=function(k,ce,ve,se,be,ct,mt){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=xe.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&mt!==void 0&&(At=At[mt]),At){J.bindFramebuffer(36160,At);try{let Ct=k.texture,Gt=Ct.format,Nt=Ct.type;if(Gt!==qr&&Re.convert(Gt)!==Y.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Dt=Nt===Wn&&(ie.has("EXT_color_buffer_half_float")||re.isWebGL2&&ie.has("EXT_color_buffer_float"));if(Nt!==_r&&Re.convert(Nt)!==Y.getParameter(35738)&&!(Nt===br&&(re.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!Dt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ce>=0&&ce<=k.width-se&&ve>=0&&ve<=k.height-be&&Y.readPixels(ce,ve,se,be,Re.convert(Gt),Re.convert(Nt),ct)}finally{let Ct=x!==null?xe.get(x).__webglFramebuffer:null;J.bindFramebuffer(36160,Ct)}}},this.copyFramebufferToTexture=function(k,ce,ve=0){let se=Math.pow(2,-ve),be=Math.floor(ce.image.width*se),ct=Math.floor(ce.image.height*se);de.setTexture2D(ce,0),Y.copyTexSubImage2D(3553,ve,0,0,k.x,k.y,be,ct),J.unbindTexture()},this.copyTextureToTexture=function(k,ce,ve,se=0){let be=ce.image.width,ct=ce.image.height,mt=Re.convert(ve.format),At=Re.convert(ve.type);de.setTexture2D(ve,0),Y.pixelStorei(37440,ve.flipY),Y.pixelStorei(37441,ve.premultiplyAlpha),Y.pixelStorei(3317,ve.unpackAlignment),ce.isDataTexture?Y.texSubImage2D(3553,se,k.x,k.y,be,ct,mt,At,ce.image.data):ce.isCompressedTexture?Y.compressedTexSubImage2D(3553,se,k.x,k.y,ce.mipmaps[0].width,ce.mipmaps[0].height,mt,ce.mipmaps[0].data):Y.texSubImage2D(3553,se,k.x,k.y,mt,At,ce.image),se===0&&ve.generateMipmaps&&Y.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(k,ce,ve,se,be=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ct=k.max.x-k.min.x+1,mt=k.max.y-k.min.y+1,At=k.max.z-k.min.z+1,Ct=Re.convert(se.format),Gt=Re.convert(se.type),Nt;if(se.isData3DTexture)de.setTexture3D(se,0),Nt=32879;else if(se.isDataArrayTexture)de.setTexture2DArray(se,0),Nt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(37440,se.flipY),Y.pixelStorei(37441,se.premultiplyAlpha),Y.pixelStorei(3317,se.unpackAlignment);let Dt=Y.getParameter(3314),Ft=Y.getParameter(32878),tn=Y.getParameter(3316),rn=Y.getParameter(3315),ao=Y.getParameter(32877),gt=ve.isCompressedTexture?ve.mipmaps[0]:ve.image;Y.pixelStorei(3314,gt.width),Y.pixelStorei(32878,gt.height),Y.pixelStorei(3316,k.min.x),Y.pixelStorei(3315,k.min.y),Y.pixelStorei(32877,k.min.z),ve.isDataTexture||ve.isData3DTexture?Y.texSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,Gt,gt.data):ve.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y.compressedTexSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,gt.data)):Y.texSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,Gt,gt),Y.pixelStorei(3314,Dt),Y.pixelStorei(32878,Ft),Y.pixelStorei(3316,tn),Y.pixelStorei(3315,rn),Y.pixelStorei(32877,ao),be===0&&se.generateMipmaps&&Y.generateMipmap(Nt),J.unbindTexture()},this.initTexture=function(k){k.isCubeTexture?de.setTextureCube(k,0):k.isData3DTexture?de.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?de.setTexture2DArray(k,0):de.setTexture2D(k,0),J.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,J.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var nw=class extends _w{};nw.prototype.isWebGL1Renderer=!0;var Lu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new We(t),this.near=e,this.far=r}clone(){return new Lu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ei=class extends Mt{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}},sy=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=HS,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=is()}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=is()),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=is()),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}}},fn=new E,mc=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++)fn.fromBufferAttribute(this,e),fn.applyMatrix4(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.applyNormalMatrix(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.transformDirection(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}setX(t,e){return this.normalized&&(e=xr(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=xr(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=xr(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=xr(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=aa(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=aa(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=aa(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=aa(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=xr(e,this.array),r=xr(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=xr(e,this.array),r=xr(r,this.array),i=xr(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=xr(e,this.array),r=xr(r,this.array),i=xr(i,this.array),s=xr(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 Xe(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 mc(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 dp=class extends Mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},gi=class extends $t{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}},SC=new ue,t4=new ue,el=class{constructor(t=[],e=[]){this.uuid=is(),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:t4;SC.multiplyMatrices(a,e[s]),SC.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new el(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=KC(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new gi(e,t,t,qr,br);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 dp),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}},fo=class extends Xe{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}},wC=new ue,AC=new ue,Vg=[],r4=new ue,Zf=new Ut,oy=class extends Ut{constructor(t,e,r){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new fo(new Float32Array(r*16),16),this.instanceColor=null,this.count=r,this.frustumCulled=!1;for(let i=0;i<r;i++)this.setMatrixAt(i,r4)}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(Zf.geometry=this.geometry,Zf.material=this.material,Zf.material!==void 0)for(let s=0;s<i;s++){this.getMatrixAt(s,wC),AC.multiplyMatrices(r,wC),Zf.matrixWorld=AC,Zf.raycast(t,Vg);for(let o=0,a=Vg.length;o<a;o++){let l=Vg[o];l.instanceId=s,l.object=this,e.push(l)}Vg.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new fo(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"})}},ss=class extends pc{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new We(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}},EC=new E,MC=new E,TC=new ue,LS=new Rs,Ug=new Or,gc=class extends Mt{constructor(t=new _e,e=new ss){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++)EC.fromBufferAttribute(e,i-1),MC.fromBufferAttribute(e,i),r[i]=r[i-1],r[i]+=EC.distanceTo(MC);t.setAttribute("lineDistance",new Me(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(),Ug.copy(r.boundingSphere),Ug.applyMatrix4(i),Ug.radius+=s,t.ray.intersectsSphere(Ug)===!1)return;TC.copy(i).invert(),LS.copy(t.ray).applyMatrix4(TC);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,p=r.index,g=r.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){let w=p.getX(x),A=p.getX(x+1);if(c.fromBufferAttribute(g,w),u.fromBufferAttribute(g,A),LS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){if(c.fromBufferAttribute(g,x),u.fromBufferAttribute(g,x+1),LS.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:x,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}}}}},CC=new E,PC=new E,tl=class extends gc{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)CC.fromBufferAttribute(e,i),PC.fromBufferAttribute(e,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+CC.distanceTo(PC);t.setAttribute("lineDistance",new Me(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var ay=class extends $t{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:rt,this.magFilter=s!==void 0?s:rt,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 ly=class extends $t{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}},os=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 p=f/t;i[f]=this.getTangentAt(p,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 p=Math.acos(di(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(di(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),o[p].crossVectors(i[p],s[p])}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}},yc=class extends os{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}},sw=class extends yc{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Dw(){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 zg=new E,BS=new Dw,NS=new Dw,FS=new Dw,ow=class extends os{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]:(zg.subVectors(i[0],i[1]).add(i[0]),c=zg);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(zg.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=zg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(c.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(u),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),BS.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,p,m,g),NS.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,p,m,g),FS.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,p,m,g)}else this.curveType==="catmullrom"&&(BS.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),NS.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),FS.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return r.set(BS.calc(l),NS.calc(l),FS.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 _C(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 i4(n,t){let e=1-n;return e*e*t}function n4(n,t){return 2*(1-n)*n*t}function s4(n,t){return n*n*t}function np(n,t,e,r){return i4(n,t)+n4(n,e)+s4(n,r)}function o4(n,t){let e=1-n;return e*e*e*t}function a4(n,t){let e=1-n;return 3*e*e*n*t}function l4(n,t){return 3*(1-n)*n*n*t}function c4(n,t){return n*n*n*t}function sp(n,t,e,r,i){return o4(n,t)+a4(n,e)+l4(n,r)+c4(n,i)}var an=class extends os{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(sp(t,i.x,s.x,o.x,a.x),sp(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}},vc=class extends os{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(sp(t,i.x,s.x,o.x,a.x),sp(t,i.y,s.y,o.y,a.y),sp(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}},ln=class extends os{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}},fp=class extends os{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}},Yn=class extends os{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(np(t,i.x,s.x,o.x),np(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}},aw=class extends os{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(np(t,i.x,s.x,o.x),np(t,i.y,s.y,o.y),np(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}},Bu=class extends os{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(_C(a,l.x,c.x,u.x,h.x),_C(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}},u4=Object.freeze({__proto__:null,ArcCurve:sw,CatmullRomCurve3:ow,CubicBezierCurve:an,CubicBezierCurve3:vc,EllipseCurve:yc,LineCurve:ln,LineCurve3:fp,QuadraticBezierCurve:Yn,QuadraticBezierCurve3:aw,SplineCurve:Bu}),pp=class extends os{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 ln(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 u4[i.type]().fromJSON(i))}return this}},xc=class extends pp{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 ln(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 Yn(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 an(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 Bu(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 yc(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}},Nu=class extends _e{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=di(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new E,d=new U,f=new E,p=new E,m=new E,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=r+v*u*i,S=Math.sin(x),w=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*S,h.y=t[A].y,h.z=t[A].x*w,o.push(h.x,h.y,h.z),d.x=v/e,d.y=A/(t.length-1),a.push(d.x,d.y);let M=l[3*A+0]*S,b=l[3*A+1],T=l[3*A+0]*w;c.push(M,b,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let S=x+v*t.length,w=S,A=S+t.length,M=S+t.length+1,b=S+1;s.push(w,A,b),s.push(M,b,A)}this.setIndex(s),this.setAttribute("position",new Me(o,3)),this.setAttribute("uv",new Me(a,2)),this.setAttribute("normal",new Me(c,3))}static fromJSON(t){return new Nu(t.points,t.segments,t.phiStart,t.phiLength)}};var bc=class extends _e{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=[],p=0,m=[],g=r/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Me(h,3)),this.setAttribute("normal",new Me(d,3)),this.setAttribute("uv",new Me(f,2));function v(){let S=new E,w=new E,A=0,M=(e-t)/r;for(let b=0;b<=s;b++){let T=[],C=b/s,P=C*(e-t)+t;for(let D=0;D<=i;D++){let _=D/i,I=_*l+a,L=Math.sin(I),j=Math.cos(I);w.x=P*L,w.y=-C*r+g,w.z=P*j,h.push(w.x,w.y,w.z),S.set(L,M,j).normalize(),d.push(S.x,S.y,S.z),f.push(_,1-C),T.push(p++)}m.push(T)}for(let b=0;b<i;b++)for(let T=0;T<s;T++){let C=m[T][b],P=m[T+1][b],D=m[T+1][b+1],_=m[T][b+1];u.push(C,P,_),u.push(P,D,_),A+=6}c.addGroup(y,A,0),y+=A}function x(S){let w=p,A=new U,M=new E,b=0,T=S===!0?t:e,C=S===!0?1:-1;for(let D=1;D<=i;D++)h.push(0,g*C,0),d.push(0,C,0),f.push(.5,.5),p++;let P=p;for(let D=0;D<=i;D++){let I=D/i*l+a,L=Math.cos(I),j=Math.sin(I);M.x=T*j,M.y=g*C,M.z=T*L,h.push(M.x,M.y,M.z),d.push(0,C,0),A.x=L*.5+.5,A.y=j*.5*C+.5,f.push(A.x,A.y),p++}for(let D=0;D<i;D++){let _=w+D,I=P+D;S===!0?u.push(I,I+1,_):u.push(I+1,I,_),b+=3}c.addGroup(y,b,S===!0?1:2),y+=b}}static fromJSON(t){return new bc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},rl=class extends bc{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 rl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Fu=class extends _e{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 Me(s,3)),this.setAttribute("normal",new Me(s.slice(),3)),this.setAttribute("uv",new Me(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new E,S=new E,w=new E;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],S),f(e[A+2],w),l(x,S,w,v)}function l(v,x,S,w){let A=w+1,M=[];for(let b=0;b<=A;b++){M[b]=[];let T=v.clone().lerp(S,b/A),C=x.clone().lerp(S,b/A),P=A-b;for(let D=0;D<=P;D++)D===0&&b===A?M[b][D]=T:M[b][D]=T.clone().lerp(C,D/P)}for(let b=0;b<A;b++)for(let T=0;T<2*(A-b)-1;T++){let C=Math.floor(T/2);T%2===0?(d(M[b][C+1]),d(M[b+1][C]),d(M[b][C])):(d(M[b][C+1]),d(M[b+1][C+1]),d(M[b+1][C]))}}function c(v){let x=new E;for(let S=0;S<s.length;S+=3)x.x=s[S+0],x.y=s[S+1],x.z=s[S+2],x.normalize().multiplyScalar(v),s[S+0]=x.x,s[S+1]=x.y,s[S+2]=x.z}function u(){let v=new E;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let S=g(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(S,1-w)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],S=o[v+2],w=o[v+4],A=Math.max(x,S,w),M=Math.min(x,S,w);A>.9&&M<.1&&(x<.2&&(o[v+0]+=1),S<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let S=v*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function p(){let v=new E,x=new E,S=new E,w=new E,A=new U,M=new U,b=new U;for(let T=0,C=0;T<s.length;T+=9,C+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),S.set(s[T+6],s[T+7],s[T+8]),A.set(o[C+0],o[C+1]),M.set(o[C+2],o[C+3]),b.set(o[C+4],o[C+5]),w.copy(v).add(x).add(S).divideScalar(3);let P=g(w);m(A,C+0,v,P),m(M,C+2,x,P),m(b,C+4,S,P)}}function m(v,x,S,w){w<0&&v.x===1&&(o[x]=v.x-1),S.x===0&&S.z===0&&(o[x]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new Fu(t.vertices,t.indices,t.radius,t.details)}},Vu=class extends Fu{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 Vu(t.radius,t.detail)}};var la=class extends xc{constructor(t){super(t),this.uuid=is(),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 xc().fromJSON(i))}return this}},h4={triangulate:function(n,t,e=2){let r=t&&t.length,i=r?t[0]*e:n.length,s=sP(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=g4(n,t,s,e)),n.length>80*e){a=c=n[0],l=u=n[1];for(let p=e;p<i;p+=e)h=n[p],d=n[p+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 mp(s,o,e,a,l,f,0),o}};function sP(n,t,e,r,i){let s,o;if(i===C4(n,t,e,r)>0)for(s=t;s<e;s+=r)o=DC(s,n[s],n[s+1],o);else for(s=e-r;s>=t;s-=r)o=DC(s,n[s],n[s+1],o);return o&&My(o,o.next)&&(yp(o),o=o.next),o}function Sc(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(My(e,e.next)||zr(e.prev,e,e.next)===0)){if(yp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function mp(n,t,e,r,i,s,o){if(!n)return;!o&&s&&S4(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?f4(n,r,i,s):d4(n)){t.push(l.i/e|0),t.push(n.i/e|0),t.push(c.i/e|0),yp(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=p4(Sc(n),t,e),mp(n,t,e,r,i,s,2)):o===2&&m4(n,t,e,r,i,s):mp(Sc(n),t,e,r,i,s,1);break}}}function d4(n){let t=n.prev,e=n,r=n.next;if(zr(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,p=r.next;for(;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Du(i,a,s,l,o,c,p.x,p.y)&&zr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function f4(n,t,e,r){let i=n.prev,s=n,o=n.next;if(zr(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,p=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=lw(f,p,t,e,r),v=lw(m,g,t,e,r),x=n.prevZ,S=n.nextZ;for(;x&&x.z>=y&&S&&S.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Du(a,u,l,h,c,d,x.x,x.y)&&zr(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Du(a,u,l,h,c,d,S.x,S.y)&&zr(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Du(a,u,l,h,c,d,x.x,x.y)&&zr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=v;){if(S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Du(a,u,l,h,c,d,S.x,S.y)&&zr(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function p4(n,t,e){let r=n;do{let i=r.prev,s=r.next.next;!My(i,s)&&oP(i,r,r.next,s)&&gp(i,s)&&gp(s,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),yp(r),yp(r.next),r=n=s),r=r.next}while(r!==n);return Sc(r)}function m4(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&E4(o,a)){let l=aP(o,a);o=Sc(o,o.next),l=Sc(l,l.next),mp(o,t,e,r,i,s,0),mp(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function g4(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=sP(n,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(A4(c));for(i.sort(y4),s=0;s<i.length;s++)e=v4(i[s],e);return e}function y4(n,t){return n.x-t.x}function v4(n,t){let e=x4(n,t);if(!e)return t;let r=aP(e,n);return Sc(r,r.next),Sc(e,e.next)}function x4(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&&Du(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),gp(e,n)&&(h<u||h===u&&(e.x>i.x||e.x===i.x&&b4(i,e)))&&(i=e,u=h)),e=e.next;while(e!==a);return i}function b4(n,t){return zr(n.prev,n,t.prev)<0&&zr(t.next,n,n.next)<0}function S4(n,t,e,r){let i=n;do i.z===0&&(i.z=lw(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,w4(i)}function w4(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 lw(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 A4(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 Du(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 E4(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!M4(n,t)&&(gp(n,t)&&gp(t,n)&&T4(n,t)&&(zr(n.prev,n,t.prev)||zr(n,t.prev,t))||My(n,t)&&zr(n.prev,n,n.next)>0&&zr(t.prev,t,t.next)>0)}function zr(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function My(n,t){return n.x===t.x&&n.y===t.y}function oP(n,t,e,r){let i=Gg(zr(n,t,e)),s=Gg(zr(n,t,r)),o=Gg(zr(e,r,n)),a=Gg(zr(e,r,t));return!!(i!==s&&o!==a||i===0&&kg(n,e,t)||s===0&&kg(n,r,t)||o===0&&kg(e,n,r)||a===0&&kg(e,t,r))}function kg(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 Gg(n){return n>0?1:n<0?-1:0}function M4(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&&oP(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function gp(n,t){return zr(n.prev,n,n.next)<0?zr(n,t,n.next)>=0&&zr(n,n.prev,t)>=0:zr(n,t,n.prev)<0||zr(n,n.next,t)<0}function T4(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 aP(n,t){let e=new cw(n.i,n.x,n.y),r=new cw(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 DC(n,t,e,r){let i=new cw(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 yp(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 cw(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 C4(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 Uu=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 Uu.area(t)<0}static triangulateShape(t,e){let r=[],i=[],s=[];IC(t),OC(r,t);let o=t.length;e.forEach(IC);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,OC(r,e[l]);let a=h4.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function IC(n){let t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function OC(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}var zu=class extends Fu{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 zu(t.radius,t.detail)}};var Ls=class extends _e{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=[],p=[],m=[],g=[];for(let y=0;y<=r;y++){let v=[],x=y/r,S=0;y==0&&o==0?S=.5/e:y==r&&l==Math.PI&&(S=-.5/e);for(let w=0;w<=e;w++){let A=w/e;h.x=-t*Math.cos(i+A*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(i+A*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(A+S,1-x),v.push(c++)}u.push(v)}for(let y=0;y<r;y++)for(let v=0;v<e;v++){let x=u[y][v+1],S=u[y][v],w=u[y+1][v],A=u[y+1][v+1];(y!==0||o>0)&&f.push(x,S,A),(y!==r-1||l<Math.PI)&&f.push(S,w,A)}this.setIndex(f),this.setAttribute("position",new Me(p,3)),this.setAttribute("normal",new Me(m,3)),this.setAttribute("uv",new Me(g,2))}static fromJSON(t){return new Ls(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var ku=class extends _e{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 p=0;p<=i;p++){let m=p/i*s,g=f/r*Math.PI*2;h.x=(t+e*Math.cos(g))*Math.cos(m),h.y=(t+e*Math.cos(g))*Math.sin(m),h.z=e*Math.sin(g),a.push(h.x,h.y,h.z),u.x=t*Math.cos(m),u.y=t*Math.sin(m),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(p/i),c.push(f/r)}for(let f=1;f<=r;f++)for(let p=1;p<=i;p++){let m=(i+1)*f+p-1,g=(i+1)*(f-1)+p-1,y=(i+1)*(f-1)+p,v=(i+1)*f+p;o.push(m,g,v),o.push(g,y,v)}this.setIndex(o),this.setAttribute("position",new Me(a,3)),this.setAttribute("normal",new Me(l,3)),this.setAttribute("uv",new Me(c,2))}static fromJSON(t){return new ku(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},Gu=class extends _e{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,p=new E,m=new E,g=new E,y=new E;for(let x=0;x<=r;++x){let S=x/r*s*Math.PI*2;v(S,s,o,t,f),v(S+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,M=-e*Math.cos(A),b=e*Math.sin(A);h.x=f.x+(M*y.x+b*m.x),h.y=f.y+(M*y.y+b*m.y),h.z=f.z+(M*y.z+b*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(x/r),u.push(w/i)}}for(let x=1;x<=r;x++)for(let S=1;S<=i;S++){let w=(i+1)*(x-1)+(S-1),A=(i+1)*x+(S-1),M=(i+1)*x+S,b=(i+1)*(x-1)+S;a.push(w,A,b),a.push(A,M,b)}this.setIndex(a),this.setAttribute("position",new Me(l,3)),this.setAttribute("normal",new Me(c,3)),this.setAttribute("uv",new Me(u,2));function v(x,S,w,A,M){let b=Math.cos(x),T=Math.sin(x),C=w/S*x,P=Math.cos(C);M.x=A*(2+P)*.5*b,M.y=A*(2+P)*T*.5,M.z=A*Math.sin(C)*.5}}static fromJSON(t){return new Gu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Ya(n,t,e){return lP(n)?new n.constructor(n.subarray(t,e!==void 0?e:n.length)):n.slice(t,e)}function jg(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 lP(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function P4(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 RC(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 cP(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 ju=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_(){}},uw=class extends ju{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:Cu,endingEnd:Cu}}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 Pu:s=t,a=2*e-r;break;case Kg: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 Pu:o=t,l=2*r-e;break;case Kg: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,p=(r-e)/(i-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,S=f*g-f*m;for(let w=0;w!==a;++w)s[w]=y*o[u+w]+v*o[c+w]+x*o[l+w]+S*o[h+w];return s}},cy=class extends ju{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}},hw=class extends ju{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t){return this.copySampleValue_(t-1)}},as=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=jg(e,this.TimeBufferType),this.values=jg(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:jg(t.times,Array),values:jg(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(r.interpolation=i)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new hw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new cy(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new uw(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Xg:e=this.InterpolantFactoryMethodDiscrete;break;case Qg:e=this.InterpolantFactoryMethodLinear;break;case cS: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 Xg;case this.InterpolantFactoryMethodLinear:return Qg;case this.InterpolantFactoryMethodSmooth:return cS}}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=Ya(r,s,o),this.values=Ya(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&&lP(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=Ya(this.times),e=Ya(this.values),r=this.getValueSize(),i=this.getInterpolation()===cS,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 p=0;p!==r;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){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=Ya(t,0,o),this.values=Ya(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Ya(this.times,0),e=Ya(this.values,0),r=this.constructor,i=new r(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};as.prototype.TimeBufferType=Float32Array;as.prototype.ValueBufferType=Float32Array;as.prototype.DefaultInterpolation=Qg;var il=class extends as{};il.prototype.ValueTypeName="bool";il.prototype.ValueBufferType=Array;il.prototype.DefaultInterpolation=Xg;il.prototype.InterpolantFactoryMethodLinear=void 0;il.prototype.InterpolantFactoryMethodSmooth=void 0;var uy=class extends as{};uy.prototype.ValueTypeName="color";var Hu=class extends as{};Hu.prototype.ValueTypeName="number";var dw=class extends ju{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)Qe.slerpFlat(s,0,o,c-a,o,c,l);return s}},wc=class extends as{InterpolantFactoryMethodLinear(t){return new dw(this.times,this.values,this.getValueSize(),t)}};wc.prototype.ValueTypeName="quaternion";wc.prototype.DefaultInterpolation=Qg;wc.prototype.InterpolantFactoryMethodSmooth=void 0;var nl=class extends as{};nl.prototype.ValueTypeName="string";nl.prototype.ValueBufferType=Array;nl.prototype.DefaultInterpolation=Xg;nl.prototype.InterpolantFactoryMethodLinear=void 0;nl.prototype.InterpolantFactoryMethodSmooth=void 0;var Wu=class extends as{};Wu.prototype.ValueTypeName="vector";var qu=class{constructor(t,e=-1,r,i=Mw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=i,this.uuid=is(),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(D4(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(as.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=P4(l);l=RC(l,1,u),c=RC(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Hu(".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,p,m){if(f.length!==0){let g=[],y=[];cP(f,g,y,p),g.length!==0&&m.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={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}i.push(new Hu(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(Wu,f+".position",d,"pos",i),r(wc,f+".quaternion",d,"rot",i),r(Wu,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 _4(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Hu;case"vector":case"vector2":case"vector3":case"vector4":return Wu;case"color":return uy;case"quaternion":return wc;case"bool":case"boolean":return il;case"string":return nl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function D4(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=_4(n.type);if(n.times===void 0){let e=[],r=[];cP(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 hy={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={}}},vp=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],p=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},I4=new vp,sl=class{constructor(t){this.manager=t!==void 0?t:I4,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}},sa={},fw=class extends Error{constructor(t,e){super(t),this.response=e}},Yu=class extends sl{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=hy.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(sa[t]!==void 0){sa[t].push({onLoad:e,onProgress:r,onError:i});return}sa[t]=[],sa[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=sa[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:S})=>{if(x)y.close();else{m+=S.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,M=u.length;A<M;A++){let b=u[A];b.onProgress&&b.onProgress(w)}y.enqueue(S),v()}})}}});return new Response(g)}else throw new fw(`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(p=>f.decode(p))}}}).then(c=>{hy.add(t,c);let u=sa[t];delete sa[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=sa[t];if(u===void 0)throw this.manager.itemError(t),c;delete sa[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 pw=class extends sl{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=hy.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=lp("img");function l(){u(),hy.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 dy=class extends sl{constructor(t){super(t)}load(t,e,r,i){let s=new $t,o=new pw(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}},ol=class extends Mt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new We(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}},fy=class extends ol{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new We(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},VS=new ue,LC=new E,BC=new E,xp=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 up,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;LC.setFromMatrixPosition(t.matrixWorld),e.position.copy(LC),BC.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(BC),e.updateMatrixWorld(),VS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(VS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(VS)}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}},mw=class extends xp{constructor(){super(new $r(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=ap*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}},py=class extends ol{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(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new mw}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}},NC=new ue,Jf=new E,US=new E,gw=class extends xp{constructor(){super(new $r(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()),Jf.setFromMatrixPosition(t.matrixWorld),r.position.copy(Jf),US.copy(r.position),US.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(US),r.updateMatrixWorld(),i.makeTranslation(-Jf.x,-Jf.y,-Jf.z),NC.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(NC)}},my=class extends ol{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 gw}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}},yw=class extends xp{constructor(){super(new $a(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},gy=class extends ol{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.shadow=new yw}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var bp=class extends _e{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}},Xu=class extends sl{constructor(t){super(t)}load(t,e,r,i){let s=this,o=new Yu(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,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=xg(g.type,y),x=new sy(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return r[p]=y,y}let o=t.isInstancedBufferGeometry?new bp:new _e,a=t.data.index;if(a!==void 0){let f=xg(a.type,a.array);o.setIndex(new Xe(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=i(t.data,p.data);m=new mc(g,p.itemSize,p.offset,p.normalized)}else{let g=xg(p.type,p.array),y=p.isInstancedBufferAttribute?fo:Xe;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let c=t.data.morphAttributes;if(c)for(let f in c){let p=c[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let S=i(t.data,v.data);x=new mc(S,v.itemSize,v.offset,v.normalized)}else{let S=xg(v.type,v.array);x=new Xe(S,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}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,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.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 Or(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var yy=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=FC(),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=FC();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function FC(){return(typeof performance>"u"?Date:performance).now()}var vw=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){Qe.slerpFlat(t,e,t,e,t,r,i)}_slerpAdditive(t,e,r,i,s){let o=this._workIndex*s;Qe.multiplyQuaternionsFlat(t,o,t,e,t,r),Qe.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}}},Iw="\\[\\]\\.:\\/",O4=new RegExp("["+Iw+"]","g"),Ow="[^"+Iw+"]",R4="[^"+Iw.replace("\\.","")+"]",L4=/((?:WC+[\/:])*)/.source.replace("WC",Ow),B4=/(WCOD+)?/.source.replace("WCOD",R4),N4=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ow),F4=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ow),V4=new RegExp("^"+L4+B4+N4+F4+"$"),U4=["material","materials","bones","map"],xw=class{constructor(t,e,r){let i=r||Zt.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()}},Zt=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Zt.parseTrackName(e),this.node=Zt.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 Zt.Composite(t,e,r):new Zt(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(O4,"")}static parseTrackName(t){let e=V4.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);U4.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=Zt.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}};Zt.Composite=xw;Zt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Zt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Zt.prototype.GetterByBindingType=[Zt.prototype._getValue_direct,Zt.prototype._getValue_array,Zt.prototype._getValue_arrayElement,Zt.prototype._getValue_toArray];Zt.prototype.SetterByBindingTypeAndVersioning=[[Zt.prototype._setValue_direct,Zt.prototype._setValue_direct_setNeedsUpdate,Zt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_array,Zt.prototype._setValue_array_setNeedsUpdate,Zt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_arrayElement,Zt.prototype._setValue_arrayElement_setNeedsUpdate,Zt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_fromArray,Zt.prototype._setValue_fromArray_setNeedsUpdate,Zt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var bw=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:Cu,endingEnd:Cu};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=Ew,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 $F:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Mw: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===wp;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(r===Aw){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=Pu,i.endingEnd=Pu):(t?i.endingStart=this.zeroSlopeAtStart?Pu:Cu:i.endingStart=Kg,e?i.endingEnd=this.zeroSlopeAtEnd?Pu:Cu:i.endingEnd=Kg)}_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}},z4=new Float32Array(1),vy=class extends pr{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,p=u[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new vw(Zt.create(r,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.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 cy(new Float32Array(2),new Float32Array(2),1,z4),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"?qu.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=Mw),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 bw(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"?qu.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))}},le=class{constructor(t){this.value=t}clone(){return new le(this.value.clone===void 0?this.value:this.value.clone())}};var Qu=class{constructor(t,e,r=0,i=1/0){this.ray=new Rs(t,e),this.near=r,this.far=i,this.camera=null,this.layers=new cp,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 Sw(t,this,r,e),r.sort(VC),r}intersectObjects(t,e=!0,r=[]){for(let i=0,s=t.length;i<s;i++)Sw(t[i],this,r,e);return r.sort(VC),r}};function VC(n,t){return n.distance-t.distance}function Sw(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++)Sw(i[s],t,e,!0)}}var Sp=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(di(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var UC=new U,Ku=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=UC.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 UC.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)}},zC=new E,Hg=new E,Mi=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){zC.subVectors(t,this.start),Hg.subVectors(this.end,this.start);let r=Hg.dot(Hg),s=Hg.dot(zC)/r;return e&&(s=di(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)}},kC=new E,xy=class extends Mt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new _e,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 Me(i,3));let s=new ss({fog:!1,toneMapped:!1});this.cone=new tl(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),kC.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(kC),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var by=class extends Ut{constructor(t,e,r){let i=new Ls(e,4,2),s=new on({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 GC=new E,Wg=new E,jC=new E,Sy=class extends Mt{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 _e;i.setAttribute("position",new Me([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new ss({fog:!1,toneMapped:!1});this.lightPlane=new gc(i,s),this.add(this.lightPlane),i=new _e,i.setAttribute("position",new Me([0,0,0,0,0,1],3)),this.targetLine=new gc(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),GC.setFromMatrixPosition(this.light.matrixWorld),Wg.setFromMatrixPosition(this.light.target.matrixWorld),jC.subVectors(Wg,GC),this.lightPlane.lookAt(Wg),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(Wg),this.targetLine.scale.z=jC.length()}},qg=new E,Wr=new qn,al=class extends tl{constructor(t){let e=new _e,r=new ss({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(p,m){l(p),l(m)}function l(p){i.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(i.length/3-1)}e.setAttribute("position",new Me(i,3)),e.setAttribute("color",new Me(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 We(16755200),u=new We(16711680),h=new We(43775),d=new We(16777215),f=new We(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;Wr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Jr("c",e,t,Wr,0,0,-1),Jr("t",e,t,Wr,0,0,1),Jr("n1",e,t,Wr,-r,-i,-1),Jr("n2",e,t,Wr,r,-i,-1),Jr("n3",e,t,Wr,-r,i,-1),Jr("n4",e,t,Wr,r,i,-1),Jr("f1",e,t,Wr,-r,-i,1),Jr("f2",e,t,Wr,r,-i,1),Jr("f3",e,t,Wr,-r,i,1),Jr("f4",e,t,Wr,r,i,1),Jr("u1",e,t,Wr,r*.7,i*1.1,-1),Jr("u2",e,t,Wr,-r*.7,i*1.1,-1),Jr("u3",e,t,Wr,0,i*2,-1),Jr("cf1",e,t,Wr,-r,0,1),Jr("cf2",e,t,Wr,r,0,1),Jr("cf3",e,t,Wr,0,-i,1),Jr("cf4",e,t,Wr,0,i,1),Jr("cn1",e,t,Wr,-r,0,-1),Jr("cn2",e,t,Wr,r,0,-1),Jr("cn3",e,t,Wr,0,-i,-1),Jr("cn4",e,t,Wr,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Jr(n,t,e,r,i,s,o){qg.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],qg.x,qg.y,qg.z)}}var ll=class extends tl{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 _e;s.setIndex(new Xe(r,1)),s.setAttribute("position",new Me(i,3)),super(s,new ss({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 wy=class extends tl{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 _e;i.setAttribute("position",new Me(e,3)),i.setAttribute("color",new Me(r,3));let s=new ss({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,r){let i=new We,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 oa=k4();function k4(){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 G4(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=di(n,-65504,65504),oa.floatView[0]=n;let t=oa.uint32View[0],e=t>>23&511;return oa.baseTable[e]+((t&8388607)>>oa.shiftTable[e])}function j4(n){let t=n>>10;return oa.uint32View[0]=oa.mantissaTable[oa.offsetTable[t]+(n&1023)]+oa.exponentTable[t],oa.floatView[0]}var uP=Object.freeze({__proto__:null,fromHalfFloat:j4,toHalfFloat:G4});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ca}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ca);var eh=".",Ap=Symbol("target"),Rw=Symbol("unsubscribe");function Ep(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function hP(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var Qn=Array.isArray;function Ac(n){return typeof n=="symbol"}var H4={after:(n,t)=>Qn(n)?n.slice(t.length):t===""?n:n.slice(t.length+1),concat:(n,t)=>Qn(n)?(n=[...n],t&&n.push(t),n):t&&t.toString!==void 0?(n!==""&&(n+=eh),Ac(t)?n+t.toString():n+t):n,initial:n=>{if(Qn(n))return n.slice(0,-1);if(n==="")return n;let t=n.lastIndexOf(eh);return t===-1?"":n.slice(0,t)},last:n=>{if(Qn(n))return n[n.length-1]||"";if(n==="")return n;let t=n.lastIndexOf(eh);return t===-1?n:n.slice(t+1)},walk:(n,t)=>{if(Qn(n))for(let e of n)t(e);else if(n!==""){let e=0,r=n.indexOf(eh);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(eh,e)}},get(n,t){return this.walk(t,e=>{n&&(n=n[e])}),n}},gn=H4;function Lw(n){return typeof n=="object"&&typeof n.next=="function"}function Bw(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[Ap].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 Ty(n,t,e){return n.isUnsubscribed||t.ignoreSymbols&&Ac(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Mp=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,gn.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 th(n){return toString.call(n)==="[object Object]"}function rh(){return!0}function cl(n,t){return n.length!==t.length||n.some((e,r)=>t[r]!==e)}var Cy=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var W4=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Nw={push:rh,pop:rh,shift:rh,unshift:rh,copyWithin:cl,reverse:cl,sort:cl,splice:cl,flat:cl,fill:cl},dP=new Set([...Cy,...W4,...Object.keys(Nw)]);function ih(n,t){if(n.size!==t.size)return!0;for(let e of n)if(!t.has(e))return!0;return!1}var Fw=["keys","values","entries"],Vw=new Set(["has","toString"]),Uw={add:ih,clear:ih,delete:ih,forEach:ih},fP=new Set([...Vw,...Object.keys(Uw),...Fw]);function nh(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 q4=new Set([...Vw,"get"]),zw={set:nh,clear:nh,delete:nh,forEach:nh},pP=new Set([...q4,...Object.keys(zw),...Fw]);var Ni=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 Cy.has(t)}_shallowClone(t){let e=t;if(th(t))e={...t};else if(Qn(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?(Qn(i)?this._onIsChanged=Nw[e]:i instanceof Set?this._onIsChanged=Uw[e]:i instanceof Map&&(this._onIsChanged=zw[e]),i):r}update(t,e,r){let i=gn.after(t,this._path);if(e!=="length"){let s=this.clone;gn.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],gn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var sh=class extends Ni{static isHandledMethod(t){return dP.has(t)}};var Tp=class extends Ni{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var oh=class extends Ni{static isHandledMethod(t){return fP.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 ah=class extends Ni{static isHandledMethod(t){return pP.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 Cp=class extends Ni{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 Pp=class extends Ni{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 Ns=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return th(t)||Qn(t)||Ep(t)}static isHandledMethod(t,e){return th(t)?Ni.isHandledMethod(e):Qn(t)?sh.isHandledMethod(e):t instanceof Set?oh.isHandledMethod(e):t instanceof Map?ah.isHandledMethod(e):Ep(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let i=Ni;Qn(t)?i=sh:t instanceof Date?i=Tp:t instanceof Set?i=oh:t instanceof Map?i=ah:t instanceof WeakSet?i=Cp:t instanceof WeakMap&&(i=Pp),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=Ns.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 Y4={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},kw=(n,t,e={})=>{e={...Y4,...e};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new Mp(i),c=typeof e.onValidate=="function",u=new Ns(c),h=(v,x,S,w,A)=>!c||u.isCloning||e.onValidate(gn.concat(l.getPath(v),x),S,w,A)===!0,d=(v,x,S,w)=>{!Ty(l,e,x)&&!(o&&l.isDetached(v,n))&&f(l.getPath(v),x,S,w)},f=(v,x,S,w,A)=>{u.isCloning?u.update(v,x,w):t(gn.concat(v,x),S,w,A)},p=v=>v&&(v[r]||v),m=(v,x,S,w)=>hP(v)||S==="constructor"||s&&!Ns.isHandledMethod(x,S)||Ty(l,e,S)||l.isGetInvariant(x,S)||o&&l.isDetached(x,n)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,gn.concat(w,S),g,r)),g={get(v,x,S){if(Ac(x)){if(x===r||x===Ap)return v;if(x===Rw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=Ep(v)?Reflect.get(v,x):Reflect.get(v,x,S);return m(w,v,x)},set(v,x,S,w){S=p(S);let A=v[r]||v,M=A[x];if(i(M,S)&&x in v)return!0;let b=h(v,x,S,M);return b&&l.setProperty(A,x,S,w,M)?(d(v,x,v[x],M),!0):!b},defineProperty(v,x,S){if(!l.isSameDescriptor(S,v,x)){let w=v[x];h(v,x,S.value,w)&&l.defineProperty(v,x,S,w)&&d(v,x,S.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let S=Reflect.get(v,x),w=h(v,x,void 0,S);return w&&l.deleteProperty(v,x,S)?(d(v,x,void 0,S),!0):!w},apply(v,x,S){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,S);if((a===!1||a!==!0&&!a.includes(v.name))&&Ns.isHandledType(w)){let A=gn.initial(l.getPath(v)),M=Ns.isHandledMethod(w,v.name);u.start(w,A,S);let b=Reflect.apply(v,u.preferredThisArg(v,x,w),M?S.map(P=>p(P)):S),T=u.isChanged(w,i),C=u.stop();if(Ns.isHandledType(b)&&M&&(x instanceof Map&&v.name==="get"&&(A=gn.concat(A,S[0])),b=l.getProxy(b,A,g)),T){let P={name:v.name,args:S,result:b},D=u.isCloning?gn.initial(A):A,_=u.isCloning?gn.last(A):"";h(gn.get(n,D),_,w,C,P)?f(D,_,w,C,P):u.undo(w)}return(x instanceof Map||x instanceof Set)&&Lw(b)?Bw(b,v,x,A,m):b}return Reflect.apply(v,x,S)}},y=l.getProxy(n,e.pathAsArray?[]:"",g);return t=t.bind(y),c&&(e.onValidate=e.onValidate.bind(y)),y};kw.target=n=>n&&n[Ap]||n;kw.unsubscribe=n=>n[Rw]||n;var Gw=kw;var X4=typeof global=="object"&&global&&global.Object===Object&&global,Py=X4;var Q4=typeof self=="object"&&self&&self.Object===Object&&self,K4=Py||Q4||Function("return this")(),Yr=K4;var Z4=Yr.Symbol,Fi=Z4;var mP=Object.prototype,J4=mP.hasOwnProperty,$4=mP.toString,_p=Fi?Fi.toStringTag:void 0;function ej(n){var t=J4.call(n,_p),e=n[_p];try{n[_p]=void 0;var r=!0}catch{}var i=$4.call(n);return r&&(t?n[_p]=e:delete n[_p]),i}var gP=ej;var tj=Object.prototype,rj=tj.toString;function ij(n){return rj.call(n)}var yP=ij;var nj="[object Null]",sj="[object Undefined]",vP=Fi?Fi.toStringTag:void 0;function oj(n){return n==null?n===void 0?sj:nj:vP&&vP in Object(n)?gP(n):yP(n)}var Kn=oj;function aj(n){return n!=null&&typeof n=="object"}var Wi=aj;var lj="[object Symbol]";function cj(n){return typeof n=="symbol"||Wi(n)&&Kn(n)==lj}var po=cj;function uj(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 _y=uj;var hj=Array.isArray,Ti=hj;var dj=1/0,xP=Fi?Fi.prototype:void 0,bP=xP?xP.toString:void 0;function SP(n){if(typeof n=="string")return n;if(Ti(n))return _y(n,SP)+"";if(po(n))return bP?bP.call(n):"";var t=n+"";return t=="0"&&1/n==-dj?"-0":t}var wP=SP;var fj=/\s/;function pj(n){for(var t=n.length;t--&&fj.test(n.charAt(t)););return t}var AP=pj;var mj=/^\s+/;function gj(n){return n&&n.slice(0,AP(n)+1).replace(mj,"")}var EP=gj;function yj(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var yi=yj;var MP=0/0,vj=/^[-+]0x[0-9a-f]+$/i,xj=/^0b[01]+$/i,bj=/^0o[0-7]+$/i,Sj=parseInt;function wj(n){if(typeof n=="number")return n;if(po(n))return MP;if(yi(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=yi(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=EP(n);var e=xj.test(n);return e||bj.test(n)?Sj(n.slice(2),e?2:8):vj.test(n)?MP:+n}var jw=wj;function Aj(n){return n}var Dy=Aj;var Ej="[object AsyncFunction]",Mj="[object Function]",Tj="[object GeneratorFunction]",Cj="[object Proxy]";function Pj(n){if(!yi(n))return!1;var t=Kn(n);return t==Mj||t==Tj||t==Ej||t==Cj}var Iy=Pj;var _j=Yr["__core-js_shared__"],Oy=_j;var TP=function(){var n=/[^.]+$/.exec(Oy&&Oy.keys&&Oy.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Dj(n){return!!TP&&TP in n}var CP=Dj;var Ij=Function.prototype,Oj=Ij.toString;function Rj(n){if(n!=null){try{return Oj.call(n)}catch{}try{return n+""}catch{}}return""}var ua=Rj;var Lj=/[\\^$.*+?()[\]{}|]/g,Bj=/^\[object .+?Constructor\]$/,Nj=Function.prototype,Fj=Object.prototype,Vj=Nj.toString,Uj=Fj.hasOwnProperty,zj=RegExp("^"+Vj.call(Uj).replace(Lj,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function kj(n){if(!yi(n)||CP(n))return!1;var t=Iy(n)?zj:Bj;return t.test(ua(n))}var PP=kj;function Gj(n,t){return n?.[t]}var _P=Gj;function jj(n,t){var e=_P(n,t);return PP(e)?e:void 0}var Cn=jj;var Hj=Cn(Yr,"WeakMap"),Ry=Hj;var DP=Object.create,Wj=function(){function n(){}return function(t){if(!yi(t))return{};if(DP)return DP(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),IP=Wj;function qj(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 OP=qj;function Yj(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var RP=Yj;var Xj=800,Qj=16,Kj=Date.now;function Zj(n){var t=0,e=0;return function(){var r=Kj(),i=Qj-(r-e);if(e=r,i>0){if(++t>=Xj)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var LP=Zj;function Jj(n){return function(){return n}}var BP=Jj;var $j=function(){try{var n=Cn(Object,"defineProperty");return n({},"",{}),n}catch{}}(),lh=$j;var eH=lh?function(n,t){return lh(n,"toString",{configurable:!0,enumerable:!1,value:BP(t),writable:!0})}:Dy,NP=eH;var tH=LP(NP),FP=tH;function rH(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var VP=rH;var iH=9007199254740991,nH=/^(?:0|[1-9]\d*)$/;function sH(n,t){var e=typeof n;return t=t??iH,!!t&&(e=="number"||e!="symbol"&&nH.test(n))&&n>-1&&n%1==0&&n<t}var ch=sH;function oH(n,t,e){t=="__proto__"&&lh?lh(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Ly=oH;function aH(n,t){return n===t||n!==n&&t!==t}var uh=aH;var lH=Object.prototype,cH=lH.hasOwnProperty;function uH(n,t,e){var r=n[t];(!(cH.call(n,t)&&uh(r,e))||e===void 0&&!(t in n))&&Ly(n,t,e)}var hh=uH;function hH(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?Ly(e,a,l):hh(e,a,l)}return e}var mo=hH;var UP=Math.max;function dH(n,t,e){return t=UP(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,s=UP(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),OP(n,this,a)}}var zP=dH;var fH=9007199254740991;function pH(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=fH}var dh=pH;function mH(n){return n!=null&&dh(n.length)&&!Iy(n)}var By=mH;var gH=Object.prototype;function yH(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||gH;return n===e}var fh=yH;function vH(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var kP=vH;var xH="[object Arguments]";function bH(n){return Wi(n)&&Kn(n)==xH}var Hw=bH;var GP=Object.prototype,SH=GP.hasOwnProperty,wH=GP.propertyIsEnumerable,AH=Hw(function(){return arguments}())?Hw:function(n){return Wi(n)&&SH.call(n,"callee")&&!wH.call(n,"callee")},ph=AH;function EH(){return!1}var jP=EH;var qP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,HP=qP&&typeof module=="object"&&module&&!module.nodeType&&module,MH=HP&&HP.exports===qP,WP=MH?Yr.Buffer:void 0,TH=WP?WP.isBuffer:void 0,CH=TH||jP,Ec=CH;var PH="[object Arguments]",_H="[object Array]",DH="[object Boolean]",IH="[object Date]",OH="[object Error]",RH="[object Function]",LH="[object Map]",BH="[object Number]",NH="[object Object]",FH="[object RegExp]",VH="[object Set]",UH="[object String]",zH="[object WeakMap]",kH="[object ArrayBuffer]",GH="[object DataView]",jH="[object Float32Array]",HH="[object Float64Array]",WH="[object Int8Array]",qH="[object Int16Array]",YH="[object Int32Array]",XH="[object Uint8Array]",QH="[object Uint8ClampedArray]",KH="[object Uint16Array]",ZH="[object Uint32Array]",Dr={};Dr[jH]=Dr[HH]=Dr[WH]=Dr[qH]=Dr[YH]=Dr[XH]=Dr[QH]=Dr[KH]=Dr[ZH]=!0;Dr[PH]=Dr[_H]=Dr[kH]=Dr[DH]=Dr[GH]=Dr[IH]=Dr[OH]=Dr[RH]=Dr[LH]=Dr[BH]=Dr[NH]=Dr[FH]=Dr[VH]=Dr[UH]=Dr[zH]=!1;function JH(n){return Wi(n)&&dh(n.length)&&!!Dr[Kn(n)]}var YP=JH;function $H(n){return function(t){return n(t)}}var mh=$H;var XP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dp=XP&&typeof module=="object"&&module&&!module.nodeType&&module,e5=Dp&&Dp.exports===XP,Ww=e5&&Py.process,t5=function(){try{var n=Dp&&Dp.require&&Dp.require("util").types;return n||Ww&&Ww.binding&&Ww.binding("util")}catch{}}(),ha=t5;var QP=ha&&ha.isTypedArray,r5=QP?mh(QP):YP,Ny=r5;var i5=Object.prototype,n5=i5.hasOwnProperty;function s5(n,t){var e=Ti(n),r=!e&&ph(n),i=!e&&!r&&Ec(n),s=!e&&!r&&!i&&Ny(n),o=e||r||i||s,a=o?kP(n.length,String):[],l=a.length;for(var c in n)(t||n5.call(n,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ch(c,l)))&&a.push(c);return a}var Fy=s5;function o5(n,t){return function(e){return n(t(e))}}var Vy=o5;var a5=Vy(Object.keys,Object),KP=a5;var l5=Object.prototype,c5=l5.hasOwnProperty;function u5(n){if(!fh(n))return KP(n);var t=[];for(var e in Object(n))c5.call(n,e)&&e!="constructor"&&t.push(e);return t}var ZP=u5;function h5(n){return By(n)?Fy(n):ZP(n)}var gh=h5;function d5(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var JP=d5;var f5=Object.prototype,p5=f5.hasOwnProperty;function m5(n){if(!yi(n))return JP(n);var t=fh(n),e=[];for(var r in n)r=="constructor"&&(t||!p5.call(n,r))||e.push(r);return e}var $P=m5;function g5(n){return By(n)?Fy(n,!0):$P(n)}var ls=g5;var y5=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,v5=/^\w*$/;function x5(n,t){if(Ti(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||po(n)?!0:v5.test(n)||!y5.test(n)||t!=null&&n in Object(t)}var e_=x5;var b5=Cn(Object,"create"),da=b5;function S5(){this.__data__=da?da(null):{},this.size=0}var t_=S5;function w5(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var r_=w5;var A5="__lodash_hash_undefined__",E5=Object.prototype,M5=E5.hasOwnProperty;function T5(n){var t=this.__data__;if(da){var e=t[n];return e===A5?void 0:e}return M5.call(t,n)?t[n]:void 0}var i_=T5;var C5=Object.prototype,P5=C5.hasOwnProperty;function _5(n){var t=this.__data__;return da?t[n]!==void 0:P5.call(t,n)}var n_=_5;var D5="__lodash_hash_undefined__";function I5(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=da&&t===void 0?D5:t,this}var s_=I5;function yh(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])}}yh.prototype.clear=t_;yh.prototype.delete=r_;yh.prototype.get=i_;yh.prototype.has=n_;yh.prototype.set=s_;var qw=yh;function O5(){this.__data__=[],this.size=0}var o_=O5;function R5(n,t){for(var e=n.length;e--;)if(uh(n[e][0],t))return e;return-1}var ul=R5;var L5=Array.prototype,B5=L5.splice;function N5(n){var t=this.__data__,e=ul(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():B5.call(t,e,1),--this.size,!0}var a_=N5;function F5(n){var t=this.__data__,e=ul(t,n);return e<0?void 0:t[e][1]}var l_=F5;function V5(n){return ul(this.__data__,n)>-1}var c_=V5;function U5(n,t){var e=this.__data__,r=ul(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var u_=U5;function vh(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])}}vh.prototype.clear=o_;vh.prototype.delete=a_;vh.prototype.get=l_;vh.prototype.has=c_;vh.prototype.set=u_;var hl=vh;var z5=Cn(Yr,"Map"),dl=z5;function k5(){this.size=0,this.__data__={hash:new qw,map:new(dl||hl),string:new qw}}var h_=k5;function G5(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var d_=G5;function j5(n,t){var e=n.__data__;return d_(t)?e[typeof t=="string"?"string":"hash"]:e.map}var fl=j5;function H5(n){var t=fl(this,n).delete(n);return this.size-=t?1:0,t}var f_=H5;function W5(n){return fl(this,n).get(n)}var p_=W5;function q5(n){return fl(this,n).has(n)}var m_=q5;function Y5(n,t){var e=fl(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var g_=Y5;function xh(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])}}xh.prototype.clear=h_;xh.prototype.delete=f_;xh.prototype.get=p_;xh.prototype.has=m_;xh.prototype.set=g_;var Mc=xh;var X5="Expected a function";function Yw(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(X5);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(Yw.Cache||Mc),e}Yw.Cache=Mc;var y_=Yw;var Q5=500;function K5(n){var t=y_(n,function(r){return e.size===Q5&&e.clear(),r}),e=t.cache;return t}var v_=K5;var Z5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,J5=/\\(\\)?/g,$5=v_(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(Z5,function(e,r,i,s){t.push(i?s.replace(J5,"$1"):r||e)}),t}),x_=$5;function eW(n){return n==null?"":wP(n)}var b_=eW;function tW(n,t){return Ti(n)?n:e_(n,t)?[n]:x_(b_(n))}var cs=tW;var rW=1/0;function iW(n){if(typeof n=="string"||po(n))return n;var t=n+"";return t=="0"&&1/n==-rW?"-0":t}var pl=iW;function nW(n,t){t=cs(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[pl(t[e++])];return e&&e==r?n:void 0}var Uy=nW;function sW(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var bh=sW;var S_=Fi?Fi.isConcatSpreadable:void 0;function oW(n){return Ti(n)||ph(n)||!!(S_&&n&&n[S_])}var w_=oW;function A_(n,t,e,r,i){var s=-1,o=n.length;for(e||(e=w_),i||(i=[]);++s<o;){var a=n[s];t>0&&e(a)?t>1?A_(a,t-1,e,r,i):bh(i,a):r||(i[i.length]=a)}return i}var E_=A_;function aW(n){var t=n==null?0:n.length;return t?E_(n,1):[]}var M_=aW;function lW(n){return FP(zP(n,void 0,M_),n+"")}var zy=lW;var cW=Vy(Object.getPrototypeOf,Object),Sh=cW;var uW="[object Object]",hW=Function.prototype,dW=Object.prototype,T_=hW.toString,fW=dW.hasOwnProperty,pW=T_.call(Object);function mW(n){if(!Wi(n)||Kn(n)!=uW)return!1;var t=Sh(n);if(t===null)return!0;var e=fW.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&T_.call(e)==pW}var C_=mW;function gW(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 P_=gW;function yW(){this.__data__=new hl,this.size=0}var __=yW;function vW(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var D_=vW;function xW(n){return this.__data__.get(n)}var I_=xW;function bW(n){return this.__data__.has(n)}var O_=bW;var SW=200;function wW(n,t){var e=this.__data__;if(e instanceof hl){var r=e.__data__;if(!dl||r.length<SW-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Mc(r)}return e.set(n,t),this.size=e.size,this}var R_=wW;function wh(n){var t=this.__data__=new hl(n);this.size=t.size}wh.prototype.clear=__;wh.prototype.delete=D_;wh.prototype.get=I_;wh.prototype.has=O_;wh.prototype.set=R_;var Ah=wh;function AW(n,t){return n&&mo(t,gh(t),n)}var L_=AW;function EW(n,t){return n&&mo(t,ls(t),n)}var B_=EW;var U_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,N_=U_&&typeof module=="object"&&module&&!module.nodeType&&module,MW=N_&&N_.exports===U_,F_=MW?Yr.Buffer:void 0,V_=F_?F_.allocUnsafe:void 0;function TW(n,t){if(t)return n.slice();var e=n.length,r=V_?V_(e):new n.constructor(e);return n.copy(r),r}var z_=TW;function CW(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 k_=CW;function PW(){return[]}var ky=PW;var _W=Object.prototype,DW=_W.propertyIsEnumerable,G_=Object.getOwnPropertySymbols,IW=G_?function(n){return n==null?[]:(n=Object(n),k_(G_(n),function(t){return DW.call(n,t)}))}:ky,Eh=IW;function OW(n,t){return mo(n,Eh(n),t)}var j_=OW;var RW=Object.getOwnPropertySymbols,LW=RW?function(n){for(var t=[];n;)bh(t,Eh(n)),n=Sh(n);return t}:ky,Gy=LW;function BW(n,t){return mo(n,Gy(n),t)}var H_=BW;function NW(n,t,e){var r=t(n);return Ti(n)?r:bh(r,e(n))}var jy=NW;function FW(n){return jy(n,gh,Eh)}var Ip=FW;function VW(n){return jy(n,ls,Gy)}var Hy=VW;var UW=Cn(Yr,"DataView"),Wy=UW;var zW=Cn(Yr,"Promise"),qy=zW;var kW=Cn(Yr,"Set"),Yy=kW;var W_="[object Map]",GW="[object Object]",q_="[object Promise]",Y_="[object Set]",X_="[object WeakMap]",Q_="[object DataView]",jW=ua(Wy),HW=ua(dl),WW=ua(qy),qW=ua(Yy),YW=ua(Ry),Tc=Kn;(Wy&&Tc(new Wy(new ArrayBuffer(1)))!=Q_||dl&&Tc(new dl)!=W_||qy&&Tc(qy.resolve())!=q_||Yy&&Tc(new Yy)!=Y_||Ry&&Tc(new Ry)!=X_)&&(Tc=function(n){var t=Kn(n),e=t==GW?n.constructor:void 0,r=e?ua(e):"";if(r)switch(r){case jW:return Q_;case HW:return W_;case WW:return q_;case qW:return Y_;case YW:return X_}return t});var fa=Tc;var XW=Object.prototype,QW=XW.hasOwnProperty;function KW(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&QW.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var K_=KW;var ZW=Yr.Uint8Array,Mh=ZW;function JW(n){var t=new n.constructor(n.byteLength);return new Mh(t).set(new Mh(n)),t}var Th=JW;function $W(n,t){var e=t?Th(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Z_=$W;var e6=/\w*$/;function t6(n){var t=new n.constructor(n.source,e6.exec(n));return t.lastIndex=n.lastIndex,t}var J_=t6;var $_=Fi?Fi.prototype:void 0,e2=$_?$_.valueOf:void 0;function r6(n){return e2?Object(e2.call(n)):{}}var t2=r6;function i6(n,t){var e=t?Th(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var r2=i6;var n6="[object Boolean]",s6="[object Date]",o6="[object Map]",a6="[object Number]",l6="[object RegExp]",c6="[object Set]",u6="[object String]",h6="[object Symbol]",d6="[object ArrayBuffer]",f6="[object DataView]",p6="[object Float32Array]",m6="[object Float64Array]",g6="[object Int8Array]",y6="[object Int16Array]",v6="[object Int32Array]",x6="[object Uint8Array]",b6="[object Uint8ClampedArray]",S6="[object Uint16Array]",w6="[object Uint32Array]";function A6(n,t,e){var r=n.constructor;switch(t){case d6:return Th(n);case n6:case s6:return new r(+n);case f6:return Z_(n,e);case p6:case m6:case g6:case y6:case v6:case x6:case b6:case S6:case w6:return r2(n,e);case o6:return new r;case a6:case u6:return new r(n);case l6:return J_(n);case c6:return new r;case h6:return t2(n)}}var i2=A6;function E6(n){return typeof n.constructor=="function"&&!fh(n)?IP(Sh(n)):{}}var n2=E6;var M6="[object Map]";function T6(n){return Wi(n)&&fa(n)==M6}var s2=T6;var o2=ha&&ha.isMap,C6=o2?mh(o2):s2,a2=C6;var P6="[object Set]";function _6(n){return Wi(n)&&fa(n)==P6}var l2=_6;var c2=ha&&ha.isSet,D6=c2?mh(c2):l2,u2=D6;var I6=1,O6=2,R6=4,h2="[object Arguments]",L6="[object Array]",B6="[object Boolean]",N6="[object Date]",F6="[object Error]",d2="[object Function]",V6="[object GeneratorFunction]",U6="[object Map]",z6="[object Number]",f2="[object Object]",k6="[object RegExp]",G6="[object Set]",j6="[object String]",H6="[object Symbol]",W6="[object WeakMap]",q6="[object ArrayBuffer]",Y6="[object DataView]",X6="[object Float32Array]",Q6="[object Float64Array]",K6="[object Int8Array]",Z6="[object Int16Array]",J6="[object Int32Array]",$6="[object Uint8Array]",e8="[object Uint8ClampedArray]",t8="[object Uint16Array]",r8="[object Uint32Array]",Pr={};Pr[h2]=Pr[L6]=Pr[q6]=Pr[Y6]=Pr[B6]=Pr[N6]=Pr[X6]=Pr[Q6]=Pr[K6]=Pr[Z6]=Pr[J6]=Pr[U6]=Pr[z6]=Pr[f2]=Pr[k6]=Pr[G6]=Pr[j6]=Pr[H6]=Pr[$6]=Pr[e8]=Pr[t8]=Pr[r8]=!0;Pr[F6]=Pr[d2]=Pr[W6]=!1;function Xy(n,t,e,r,i,s){var o,a=t&I6,l=t&O6,c=t&R6;if(e&&(o=i?e(n,r,i,s):e(n)),o!==void 0)return o;if(!yi(n))return n;var u=Ti(n);if(u){if(o=K_(n),!a)return RP(n,o)}else{var h=fa(n),d=h==d2||h==V6;if(Ec(n))return z_(n,a);if(h==f2||h==h2||d&&!i){if(o=l||d?{}:n2(n),!a)return l?H_(n,B_(o,n)):j_(n,L_(o,n))}else{if(!Pr[h])return i?n:{};o=i2(n,h,a)}}s||(s=new Ah);var f=s.get(n);if(f)return f;s.set(n,o),u2(n)?n.forEach(function(g){o.add(Xy(g,t,e,g,n,s))}):a2(n)&&n.forEach(function(g,y){o.set(y,Xy(g,t,e,y,n,s))});var p=c?l?Hy:Ip:l?ls:gh,m=u?void 0:p(n);return VP(m||n,function(g,y){m&&(y=g,g=n[y]),hh(o,y,Xy(g,t,e,y,n,s))}),o}var Qy=Xy;var i8=1,n8=4;function s8(n){return Qy(n,i8|n8)}var pa=s8;var o8="__lodash_hash_undefined__";function a8(n){return this.__data__.set(n,o8),this}var p2=a8;function l8(n){return this.__data__.has(n)}var m2=l8;function Ky(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Mc;++t<e;)this.add(n[t])}Ky.prototype.add=Ky.prototype.push=p2;Ky.prototype.has=m2;var g2=Ky;function c8(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 y2=c8;function u8(n,t){return n.has(t)}var v2=u8;var h8=1,d8=2;function f8(n,t,e,r,i,s){var o=e&h8,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&d8?new g2:void 0;for(s.set(n,t),s.set(t,n);++h<a;){var p=n[h],m=t[h];if(r)var g=o?r(m,p,h,t,n,s):r(p,m,h,n,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!y2(t,function(y,v){if(!v2(f,v)&&(p===y||i(p,y,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||i(p,m,e,r,s))){d=!1;break}}return s.delete(n),s.delete(t),d}var Zy=f8;function p8(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var x2=p8;function m8(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var b2=m8;var g8=1,y8=2,v8="[object Boolean]",x8="[object Date]",b8="[object Error]",S8="[object Map]",w8="[object Number]",A8="[object RegExp]",E8="[object Set]",M8="[object String]",T8="[object Symbol]",C8="[object ArrayBuffer]",P8="[object DataView]",S2=Fi?Fi.prototype:void 0,Xw=S2?S2.valueOf:void 0;function _8(n,t,e,r,i,s,o){switch(e){case P8:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case C8:return!(n.byteLength!=t.byteLength||!s(new Mh(n),new Mh(t)));case v8:case x8:case w8:return uh(+n,+t);case b8:return n.name==t.name&&n.message==t.message;case A8:case M8:return n==t+"";case S8:var a=x2;case E8:var l=r&g8;if(a||(a=b2),n.size!=t.size&&!l)return!1;var c=o.get(n);if(c)return c==t;r|=y8,o.set(n,t);var u=Zy(a(n),a(t),r,i,s,o);return o.delete(n),u;case T8:if(Xw)return Xw.call(n)==Xw.call(t)}return!1}var w2=_8;var D8=1,I8=Object.prototype,O8=I8.hasOwnProperty;function R8(n,t,e,r,i,s){var o=e&D8,a=Ip(n),l=a.length,c=Ip(t),u=c.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:O8.call(t,d)))return!1}var f=s.get(n),p=s.get(t);if(f&&p)return f==t&&p==n;var m=!0;s.set(n,t),s.set(t,n);for(var g=o;++h<l;){d=a[h];var y=n[d],v=t[d];if(r)var x=o?r(v,y,d,t,n,s):r(y,v,d,n,t,s);if(!(x===void 0?y===v||i(y,v,e,r,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var S=n.constructor,w=t.constructor;S!=w&&"constructor"in n&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof w=="function"&&w instanceof w)&&(m=!1)}return s.delete(n),s.delete(t),m}var A2=R8;var L8=1,E2="[object Arguments]",M2="[object Array]",Jy="[object Object]",B8=Object.prototype,T2=B8.hasOwnProperty;function N8(n,t,e,r,i,s){var o=Ti(n),a=Ti(t),l=o?M2:fa(n),c=a?M2:fa(t);l=l==E2?Jy:l,c=c==E2?Jy:c;var u=l==Jy,h=c==Jy,d=l==c;if(d&&Ec(n)){if(!Ec(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new Ah),o||Ny(n)?Zy(n,t,e,r,i,s):w2(n,t,l,e,r,i,s);if(!(e&L8)){var f=u&&T2.call(n,"__wrapped__"),p=h&&T2.call(t,"__wrapped__");if(f||p){var m=f?n.value():n,g=p?t.value():t;return s||(s=new Ah),i(m,g,e,r,s)}}return d?(s||(s=new Ah),A2(n,t,e,r,i,s)):!1}var C2=N8;function P2(n,t,e,r,i){return n===t?!0:n==null||t==null||!Wi(n)&&!Wi(t)?n!==n&&t!==t:C2(n,t,e,r,P2,i)}var _2=P2;function F8(n,t){return n!=null&&t in Object(n)}var D2=F8;function V8(n,t,e){t=cs(t,n);for(var r=-1,i=t.length,s=!1;++r<i;){var o=pl(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&&dh(i)&&ch(o,i)&&(Ti(n)||ph(n)))}var I2=V8;function U8(n,t){return n!=null&&I2(n,t,D2)}var O2=U8;var z8=function(){return Yr.Date.now()},$y=z8;var k8="Expected a function",G8=Math.max,j8=Math.min;function H8(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(k8);t=jw(t)||0,yi(e)&&(u=!!e.leading,h="maxWait"in e,s=h?G8(jw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var M=r,b=i;return r=i=void 0,c=A,o=n.apply(b,M),o}function p(A){return c=A,a=setTimeout(y,t),u?f(A):o}function m(A){var M=A-l,b=A-c,T=t-M;return h?j8(T,s-b):T}function g(A){var M=A-l,b=A-c;return l===void 0||M>=t||M<0||h&&b>=s}function y(){var A=$y();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function S(){return a===void 0?o:v($y())}function w(){var A=$y(),M=g(A);if(r=arguments,i=this,l=A,M){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=S,w}var go=H8;function W8(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var R2=W8;function q8(n,t){return n>t}var L2=q8;function Y8(n,t){return t.length<2?n:Uy(n,P_(t,0,-1))}var B2=Y8;function X8(n,t){return _2(n,t)}var Cc=X8;function Q8(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&&!po(o):e(o,a)))var a=o,l=s}return l}var N2=Q8;function K8(n){return n&&n.length?N2(n,Dy,L2):void 0}var Qw=K8;function Z8(n,t){return t=cs(t,n),n=B2(n,t),n==null||delete n[pl(R2(t))]}var F2=Z8;function J8(n){return C_(n)?void 0:n}var V2=J8;var $8=1,eq=2,tq=4,rq=zy(function(n,t){var e={};if(n==null)return e;var r=!1;t=_y(t,function(s){return s=cs(s,n),r||(r=s.length>1),s}),mo(n,Hy(n),e),r&&(e=Qy(e,$8|eq|tq,V2));for(var i=t.length;i--;)F2(e,t[i]);return e}),Ch=rq;function iq(n,t,e,r){if(!yi(n))return n;t=cs(t,n);for(var i=-1,s=t.length,o=s-1,a=n;a!=null&&++i<s;){var l=pl(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=yi(u)?u:ch(t[i+1])?[]:{})}hh(a,l,c),a=a[l]}return n}var U2=iq;function nq(n,t,e){for(var r=-1,i=t.length,s={};++r<i;){var o=t[r],a=Uy(n,o);e(a,o)&&U2(s,cs(o,n),a)}return s}var z2=nq;function sq(n,t){return z2(n,t,function(e,r){return O2(n,r)})}var k2=sq;var oq=zy(function(n,t){return n==null?{}:k2(n,t)}),Pn=oq;var aq="Expected a function";function lq(n,t,e){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(aq);return yi(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),go(n,t,{leading:r,maxWait:t,trailing:i})}var Kw=lq;function ev(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function qi(n,t){return Object.setPrototypeOf(n,t),n}var cq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),uq=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),hq=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ph&&"ontouchend"in document,dq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,fq=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,pq=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},mq=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},gq=()=>{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"},Zw=cq(),mce=Zw?gq():void 0,Ph=uq(),yo=hq(),G2=dq(),Ci=fq(),Jw=pq(),j2=Number(mq());function tv(n){return Array.isArray(n)?n:[n]}function rv(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 Op(n){return Ph?n.metaKey:n.ctrlKey}function H2(n){return n.wheelDeltaY===0||n.deltaY===0?Ph&&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 Je=[],nv={},Rp={},iv={};function W2(n){Je.includes(n)||Je.push(n)}function _h(n){delete nv[n.pointerId];for(let t=0;t<Je.length;t++)if(Je[t].pointerId===n.pointerId){Je.splice(t,1);break}}function q2(){Je.splice(0,Je.length)}function sv(n){if(n.pointerType!=="touch")return;let t=nv[n.pointerId];t===void 0&&(t={x:0,y:0},nv[n.pointerId]=t),t.x=n.pageX,t.y=n.pageY}function ov(n){let t=n.pointerId===Je[0].pointerId?Je[1]:Je[0];return nv[t.pointerId]}function Y2(n){Rp[n.key]=!0,iv[n.key]=iv[n.key]===void 0?1:iv[n.key]+1}function X2(n){if(Ph&&Rp.Meta)for(let t in Rp)Rp[t]=!1;else Rp[n.key]=!1;iv={}}function Q2(n){n.addEventListener("pointerdown",W2,!0),n.addEventListener("pointerdown",sv,!0),n.addEventListener("pointermove",sv,!0),n.addEventListener("pointerup",_h,!0),n.addEventListener("pointercancel",_h,!0),n.addEventListener("pointerleave",_h,!0),window.addEventListener("keydown",Y2,!0),window.addEventListener("keyup",X2,!0)}function K2(n){n.removeEventListener("pointerdown",W2,!0),n.removeEventListener("pointerdown",sv,!0),n.removeEventListener("pointermove",sv,!0),n.removeEventListener("pointerup",_h,!0),n.removeEventListener("pointercancel",_h,!0),n.removeEventListener("pointerleave",_h,!0),window.removeEventListener("keydown",Y2,!0),window.removeEventListener("keyup",X2,!0)}var Z2,J2=new Promise(n=>{Z2=n});var av;function $2(){if(av)return av;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.9.32/build",i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});Z2(l)}return av=n(),av}var eD,tD=new Promise(n=>{eD=n});var lv;function rD(){if(lv)return lv;async function n(){let e=await import("./physics.js");await e.init(),eD(e)}return lv=n(),lv}var Ke=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,Ke.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,Ke.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,Ke.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:i}}}}return null}};function Lp(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"&&Lp(r)}return Object.freeze(n)}function iD(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 Dh=class extends Error{};function cv(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function vo(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 Ih(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 nD(){return typeof process<"u"}function sD(n,t){for(let e of n)t(e.id,e.data)!==!0&&sD(e.children,t)}function oD(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)oD(e,t)}var gr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,gr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lp(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&&oD(i,r)}}traverse(e){sD(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,gr.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 Dh("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,p)=>f.fi-p.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)=>iD(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 vo(0,i,i);{let o=s[0].fi;return vo(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 vo(l,l+i,i)}else return vo(o.fi,a.fi,i)}}};var Oh;(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})(Oh||(Oh={}));var Ue=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ue.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lp(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,Ue.prototype);let r=e;return nD()||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 vo(0,r,r);{let s=i[0].fi;return vo(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 vo(a,a+r,r)}else return vo(s.fi,o.fi,r)}}};function Rh(n){return n&&typeof n=="object"&&n instanceof yr}var yr=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&&!Rh(r))return null;i+=1}r=r?cv(r):new yr;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=cv(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=cv(l);c[t.path[i-1]]=r,r=c}else{let c=new yr;c[t.path[i-1]]=r,r=c}}i-=1}let o=Object.setPrototypeOf(r,yr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},xo;(r=>{function n(i,s){return Bp(i,s)??i}r.apply=n;function t(i,s){return e1(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=Sr.zoomOnce(l,a[o]),l===void 0)return s;if(!Rh(l))return;o+=1}if(l===void 0)return s;if(!!Rh(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=$w([s],l);return c?(console.log(c),c):s}else return s}r.filterOp=e})(xo||(xo={}));function $w(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=Bp(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=$w(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 yq(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=Bp(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 Bp(n,t){if(!Rh(t))return t;if(n instanceof gr){let e=$w(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Ue)return yq(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,s)=>{let o=Bp(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 yr)return e1(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,s]of Object.entries(n)){let o=Bp(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 e1(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!Rh(t))return t;if(!Rh(n))return xo.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 yr;for(let i of e){let s=e1(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=s}return r}function aD(n,t){let e={cur:[],result:[],len:0};return n=Np(n,t,e)??n,[n,e.result]}function uv(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function hv(n){n&&(n.len-=1)}function vq(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function lD(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=Np(s.data,t,uv(e,o));hv(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=lD(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 xq(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=Np(s.data,t,uv(e,o));return hv(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 Np(n,t,e){if(n instanceof gr){let r=lD(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof Ue)return xq(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((s,o)=>{let a=Np(s,t,uv(e,o));return hv(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"&&!Ih(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=Np(o,t,uv(e,s));hv(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&&vq(e),r}else return}}var Lh;(t=>{function n(e,r){let i=Sr.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})(Lh||(Lh={}));var Lr;(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 yr&&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 gr||l instanceof Ue||l instanceof Ke?d=l.runOp(c):d=Oh.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=u[g],v=h[g];if(v instanceof gr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Ue){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Ke){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof yr){let x={...v,[y]:m};m=Object.setPrototypeOf(x,yr.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],p;if(l instanceof gr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Ue){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;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})(Lr||(Lr={}));var Fp;(l=>{function n(){return[]}l.empty=n;function t(c,u){let h=[];for(let d of c){let[f,...p]=d.path;f===u&&h.push({...d,path:p})}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=>Lr.subsumed(d,f))),...u]}l.compress=i;function s(c,u){return c.every(h=>u.every(d=>Lr.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 p of u)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Sr.zoom(h,[...p.path,p.id]),y=Lr.apply(h,{...p,type:2})):(m=Sr.zoom(h,[...p.path,p.id,"value"]),y=Lr.apply(h,p)),y!==null){h=y.data;let[v,x]=aD(h,{[p.id]:m});h=v;for(let S=0;S<x.length;S++){let w=x[S],A=w.pop();if(typeof A=="number"){let M=[A];for(let T=S+1;T<x.length;T++){let C=x[T],P=C[C.length-1];if(typeof P=="number"&&Sr.equal(w,C.slice(0,C.length-1)))M.push(P),x.splice(T,1);else break}let b=Sr.zoom(h,w);g=b.map((T,C)=>M.includes(C)?p.id:T),m=b,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let M=m,b=Sr.zoom(h,w.slice(0,w.length-2)),T=b.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:M}}:C);Object.setPrototypeOf(T,Object.getPrototypeOf(b.layers)),b.layers=T}g=p.id}d.push({type:0,path:w,props:{[A]:m}}),f.push({type:0,path:w,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Lr.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Dh)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(Fp||(Fp={}));var cD=Symbol(),bq=Symbol(),fv=Symbol(),Pc=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let s=r;for(;!(i instanceof dv);){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[fv];r&&r(),delete this._children[t]}}}},r1=class extends Pc{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 this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Oh.runOp(this._current,t),t.path)}},i1=class extends Pc{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,Ke.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},uD={get(n,t){if(t===fv)return()=>{n._parent=null};if(t===cD)return n._current;if(t===bq)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=pv(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]}}},Sq={...uD,set(n,t,e){let r={type:0,props:{[t]:kr(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}},wq={...uD,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}},Bh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fv]=()=>{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=pv(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)}},Nh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[fv]=()=>{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=pv(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 t1(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Sr.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var dv=class extends Pc{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){t1(this.ts,e,t),t1(this.actual,r,t),t1(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function pv(n,t,e){return e instanceof gr?new Bh(n,t,e):e instanceof Ue?new Nh(n,t,e):e instanceof Ke?new Proxy(new i1(n,t,e),wq):e!==null&&typeof e=="object"?Ih(e)?e:new Proxy(new r1(n,t,e),Sq):e}function n1(n){let t=new dv(n);return[pv(t,"",n),t]}function ml(n,t){let[e,r]=n1(n);return t(e),r.result()}function kr(n){return n instanceof Bh||n instanceof Nh?n._current:n!==null&&typeof n=="object"?n[cD]:n}var Sr;(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 gr||s instanceof Bh)&&typeof o=="string")return s.data(o);if((s instanceof Ue||s instanceof Nh)&&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})(Sr||(Sr={}));function hD(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 Lt(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 mv=class{},Vp=class extends mv{constructor(e){super();this.id=e}},Up=class extends mv{constructor(e){super();this.data=e}};var o1;try{o1=new TextDecoder}catch{}var qe,yl,ne=0;var xD=[],a1=xD,l1=0,_n={},Qt,gl,us=0,bo=0,Zn,ma,yn=[],nr,dD={useRecords:!1,mapsAsObjects:!0},zp=class{},u1=new zp;u1.name="MessagePack 0xC1";var Fh=!1,So=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(qe)return ED(()=>(yv(),this?this.unpack(t,e):So.prototype.unpack.call(dD,t,e)));yl=e>-1?e:t.length,ne=0,l1=0,bo=0,gl=null,a1=xD,Zn=null,qe=t;try{nr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw qe=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 So){if(_n=this,this.structures)return Qt=this.structures,gv();(!Qt||Qt.length>0)&&(Qt=[])}else _n=dD,(!Qt||Qt.length>0)&&(Qt=[]);return gv()}unpackMultiple(t,e){let r,i=0;try{Fh=!0;let s=t.length,o=this?this.unpack(t,s):bv.unpack(t,s);if(e){for(e(o);ne<s;)if(i=ne,e(gv())===!1)return}else{for(r=[o];ne<s;)i=ne,r.push(gv());return r}}catch(s){throw s.lastPosition=i,s.values=r,s}finally{Fh=!1,yv()}}_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 gv(){try{if(!_n.trusted&&!Fh){let t=Qt.sharedLength||0;t<Qt.length&&(Qt.length=t)}let n=Xr();if(ne==yl)Qt.restoreStructures&&fD(),Qt=null,qe=null,ma&&(ma=null);else if(ne>yl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Fh)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Qt.restoreStructures&&fD(),yv(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function fD(){for(let n in Qt.restoreStructures)Qt[n]=Qt.restoreStructures[n];Qt.restoreStructures=null}function Xr(){let n=qe[ne++];if(n<160)if(n<128){if(n<64)return n;{let t=Qt[n&63]||_n.getStructures&&bD()[n&63];return t?(t.read||(t.read=h1(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,_n.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[wD()]=Xr();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Xr(),Xr());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=Xr();return t}else if(n<192){let t=n-160;if(bo>=ne)return gl.slice(ne-us,(ne+=t)-us);if(bo==0&&yl<140){let e=t<16?d1(t):SD(t);if(e!=null)return e}return c1(t)}else{let t;switch(n){case 192:return null;case 193:return Zn?(t=Xr(),t>0?Zn[1].slice(Zn.position1,Zn.position1+=t):Zn[0].slice(Zn.position0,Zn.position0-=t)):u1;case 194:return!1;case 195:return!0;case 196:return s1(qe[ne++]);case 197:return t=nr.getUint16(ne),ne+=2,s1(t);case 198:return t=nr.getUint32(ne),ne+=4,s1(t);case 199:return _c(qe[ne++]);case 200:return t=nr.getUint16(ne),ne+=2,_c(t);case 201:return t=nr.getUint32(ne),ne+=4,_c(t);case 202:if(t=nr.getFloat32(ne),_n.useFloat32>2){let e=xv[(qe[ne]&127)<<1|qe[ne+1]>>7];return ne+=4,(e*t+(t>0?.5:-.5)>>0)/e}return ne+=4,t;case 203:return t=nr.getFloat64(ne),ne+=8,t;case 204:return qe[ne++];case 205:return t=nr.getUint16(ne),ne+=2,t;case 206:return t=nr.getUint32(ne),ne+=4,t;case 207:return _n.int64AsNumber?(t=nr.getUint32(ne)*4294967296,t+=nr.getUint32(ne+4)):t=nr.getBigUint64(ne),ne+=8,t;case 208:return nr.getInt8(ne++);case 209:return t=nr.getInt16(ne),ne+=2,t;case 210:return t=nr.getInt32(ne),ne+=4,t;case 211:return _n.int64AsNumber?(t=nr.getInt32(ne)*4294967296,t+=nr.getUint32(ne+4)):t=nr.getBigInt64(ne),ne+=8,t;case 212:if(t=qe[ne++],t==114)return vD(qe[ne++]&63);{let e=yn[t];if(e)return e.read?(ne++,e.read(Xr())):e.noBuffer?(ne++,e()):e(qe.subarray(ne,++ne));throw new Error("Unknown extension "+t)}case 213:return t=qe[ne],t==114?(ne++,vD(qe[ne++]&63,qe[ne++])):_c(2);case 214:return _c(4);case 215:return _c(8);case 216:return _c(16);case 217:return t=qe[ne++],bo>=ne?gl.slice(ne-us,(ne+=t)-us):Eq(t);case 218:return t=nr.getUint16(ne),ne+=2,bo>=ne?gl.slice(ne-us,(ne+=t)-us):Mq(t);case 219:return t=nr.getUint32(ne),ne+=4,bo>=ne?gl.slice(ne-us,(ne+=t)-us):Tq(t);case 220:return t=nr.getUint16(ne),ne+=2,mD(t);case 221:return t=nr.getUint32(ne),ne+=4,mD(t);case 222:return t=nr.getUint16(ne),ne+=2,gD(t);case 223:return t=nr.getUint32(ne),ne+=4,gD(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 Aq=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function h1(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>Aq.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Xr);return n.highByte===0&&(n.read=pD(t,n.read)),i()}let r={};for(let i=0,s=n.length;i<s;i++){let o=n[i];r[o]=Xr()}return r}return e.count=0,n.highByte===0?pD(t,e):e}var pD=(n,t)=>function(){let e=qe[ne++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Qt[r]||bD()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=h1(i,n)),i.read()};function bD(){let n=ED(()=>(qe=null,_n.getStructures()));return Qt=_n._mergeStructures(n,Qt)}var c1=vv,Eq=vv,Mq=vv,Tq=vv;function vv(n){let t;if(n<16&&(t=d1(n)))return t;if(n>64&&o1)return o1.decode(qe.subarray(ne,ne+=n));let e=ne+n,r=[];for(t="";ne<e;){let i=qe[ne++];if((i&128)===0)r.push(i);else if((i&224)===192){let s=qe[ne++]&63;r.push((i&31)<<6|s)}else if((i&240)===224){let s=qe[ne++]&63,o=qe[ne++]&63;r.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=qe[ne++]&63,o=qe[ne++]&63,a=qe[ne++]&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+=Vi.apply(String,r),r.length=0)}return r.length>0&&(t+=Vi.apply(String,r)),t}function mD(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=Xr();return t}function gD(n){if(_n.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[wD()]=Xr();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Xr(),Xr());return t}}var Vi=String.fromCharCode;function SD(n){let t=ne,e=new Array(n);for(let r=0;r<n;r++){let i=qe[ne++];if((i&128)>0){ne=t;return}e[r]=i}return Vi.apply(String,e)}function d1(n){if(n<4)if(n<2){if(n===0)return"";{let t=qe[ne++];if((t&128)>1){ne-=1;return}return Vi(t)}}else{let t=qe[ne++],e=qe[ne++];if((t&128)>0||(e&128)>0){ne-=2;return}if(n<3)return Vi(t,e);let r=qe[ne++];if((r&128)>0){ne-=3;return}return Vi(t,e,r)}else{let t=qe[ne++],e=qe[ne++],r=qe[ne++],i=qe[ne++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){ne-=4;return}if(n<6){if(n===4)return Vi(t,e,r,i);{let s=qe[ne++];if((s&128)>0){ne-=5;return}return Vi(t,e,r,i,s)}}else if(n<8){let s=qe[ne++],o=qe[ne++];if((s&128)>0||(o&128)>0){ne-=6;return}if(n<7)return Vi(t,e,r,i,s,o);let a=qe[ne++];if((a&128)>0){ne-=7;return}return Vi(t,e,r,i,s,o,a)}else{let s=qe[ne++],o=qe[ne++],a=qe[ne++],l=qe[ne++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){ne-=8;return}if(n<10){if(n===8)return Vi(t,e,r,i,s,o,a,l);{let c=qe[ne++];if((c&128)>0){ne-=9;return}return Vi(t,e,r,i,s,o,a,l,c)}}else if(n<12){let c=qe[ne++],u=qe[ne++];if((c&128)>0||(u&128)>0){ne-=10;return}if(n<11)return Vi(t,e,r,i,s,o,a,l,c,u);let h=qe[ne++];if((h&128)>0){ne-=11;return}return Vi(t,e,r,i,s,o,a,l,c,u,h)}else{let c=qe[ne++],u=qe[ne++],h=qe[ne++],d=qe[ne++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){ne-=12;return}if(n<14){if(n===12)return Vi(t,e,r,i,s,o,a,l,c,u,h,d);{let f=qe[ne++];if((f&128)>0){ne-=13;return}return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f)}}else{let f=qe[ne++],p=qe[ne++];if((f&128)>0||(p&128)>0){ne-=14;return}if(n<15)return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f,p);let m=qe[ne++];if((m&128)>0){ne-=15;return}return Vi(t,e,r,i,s,o,a,l,c,u,h,d,f,p,m)}}}}}function s1(n){return _n.copyBuffers?Uint8Array.prototype.slice.call(qe,ne,ne+=n):qe.subarray(ne,ne+=n)}function _c(n){let t=qe[ne++];if(yn[t])return yn[t](qe.subarray(ne,ne+=n));throw new Error("Unknown extension type "+t)}var yD=new Array(4096);function wD(){let n=qe[ne++];if(n>=160&&n<192){if(n=n-160,bo>=ne)return gl.slice(ne-us,(ne+=n)-us);if(!(bo==0&&yl<180))return c1(n)}else return ne--,Xr();let t=(n<<5^(n>1?nr.getUint16(ne):n>0?qe[ne]:0))&4095,e=yD[t],r=ne,i=ne+n-3,s,o=0;if(e&&e.bytes==n){for(;r<i;){if(s=nr.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(s=qe[r++],s!=e[o++]){r=1879048192;break}if(r===i)return ne=r,e.string;i-=3,r=ne}for(e=[],yD[t]=e,e.bytes=n;r<i;)s=nr.getUint32(r),e.push(s),r+=4;for(i+=3;r<i;)s=qe[r++],e.push(s);let a=n<16?d1(n):SD(n);return a!=null?e.string=a:e.string=c1(n)}var vD=(n,t)=>{var e=Xr();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Qt[n];return i&&i.isShared&&((Qt.restoreStructures||(Qt.restoreStructures=[]))[n]=i),Qt[n]=e,e.read=h1(e,r),e.read()},AD=typeof self=="object"?self:global;yn[0]=()=>{};yn[0].noBuffer=!0;yn[101]=()=>{let n=Xr();return(AD[n[0]]||Error)(n[1])};yn[105]=n=>{let t=nr.getUint32(ne-4);ma||(ma=new Map);let e=qe[ne],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};ma.set(t,i);let s=Xr();return i.used?Object.assign(r,s):(i.target=s,s)};yn[112]=n=>{let t=nr.getUint32(ne-4),e=ma.get(t);return e.used=!0,e.target};yn[115]=()=>new Set(Xr());var f1=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");yn[116]=n=>{let t=n[0],e=f1[t];if(!e)throw new Error("Could not find typed array for code "+t);return new AD[e](Uint8Array.prototype.slice.call(n,1).buffer)};yn[120]=()=>{let n=Xr();return new RegExp(n[0],n[1])};yn[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=ne;ne+=t-4,Zn=[Xr(),Xr()],Zn.position0=0,Zn.position1=0;let r=ne;ne=e;try{return Xr()}finally{ne=r}};yn[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 ED(n){let t=yl,e=ne,r=l1,i=us,s=bo,o=gl,a=a1,l=ma,c=Zn,u=new Uint8Array(qe.slice(0,yl)),h=Qt,d=Qt.slice(0,Qt.length),f=_n,p=Fh,m=n();return yl=t,ne=e,l1=r,us=i,bo=s,gl=o,a1=a,ma=l,Zn=c,qe=u,Fh=p,Qt=h,Qt.splice(0,Qt.length,...d),_n=f,nr=new DataView(qe.buffer,qe.byteOffset,qe.byteLength),m}function yv(){qe=null,ma=null,Qt=null}function MD(n){n.unpack?yn[n.type]=n.unpack:yn[n.type]=n}var xv=new Array(147);for(let n=0;n<256;n++)xv[n]=+("1e"+Math.floor(45.15-n*.30103));var bv=new So({useRecords:!1}),Cq=bv.unpack,Pq=bv.unpackMultiple,_q=bv.unpack,Sv={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Dq=new Float32Array(1),Tue=new Uint8Array(Dq.buffer,0,4);var wv;try{wv=new TextEncoder}catch{}var Av,m1,Ev=typeof Buffer<"u",p1=Ev?Buffer.allocUnsafeSlow:Uint8Array,_D=Ev?Buffer:Uint8Array,TD=Ev?4294967296:2144337920,Se,ti,he=0,wo,Ao=null,Iq=/[\u0080-\uFFFF]/,kp=Symbol("record-id"),Dc=class extends So{constructor(t){super(t),this.offset=0;let e,r,i,s,o,a,l=0,c=_D.prototype.utf8Write?function(b,T,C){return Se.utf8Write(b,T,C)}:wv&&wv.encodeInto?function(b,T){return wv.encodeInto(b,Se.subarray(T)).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 p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,S=0;this.pack=this.encode=function(b,T){if(Se||(Se=new p1(8192),ti=new DataView(Se.buffer,0,8192),he=0),wo=Se.length-10,wo-he<2048?(Se=new p1(Se.length),ti=new DataView(Se.buffer,0,Se.length),wo=Se.length-10,he=0):he=he+7&2147483640,r=he,a=u.structuredClone?new Map:null,u.bundleStrings?(Ao=["",""],Se[he++]=214,Se[he++]=98,Ao.position=he-r,he+=4):Ao=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 D=i[P];if(!D)continue;let _,I=i.transitions;for(let L=0,j=D.length;L<j;L++){let V=D[L];_=I[V],_||(_=I[V]=Object.create(null)),I=_}I[kp]=P+64}l=C}h||(i.nextId=C+64)}s&&(s=!1),o=i||[];try{if(w(b),Ao){ti.setUint32(Ao.position+r,he-Ao.position-r);let C=Ao;Ao=null,w(C[0]),w(C[1])}if(u.offset=he,a&&a.idsToInsert){he+=a.idsToInsert.length*6,he>wo&&M(he),u.offset=he;let C=Rq(Se.subarray(r,he),a.idsToInsert);return a=null,C}return T&ID?(Se.start=r,Se.end=he,Se):Se.subarray(r,he)}finally{if(i){if(S<10&&S++,x>1e4)i.transitions=null,S=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let C=0,P=v.length;C<P;C++)v[C][kp]=0;v=[]}if(s&&u.saveStructures){let C=i.sharedLength||f;i.length>C&&(i=i.slice(0,C));let P=Se.subarray(r,he);return u.saveStructures(i,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(b)):(l=C,P)}}T&zq&&(he=r)}};let w=b=>{he>wo&&(Se=M(he));var T=typeof b,C;if(T==="string"){let P=b.length;if(Ao&&P>=8&&P<4096){let I=Iq.test(b);Ao[I?0:1]+=b,Se[he++]=193,w(I?-P:P);return}let D;P<32?D=1:P<256?D=2:P<65536?D=3:D=5;let _=P*3;if(he+_>wo&&(Se=M(he+_)),P<64||!c){let I,L,j,V=he+D;for(I=0;I<P;I++)L=b.charCodeAt(I),L<128?Se[V++]=L:L<2048?(Se[V++]=L>>6|192,Se[V++]=L&63|128):(L&64512)===55296&&((j=b.charCodeAt(I+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),I++,Se[V++]=L>>18|240,Se[V++]=L>>12&63|128,Se[V++]=L>>6&63|128,Se[V++]=L&63|128):(Se[V++]=L>>12|224,Se[V++]=L>>6&63|128,Se[V++]=L&63|128);C=V-he-D}else C=c(b,he+D,_);C<32?Se[he++]=160|C:C<256?(D<2&&Se.copyWithin(he+2,he+1,he+1+C),Se[he++]=217,Se[he++]=C):C<65536?(D<3&&Se.copyWithin(he+3,he+2,he+2+C),Se[he++]=218,Se[he++]=C>>8,Se[he++]=C&255):(D<5&&Se.copyWithin(he+5,he+3,he+3+C),Se[he++]=219,ti.setUint32(he,C),he+=4),he+=C}else if(T==="number")if(b>>>0===b)b<64?Se[he++]=b:b<256?(Se[he++]=204,Se[he++]=b):b<65536?(Se[he++]=205,Se[he++]=b>>8,Se[he++]=b&255):(Se[he++]=206,ti.setUint32(he,b),he+=4);else if(b>>0===b)b>=-32?Se[he++]=256+b:b>=-128?(Se[he++]=208,Se[he++]=b+256):b>=-32768?(Se[he++]=209,ti.setInt16(he,b),he+=2):(Se[he++]=210,ti.setInt32(he,b),he+=4);else{let P;if((P=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Se[he++]=202,ti.setFloat32(he,b);let D;if(P<4||(D=b*xv[(Se[he]&127)<<1|Se[he+1]>>7])>>0===D){he+=4;return}else he--}Se[he++]=203,ti.setFloat64(he,b),he+=8}else if(T==="object")if(!b)Se[he++]=192;else{if(a){let D=a.get(b);if(D){if(!D.id){let _=a.idsToInsert||(a.idsToInsert=[]);D.id=_.push(D)}Se[he++]=214,Se[he++]=112,ti.setUint32(he,D.id),he+=4;return}else a.set(b,{offset:he-r})}let P=b.constructor;if(P===Object)A(b,!0);else if(P===Array){C=b.length,C<16?Se[he++]=144|C:C<65536?(Se[he++]=220,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=221,ti.setUint32(he,C),he+=4);for(let D=0;D<C;D++)w(b[D])}else if(P===Map){C=b.size,C<16?Se[he++]=128|C:C<65536?(Se[he++]=222,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=223,ti.setUint32(he,C),he+=4);for(let[D,_]of b)w(D),w(_)}else{for(let D=0,_=Av.length;D<_;D++){let I=m1[D];if(b instanceof I){let L=Av[D];if(L.write){L.type&&(Se[he++]=212,Se[he++]=L.type,Se[he++]=0),w(L.write.call(this,b));return}let j=Se,V=ti,H=he;Se=null;let W;try{W=L.pack.call(this,b,q=>(Se=j,j=null,he+=q,he>wo&&M(he),{target:Se,targetView:ti,position:he-q}),w)}finally{j&&(Se=j,ti=V,he=H,wo=Se.length-10)}W&&(W.length+he>wo&&M(W.length+he),he=Oq(W,Se,he,L.type));return}}A(b,!b.hasOwnProperty)}}else if(T==="boolean")Se[he++]=b?195:194;else if(T==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))Se[he++]=211,ti.setBigInt64(he,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)Se[he++]=207,ti.setBigUint64(he,b);else if(this.largeBigIntToFloat)Se[he++]=203,ti.setFloat64(he,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");he+=8}else if(T==="undefined")this.encodeUndefinedAsNil?Se[he++]=192:(Se[he++]=212,Se[he++]=0,Se[he++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},A=this.useRecords===!1?this.variableMapSize?b=>{let T=Object.keys(b),C=T.length;C<16?Se[he++]=128|C:C<65536?(Se[he++]=222,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=223,ti.setUint32(he,C),he+=4);let P;for(let D=0;D<C;D++)w(P=T[D]),w(b[P])}:(b,T)=>{Se[he++]=222;let C=he-r;he+=2;let P=0;for(let D in b)(T||b.hasOwnProperty(D))&&(w(D),w(b[D]),P++);Se[C+++r]=P>>8,Se[C+r]=P&255}:b=>{let T=Object.keys(b),C,P=o.transitions||(o.transitions=Object.create(null)),D=0;for(let I=0,L=T.length;I<L;I++){let j=T[I];C=P[j],C||(C=P[j]=Object.create(null),D++),P=C}let _=P[kp];if(_)_>=96&&m?(Se[he++]=((_-=96)&31)+96,Se[he++]=_>>5):Se[he++]=_;else{_=o.nextId,_||(_=64),_<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(_=o.nextOwnId,_<y||(_=g),o.nextOwnId=_+1):(_>=y&&(_=g),o.nextId=_+1);let I=T.highByte=_>=96&&m?_-96>>5:-1;P[kp]=_,o[_-64]=T,_<g?(T.isShared=!0,o.sharedLength=_-63,s=!0,I>=0?(Se[he++]=(_&31)+96,Se[he++]=I):Se[he++]=_):(I>=0?(Se[he++]=213,Se[he++]=114,Se[he++]=(_&31)+96,Se[he++]=I):(Se[he++]=212,Se[he++]=114,Se[he++]=_),D&&(x+=S*D),v.length>=p&&(v.shift()[kp]=0),v.push(P),w(T))}for(let I=0,L=T.length;I<L;I++)w(b[T[I]])},M=b=>{let T;if(b>16777216){if(b-r>TD)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(TD,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(b-r<<2,Se.length-1)>>12)+1<<12;let C=new p1(T);return ti=new DataView(C.buffer,0,T),Se.copy?Se.copy(C,0,r,b):C.set(Se.slice(r,b)),he-=r,r=0,wo=C.length-10,Se=C}}useBuffer(t){Se=t,ti=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),he=0}};m1=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,zp];Av=[{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?CD(n,16,t):PD(Ev?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==_D&&this.structuredClone?CD(n,f1.indexOf(e.name),t):PD(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function CD(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 PD(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 Oq(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 Rq(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 vl(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)");m1.unshift(n.Class),Av.unshift(n)}MD(n)}var DD=new Dc({useRecords:!1}),Lq=DD.pack,Bq=DD.pack;var{NEVER:Nq,ALWAYS:Fq,DECIMAL_ROUND:Vq,DECIMAL_FIT:Uq}=Sv,ID=512,zq=1024;var OD=new Dc({structuredClone:!0});vl({Class:Ke.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ke.prototype),n}});vl({Class:Ue.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Ue.prototype),n}});vl({Class:gr.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,gr.prototype),n}});vl({Class:Vp.prototype.constructor,type:4,write(n){return n.id},read(n){return new Vp(n)}});vl({Class:Up.prototype.constructor,type:5,write(n){return n.data},read(n){return new Up(n)}});vl({Class:yr.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,yr.prototype),n}});function kq(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 g1(n){if(Ih(n))return n;if(Array.isArray(n))return n.map(g1);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=g1(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var Mv;(r=>{function n(i){return OD.pack(i)}r.serialize=n;function t(i){return OD.unpack(i)}r.deserialize=t;function e(i){return kq(n(g1(i))).toString()}r.checksum=e})(Mv||(Mv={}));var RD;(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})(RD||(RD={}));function v1(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var Yi={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseHover"]:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Start"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["Conditional"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MouseUp"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["MousePress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],["KeyUp"]:["Transition","Animation","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","Audio","Particles","Create","Conditional"],["Collision"]:["Transition","Animation","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"]},LD;(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,actions:new Ue}:{type:r,disabled:!1,key:void 0,actions:new Ue}}e.defaultData=t})(LD||(LD={}));var Tv;(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(Tv||(Tv={}));var y1;(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:Tv.propertyDefaultData(i),rOperand:{...Tv.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})(y1||(y1={}));var BD;(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(BD||(BD={}));var ND;(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,inActions:new Ue,outActions:new Ue,condition:y1.distanceDefaultData(r)}}e.defaultData=t})(ND||(ND={}));var FD;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Ue,drop:new Ue}})(FD||(FD={}));var Cv;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Ue})(Cv||(Cv={}));var Pv;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Pv||(Pv={}));var VD;(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,actions:new Ue}}e.defaultData=t})(VD||(VD={}));var UD;(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Ue}}e.defaultData=t})(UD||(UD={}));var zD;(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,actions:new Ue}}e.defaultData=t})(zD||(zD={}));var kD;(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,target:"character",actions:new Ue}}e.defaultData=t})(kD||(kD={}));var GD;(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new Ue,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(GD||(GD={}));var _v;(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 Ue},l={size:"tablet",operator:"<",actions:new Ue},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new Ue},u=new Ue;return u.push({id:we.generateUUID(),fi:0,data:a},{id:we.generateUUID(),fi:1,data:l},{id:we.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:u}}o.defaultData=i;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Ue}}o.defaultBreakpointData=s})(_v||(_v={}));var Dv;(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",actions:new Ue,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(Dv||(Dv={}));var jD;(e=>{function n(r){return r.type==="API"}e.is=n;function t(){return{disabled:!1,type:"API",successActions:new Ue,errorActions:new Ue,userAPIId:""}}e.defaultData=t})(jD||(jD={}));var HD;(e=>{function n(r){return r.type==="WEBHOOK"}e.is=n;function t(){return{disabled:!1,type:"WEBHOOK",actions:new Ue,userWebhookId:""}}e.defaultData=t})(HD||(HD={}));var hs="personal camera",bl="a218fcc3-276b-49b9-b485-49037fd14f5f",XD=2960946,ii=5526619;var Fs;(f=>{function n(p,m){return p[0]===m[0]&&p[1]===m[1]}f.isEqual=n;function t(p,m,g){return[p[0]+(m[0]-p[0])*g,p[1]+(m[1]-p[1])*g]}f.lerp=t;function e(p,m){return[p[0]+m[0],p[1]+m[1]]}f.add=e;function r(p,m){return[p[0]-m[0],p[1]-m[1]]}f.sub=r;function i(p,m){return[p[0]*m[0],p[1]*m[1]]}f.multiply=i;function s(p,m){return[p[0]/m[0],p[1]/m[1]]}f.divide=s;function o(p,m){return Math.pow(m[0]-p[0],2)+Math.pow(m[1]-p[1],2)}f.distanceSquared=o;function a(p,m){return Math.sqrt(o(p,m))}f.distance=a;function l(p,m){return p[0]*m[0]+p[1]*m[1]}f.dot=l;function c(p,m){return[p[0]*m,p[1]*m]}f.scalarMultiply=c;function u(p,m,g){let y=f.sub(m,p),v=f.sub(g,p),x=f.dot(y,v)/f.dot(y,y),S=f.scalarMultiply(y,x);return f.add(p,S)}f.projectionOnto=u;function h(p,m,g){return a(p,u(p,m,g))}f.projectionOntoDistance=h;function d(p,m){return[(p[0]+m[0])*.5,(p[1]+m[1])*.5]}f.center=d})(Fs||(Fs={}));var Eo;(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})(Eo||(Eo={}));var Gp;(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})(Gp||(Gp={}));var WD;(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})(WD||(WD={}));var xl;(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})(xl||(xl={}));var ri;(h=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}h.isRGB=n,h.white={r:1,g:1,b:1},h.red={r:1,g:0,b:0},h.black={r:0,g:0,b:0};function i(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}h.toRgb255a1=i;function s(d){return{r:d.r,g:d.g,b:d.b}}h.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}h.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}h.toHex=a;function l(d,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}h.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}h.equalsFixed=c;function u(d,f,p){return{r:d.r+(f.r-d.r)*p,g:d.g+(f.g-d.g)*p,b:d.b+(f.b-d.b)*p}}h.lerp=u})(ri||(ri={}));var bt;(c=>{c.white={...ri.white,a:1},c.transparent={...ri.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function r(u,h){return{...ri.fromHex(u),a:h}}c.fromHexAndA=r;function i(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=i;function s(u,h){return ri.equals(u,h)&&u.a===h.a}c.equals=s;function o(u,h){return ri.equalsFixed(u,h)&&u.a.toFixed(2)===h.a.toFixed(2)}c.equalsFixed=o;function a(u,h,d){return{r:u.r+(h.r-u.r)*d,g:u.g+(h.g-u.g)*d,b:u.b+(h.b-u.b)*d,a:u.a+(h.a-u.a)*d}}c.lerp=a;function l({r:u,g:h,b:d,a:f}=c.white){return`rgba(${u*255}, ${h*255}, ${d*255}, ${f})`}c.toStyle=l})(bt||(bt={}));var Iv;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Iv||(Iv={}));var qD;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(qD||(qD={}));var YD;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(YD||(YD={}));var ga;(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]))(ga||(ga={}));function x1(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 Vs;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Vs||(Vs={}));var Sl;(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})(Sl||(Sl={}));var Mo;(e=>{function n(r,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*i,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function t(r,i){let s={...r};if(b1.forEach(o=>{Object.assign(s,{[o]:i[o]??r[o]})}),s.radial={...r.radial},i.radial){let o=r.radial,a=i.radial;S1.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},i.linear){let o=r.linear,a=i.linear;w1.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},i.grid){let o=r.grid,a=i.grid;A1.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},i.toObject){let o=r.toObject,a=i.toObject;E1.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},i.randomnessObject){let o=r.randomnessObject,a=i.randomnessObject;M1.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Mo||(Mo={}));var Ov;(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})(Ov||(Ov={}));var b1=["count"],S1=["radius","start","end","position","scale","rotation"],w1=["position","scale","rotation"],A1=["count","size"],E1=["count","position","scale","rotation"],M1=["strength","scale","rotation","position","movement","seed","freqScale"];var Rv;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Rv||(Rv={}));var Lv;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:bt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:bt.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:bt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Lv||(Lv={}));var Vh;(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}))(Vh||(Vh={}));var wl;(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]})(wl||(wl={}));var T1;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(T1||(T1={}));var C1;(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})(C1||(C1={}));var Bv;(t=>t.defaultData={...C1.defaultData,...T1.defaultData})(Bv||(Bv={}));var QD;(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})(QD||(QD={}));var Uh;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Uh||(Uh={}));var KD;(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})(KD||(KD={}));function JD(n){return n.type!=="displace"}var ZD;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(ZD||(ZD={}));var Nv=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],$D=["wrapping","image","video","name","minFilter","magFilter"],Gr;(i=>{function n(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let c=s.texture;c&&Object.assign(c,a)}}i.patch=n;function t(s,o){return s==="light"&&o?e(o):r(s)}i.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,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{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Uh.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...o,type:"color",color:ri.fromHex(ii)};case"depth":return{...o,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{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,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{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ri.fromHex(6710886),a:1},colorB:{...ri.fromHex(6710886),a:1},colorC:{...ri.fromHex(16777215),a:1},colorD:{...ri.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{...o,type:"fresnel",color:bt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,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:bt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:bt.fromHexAndA(0,1),contourColor:bt.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{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...o,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{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ri.fromHex(0),a:1},colorB:{...ri.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}}}})(Gr||(Gr={}));var Qr;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function t(u){let h="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,p])=>{h+=`${f}${p}`,Array.isArray(p)?p.forEach(m=>h+=`${m}`):typeof p=="object"?Object.values(p).forEach(m=>{typeof m=="number"?h+=`${m.toFixed(4)}`:h+=`${m}`}):h+=`${p}`})}),h}c.getHash=t;function e(){return{layers:new Ue}}c.defaultEmptyData=e;function r(u="layer1",h="layer2"){return s("phong",u,h)}c.defaultData=r;function i(u,h){return{...u,name:h}}c.withName=i;function s(u,h="layer1",d="layer2"){let f=new Ue;return f.push({fi:0,data:Gr.defaultData("light",u),id:h}),f.push({fi:1,data:Gr.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=s;function o(u){let h=Gr.defaultData("texture");u&&Object.assign(h.texture,{image:u});let d=new Ue;return d.push({fi:0,data:h,id:"layer1"}),d.push({fi:1,data:{...Gr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Gr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=o;function a(u,h="phong",d="layer1",f="layer2"){let p=Gr.defaultData("texture");Object.assign(p.texture,{image:u});let m=new Ue;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:Gr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerTextureData=a;function l(u,h="phong",d="layer1",f="layer2"){let p=Gr.defaultData("video");Object.assign(p.texture,{video:u});let m=new Ue;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:Gr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Qr||(Qr={}));var zh;(t=>{function n(){return{points:new Ue,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(zh||(zh={}));var kh;(t=>{function n(){return{points:new Ue,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(kh||(kh={}));var P1={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Fv;(t=>{function n(e,r){let i={...e};return _1.forEach(s=>{Object.assign(i,{[s]:r[s]??e[s]})}),i}t.merge=n})(Fv||(Fv={}));var Vv={shape:P1,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},_1=["depth","offset","angle","twist","startScale","endScale"];var jp;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"||r==="InputGeometry"}e.isParametricMesh=t})(jp||(jp={}));var Uv;(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,Fv.merge(i.extrusion,r.extrusion))),i}t.merge=n})(Uv||(Uv={}));var ya;(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:kh.defaultData(),extrusion:Vv};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:zh.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==="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})(ya||(ya={}));var zv=["width","height","depth"];var kv;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:ri.white,near:.1,far:2e3})(kv||(kv={}));var Gh;(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}}})(Gh||(Gh={}));var D1;(t=>t.defaultData={softShadowQuality:"low"})(D1||(D1={}));var I1;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(I1||(I1={}));var O1;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(O1||(O1={}));var Al;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Al||(Al={}));var R1;(t=>t.defaultData={playCamera:hs,gameControlObject:null})(R1||(R1={}));var Gv;(t=>t.defaultData={backgroundColor:bt.fromHexAndA(XD,1),postprocessing:Gh.defaultData,fog:kv.defaultData,globalPhysics:Al.defaultData,ambient:I1.defaultData,ao:O1.defaultData,shadow:D1.defaultData,publish:R1.defaultData})(Gv||(Gv={}));var jv;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(jv||(jv={}));var eI;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(eI||(eI={}));var jh;(i=>{i.identity={...Iv.identity,hiddenMatrix:xl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function r(s,o){return ev({position:Eo.isEqual(s.position,o.position)?void 0:o.position,rotation:Eo.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Eo.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:xl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=r})(jh||(jh={}));var vi;(t=>t.defaultData={states:new Ue,events:new Ue,visible:!0,raycastLock:!1,physics:wl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...jh.identity,cloner:null})(vi||(vi={}));var Hv;(t=>t.defaultData={type:"Empty",...vi.defaultData})(Hv||(Hv={}));var tI;(t=>t.defaultData={type:"ParticleCollider",...jv.defaultData,...vi.defaultData})(tI||(tI={}));var rI;(t=>t.defaultData={type:"Component",...vi.defaultData})(rI||(rI={}));var iI;(t=>t.defaultData={type:"Particle",...vi.defaultData,...Vh.defaultData})(iI||(iI={}));var El;(t=>t.defaultData={type:"Mesh",...vi.defaultData,...Bv.defaultData})(El||(El={}));var Ic;(t=>t.defaultData={...vi.defaultData,...jh.identity,position:[0,0,Sl.DefaultTargetOffset],...Sl.defaultData})(Ic||(Ic={}));var Wv;(e=>{function n(r){return{...vi.defaultData,...Lv.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Wv||(Wv={}));var Hh;(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})(Hh||(Hh={}));var To;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...vi.defaultData,...a,component:o,overrides:new yr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function i(o){let a=jh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=i})(To||(To={}));var va;(e=>{e.defaultData={type:"Page",...vi.defaultData,physics:{...wl.defaultData,fusedBody:!1},...Gv.defaultData,camera:Ic.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(va||(va={}));var qv;(o=>(o.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:xl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:wl.defaultData,states:new Ue,events:new Ue,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Sl.defaultData},o.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"]},o.defaultMeshObject={name:"Rectangle",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("RectangleGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultBooleanObject={name:"Boolean",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("BooleanGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultTextObject={name:"Text",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("TextGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")},o.defaultInputObject={name:"Input",...vi.defaultData,...El.defaultData,geometry:ya.defaultData("InputGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")}))(qv||(qv={}));var xa;(i=>{function n(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new yr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new yr})))):Vs.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=ml(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&Gr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=ml(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&&Gr.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,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,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(...Ov.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,p]of Object.entries(d))u(["materials",f],p);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,jh.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})}),Vs.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:Uv.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Mo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Mo.merge(a.cloner,o.cloner)});else if(Rv.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=ri.clone(l.color))}return a}i.patch=r})(xa||(xa={}));var Wh;(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,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})(Wh||(Wh={}));var Us;(t=>t.defaultData={orbitControls:Wh.defaultData,playPage:bl,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},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70}},stopRaycast:!0,hdTransmission:!1})(Us||(Us={}));var L1;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(L1||(L1={}));var B1;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(B1||(B1={}));var ba;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...L1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:B1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ba||(ba={}));var Ml;(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=qh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Ml||(Ml={}));var Sa;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:Wv.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,h=[]){let d=[],f=qv.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...h);let p=new gr;return p.push({fi:1,id:bl,data:{...va.defaultData,name:"Scene 1"},children:d}),p}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Us.defaultData,styles:ba.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new gr,publish:Us.defaultData,styles:ba.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Us.defaultData,styles:ba.defaultData()}},c.emptyData=function(){return{objects:new gr,publish:{...Us.defaultData},styles:ba.defaultData()}};function a(u){return{...c.defaultData,objects:qi(u,gr.prototype)}}c.withObjs=a;function l(u,h){return a([{id:u,data:h,children:[],fi:0}])}c.withObj=l})(Sa||(Sa={}));var Yh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Yh||(Yh={}));var Yv;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new Ue}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(Yv||(Yv={}));var nI;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new Ue,queries:new Ue,autoStart:!0}))(nI||(nI={}));var Br;(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})(Br||(Br={}));var N1;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(N1||(N1={}));var sI;(t=>t.all=[...N1.all,"components"])(sI||(sI={}));var oI;(t=>{function n(){return{images:new Ke,videos:new Ke,colors:new Ke,audios:new Ke,particles:new Ke,fonts:new Ke,materials:new Ke,components:new Ke,variables:new Ke,userAPIs:new Ke,userWebhooks:new Ke}}t.defaultData=n})(oI||(oI={}));var zs;(t=>{function n(){return{images:new Ke,videos:new Ke,colors:new Ke,audios:new Ke,particles:new Ke,fonts:new Ke,materials:new Ke,components:new Ke,variables:new Ke,userAPIs:new Ke,userWebhooks:new Ke}}t.defaultData=n})(zs||(zs={}));var vn;(s=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},qi(o,Ke.prototype)}s.defaultColors=n;function t(){return qi({},Ke.prototype)}s.defaultImages=t;function e(){return{catelogs:new Ke,materials:new Ke,images:new Ke,videos:new Ke,colors:new Ke,audios:new Ke,particles:new Ke,fonts:new Ke,variables:new Ue,userAPIs:new Ke,userWebhooks:new Ke,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})(vn||(vn={}));var Xh;(t=>t.list=["idle","move","jump","run"])(Xh||(Xh={}));var Qh;(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 Ue,move:new Ue,jump:new Ue,run:new Ue},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:bt.fromHexAndA(3728051,1)}}))(Qh||(Qh={}));function aI(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={...Pn(kr(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={...kr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function wa(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Aa(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,s)=>{i===void 0&&(r.materials[s]=Qr.defaultData(),i=r.materials[s]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Qr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Qr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==yr.prototype&&t(i.material)})})}function jq(n){Object.assign(n.scene.publish,{orbitControls:{...Wh.defaultData,...kr(n.scene.publish.orbitControls)}})}function Hq(n){Object.assign(n.scene.publish.settings,{video:{...Us.defaultData.settings.video,...kr(n.scene.publish.settings.video)}})}function Wq(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((Nv.includes(i)||typeof s=="boolean")&&delete r[i],i==="texture")for(let[o,a]of Object.entries(s))($D.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 qq(n){n.scene.publish.withBackground=!0}function Yq(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Xq(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 Qq(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 Kq(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=kr(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=kr(e).booleanExclude!==!0)}})}function Zq(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 Jq(n){function t(r){Object.setPrototypeOf(r,yr.prototype),r.texture&&Object.setPrototypeOf(r.texture,yr.prototype)}function e(r){Object.setPrototypeOf(r,yr.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=kr(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=kr(l).layers;e(c),l.layers=c}})})}function lI(n){n.layers===void 0&&Object.assign(n,Qr.defaultTwoLayerData("lambert"))}function F1(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={...kr(t),colors:e,steps:r};Object.assign(t,i)}})}function $q(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function cI(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&F1(r)}):"material"in e&&typeof e.material!="string"&&F1(e.material)}),Object.values(n.shared.materials).forEach(t=>F1(t))}function e9(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 t9(n){n.shared.audios=qi({},Ke.prototype)}function r9(n){n.shared.videos=qi({},Ke.prototype)}function i9(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 n9(n){Object.entries(kr(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(kr(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function s9(n){n.scene.publish.settings.web.preload=!1}function uI(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 hI(n){n.layers&&n.layers.forEach(t=>{JD(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 o9(n){n.shared.fonts=qi({},Ke.prototype)}function a9(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 l9(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let s=Qr.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=a9(i.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let l={name:i.name,...vi.defaultData,...El.defaultData,flatShading:!1,wireframe:!1,geometry:{...ya.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:kr(i.states),events:kr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=kr(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 c9(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 Ue,move:new Ue,jump:new Ue}});else{let s=new Ue;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:we.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,Pn(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 Ue({fi:0,id:we.generateUUID(),data:c},{fi:1,id:we.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function u9(n){n.scene.objects.traverse((t,e)=>{function r(i,s){let o=new Ue,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Pn(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={...Pn(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:we.generateUUID(),data:{type:i,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function dI(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Gr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function fI(n){wa(n,dI),Aa(n,dI)}function h9(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function d9(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 f9(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Qr.defaultTwoLayerData("phong"))})}function p9(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 m9(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 g9(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 y9(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function v9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function x9(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function b9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Qh.defaultDataThirdPerson.navmesh)})})}function S9(n){n.scene.styles||(n.scene.styles=ba.defaultData())}function pI(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function w9(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}),Aa(n,pI),wa(n,pI)}function A9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Ue})})})}function E9(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function mI(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function gI(n,t){if(t<1&&(Aa(n,aI),wa(n,aI),n.schema=1),t<2&&(jq(n),n.schema=2),t<3&&(Wq(n),n.schema=3),t<4&&(qq(n),n.schema=4),t<5&&(Yq(n),n.schema=5),t<6&&(Xq(n),n.schema=6),t<7&&(Qq(n),n.schema=7),t<8&&(n.schema=8),t<9&&(cI(n),n.schema=9),t<10&&($q(n),n.schema=10),t<11&&(e9(n),n.schema=11),t<12&&(cI(n),n.schema=12),t<13&&(t9(n),n.schema=13),t<14&&(i9(n),n.schema=14),t<15&&(n9(n),n.schema=15),t<16&&(s9(n),n.schema=16),t<17&&(Aa(n,uI),wa(n,uI),n.schema=17),t<18&&(Aa(n,lI),wa(n,lI),n.schema=18),t<19&&(Hq(n),n.schema=19),t<20&&(o9(n),l9(n),n.schema=20),t<21&&(c9(n),u9(n),n.schema=21),t<22&&(fI(n),n.schema=22),t<23&&(h9(n),n.schema=23),t<24&&(d9(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(r9(n),t<25&&(n.schema=25)),t<26&&(Kq(n),n.schema=26),t<27&&(Zq(n),n.schema=27),t<28&&(fI(n),n.schema=28),t<29&&(Jq(n),n.schema=29),t<30&&(f9(n),n.schema=30),t<31&&(p9(n),n.schema=31),t<33&&(m9(n),n.schema=33),t<34&&(g9(n),n.schema=34),t<35&&(y9(n),n.schema=35),t<36&&(v9(n),n.schema=36),t<37&&(x9(n),n.schema=37),t<38&&(Aa(n,hI),wa(n,hI),n.schema=38),t<39&&(b9(n),n.schema=39),t<40&&(S9(n),n.schema=40),t<41&&(w9(n),n.schema=41),t<42&&(A9(n),n.schema=42),t<43&&(E9(n),n.schema=43),t<99){Aa(n,mI),wa(n,mI),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=hs);let e=kr(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=bl,r.insertBefore(null,null,[{id:bl,data:{...va.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Pn(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Pn(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Al.defaultData,...Pn(n.scene.environment,"usePhysics","gravity")},camera:kr(n.scene.ownerCamera)??va.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Sa.TRASH_CAN_ID&&r.move(bl,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,wl.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function yI(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function M9(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 T9(n){Array.isArray(kr(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 Kh=180/Math.PI;function vI(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Kh)}function xI(n){vI(n),n.type==="Page"&&vI(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Kh))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Kh),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Kh),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Kh,t.extrusion.twist*=Kh),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(kr(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 C9(n){n.shared.variables=qi({},Ke.prototype)}function P9(n){let t=kr(n.shared.variables);n.shared.variables=qi(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),Ue.prototype)}var Co=115;function bI(n,t){t(n.data);for(let e of n.children)bI(e,t)}function _9(n){let t=n.schema??104;t!==Co&&t<105&&(bI(n.asset,xI),n.schema=105)}function D9(n){n.shared.particles=qi({},Ke.prototype),n.shared.lib&&(n.shared.lib.particles=zs.defaultData().particles)}function I9(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 O9(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 R9(n){n.scene.objects.traverse((t,e)=>{Array.isArray(kr(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 L9(n){n.shared.userAPIs=qi({},Ke.prototype),n.shared.userWebhooks=qi({},Ke.prototype),n.shared.lib&&(n.shared.lib.userAPIs=zs.defaultData().userAPIs,n.shared.lib.userWebhooks=zs.defaultData().userWebhooks)}function Xv(n){let t=n.schema??0;if(t!==Co){console.warn("updating from ",t,"to ",Co),gI(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Us.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Aa(n,yI),wa(n,yI),n.schema=101),t<102&&(M9(n),n.schema=102),t<104&&(n.shared.catelogs=new Ke,n.shared.lib=zs.defaultData(),n.schema=104),t<105&&(C9(n),n.scene.objects.traverse((e,r)=>{xI(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))_9(e);t<106&&(P9(n),n.schema=106),t<107&&(n.shared.lib.variables=zs.defaultData().variables,n.schema=107),t<109&&(D9(n),n.schema=109),t<110&&(I9(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{T9(r)}),n.schema=111),t<112&&(O9(n),n.schema=112),t<113&&(R9(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&&(L9(n),n.schema=115)}}var qh;(c=>{c.defaultData={schema:Co,scene:Sa.defaultData,frames:new Ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Yh.defaultData),shared:{...vn.emptyData(),colors:vn.defaultColors()}},c.emptyDataForImports=function(){let u=Sa.emptyDataWithPage();return{schema:Co,scene:u,frames:new Ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Yh.defaultData),shared:{...vn.emptyData(),colors:vn.defaultColors(),images:vn.defaultImages()}}},c.emptyData=function(){return{schema:Co,scene:Sa.emptyDataWithPage(),frames:new Ke().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Yh.defaultData),shared:vn.emptyData()}},c.clipboard2dData=function(){return{schema:Co,scene:Sa.emptyData(),frames:new Ke,shared:vn.emptyData()}},c.collabHelper={...Fp,updateSchema(u){return(u.schema??0)<Co?ml(u,Xv):(u.schema??0)-Co}};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}}c.getComponentData=a;function l(u){let h=Object.values(u.shared.userAPIs);for(let d of h){let f=d.headers;for(let p of f)if(p.data.key.toLowerCase()==="authorization"&&p.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(qh||(qh={}));var Qv;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Qv||(Qv={}));var SI;(t=>{function n(e){return!0}t.is=n})(SI||(SI={}));var Kv;(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 ev({position:Fs.isEqual(i.position,s.position)?void 0:s.position,rotation:i.rotation===s.rotation?void 0:s.rotation,scale:Fs.isEqual(i.scale,s.scale)?void 0:s.scale,shear:i.shear&&s.shear&&Fs.isEqual(i.shear,s.shear)?void 0:s.shear})}r.diff=e})(Kv||(Kv={}));var V1;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(V1||(V1={}));var wI;(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})(wI||(wI={}));var Zv;(t=>t.defaultData={opacity:1,fill:{color:bt.fromHexAndA(ii,1),enabled:!0},stroke:{color:bt.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:bt.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:bt.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Zv||(Zv={}));var Ea;(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,Kv.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})(Ea||(Ea={}));var Hp;(t=>t.defaultData={...Kv.defaultData,...V1.defaultData,states:new Ue,events:new Ue,visible:!0,raycastLock:!1})(Hp||(Hp={}));var Zh;(t=>t.defaultData={...Hp.defaultData,...Zv.defaultData})(Zh||(Zh={}));var Jv;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(Jv||(Jv={}));var U1;(t=>t.defaultData={...Zh.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(U1||(U1={}));var Jh;(t=>t.defaultData={...Zh.defaultData,...Jv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Jh||(Jh={}));var z1;(t=>t.defaultData={...Zh.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"})(z1||(z1={}));var k1;(t=>t.defaultData={...Zh.defaultData,type:"path2d",path:"",name:"Path"})(k1||(k1={}));var AI;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(AI||(AI={}));var Wp;(t=>t.defaultData={...Hp.defaultData,name:"Group",type:"group2d"})(Wp||(Wp={}));var G1;(t=>t.defaultData=()=>({...Hp.defaultData,...Jv.defaultData,...Zv.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:bt.fromHexAndA(4737101,1),enabled:!0},stroke:{color:bt.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(G1||(G1={}));var Ma;(s=>{function n(o){switch(o){case"rectangle2d":return{...Jh.defaultData};case"ellipse2d":return{...U1.defaultData};case"text2d":return{...z1.defaultData};case"vector2d":return{...Jh.defaultData};case"path2d":return{...k1.defaultData};case"frame2d":return{...G1.defaultData()};case"group2d":return{...Wp.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})(Ma||(Ma={}));var $v;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new gr},e.emptyData=function(){return{type:"scene2d",objects:new gr}}))($v||($v={}));function ks(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 _e,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 p=0;p<f.count;++p)h.push(f.getX(p)+u);u+=n[d].attributes.position.count}l.setIndex(h)}for(let u in s){let h=EI(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 m=0;m<o[u].length;++m)f.push(o[u][m][d]);let p=EI(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(p)}}return l}function EI(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 Xe(s,e,r)}var MI=Math.pow(2,-24);var Oc=class{constructor(){}};function fs(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 j1(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 H1(n,t){t.set(n)}function W1(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 qp(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 $h(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 F9(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 Xe(i,1));for(let s=0;s<e;s++)i[s]=s}}function V9(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 Y1(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,p=-1/0,m=-1/0,g=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let S=n[v+0],w=n[v+1],A=S-w,M=S+w;A<s&&(s=A),M>l&&(l=M),y&&S<h&&(h=S),y&&S>p&&(p=S);let b=n[v+2],T=n[v+3],C=b-T,P=b+T;C<o&&(o=C),P>c&&(c=P),y&&b<d&&(d=b),y&&b>m&&(m=b);let D=n[v+4],_=n[v+5],I=D-_,L=D+_;I<a&&(a=I),L>u&&(u=L),y&&D<f&&(f=D),y&&D>g&&(g=D)}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]=p,i[4]=m,i[5]=g)}function U9(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 p=n[u+4];p<o&&(o=p),p>c&&(c=p)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function z9(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 Ta=32,k9=(n,t)=>n.candidate-t.candidate,Tl=new Array(Ta).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),e0=new Float32Array(6);function G9(n,t,e,r,i,s){let o=-1,a=0;if(s===0)o=j1(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=j1(n),o!==-1&&(a=j9(e,r,i,o));else if(s===2){let l=$h(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)/Ta;if(i<Ta/4){let y=[...Tl];y.length=i;let v=0;for(let S=u;S<h;S+=6,v++){let w=y[v];w.candidate=e[S+2*d],w.count=0;let{bounds:A,leftCacheBounds:M,rightCacheBounds:b}=w;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0,M[T]=1/0,M[T+3]=-1/0,A[T]=1/0,A[T+3]=-1/0;qp(S,e,A)}y.sort(k9);let x=i;for(let S=0;S<x;S++){let w=y[S];for(;S+1<x&&y[S+1].candidate===w.candidate;)y.splice(S+1,1),x--}for(let S=u;S<h;S+=6){let w=e[S+2*d];for(let A=0;A<x;A++){let M=y[A];w>=M.candidate?qp(S,e,M.rightCacheBounds):(qp(S,e,M.leftCacheBounds),M.count++)}}for(let S=0;S<x;S++){let w=y[S],A=w.count,M=i-w.count,b=w.leftCacheBounds,T=w.rightCacheBounds,C=0;A!==0&&(C=$h(b)/l);let P=0;M!==0&&(P=$h(T)/l);let D=1+1.25*(C*A+P*M);D<c&&(o=d,c=D,a=w.candidate)}}else{for(let x=0;x<Ta;x++){let S=Tl[x];S.count=0,S.candidate=f+g+x*g;let w=S.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let x=u;x<h;x+=6){let A=~~((e[x+2*d]-f)/g);A>=Ta&&(A=Ta-1);let M=Tl[A];M.count++,qp(x,e,M.bounds)}let y=Tl[Ta-1];H1(y.bounds,y.rightCacheBounds);for(let x=Ta-2;x>=0;x--){let S=Tl[x],w=Tl[x+1];W1(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let x=0;x<Ta-1;x++){let S=Tl[x],w=S.count,A=S.bounds,b=Tl[x+1].rightCacheBounds;w!==0&&(v===0?H1(A,e0):W1(A,e0,e0)),v+=w;let T=0,C=0;v!==0&&(T=$h(e0)/l);let P=i-v;P!==0&&(C=$h(b)/l);let D=1+1.25*(T*v+C*P);D<c&&(o=d,c=D,a=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function j9(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 H9(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,p,m,g;o?(p=r[d+0],m=r[d+1],g=r[d+2]):(p=r[d+0]*c+l,m=r[d+1]*c+l,g=r[d+2]*c+l);for(let y=0;y<3;y++){let v,x,S;o?(v=e[u[y]](p),x=e[u[y]](m),S=e[u[y]](g)):(v=a[p+y],x=a[m+y],S=a[g+y]);let w=v;x<w&&(w=x),S<w&&(w=S);let A=v;x>A&&(A=x),S>A&&(A=S);let M=(A-w)/2,b=y*2;s[f+b+0]=w+M,s[f+b+1]=M+(Math.abs(w)+M)*MI,w<t[y]&&(t[y]=w),A>t[y+3]&&(t[y+3]=A)}}return s}function W9(n,t){function e(y){d&&d(y/f)}function r(y,v,x,S=null,w=0){if(!p&&w>=l&&(p=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),x<=u||w>=l)return e(v+x),y.offset=v,y.count=x,y;let A=G9(y.boundingData,S,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=z9(a,o,v,x,A);if(M===v||M===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new Oc,T=v,C=M-v;y.left=b,b.boundingData=new Float32Array(6),Y1(o,T,C,b.boundingData,s),r(b,T,C,s,w+1);let P=new Oc,D=M,_=x-C;y.right=P,P.boundingData=new Float32Array(6),Y1(o,D,_,P.boundingData,s),r(P,D,_,s,w+1)}return y}F9(n,t);let i=new Float32Array(6),s=new Float32Array(6),o=H9(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,p=!1,m=[],g=V9(n);if(g.length===1){let y=g[0],v=new Oc;v.boundingData=i,U9(o,y.offset,y.count,s),r(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new Oc;v.boundingData=new Float32Array(6),Y1(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function PI(n,t){let e=W9(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,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(p){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,v=h.splitAxis,x;if(x=c(u+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=x/4,x=c(x,y),i[d+7]=v,x}}}var Dn=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}};Dn.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 Ipe=function(){let n=new Dn;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 q9=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),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),Yp=function(){let n=new U,t=new E,e=new E;return function(i,s,o,a){q9(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}}}}(),_I=function(){let n=new E,t=new E,e=new Ur,r=new Mi;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 m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var Y9=1e-15;function ed(n){return Math.abs(n)<Y9}var In=class extends Cr{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Dn),this.points=[this.a,this.b,this.c],this.sphere=new Or,this.plane=new Ur,this.needsUpdate=!0}intersectsSphere(t){return _I(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],p=o[3];f.subVectors(r,t),p.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};In.prototype.closestPointToSegment=function(){let n=new E,t=new E,e=new Mi;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]),Yp(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)}}();In.prototype.intersectsTriangle=function(){let n=new In,t=new Array(3),e=new Array(3),r=new Dn,i=new Dn,s=new E,o=new E,a=new E,l=new E,c=new Mi,u=new Mi,h=new Mi;return function(f,p=null,m=!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 v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let M=v[A],b=x[A];if(r.setFromPoints(b,e),M.isSeparated(r))return!1}let S=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 M=S[A],b=w[A];if(r.setFromPoints(b,t),M.isSeparated(r))return!1}for(let A=0;A<4;A++){let M=x[A];for(let b=0;b<4;b++){let T=w[b];if(s.crossVectors(M,T),r.setFromPoints(s,t),i.setFromPoints(s,e),r.isSeparated(i))return!1}}return p&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,x=!1,S=0;for(let I=0;I<3;I++){let L=v[I],j=v[(I+1)%3];c.start.copy(L),c.end.copy(j),c.delta(o);let V=x?u.start:u.end,H=ed(y.distanceToPoint(L));if(ed(y.normal.dot(o))&&H){u.copy(c),S=2;break}if((y.intersectLine(c,V)||H)&&!ed(V.distanceTo(j))){if(S++,x)break;x=!0}}if(S===1&&f.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(S!==2)return!1;let w=f.points,A=!1,M=0;for(let I=0;I<3;I++){let L=w[I],j=w[(I+1)%3];c.start.copy(L),c.end.copy(j),c.delta(a);let V=A?h.start:h.end,H=ed(g.distanceToPoint(L));if(ed(g.normal.dot(a))&&H){h.copy(c),M=2;break}if((g.intersectLine(c,V)||H)&&!ed(V.distanceTo(j))){if(M++,A)break;A=!0}}if(M===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(M!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let b=u.start.dot(o),T=u.end.dot(o),C=h.start.dot(o),P=h.end.dot(o),D=T<C,_=b<P;return b!==P&&C!==T&&D===_?!1:(p&&(l.subVectors(u.start,h.start),l.dot(o)>0?p.start.copy(u.start):p.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?p.end.copy(u.end):p.end.copy(h.end)),!0)}}}();In.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();In.prototype.distanceToTriangle=function(){let n=new E,t=new E,e=["a","b","c"],r=new Mi,i=new Mi;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],p=o[f];this.closestPointToPoint(p,n),d=p.distanceToSquared(n),d<u&&(u=d,a&&a.copy(n),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,n),d=m.distanceToSquared(n),d<u&&(u=d,a&&a.copy(m),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 p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];i.set(o[m],o[g]),Yp(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 On=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 Dn),this.alignedSatBounds=new Array(3).fill().map(()=>new Dn),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}};On.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}}();On.prototype.intersectsBox=function(){let n=new Dn;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}}();On.prototype.intersectsTriangle=function(){let n=new In,t=new Array(3),e=new Dn,r=new Dn,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],p=l[d];if(e.setFromPoints(p,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],p=u[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=u[p];if(i.crossVectors(f,m),e.setFromPoints(i,t),r.setFromPoints(i,h),e.isSeparated(r))return!1}}return!0}}();On.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}}();On.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();On.prototype.distanceToBox=function(){let n=["x","y","z"],t=new Array(12).fill().map(()=>new Mi),e=new Array(12).fill().map(()=>new Mi),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,p=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(h,d);let v=y.distanceToSquared(i);if(v<p&&(p=v,l&&l.copy(y),c&&c.copy(i),v<u))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,S=(g+2)%3,w=y<<x|v<<S,A=1<<g|y<<x|v<<S,M=f[w],b=f[A];t[m].set(M,b);let C=n[g],P=n[x],D=n[S],_=e[m],I=_.start,L=_.end;I[C]=h[C],I[P]=y?h[P]:d[P],I[D]=v?h[D]:d[P],L[C]=d[C],L[P]=y?h[P]:d[P],L[D]=v?h[D]:d[P],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?d.x:h.x,i.y=y?d.y:h.y,i.z=v?d.z:h.z,this.closestPointToPoint(i,r);let x=i.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),c&&c.copy(i),x<u))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Yp(y,x,r,i);let S=r.distanceToSquared(i);if(S<p&&(p=S,l&&l.copy(r),c&&c.copy(i),S<u))return Math.sqrt(S)}}return Math.sqrt(p)}}();var td=new E,rd=new E,id=new E,r0=new U,i0=new U,n0=new U,DI=new E,II=new E,OI=new E,s0=new E;function X9(n,t,e,r,i,s){let o;return s===pi?o=n.intersectTriangle(r,e,t,!0,i):o=n.intersectTriangle(t,e,r,s!==fi,i),o===null?null:{distance:n.origin.distanceTo(i),point:i.clone()}}function Q9(n,t,e,r,i,s,o,a,l){td.fromBufferAttribute(t,s),rd.fromBufferAttribute(t,o),id.fromBufferAttribute(t,a);let c=X9(n,td,rd,id,s0,l);if(c){r&&(r0.fromBufferAttribute(r,s),i0.fromBufferAttribute(r,o),n0.fromBufferAttribute(r,a),c.uv=Cr.getInterpolation(s0,td,rd,id,r0,i0,n0,new U)),i&&(r0.fromBufferAttribute(i,s),i0.fromBufferAttribute(i,o),n0.fromBufferAttribute(i,a),c.uv1=Cr.getInterpolation(s0,td,rd,id,r0,i0,n0,new U)),e&&(DI.fromBufferAttribute(e,s),II.fromBufferAttribute(e,o),OI.fromBufferAttribute(e,a),c.normal=Cr.getInterpolation(s0,td,rd,id,DI,II,OI,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};Cr.getNormal(td,rd,id,u.normal),c.face=u,c.faceIndex=s}return c}function Q1(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=Q9(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,i&&i.push(f),f):null}function RI(n,t,e,r,i,s){for(let o=r,a=r+i;o<a;o++)Q1(n,t,e,o,s)}function LI(n,t,e,r,i){let s=1/0,o=null;for(let a=r,l=r+i;a<l;a++){let c=Q1(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 K1(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 nd=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 Ca(n,t){return t[n+15]===65535}function Rc(n,t){return t[n+6]}function sd(n,t){return t[n+14]}function od(n){return n+8}function ad(n,t){return t[n+6]}function BI(n,t){return t[n+7]}var ld=new jt,a0=new E,Z9=["x","y","z"];function l0(n,t,e,r,i){let s=n*2,o=cd,a=Cl,l=Pl;if(Ca(s,a)){let u=Rc(n,l),h=sd(s,a);RI(t,e,r,u,h,i)}else{let u=od(n);u0(u,o,r,a0)&&l0(u,t,e,r,i);let h=ad(n,l);u0(h,o,r,a0)&&l0(h,t,e,r,i)}}function c0(n,t,e,r){let i=n*2,s=cd,o=Cl,a=Pl;if(Ca(i,o)){let c=Rc(n,a),u=sd(i,o);return LI(t,e,r,c,u)}else{let c=BI(n,a),u=Z9[c],d=r.direction[u]>=0,f,p;d?(f=od(n),p=ad(n,a)):(f=ad(n,a),p=od(n));let g=u0(f,s,r,a0)?c0(f,t,e,r):null;if(g){let x=g.point[u];if(d?x<=s[p+c]:x>=s[p+c+3])return g}let v=u0(p,s,r,a0)?c0(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var NI=function(){let n,t,e=[],r=new nd(()=>new jt);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(x){let S=x*2,w=Cl,A=Pl;for(;!Ca(S,w);)x=od(x),S=x*2;return Rc(x,A)}function f(x){let S=x*2,w=Cl,A=Pl;for(;!Ca(S,w);)x=ad(x,A),S=x*2;return Rc(x,A)+sd(S,w)}let p=s*2,m=cd,g=Cl,y=Pl;if(Ca(p,g)){let x=Rc(s,y),S=sd(p,g);return fs(s,m,n),l(x,S,!1,h,u+s,n)}else{let x=od(s),S=ad(s,y),w=x,A=S,M,b,T,C;if(c&&(T=n,C=t,fs(w,m,T),fs(A,m,C),M=c(T),b=c(C),b<M)){w=S,A=x;let V=M;M=b,b=V,T=C}T||(T=n,fs(w,m,T));let P=Ca(w*2,g),D=a(T,P,M,h+1,u+w),_;if(D===2){let V=d(w),W=f(w)-V;_=l(V,W,!0,h+1,u+w,T)}else _=D&&i(w,o,a,l,c,u,h+1);if(_)return!0;C=t,fs(A,m,C);let I=Ca(A*2,g),L=a(C,I,b,h+1,u+A),j;if(L===2){let V=d(A),W=f(A)-V;j=l(V,W,!0,h+1,u+A,C)}else j=L&&i(A,o,a,l,c,u,h+1);return!!j}}}(),FI=function(){let n=new In,t=new In,e=new ue,r=new On,i=new On;return function s(o,a,l,c,u=null){let h=o*2,d=cd,f=Cl,p=Pl;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,c),u=r),Ca(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,S=l.attributes.position,w=Rc(o,p),A=sd(h,f);if(e.copy(c).invert(),l.boundsTree)return fs(o,d,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>i.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(c),b.b.applyMatrix4(c),b.c.applyMatrix4(c),b.needsUpdate=!0;for(let T=w*3,C=(A+w)*3;T<C;T+=3)if(ps(t,T,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let M=w*3,b=A+w*3;M<b;M+=3){ps(n,M,y,v),n.a.applyMatrix4(e),n.b.applyMatrix4(e),n.c.applyMatrix4(e),n.needsUpdate=!0;for(let T=0,C=x.count;T<C;T+=3)if(ps(t,T,x,S),t.needsUpdate=!0,n.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return fs(g,d,ld),!!(u.intersectsBox(ld)&&s(g,a,l,c,u)||(fs(y,d,ld),u.intersectsBox(ld)&&s(y,a,l,c,u)))}}}();function u0(n,t,e,r){return fs(n,t,ld),e.intersectBox(ld,r)}var Z1=[],o0,cd,Cl,Pl;function ud(n){o0&&Z1.push(o0),o0=n,cd=new Float32Array(n),Cl=new Uint16Array(n),Pl=new Uint32Array(n)}function Xp(){o0=null,cd=null,Cl=null,Pl=null,Z1.length&&ud(Z1.pop())}var J1=Symbol("skip tree generation"),$1=new jt,eA=new jt,hd=new ue,Lc=new On,Qp=new On,Kp=new E,h0=new E,J9=new E,$9=new E,e7=new E,VI=new jt,Po=new nd(()=>new In),_o=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."),_o.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."),_o.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 _o(e,{...r,[J1]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Xe(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,[J1]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[J1]||(this._roots=PI(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new jt))),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,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,S=1/0,w=1/0,A=-1/0,M=-1/0,b=-1/0;for(let T=3*y,C=3*(y+v);T<C;T++){let P=r[T],D=i.getX(P),_=i.getY(P),I=i.getZ(P);D<x&&(x=D),D>A&&(A=D),_<S&&(S=_),_>M&&(M=_),I<w&&(w=I),I>b&&(b=I)}return l[d+0]!==x||l[d+1]!==S||l[d+2]!==w||l[d+3]!==A||l[d+4]!==M||l[d+5]!==b?(l[d+0]=x,l[d+1]=S,l[d+2]=w,l[d+3]=A,l[d+4]=M,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,S=v+f,w=p,A=!1,M=!1;t?w||(A=t.has(x),M=t.has(S),w=!A&&!M):(A=!0,M=!0);let b=w||A,T=w||M,C=!1;b&&(C=h(y,f,w));let P=!1;T&&(P=h(v,f,w));let D=C||P;if(D)for(let _=0;_<3;_++){let I=y+_,L=v+_,j=l[I],V=l[I+3],H=l[L],W=l[L+3];l[d+_]=j<H?j:H,l[d+_+3]=V>W?V:W}return D}}}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=Hn){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(ud(r[u]),l0(0,i,d,t,s),Xp(),a){let p=l[u].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=Hn){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;ud(r[u]);let f=c0(0,i,d,t);Xp(),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(ud(s),i=FI(0,r,t,e),Xp(),i)break;return i}shapecast(t,e,r){let i=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,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=Po.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:K1(f,p,i,c,m,g,s)}else l||(c?l=(d,f,p,m)=>K1(d,f,i,c,p,m,s):l=(d,f,p)=>p);let u=!1,h=0;for(let d of this._roots){if(ud(d),u=NI(0,i,a,l,o,h),Xp(),u)break;h+=d.byteLength}return Po.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;hd.copy(e).invert();let u=Po.getPrimitive(),h=Po.getPrimitive();if(s){let f=function(p,m,g,y,v,x,S,w){for(let A=g,M=g+y;A<M;A++){ps(h,A*3,l,c),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let b=p,T=p+m;b<T;b++)if(ps(u,b*3,o,a),u.needsUpdate=!0,s(u,h,b,A,v,x,S,w))return!0}return!1};if(i){let p=i;i=function(m,g,y,v,x,S,w,A){return p(m,g,y,v,x,S,w,A)?!0:f(m,g,y,v,x,S,w,A)}}else i=f}t.getBoundingBox(eA),eA.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>eA.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>($1.copy(v),$1.applyMatrix4(hd),t.shapecast({intersectsBounds:x=>$1.intersectsBox(x),intersectsRange:(x,S,w,A,M)=>i(f,p,x,S,g,y,A,M)}))});return Po.releasePrimitive(u),Po.releasePrimitive(h),d}intersectsBox(t,e){return Lc.set(t.min,t.max,e),Lc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Lc.intersectsBox(r),intersectsTriangle:r=>Lc.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(),Lc.set(t.boundingBox.min,t.boundingBox.max,e),Lc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=Po.getPrimitive(),f=Po.getPrimitive(),p=h0,m=J9,g=null,y=null;i&&(g=$9,y=e7);let v=1/0,x=null,S=null;return hd.copy(e).invert(),Qp.matrix.copy(hd),this.shapecast({boundsTraverseOrder:w=>Lc.distanceToBox(w),intersectsBounds:(w,A,M)=>M<v&&M<o?(A&&(Qp.min.copy(w.min),Qp.max.copy(w.max),Qp.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>Qp.distanceToBox(M),intersectsBounds:(M,b,T)=>T<v&&T<o,intersectsRange:(M,b)=>{for(let T=M*3,C=(M+b)*3;T<C;T+=3){ps(f,T,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let P=w*3,D=(w+A)*3;P<D;P+=3){ps(d,P,c,l),d.needsUpdate=!0;let _=d.distanceToTriangle(f,p,g);if(_<v&&(m.copy(p),y&&y.copy(g),v=_,x=P/3,S=T/3),_<s)return!0}}}});{let M=h?h.count:u.count;for(let b=0,T=M;b<T;b+=3){ps(f,b,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=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=C/3,S=b/3),D<s)return!0}}}}}),Po.releasePrimitive(d),Po.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=v,r.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(hd),m.applyMatrix4(hd),i.distance=m.sub(i.point).length(),i.faceIndex=S),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=>(Kp.copy(t).clamp(u.min,u.max),Kp.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d<a&&d<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,Kp);let d=t.distanceToSquared(Kp);return d<a&&(h0.copy(Kp),a=d,l=h),d<s}}),a===1/0)return null;let c=Math.sqrt(a);return e.point?e.point.copy(h0):e.point=h0.clone(),e.distance=c,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{fs(0,new Float32Array(r),VI),t.union(VI)}),t}};var tf=$o(zI());var t7=.5*(Math.sqrt(3)-1),Zp=(3-Math.sqrt(3))/6,r7=1/3,Do=1/6,Eme=(Math.sqrt(5)-1)/4,Mme=(5-Math.sqrt(5))/20,Jp=n=>Math.floor(n)|0,kI=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]),rA=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 d0(n=Math.random){let t=jI(n),e=new Float64Array(t).map(i=>kI[i%12*2]),r=new Float64Array(t).map(i=>kI[i%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*t7,h=Jp(s+u),d=Jp(o+u),f=(h+d)*Zp,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let S=g-v+Zp,w=y-x+Zp,A=g-1+2*Zp,M=y-1+2*Zp,b=h&255,T=d&255,C=.5-g*g-y*y;if(C>=0){let _=b+t[T],I=e[_],L=r[_];C*=C,a=C*C*(I*g+L*y)}let P=.5-S*S-w*w;if(P>=0){let _=b+v+t[T+x],I=e[_],L=r[_];P*=P,l=P*P*(I*S+L*w)}let D=.5-A*A-M*M;if(D>=0){let _=b+1+t[T+1],I=e[_],L=r[_];D*=D,c=D*D*(I*A+L*M)}return 70*(a+l+c)}}function GI(n=Math.random){let t=jI(n),e=new Float64Array(t).map(s=>rA[s%12*3]),r=new Float64Array(t).map(s=>rA[s%12*3+1]),i=new Float64Array(t).map(s=>rA[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*r7,p=Jp(o+f),m=Jp(a+f),g=Jp(l+f),y=(p+m+g)*Do,v=p-y,x=m-y,S=g-y,w=o-v,A=a-x,M=l-S,b,T,C,P,D,_;w>=A?A>=M?(b=1,T=0,C=0,P=1,D=1,_=0):w>=M?(b=1,T=0,C=0,P=1,D=0,_=1):(b=0,T=0,C=1,P=1,D=0,_=1):A<M?(b=0,T=0,C=1,P=0,D=1,_=1):w<M?(b=0,T=1,C=0,P=0,D=1,_=1):(b=0,T=1,C=0,P=1,D=1,_=0);let I=w-b+Do,L=A-T+Do,j=M-C+Do,V=w-P+2*Do,H=A-D+2*Do,W=M-_+2*Do,q=w-1+3*Do,K=A-1+3*Do,G=M-1+3*Do,Z=p&255,te=m&255,$=g&255,Y=.6-w*w-A*A-M*M;if(Y<0)c=0;else{let J=Z+t[te+t[$]];Y*=Y,c=Y*Y*(e[J]*w+r[J]*A+i[J]*M)}let oe=.6-I*I-L*L-j*j;if(oe<0)u=0;else{let J=Z+b+t[te+T+t[$+C]];oe*=oe,u=oe*oe*(e[J]*I+r[J]*L+i[J]*j)}let ie=.6-V*V-H*H-W*W;if(ie<0)h=0;else{let J=Z+P+t[te+D+t[$+_]];ie*=ie,h=ie*ie*(e[J]*V+r[J]*H+i[J]*W)}let re=.6-q*q-K*K-G*G;if(re<0)d=0;else{let J=Z+1+t[te+1+t[$+1]];re*=re,d=re*re*(e[J]*q+r[J]*K+i[J]*G)}return 32*(c+u+h+d)}}function jI(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 Gs=new Cr,f0=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;Gs.a.fromBufferAttribute(t,i),Gs.b.fromBufferAttribute(t,i+1),Gs.c.fromBufferAttribute(t,i+2),s*=Gs.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),Gs.a.fromBufferAttribute(this.positionAttribute,t*3),Gs.b.fromBufferAttribute(this.positionAttribute,t*3+1),Gs.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Gs.a,i).addScaledVector(Gs.b,s).addScaledVector(Gs.c,1-(i+s)),Gs.getNormal(r),this}};var WI=$o(iA()),i7=new ue,n7=new ue,s7=new ue,dd;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(dd||(dd={}));var fd=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new ue;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ue;this.matrixWorldRigid=new ue;this.shearScale=new ue;this.shearScaleInv=new ue}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Mt&&(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.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)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,i=0){for(let s of this.children)dd.is(s)&&s.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let o of this.children)dd.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,WI.SVD)(i),l=i7.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=n7.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=s7.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 nA=class extends fd(Mt){},o7=n=>n.type==="Mesh",Nr=class extends nA{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 Nr(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.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return o7(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}};var Bc=new E,Nc=new E,pd=new ue,YI=[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)],a7=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],l7=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],qI=(n,t,e)=>{n.updateEntityBoxSize(Bc,Nc),pd.copy(t).multiply(n.matrixWorld),Nc.x===0&&Nc.y===0&&Nc.z===0?e.push(new E(Bc.x,Bc.y,Bc.z).applyMatrix4(pd)):YI.forEach(r=>{e.push(r.clone().multiply(Nc).add(Bc).applyMatrix4(pd))})},$p=class extends jt{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}qI(o,r,s)}}):qI(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(pd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Nc).multiplyScalar(.5),this.getCenter(Bc),pd.copy(this.matrix).setPosition(Bc),this.vertices=YI.map(e=>e.clone().multiply(Nc).applyMatrix4(pd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=a7.map(([e,r])=>new Mi(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=l7.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var js={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var oA=class extends pp{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 p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var aA=.001;function lA(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=aA}function sA(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 lA(e,r,s)&&lA(e,i,s)}function m0(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++)lA(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),p=new E(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!n.isClosed&&(u===0||u===o-1)){a[u]={...m,removedLength:0};continue}let g=i&&u==0?o-1:u-1,y=i&&u==o-1?0:u+1,v=e[g].data,x=e[y].data,S=new E(...v.position),w=new E(...x.position),A=S.clone().sub(d).normalize(),M=w.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:M});let b=sA(v,h),T=sA(h,x);if(!b||!T)a[u]={...m,removedLength:0};else{let C=A.clone().add(M).normalize(),P=C.clone().cross(A).length()/A.dot(C);a[u]={...m,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],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],p=a[d],m=null;if(!sA(e[h].data,e[d].data))f.position.distanceTo(p.position)>aA&&(m=new vc(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>aA&&(m=new vc(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*u+1]=m}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),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),S=g.clone().multiplyScalar(-m).add(x),w=d.distanceTo(S)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(w*d.distanceTo(f)).add(d),M=A.clone().lerp(S,2),b=f.clone().lerp(A,4/3),T=p.clone().lerp(M,4/3);l[2*u]=new vc(f,b,T,p)}let c=new oA;return l.forEach(u=>{u&&c.add(u)}),c}var yt;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(yt||(yt={}));var Io=n=>yt.is(n),c7={type:"completeState",isfromEntity:!0},u7=["x","y","z"],cA=new E,h7=new E().set(0,1,0),md=n=>class extends fd(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.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new $p;this._recursiveBBox=new $p;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(yt.is(i))return i}entityChildrenCount(){let r=this.children.length;for(;r--;)if(yt.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(yt.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)xa.toOps(this.data,o.data).forEach(l=>{let c=Lh.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=xa.patch(this.data,o),xa.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=>{Io(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(yt.is(i[s]))return i[s];if(yt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&yt.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)Io(i)&&r(i)}traverseEntityAncestors(r){this.traverseAncestors(i=>{yt.is(i)&&r(i)})}traverseConcreteEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Io(o)&&o.isConcreteEntity&&o.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Io(o)&&o.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Io(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=>Io(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*we.RAD2DEG,this.rotation.y*we.RAD2DEG,this.rotation.z*we.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ch(i,r)}getTransformValues(r,i,s){return i[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,u7[a]])??o)}updateTransformState(r,i){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),s=!0),r.rotation&&(cA.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(we.DEG2RAD),this.rotation.setFromVector3(cA),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??xl.identity)),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)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)yt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{yt.is(r)&&r.disposeRecursively()})}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Ch(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=Lt(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=Sr.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}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=Sr.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,xa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Lt(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(xo.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Sr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[m,g]of Object.entries(r.props))g===void 0&&(p===r.props&&(p={...r.props}),p[m]=f[m]);r={...r,props:p}}d.overrideData=Hh.resolve(i.overrides,u),d.updateByOp(r,Lr.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 To.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of To.rootOverrideProps)if(Lt(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=xo.filterOp(h.overrideData,u);d&&h.updateByOp(d,Lr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=xo.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=i:f=Lr.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&&!Vs.is(r.props.type)&&js.changeEntityProptotype(this,i,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){js.changeEntityProptotype(this,i,s);for(let o of this.children)yt.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),Lt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Lt(r.path,["cloner"])!==null){let o=Lr.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.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),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=m0(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 p=new ue().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let g=new ue().extractRotation(l.matrixWorld),y=u.getTangentAt(h).applyMatrix4(g).add(d),v=new ue().lookAt(d,y,h7),x=cA.setFromEuler(new ir().setFromRotationMatrix(v)).multiplyScalar(we.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(c7)})}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 js.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 js.Cloner(this,r),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,i.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var g0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=we.clamp(e.thetaLength,0,360);let r=e.width/2,i=e.radiusTop??r,s=e.radiusBottom??r;return i===s?(i=r,s=r):i>s?(i=r,s=s*r/i):(i=i*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}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,p;return l===0?(p=new _e,p.setAttribute("position",new Me([],3))):h||f?p=new em(c,u,r,i,s,o,a,l*Math.PI/180,h,h,d,f):p=new bc(c,u,r,i,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"CylinderGeometry"}})}};function _l(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function XI(n){return new U(n.y,-n.x)}var em=class extends _e{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 p=[],m=[],g=[],y=[],v=0,x=r/2,S=new E,w=new E;f&&t==0&&(t=c),f&&e==0&&(e=u);let A=new U(t,x),M=new U(e,-x),b=null,T=null,C=null,P=null,D=A.clone().sub(M),_=0,I=0,L=0;d>0&&(_=Math.min(t,e)*(1-d),I=t-_,L=e-_);let j=A.clone();j.x-=_;let V=Math.PI-D.angle(),H=D.angle(),W=Math.tan(H/2),q=Math.tan(V/2),K=W+q,G=d?K:q,Z=d?K:W;if(c=Math.min(c,(t-I)/G,D.length()/K),u=Math.min(u,(e-L)/Z,D.length()/K),c>0){let re=c/W;b=A.clone().sub(new U(re,c)),d&&(C=b.clone(),C.x-=_-K*c),A.sub(D.clone().setLength(re))}if(u>0){let re=u/q;T=M.clone().sub(new U(re,-u)),M.add(D.clone().setLength(re)),d&&(P=T.clone(),P.x-=_-K*u,j.sub(D.clone().setLength(re)))}D=A.clone().sub(M);let te=D.length()<.5,$=[];for(let re=0;re<=i;re++){let J=[],Ae=re/i,xe=Ae*l+a,de=new U(Math.sin(xe),Math.cos(xe));P&&T?(Y(J,Ae,de,V,u,P,-1,!0),Y(J,Ae,de,H,u,T,-1,!1)):T?(oe(J,de,T.x,0,-1),Y(J,Ae,de,H,u,T,-1,!1)):o||oe(J,de,e,L,-1);let Ie=XI(D).normalize();if(_l(Ie,de,S),!te)for(let Ce=0;Ce<=s;Ce++){let ke=Ce/s,ze=D.clone().multiplyScalar(ke).add(M);_l(ze,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}if(C&&b?(Y(J,Ae,de,V,c,b,1,!1),Y(J,Ae,de,H,c,C,1,!0)):b?(Y(J,Ae,de,V,c,b,1,!1),oe(J,de,b.x,0,1)):o||oe(J,de,t,I,1),d&&!te){let Ce=XI(D).multiplyScalar(-1).normalize();_l(Ce,de,S);for(let ke=0;ke<=s;ke++){let ze=ke/s,Ve=D.clone().multiplyScalar(-ze).add(j);_l(Ve,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}}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 Ae=$[re][J],xe=$[re+1][J],de=$[re+1][J+1],Ie=$[re][J+1],Ce=m[de*3+0],ke=m[de*3+2];p.push(Ae,xe,Ie),(Ce!=0||ke!=0)&&p.push(xe,de,Ie)}l<Math.PI*2&&(ie(-1,$[0],a),ie(1,$[$.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new Me(m,3)),this.setAttribute("normal",new Me(g,3)),this.setAttribute("uv",new Me(y,2));function Y(re,J,Ae,xe,de,Ie,Ce,ke){for(let ze=0;ze<h+1;ze++){let Ve=ze/h,Oe=Ce<0?Ve:1-Ve;ke&&(Oe-=1),Oe*=xe;let Ye=new U(Math.sin(Oe),Math.cos(Oe)*Ce),F=Ye.clone().multiplyScalar(de).add(Ie);_l(F,Ae,w),m.push(w.x,w.y,w.z),_l(Ye,Ae,S),g.push(S.x,S.y,S.z),y.push(J,.5+w.y/r),re.push(v++)}}function oe(re,J,Ae,xe,de){let Ie=new E,Ce=new U,ke=[Ae,xe];de<0&&ke.reverse();for(let ze of ke)Ce.set(ze,x*de),_l(Ce,J,Ie),m.push(Ie.x,Ie.y,Ie.z),g.push(0,de,0),y.push(.5,.5),re.push(v++)}function ie(re,J,Ae){let xe=new U(Math.sin(Ae),Math.cos(Ae)),de=new U(-Math.cos(Ae),Math.sin(Ae)),Ie=new E,Ce=re<0?(Ve,Oe,Ye)=>p.push(Ve,Oe,Ye):(Ve,Oe,Ye)=>p.push(Ve,Ye,Oe),ke=new U((t+e+I+L)/4,0);_l(ke,xe,Ie),m.push(Ie.x,Ie.y,Ie.z),g.push(de.x,0,de.y),y.push(.5,.5);let ze=v++;for(let Ve of J){let Oe=m.slice(Ve*3,Ve*3+3);m.push(...Oe),g.push(de.x,0,de.y);let Ye=y.slice(Ve*2,Ve*2+2);y.push(...Ye),v++}for(let Ve=ze+1;Ve<v-1;Ve++)Ce(ze,Ve,Ve+1);Ce(ze,v-1,ze+1)}}};var QI=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=we.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 _e,d.setAttribute("position",new Me([],3))):c>0||u>0||l<360?d=new em(0,t/2,r,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new rl(t/2,r,i,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var KI=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 mi(t,e,r,i,s,o):c=new hA(t,e,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},uA=Math.PI/2,hA=class extends _e{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;p("z","y","x",-1,-1,r,e,t,o,s),p("z","y","x",1,-1,r,e,-t,o,s),p("x","z","y",1,1,t,r,e,i,o),p("x","z","y",1,-1,t,r,-e,i,o),p("x","y","z",1,-1,t,e,r,i,s),p("x","y","z",-1,-1,t,e,-r,i,s),a>0&&(m("z","y","x",-1,-1,1,r,e,t,o),m("z","y","x",1,-1,-1,r,e,t,o),m("z","y","x",-1,1,-1,r,e,t,o),m("z","y","x",1,1,1,r,e,t,o),m("x","y","z",-1,-1,-1,t,e,r,i),m("x","y","z",1,-1,1,t,e,r,i),m("x","y","z",-1,1,1,t,e,r,i),m("x","y","z",1,1,-1,t,e,r,i),m("y","x","z",-1,-1,1,e,t,r,s),m("y","x","z",1,-1,-1,e,t,r,s),m("y","x","z",1,1,1,e,t,r,s),m("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 Me(u,3)),this.setAttribute("normal",new Me(h,3)),this.setAttribute("uv",new Me(d,2));function p(y,v,x,S,w,A,M,b,T,C){let P=(A-2*a)/T,D=(M-2*a)/C,_=A/2-a,I=M/2-a,L=b/2,j=T+1,V=C+1,H=0,W=new E;for(let q=0;q<V;q++){let K=q*D-I;for(let G=0;G<j;G++){let Z=G*P-_;W[y]=Z*S,W[v]=K*w,W[x]=L,u.push(W.x,W.y,W.z),W[y]=0,W[v]=0,W[x]=b>0?1:-1,h.push(W.x,W.y,W.z),d.push(G/T),d.push(1-q/C),H+=1}}for(let q=0;q<C;q++)for(let K=0;K<T;K++){let G=f+K+j*q,Z=f+K+j*(q+1),te=f+(K+1)+j*(q+1),$=f+(K+1)+j*q;c.push(G,Z,$),c.push(Z,te,$)}f+=H}function m(y,v,x,S,w,A,M,b,T,C){let P=(M-2*a)/C,D=M/2-a,_=b/2-a,I=T/2,L=C+1,j=0,V=new E,H=new E;for(let W=0;W<l+1;W++){let q=W/l*uA,K=Math.sin(q)*a,G=(1-Math.cos(q))*a,Z=Math.sin(q),te=Math.cos(q);V[v]=(_+K)*w,V[x]=(I-G)*A,H[y]=0,H[v]=Z*Math.sign(V[v]),H[x]=te*Math.sign(V[x]);for(let $=0;$<L;$++){let Y=$*P-D;V[y]=Y*S,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 W=0;W<l;W++)for(let q=0;q<C;q++){let K=f+q+L*W,G=f+q+L*(W+1),Z=f+(q+1)+L*(W+1),te=f+(q+1)+L*W;c.push(K,G,te),c.push(G,Z,te)}f+=j}function g(y,v,x){let S=new E,w=new E(t/2,e/2,r/2);w.subScalar(a);let A=[],M=y*v*x>0?(T,C,P)=>c.push(T,C,P):(T,C,P)=>c.push(T,P,C);for(let T=0;T<=l;T++){let C=[],P=uA*(1-T/l),D=Math.cos(P),_=Math.sin(P),I=0;for(let L=0;L<=T;L++){let j=Math.cos(I),V=Math.sin(I);S.x=D*j,S.y=_,S.z=D*V;let H=w.clone().addScaledVector(S,a);u.push(y*H.x,v*H.y,x*H.z),h.push(y*S.x,v*S.y,x*S.z),d.push(0,0),C.push(f++),I+=uA/T}A.push(C)}let b=A.length-1;for(let T=0;T<b;T++){let C=A[T],P=A[T+1],D=C.length-1;M(C[0],P[1],P[0]);for(let _=1;_<=D;_++)M(C[_-1],C[_],P[_]),M(C[_],P[_+1],P[_])}}}};var Dl=class extends _e{constructor(t=[],e=[],r="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),h(),this.setAttribute("position",new Me(a,3)),this.setAttribute("normal",new Me(c,3)),this.setAttribute("uv",new Me(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],p=new E,m=p.clone(),g=new Cr,y=s*i,v=i-y,x=o+1,S=new E,w=(W,q)=>S.subVectors(W,q).normalize(),A=(W,q)=>Array(W).fill(void 0).map(q),M=A(t.length/3,(W,q)=>new E().fromArray(t,q*3).setLength(i)),b=[],T=1e6;for(let W=0;W<M.length;W++){let q=M[W],K=[],G,Z,te,$=1e10,Y=-1;for(;(Y=e.indexOf(W,Y+1))!=-1;){let J=Y-Y%3;G=e[J+(Y+1)%3],Z=e[J+(Y+2)%3],te=q.distanceToSquared(M[G]),$=Math.min($,te),K.push([G,Z,te])}$+=1e-6;let oe=[],ie=0,re=K.length;for(let J=0;J<re;J++){[G,Z,te]=K[ie];let Ae=b[G]?.includes(W)==!0;te<=$&&oe.push(G+ +Ae*T),ie=K.findIndex(xe=>xe[0]==Z)}b.push(oe)}let C=[];{let W=0,q=0,K,G,Z=f==3;for(let te=0;te<=o;te++){K=te*(te+1)/2,G=(te+1)*(te+2)/2;for(let $=0;$<o-te;$++)[W,q]=[K+$+te+2,G+$+te+3],C.push(K,G,...Z?[q,K]:[W,G],q,W),[K,G]=[W,q];C.push(K,G,K+o+2)}}let P=p.clone(),D=p.clone(),_=p.clone(),I=p.clone(),L=p.clone(),j=[],V=A(M.length,()=>A(f,()=>p.clone()));for(let W=0;W<M.length;W++){p.copy(M[W]).normalize(),P.copy(p).multiplyScalar(v);let q=b[W];for(let oe=0;oe<q.length;oe++){let ie=q[oe],re=q[(oe+1)%f];g.setFromPointsAndIndices(M,W,ie%T,re%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(P,V[W][oe])}let K=[],G=[],Z=[],te=new E;o==0&&[...V[W]].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[W][re],Ae=V[W][oe];p.copy(J).sub(P),m.copy(Ae).sub(P);let xe=P.angleTo(p),de=p.angleTo(m),Ie=Math.cos(xe)*y;o==0?D.copy(te):D.copy(P).setLength(v+Ie),G.push(Ie);let Ce=[D,J,Ae];for(let ke=0;ke<2;ke++){let ze=Ce[ke],Ve=Ce[ke+1];I.subVectors(ze,P),L.subVectors(Ve,P),_.crossVectors(I,L).normalize();for(let Oe=0;Oe<x;Oe++){let Ye=[xe,de][ke]*Oe/x;p.copy(I).applyAxisAngle(_,Ye).add(P),K.push(p.clone()),ke&&(w(p,P),ie.push([Oe==0?ze:p.clone(),S.clone()]))}ke&&(w(Ve,P),ie.push([Ve,S.clone()]))}Z.push(ie)}j.push(Z);let $=2*x,Y=2;for(let oe=0;oe<f;oe++){let ie=$*oe,re=$*((oe+1)%f),J=[K[ie]];for(let xe=1;xe<x;xe++){I=K[ie+xe],L=K[re+xe],J.push(I);for(let de=1,Ie=xe-Y+1;de<=Ie;de++)p.lerpVectors(I,L,de/(Ie+1)),p.sub(P).setLength(G[oe]).add(P),J.push(p.clone());J.push(L)}for(let xe=0;xe<x;xe++)J.push(K[xe+x+ie]);J.push(K[re+x]);let Ae=C.map(xe=>J[xe]);a.push(...Ae.map(xe=>[xe.x,xe.y,xe.z]).flat()),c.push(...Ae.map(xe=>(w(xe,P),[S.x,S.y,S.z])).flat())}}let H=[];for(let W=0;W<b.length;W++)for(let q=0;q<f;q++){let K=b[W][q];if(K<T){let G=b[K].findIndex($=>$%T==W),Z=j[W][q],te=j[K][G];for(let $=0;$<x;$++){let Y=Z[$],oe=te[x-$],ie=Z[$+1],re=te[x-($+1)];[Y,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(Z[0][0],te[x][0],Z[x][0],te[0][0])}}for(;H.length;){let W,q,K,G;[W,q]=H.splice(0,2);let Z=[W];for(;W!=q;)Z.push(q),K=H.indexOf(q),G=K%2,q=H.splice(K-G,2)[1-G];S.subVectors(Z[0],Z[1]).cross(p.subVectors(Z[0],Z[2])).normalize();let te=S.dot(Z[0])<0;te&&S.negate();for(let $=1;$<=Z.length-2;$++)[Z[$+ +te],Z[$+1-+te],Z[0]].forEach(Y=>{a.push(Y.x,Y.y,Y.z),c.push(S.x,S.y,S.z)})}}function h(){let d=new E;for(let M=0;M<a.length;M+=3){d.x=a[M+0],d.y=a[M+1],d.z=a[M+2];let b=w(d)/2/Math.PI+.5,T=A(d)/Math.PI+.5;l.push(b,1-T)}let f=new E,p=new E,m=new E,g=new E,y=new U,v=new U,x=new U,S=(M,b,T,C)=>{C<0&&M.x===1&&(l[b]=M.x-1),T.x===0&&T.z===0&&(l[b]=C/2/Math.PI+.5)};for(let M=0,b=0;M<a.length;M+=9,b+=6){f.set(a[M+0],a[M+1],a[M+2]),p.set(a[M+3],a[M+4],a[M+5]),m.set(a[M+6],a[M+7],a[M+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(p).add(m).divideScalar(3);let T=w(g);S(y,b+0,f,T),S(v,b+2,p,T),S(x,b+4,m,T)}for(let M=0;M<l.length;M+=6){let b=l[M+0],T=l[M+2],C=l[M+4],P=Math.max(b,T,C),D=Math.min(b,T,C);P>.9&&D<.1&&(b<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),C<.2&&(l[M+4]+=1))}function w(M){return Math.atan2(M.z,-M.x)}function A(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new Dl(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var ZI=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 tm(t*.5,s,o):new Vu(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},tm=class extends Dl{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 tm(t.radius,t.corner,t.cornerSides)}};var rm=1e-12,gd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=we.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]}},yd=class extends gd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new yd(this.parent).copy(this)}},Hs=class extends gd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new yd(this),new yd(this))}static create(e,r){let i=new Hs(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 Hs(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&&(JI(i,e),JI(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 JI(n,t=new U){let e=n.length();return t.set(-n.y/e,n.x/e)}var fA=n=>n,vd=new U,y0=new U,d7=new U,f7=new U,p7=new U,m7=new U,eO=new E,tO=new E;function rO(n){let t=new U;t.addVectors(n.v0,vd.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new U;return e.addVectors(n.v2,y0.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new an(n.v0,t,e,n.v2)}function im(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function g7(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function y7(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function pA(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 iO(n,t,e){return $I(n,t)&&$I(t,e)&&dA(n.position,t.position,e.position)}function dA(n,t,e){return vd.copy(t).sub(n).cross(y0.copy(e).sub(n))===0}function nO(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 sO(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function oO(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 pA(t,n,e)>Math.PI&&(u*=-1),im(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 mA(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function $I(n,t){return dA(n.position,n.controls[1].position,t.position)&&dA(n.position,t.controls[0].position,t.position)}function aO(n,t,e,r,i=.5){let s=vd.subVectors(t,n).multiplyScalar(i).add(n),o=y0.subVectors(e,t).multiplyScalar(i).add(t),a=d7.subVectors(r,e).multiplyScalar(i).add(e),l=s,c=f7.subVectors(o,s).multiplyScalar(i).add(s),u=p7.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=m7.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 lO(n,t,e=12,r=!0){let i=tO.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let c=fA(t[l]),u=vd,h=Il(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof an||c instanceof Yn||c instanceof ln){if(c.getPoint(d/h,u),i.set(u.x,u.y,0),s!==void 0&&y7(s,i))continue;s===void 0&&(s=eO),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 cO(n,t,e,r=12,i=!0){let s=tO.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=fA(t[l]),h=vd,d=Il(u,r);a.push(d);for(let f=0;f<=d;f++)if(u instanceof an||u instanceof Yn||u instanceof ln){if(u.getPoint(f/d,h),s.set(h.x,h.y,0),c?.equals(s))continue;c===void 0?c=eO:(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 gA(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=Il(o.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Il(o.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Il(n[0].roundedCurveCorner,t)*.5),r}function Il(n,t=12){return n&&n instanceof yc?t*2:n&&(n instanceof ln||n instanceof fp)?1:n&&n instanceof Bu?t*n.points.length:t}function uO(n,t,e=12,r=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=fA(t[o]),l=Il(a,e),c=vd;for(let u=0;u<=l;u++)if(a instanceof an||a instanceof Yn||a instanceof ln){if(a.getPoint(u/l,c),i!==void 0&&g7(i,c,rm))continue;i===void 0&&(i=y0),i.copy(c),n.push(c.x,c.y),s++}}return im(n[0],n[n.length-2],rm)&&im(n[1],n[n.length-1],rm)&&(n.pop(),n.pop()),r&&s>1&&!(im(n[s-1],n[1],rm)&&im(n[s-2],n[0],rm))&&(n.push(n[0],n[1]),s++),n}var yA=new U,v7=new U,x7=new U,b7=new U,S7=new U,w7=new U,qt=class extends la{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ur(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=we.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let s=new qt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Hs.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>qt.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=yA.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=we.generateUUID()){let s;e instanceof U?s=e:s=new U(e,r);let o=new Hs(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 lO(e,i?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=gA(this.points,e,!1),this.roundedCurveDivisions=gA(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return cO(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),uO(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=Il(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(mA(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(yA.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){mA(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&&iO(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,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(c,m*.499),v=Math.min(c,g*.499),x=Math.min(y,v),S=1-x/m,w=x/g,A=h.getPointAt(S,yA),M=d.getPointAt(w,v7);this._subSplitCurve(h,f,S,A,void 0),this._subSplitCurve(d,p,w,void 0,M);let b;if(this.useCubicForRoundedCorners){let T=pA(A,o.position,M)/2,C=Math.tan(T)*A.distanceTo(o.position),[P,D]=nO(A,M,C,x7,b7),_=sO(P,D,o.position),[I,L]=oO(_,A,M,C,S7,w7);b=new an(A.clone(),I.clone(),L.clone(),M.clone())}else b=new Yn(A.clone(),o.position.clone(),M.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+r,0,b),r++}}}}_subSplitCurve(e,r,i,s,o){if(e instanceof ln)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=aO(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 qt(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 Hs(we.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 qt;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 an&&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 Yn&&(o[l]=rO(o[l]));for(l=0,c=o.length;l<c;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof an?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof ln&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&i(p,f),a.push(p))}let u=o[o.length-1],h=!1;return u instanceof an?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof ln&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof la&&(this.shapeHoles=e.holes.map(o=>{let a=new qt;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 xA=Math.PI*2;function vA({x:n,y:t},e,r,i,s){return{x:n*e+i,y:t*r+s}}function A7(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 hO(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 E7(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),p=u*h-u*f-h*d;p<0&&(p=0),p/=u*f+h*d,p=Math.sqrt(p)*(l===c?-1:1);let m=p*i/s*a,g=p*-s/i*o,y=m+(n+e)/2,v=g+(t+r)/2,x=(o-m)/i,S=(a-g)/s,w=(-o-m)/i,A=(-a-g)/s,M=hO(1,0,x,S),b=hO(x,S,w,A);return!c&&b>0&&(b-=xA),c&&b<0&&(b+=xA),{centerx:y,centery:v,ang1:M,ang2:b}}function dO({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=E7(n,t,e,r,i,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(xA/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(A7(f,p)),f+=p;return l.map(x=>{let{x:S,y:w}=vA(x[0],i,s,m,g),{x:A,y:M}=vA(x[1],i,s,m,g),{x:b,y:T}=vA(x[2],i,s,m,g);return{x1:S,y1:w,x2:A,y2:M,x:b,y:T}})}var zt;(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"})(zt||(zt={}));var jr;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(jr||(jr={}));function ut(n,t){if(!n)throw t||"Assertion Failed!"}var ot=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){ut(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){ut(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){ut(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){ut(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}(),nm=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}(),v0=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}(),xd=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}(),fO=function(){function n(){var t=new xd,e=new nm,r=new v0(0),i=new v0(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 v0(0),r=new v0(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;ut(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;ut(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 xd,e=new xd,r=new nm,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 xd;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new nm;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 nm;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 xd;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 nm;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&&ot.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&ot.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){ut(i.prev===s),l=i.anEdge;do ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l),ut(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(ut(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){ut(o.prev===a),l=o.anEdge;do ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l),ut(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(ut(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ut(l.Sym.next===c.Sym),ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Org!==null),ut(l.Dst!==null),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l);ut(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}(),pO=function(){function n(){this.handle=null}return n}(),mO=function(){function n(){this.key=null,this.node=0}return n}(),M7=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 pO,this.handles[r]=new mO;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,ut(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 pO;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new mO}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;ut(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}(),bA=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}(),gO=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),T7=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new gO,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 gO;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}(),C7=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?ot.vertLeq(s.Org,o.Org)?ot.edgeSign(o.Dst,s.Org,o.Org)<=0:ot.edgeSign(s.Dst,o.Org,s.Org)>=0:ot.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ot.edgeSign(s.Dst,i,s.Org)>=0;var a=ot.edgeEval(s.Dst,i,s.Org),l=ot.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ut(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ut(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 bA;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 zt.ODD:return(e&1)!==0;case zt.NONZERO:return e!==0;case zt.POSITIVE:return e>0;case zt.NEGATIVE:return e<0;case zt.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 ut(ot.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,ut(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=ot.vertL1dist(e,t),s=ot.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(ot.vertLeq(i.Org,s.Org)){if(ot.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ot.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(ot.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(ut(!ot.vertEq(i.Dst,s.Dst)),ot.vertLeq(i.Dst,s.Dst)){if(ot.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(ot.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 xd,f,p;if(ut(!ot.vertEq(c,l)),ut(ot.edgeSign(l,t.event,o)<=0),ut(ot.edgeSign(c,t.event,a)>=0),ut(o!==t.event&&a!==t.event),ut(!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(ot.vertLeq(o,a)){if(ot.edgeSign(c,o,a)>0)return!1}else if(ot.edgeSign(l,a,o)<0)return!1;return n.debugEvent(t),ot.intersect(l,o,c,a,d),ut(Math.min(o.t,l.t)<=d.t),ut(d.t<=Math.max(a.t,c.t)),ut(Math.min(c.s,l.s)<=d.s),ut(d.s<=Math.max(a.s,o.s)),ot.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=ot.vertLeq(o,a)?o:a,ot.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ot.vertEq(d,o)||ot.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!ot.vertEq(l,t.event)&&ot.edgeSign(l,t.event,d)>=0||!ot.vertEq(c,t.event)&&ot.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),p=n.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,s.Onext,i.Rprev,p,!0),!0):(ot.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),ot.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),ot.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),ot.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}ot.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,ot.vertEq(i.Org,r)){ut(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!ot.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}ut(!1),e=n.topRightRegion(e),l=n.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(ut(s!==o),n.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),ot.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 bA;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,ot.edgeSign(o.Dst,e,o.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(s=ot.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);ut(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 bA,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 T7(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||(ut(e.fixUpperEdge),ut(++r===1)),ut(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,ot.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 M7(s,ot.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,ut(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||!ot.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}(),P7=function(){function n(){this.mesh=new fO,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=zt.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],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],c[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<c[y]&&(c[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],i=f[v],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=m.next;e!==m;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(;ot.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ot.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(ot.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ot.edgeGoesLeft(i.Lnext)||ot.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&&(ot.edgeGoesRight(r.Lprev)||ot.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===jr.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===jr.CONNECTED_POLYGONS){s=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==u.anEdge);for(var p=l;p<r;++p)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 fO),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=zt.ODD),e===void 0&&(e=jr.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_(),C7.computeInterior(this,o);var a=this.mesh;return e===jr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===jr.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function Ws(n){var t=n.windingRule,e=t===void 0?zt.ODD:t,r=n.elementType,i=r===void 0?jr.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,p=f===void 0?!0:f,m=n.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new P7;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,i,o,l,u,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var $ge=zt.ODD,eye=zt.NONZERO,tye=zt.POSITIVE,rye=zt.NEGATIVE,iye=zt.ABS_GEQ_TWO,nye=jr.POLYGONS,sye=jr.CONNECTED_POLYGONS,oye=jr.BOUNDARY_CONTOURS;var x0=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*x0.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*x0.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)}},sm=x0;sm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var bO=$o(xO()),om={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},MA={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},TA={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},EA=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Rl=class extends _e{constructor(e,r,i=0,s=12,o=3,a=zt.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 D=P.extractShapePointsToFlatArray([],s),_=[];for(let I=D.length-1;I>=1;I-=2){let L=D[I-1],j=D[I-0];_.push(L,j)}return _}),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 D=u[P],_=[];for(let I=0;I<D.length;I+=2)_.push([D[I],D[I+1]]);h.push(_)}let f;e.isText?f=new Ku().setFromPoints(e.points.map(D=>D.position)).getSize(new U).length()*.1:h[0].length===0?f=i:f=(0,bO.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=Ws({windingRule:a,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{p=om}let m;try{m=Ws({windingRule:zt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=MA}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let P=0;P<m.elements.length;P++){let D=m.elements[P],_=P%2===0?p.vertexCount:0;p.elements.push(D+_)}for(let P=0;P<m.vertexIndices.length;P++){let D=m.vertexIndices[P],_=p.vertexCount;p.vertexIndices.push(D+_)}for(let P=0;P<m.vertices.length;P++){let D=m.vertices[P];p.vertices.push(D)}}let y=1/0,v=-1/0,x=1/0,S=-1/0;for(let P=0,D=p.vertexCount;P<D;P++){let _=P*2,I=p.vertices[_+0],L=p.vertices[_+1];I<y&&(y=I),I>v&&(v=I),L<x&&(x=L),L>S&&(S=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=S-x,this._buffer=new sm(this._computeBufferEstimatedSize(p));let w=[],A=[];for(let P=p.elementCount-1;P>=0;P--){let D=P>=g,_=P*2,I=p.elements[_+0],L=p.elements[_+1],j=I+L,V={start:I,count:L,normals:[],continuous:[],concave:[]},H=I,W=j-1,q=I+1,K=this._shape.roundedCurves.length;do{let Y=H-I,oe=p.vertices[W*2+0],ie=p.vertices[W*2+1],re=p.vertices[H*2+0],J=p.vertices[H*2+1],Ae=p.vertices[q*2+0],xe=p.vertices[q*2+1],de=re-oe,Ie=J-ie,Ce=Math.sqrt(de*de+Ie*Ie);de/=Ce,Ie/=Ce;let ke=re-Ae,ze=J-xe,Ve=Math.sqrt(ke*ke+ze*ze);ke/=Ve,ze/=Ve,V.normals[Y*2+0]=-ze,V.normals[Y*2+1]=ke,V.concave[Y]=de*ze-Ie*ke>0;let Oe=p.vertexIndices[H];if(Array.isArray(Oe))V.continuous[Y]=!1;else{let[Ye,F]=this._shape.getCurveIndexFromVertexId(Oe-1,!0);if(F>0&&F<1)V.continuous[Y]=!0;else{let N=F===1?Ye+1:Ye-1;N=(N+K)%K;let B=F===1?0:1,ae=this._shape.roundedCurves[Ye].getTangent(F),ge=this._shape.roundedCurves[N].getTangent(B);V.continuous[Y]=ae.dot(ge)>.95}}D&&(V.normals[Y*2+0]*=-1,V.normals[Y*2+1]*=-1),[W,H,q]=[H,q,q+1],q>=j&&(q-=L)}while(q!==I+1);let G=[];G.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,j*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((Y,oe)=>[oe,oe]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,j*2)});let Z=0;for(let Y=1;Y<=this._bevelSegments;Y++){let oe=Y/this._bevelSegments*Math.PI/2,ie=(1-Math.cos(oe))*this._bevel,re=[],J=[],Ae=[],xe=[],de=0;for(let Ce=0;Ce<L;Ce++){let ke=Ce*2,ze=(Ce-1+L)%L*2,Ve=p.vertices[V.start*2+ke+0],Oe=p.vertices[V.start*2+ke+1],Ye=-V.normals[ze+0]*ie,F=-V.normals[ze+1]*ie,N=-V.normals[ke+0]*ie,B=-V.normals[ke+1]*ie;if(V.concave[Ce]||!V.concave[Ce]&&D){let ae=Math.atan2(F,Ye),ge=Math.atan2(B,N);ge>ae&&(ge-=Math.PI*2);let me=ge-ae;if(V.continuous[Ce]||D){let Le=ae+me/2,Ne=Math.cos(Le)*ie,Re=Math.sin(Le)*ie;re[2*de+0]=Ve+Ne*(D?-1:1),re[2*de+1]=Oe+Re*(D?-1:1),xe[de]=Ce,de++}else{let Le=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Ne=0;Ne<=Le;Ne++){let Re=ae+me*(Ne/Le),pe=Math.cos(Re)*ie,nt=Math.sin(Re)*ie;re[2*de+0]=Ve+pe,re[2*de+1]=Oe+nt,xe[de]=Ce,de++}}}else re[2*de+0]=Ve+Ye,re[2*de+1]=Oe+F,xe[de]=Ce,J[Ce]=de,de++,re[2*de+0]=Ve,re[2*de+1]=Oe,xe[de]=Ce,de++,re[2*de+0]=Ve+N,re[2*de+1]=Oe+B,xe[de]=Ce,Ae[Ce]=de,de++}let Ie=Ws({windingRule:zt.POSITIVE,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[re],edgeCreateCallback:Ce=>{let ze=Ce.Org.idx,Ve=xe[ze],Oe=xe[(ze+1)%xe.length];Ce.idx=[Ve,Oe],Ce.Sym.idx=[Oe,Ve]},vertexIdCallback:Ce=>{let ke=Ce.Lprev.idx;return[ke?ke[1]:0,Ce.idx?Ce.idx[0]:0]}});if(!Ie)throw console.log("Error"),new Error(`error generating bevel geometry for ${Y}'th loop`);if(!Ie.vertexCount){let Ce=(Y-1)/this._bevelSegments*Math.PI/2;Z=(1-Math.sin(Ce))*this._bevel;break}for(let Ce=0;Ce<Ie.vertexIndices.length;Ce++){let[ke,ze]=Ie.vertexIndices[Ce];if(ke===ze)continue;let Ve=ze;ze<ke&&(Ve+=L);for(let Oe=ke;Oe<Ve;Oe++){let Ye=Oe%L,F=(Oe+1)%L;if(!V.continuous[Ye]||!V.continuous[F]){Ie.vertexIndices[Ce]=[ke,Ye],Ie.vertexIndices.splice(Ce+1,0,[F,ze]),Ie.vertices.splice((Ce+1)*2,0,Ie.vertices[Ce*2],Ie.vertices[Ce*2+1]);break}}}G.push({bevelI:Y,angle:oe,size:ie,boundary:Ie,reverseMap:xe,insetPoints:re})}let te=(Y,oe,ie)=>{let re=0,J=Y.boundary.vertexIndices.length;for(;re<J&&ie(Y.boundary.vertexIndices[oe]);)oe=(oe+1)%J,re++;return re},$=w.length;for(let Y=1;Y<G.length;Y++){let oe=G[Y-1],ie=G[Y],re=oe.boundary.vertexIndices.length,J=ie.boundary.vertexIndices.length;if(!re||!J)break;let Ae=V.concave.length,xe=0,de=EA(xe,L);for(;!oe.boundary.vertexIndices.filter(de).length||!ie.boundary.vertexIndices.filter(de).length;)xe++,de=EA(xe,L);let Ie=oe.boundary.vertexIndices.findIndex(de),Ce=ie.boundary.vertexIndices.findIndex(de);do Ie=(Ie+1)%re;while(de(oe.boundary.vertexIndices[Ie]));do Ce=(Ce+1)%J;while(de(ie.boundary.vertexIndices[Ce]));xe=(xe+1)%L;let ke=xe,ze=0,Ve=this._buildBevelVert(V,oe,(Ie-1+re)%re,void 0,ze),Oe=this._buildBevelVert(V,ie,(Ce-1+J)%J,void 0,ze),Ye=Ve,F=Oe,N,B,ae=!1;do{ze=(xe||Ae)/Ae,de=EA(xe,L);let ge=te(oe,Ie,de),me=te(ie,Ce,de),Le=ae;if(ae=!1,ge&&!me){for(let Ne=0;Ne<ge;Ne++)N=this._buildBevelVert(V,oe,(Ie+Ne)%re,Ne/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N;ae=!0}else if(!ge&&me)for(let Ne=0;Ne<me;Ne++)B=this._buildBevelVert(V,ie,(Ce+Ne)%J,Ne/(me-1),ze),w.push(F.topN,Ye.topP,B.topP),l===!1&&w.push(Ye.bottomP,F.bottomN,B.bottomP),F=B;else if(ge&&me)if(N=this._buildBevelVert(V,oe,Ie,0,ze),B=this._buildBevelVert(V,ie,Ce,0,ze),Le?(w.push(Ye.topN,B.topP,F.topN),w.push(Ye.topN,N.topP,B.topP),l===!1&&(w.push(B.bottomP,Ye.bottomN,F.bottomN),w.push(B.bottomP,N.bottomP,Ye.bottomN))):(w.push(F.topN,Ye.topN,N.topP),w.push(F.topN,N.topP,B.topP),l===!1&&(w.push(N.bottomP,Ye.bottomN,F.bottomN),w.push(N.bottomP,F.bottomN,B.bottomP))),Ye=N,F=B,ge===me)for(let Ne=1;Ne<ge;Ne++)N=this._buildBevelVert(V,oe,(Ie+Ne)%re,Ne/(ge-1),ze),B=this._buildBevelVert(V,ie,(Ce+Ne)%J,Ne/(me-1),ze),w.push(Ye.topN,N.topP,F.topN),w.push(F.topN,N.topP,B.topP),l===!1&&(w.push(N.bottomP,Ye.bottomN,F.bottomN),w.push(N.bottomP,F.bottomN,B.bottomP)),Ye=N,F=B;else if(ge>me){let Ne=ge/me,Re=0;for(let pe=1;pe<ge;pe++)N=this._buildBevelVert(V,oe,(Ie+pe)%re,pe/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N,pe>(Re+1)*Ne&&(Re++,B=this._buildBevelVert(V,ie,(Ce+Re)%J,Re/(me-1),ze),w.push(F.topN,N.topP,B.topP),l===!1&&w.push(N.bottomP,F.bottomN,B.bottomP),F=B)}else{let Ne=me/ge,Re=0;for(let pe=1;pe<me;pe++)B=this._buildBevelVert(V,ie,(Ce+pe)%J,pe/(me-1),ze),w.push(F.topN,N.topP,B.topP),l===!1&&w.push(N.bottomP,F.bottomN,B.bottomP),F=B,pe>(Re+1)*Ne&&(Re++,N=this._buildBevelVert(V,oe,(Ie+Re)%re,Re/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N)}Ie=(Ie+ge)%re,Ce=(Ce+me)%J,xe=(xe+1)%Ae}while(xe!==ke)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(G,V,w),D){let Y=[];for(let oe=w.length-1;oe>=$+2;oe-=3){let ie=w[oe-2],re=w[oe-1],J=w[oe-0];Y.push(J,re,ie)}w.splice($,w.length-$,...Y)}if(D){let Y=[];for(let oe=G[G.length-1].boundary.vertices.length-1;oe>=1;oe-=2){let ie=G[G.length-1].boundary.vertices[oe-1],re=G[G.length-1].boundary.vertices[oe-0];Y.push(ie,re)}A.push(Y)}if(!D){let Y=G[G.length-1],oe;try{oe=Ws({windingRule:G.length>1?zt.POSITIVE:zt.ODD,elementType:jr.POLYGONS,vertexSize:2,strict:!0,contours:[Y.insetPoints,...A]})}catch{oe=TA}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],Z),J=this._buildSurfaceVert(oe,oe.elements[ie+1],Z),Ae=this._buildSurfaceVert(oe,oe.elements[ie+2],Z);w.push(re.top,J.top,Ae.top),l===!1&&w.push(Ae.bottom,J.bottom,re.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new Xe(Uint32Array.from(w),1),b=new Xe(this._buffer.positions,3),T=new Xe(this._buffer.normals,3),C=new Xe(this._buffer.uvs,2);b.needsUpdate=!0,T.needsUpdate=!0,C.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",T),this.setAttribute("uv",C),this.setIndex(M)}_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 p=Math.cos(r.angle),m=Math.sin(r.angle),g=i*2,y=u*2,v=h*2,x=r.boundary.vertices[g+0],S=r.boundary.vertices[g+1],w=(1-m)*this._bevel,A=(x-this._minX)/this._width,M=(S-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),M=1);let b=e.normals[y+0],T=e.normals[y+1],C=e.normals[v+0],P=e.normals[v+1];if(f){let j=C-b,V=P-T;b=b+j*(1-s),T=T+V*(1-s);let H=Math.sqrt(b*b+T*T);b/=H,T/=H}let D=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=D*3,I=D*2,L={i,fi:u,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:o};return this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=b*p,this._buffer.normals[_+1]=T*p,this._buffer.normals[_+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=b*p,this._buffer.normals[_+4]=T*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[I+2]=M,this._buffer.uvs[I+3]=A),d||(this.forPathBevel?(D+=1,_+=3,I+=2):(D+=2,_+=6,I+=4),L.topP=D+0,L.bottomP=D+1,this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=C*p,this._buffer.normals[_+1]=P*p,this._buffer.normals[_+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=C*p,this._buffer.normals[_+4]=P*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[I+2]=M,this._buffer.uvs[I+3]=A)),this.vertexCache[a]=L,L}clone(){let e=new Rl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=pa(this.userData),e}};var bd=class extends _e{constructor(e,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=zt.ODD;this.elementType=jr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:zt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(u!==void 0&&y!==u&&(l=!1),h!==void 0&&v!==h&&(c=!1),u=y,h=v,!l&&!c)break}if(!l&&!c)try{a=Ws({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=om}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(d*3),3),this._normalAttribute=new Xe(new Float32Array(d*3),3),this._uvAttribute=new Xe(new Float32Array(d*2),2),this._indexAttribute=new Xe(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let S=0,w=d;S<w;S++){let A=S*2,M=a.vertices[A+0],b=a.vertices[A+1];M<p&&(p=M),M>m&&(m=M),b<g&&(g=b),b>y&&(y=b)}let v=m-p,x=y-g;for(let S=0,w=d;S<w;S++){let A=S*2,M=a.vertices[A+0],b=a.vertices[A+1],T=(M-p)/v,C=(b-g)/x;this._positionAttribute.setXYZ(S,M,b,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,T,C)}for(let S=0,w=f;S<w;S++){let A=S*3,M=a.elements[A+0],b=a.elements[A+1],T=a.elements[A+2];this._indexAttribute.setX(A+0,M),this._indexAttribute.setX(A+1,b),this._indexAttribute.setX(A+2,T)}}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 bd(this._shape,this._curveSegments);return e.userData=pa(this.userData),e}};var Sd=class extends Rl{constructor(e,r,i=0,s=12,o=3,a=zt.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 Sd(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=pa(this.userData),e}};var Rn=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:zt.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 qt?(o.width!==r||o.height!==i)&&o.applySize(r,i):o=new qt(r,i).fromJSON(o),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&o.update());let l=o??new qt(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 bd(n.shape,i,{windingRule:o}):a=new Sd(n.shape,t,e,i,r,o),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};var wO=Math.PI*2,Ad=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=we.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof qt?n.shape:new qt,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=R7(c,u,h,i*Math.PI/180,r,s);c.isClosed=!0,c.update();let f;return i===0?(f=new _e,f.setAttribute("position",new Me([],3))):f=Rn.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function R7(n,t,e,r,i,s){if(r>=wO)return i>30||i%4===0?(B7(n,t,e,s),Math.round(i/4)):SO(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=dO({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?L7(n,o.x,o.y,c,i,t,e,s):SO(n,r,i,t,e,s)}function L7(n,t,e,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(wd(t,e));for(let c=0,u=r.length;c<u;c++){let h=r[c],d=n.points[c],f=wd(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?AO(n,s,o,a):n.addPoint(wd(0,0)),l}function SO(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(wd(c,u))}return t<wO?s>0?AO(n,r,i,s):n.addPoint(wd(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&EO(n,r,i,s)),1}function B7(n,t,e,r=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;n.addPoint(S0(i-t,s,i-t,s-l,i-t,s+l)),n.addPoint(S0(i,s+e,i-a,s+e,i+a,s+e)),n.addPoint(S0(i+t,s,i+t,s+l,i+t,s-l)),n.addPoint(S0(i,s-e,i+a,s-e,i-a,s-e)),r>0&&EO(n,t,e,r)}function wd(n,t){return new Hs(we.generateUUID(),new U(n,t))}function S0(n,t,e,r,i,s){let o=wd(n,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(i,s),o}function AO(n,t,e,r){MO(n,t,e,r).forEach(s=>n.addPoint(s))}function EO(n,t,e,r){let i=MO(n,t,e,r),s=new qt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function MO(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=we.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 TO=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 am(!1,t,e,r,i,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},CA=new ho([0,0,0],1),am=class extends _e{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 p=()=>new E,m=new E,g=p(),y=p(),v=p(),x,S,w,A,M,b,T,C,P=p(),D=p(),_=p(),I=p(),L=p(),j=p(),V=p(),H=p(),W=r-2*l+.001,q=W/o,K=Math.ceil(a*o),G=K+1,Z=W/K,te=-W/2,$=u+1,Y=2*Math.PI/u,oe=Math.PI/2/d,ie=.01,re=Math.min((1-h/100)*l,l-ie),J=l-re,Ae=0,xe=2,de=d*xe+xe,Ie=$*de/xe,Ce=Ie+$*G,ke=Math.max(0,$*(G+de)),[ze,Ve,Oe]=[3,3,2].map(Ge=>Array(ke*Ge).fill(0)),Ye=[],F=s-l;function N(Ge,Be){let et=Math.PI/2;b=Be*Z,C=2*Math.PI*(b%q)/q+et,b+=te,T=Math.sin(C)*F,M=Math.cos(C)*F,t?Ge.set(M,T,b):Ge.set(M,b,T)}N(m,-1e-10),N(g,0),P.copy(m),N(m,1);let B=m.distanceTo(g),ae=f?0:J+re,ge=B*K+2*ae,me=re,Le=ge-ae;for(let Ge=0;Ge<=K;Ge++){N(y,Ge),H.subVectors(y,P).normalize(),P.copy(y),j.copy(y).setComponent(+t+1,0).normalize(),V.crossVectors(H,j).normalize();let Be=Ge===0,et=Ge===K,st=Be?3*Math.PI/2:oe,Bt=Be?me:Le,dr=Be?$:Ce,Mr=Be?0:ke-$,Q=H.clone().multiplyScalar(Be?-J:J).add(y),ye=H.clone().multiplyScalar(Be?-1:1).normalize();for(let Te=0;Te<$;Te++){let je=Te*Y;if(D.addVectors(m.copy(j).multiplyScalar(l*Math.cos(je)),g.copy(V).multiplyScalar(l*Math.sin(je))),_.copy(D).normalize(),Be||et){f||(Ae=Mr+Te,[0,1,2].forEach(He=>{ze[Ae*3+He]=Q.getComponent(He),Ve[Ae*3+He]=ye.getComponent(He)}),Oe[Ae*2]=+et,Oe[Ae*2+1]=Te/u),g.copy(_).multiplyScalar(re),v.addVectors(y,g);for(let He=0;He<d;He++){let _t=He*oe+st;I.addVectors(m.copy(H).multiplyScalar(J*Math.sin(_t)),g.copy(_).multiplyScalar(J*Math.cos(_t))),L.copy(I).normalize(),g.addVectors(v,I),I.normalize(),Ae=dr+He*$+Te,[0,1,2].forEach(Vr=>{ze[Ae*3+Vr]=g.getComponent(Vr),Ve[Ae*3+Vr]=L.getComponent(Vr)});let Fr=+Be+Math.sin(_t);Oe[Ae*2]=(Bt+J*Fr)/ge,Oe[Ae*2+1]=Te/u}}g.addVectors(y,D),Ae=Ie+Ge*$+Te,[0,1,2].forEach(He=>{ze[Ae*3+He]=g.getComponent(He),Ve[Ae*3+He]=_.getComponent(He)}),Oe[Ae*2]=(ae+Ge*B)/ge,Oe[Ae*2+1]=Te/u}}let Ne=G+2*d+xe,Re=1,[pe,nt]=[+f,Ne-1];for(let Ge=pe;Ge<=nt-1;Ge++){let Be=f&&Ge===nt-1;for(let et=0;et<$-1;et++)x=Ge*$+et,S=x+1,w=(Be?et:x)+$,A=(Be?et+1:S)+$,Ge===0?Ye.push(S,A,w):Ge===Ne-2?Ye.push(x,S,w):Ye.push(x,S,w,S,A,w)}this.setIndex(Ye),this.setAttribute("position",new Me(ze,3)),this.setAttribute("normal",new Me(Ve,3)),this.setAttribute("uv",new Me(Oe,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,CA.array=i,CA.count=i.length,CA}};var CO=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 lm(t*.5,s,o):new zu(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},lm=class extends Dl{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 lm(t.radius,t.corner,t.cornerSides)}};var PO=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 la;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 Nu(i.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var Oo=new ue,PA=new Mt,w0=new E,Ll=class extends pr{constructor(){super(),this.uuid=we.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 fr().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 Oo.makeRotationX(t),this.applyMatrix4(Oo),this}rotateY(t){return Oo.makeRotationY(t),this.applyMatrix4(Oo),this}rotateZ(t){return Oo.makeRotationZ(t),this.applyMatrix4(Oo),this}translate(t,e,r){return Oo.makeTranslation(t,e,r),this.applyMatrix4(Oo),this}scale(t,e,r){return Oo.makeScale(t,e,r),this.applyMatrix4(Oo),this}lookAt(t){return PA.lookAt(t),PA.updateMatrix(),this.applyMatrix4(PA.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 We().fromBufferAttribute(a,d));function u(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new E().fromBufferAttribute(o,d),new E().fromBufferAttribute(o,f),new E().fromBufferAttribute(o,p)],v=new Ed(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new U().fromBufferAttribute(l,d),new U().fromBufferAttribute(l,f),new U().fromBufferAttribute(l,p)]),c!==void 0&&e.faceVertexUvs[1].push([new U().fromBufferAttribute(c,d),new U().fromBufferAttribute(c,f),new U().fromBufferAttribute(c,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;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(w0).negate(),this.translate(w0.x,w0.y,w0.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 Ll;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 jt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Or),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 fr().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}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 p=c[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new Ed(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let S=0,w=y.length;S<w;S++)m=y[S].clone(),i!==void 0&&m.applyMatrix3(i).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let S=0,w=v.length;S<w;S++)g=v[S],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,S=y.length;x<S;x++)v.push(y[x].clone());this.faceVertexUvs[d].push(v)}}}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 p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let r=[],i=[],s={},o=[],a={},l=[],c={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,S=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,M=0;if(M=u(M,0,0),M=u(M,1,g),M=u(M,2,y),M=u(M,3,v),M=u(M,4,x),M=u(M,5,S),M=u(M,6,w),M=u(M,7,A),r.push(M),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let b=this.faceVertexUvs[0][p];r.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&r.push(h(m.normal)),S){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(w&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function u(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=i.length/3,i.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(p.x,p.y)),c[m]}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 Ll().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 p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,S=y.length;x<S;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}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 _A().fromGeometry(this),e=new _e,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",A0.call(new Xe(r,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",A0.call(new Xe(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",_O.call(new Xe(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",DO.call(new Xe(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",DO.call(new Xe(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 Me(c.data.length*3,3);u.name=c.name,s.push(A0.call(u,c.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new Me(t.skinIndices.length*4,4);e.setAttribute("skinIndex",IO.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Me(t.skinWeights.length*4,4);e.setAttribute("skinWeight",IO.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 _e,r=t.geometry;if(t.isPoints||t.isLine){let i=new Me(r.vertices.length*3,3),s=new Me(r.colors.length*3,3);if(e.setAttribute("position",A0.call(i,r.vertices)),e.setAttribute("color",_O.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Me(r.lineDistances.length,1);e.setAttribute("lineDistance",N7.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}};Ll.prototype.isGeometry=!0;var _A=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,p=t.skinWeights,m=f.length===r.length,g=p.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 v=e[y];this.vertices.push(r[v.a],r[v.b],r[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let w=v.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[v.a],A[v.b],A[v.c])}for(let w=0;w<h;w++){let A=u[w].vertexNormals[y];d[w].data.push(A.a,A.b,A.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.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}},Ed=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 We,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 N7(n){return this.array.set(n),this}function _O(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 We),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function DO(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 A0(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 IO(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 F7=["a","b","c"];function V7(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function DA(n,t,e){let r=Math.min(n,t),i=Math.max(n,t),s=r+"_"+i;return e.get(s)}function IA(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 U7(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],IA(o.a,o.b,n,r,o,e),IA(o.b,o.c,n,r,o,e),IA(o.c,o.a,n,r,o,e)}function E0(n,t,e,r,i){n.push(new Ed(t,e,r,void 0,void 0,i))}function Md(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function M0(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var T0=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof _e?t=new Ll().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;U7(l,c,d,f);let p=[],m,g,y,v,x,S,w;for(let ie of Array.from(f.keys())){for(g=f.get(ie),y=new E,x=3/8,S=1/8,w=g.faces.length,w!=2&&(x=.5,S=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=g.faces[o],a=0;a<3&&(m=l[V7(v,F7[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(S),y.add(e),g.newEdge=p.length,p.push(y)}let A,M,b,T,C,P,D,_=[];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)),M=1-r*Number(A),b=A,r<=2&&(r==2?(M=3/4,b=1/8):r==1||r==0),D=P.clone().multiplyScalar(M),e.set(0,0,0),o=0;o<r;o++)T=C[o],m=T.a!==P?T.a:T.b,e.add(m);e.multiplyScalar(Number(b)),D.add(e),_.push(D)}let I=_.concat(p),L=_.length,j,V,H,W=[],q=[],K,G,Z,te,$=new U,Y=new U,oe=new U;for(i=0,s=c.length;i<s;i++)v=c[i],j=Number(DA(v.a,v.b,f).newEdge)+L,V=Number(DA(v.b,v.c,f).newEdge)+L,H=Number(DA(v.c,v.a,f).newEdge)+L,E0(W,j,V,H,v.materialIndex),E0(W,v.a,j,H,v.materialIndex),E0(W,v.b,V,j,v.materialIndex),E0(W,v.c,H,V,v.materialIndex),h&&(K=u[i],G=K[0],Z=K[1],te=K[2],$.set(Md(G.x,Z.x),Md(G.y,Z.y)),Y.set(Md(Z.x,te.x),Md(Z.y,te.y)),oe.set(Md(G.x,te.x),Md(G.y,te.y)),M0(q,$,Y,oe),M0(q,G,$,oe),M0(q,Z,Y,$),M0(q,te,oe,Y));t.vertices=I,t.faces=W,h&&(t.faceVertexUvs[0]=q)}};var Pi=new E,OO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new _e().copy(new mi(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Pi),r={width:Pi.x,height:Pi.y,depth:Pi.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 _e().copy(new mi(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Pi)):Pi.set(o.width,o.height,o.depth),(t!==Pi.x||e!==Pi.y||r!==Pi.z)&&s.scale(Pi.x===0?1:t/Pi.x,Pi.y===0?1:e/Pi.y,Pi.z===0?1:r/Pi.z);let a=s.originalGeometry;try{i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new T0(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 Xu(e).load(n,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Pi);let o=100/Pi.x;Object.assign(s.parameters,{width:100,height:Pi.y*o,depth:Pi.z*o}),t(this.build(s))})}};var C0=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 qt?n.shape:new qt,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 m=0;m<r;m++){let g=f*m,y=h+Math.sin(g)*c,v=d+Math.cos(g)*u;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=i;l.roundness=i,l.update();let p=Rn.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...n,type:"PolygonGeometry"}})}};var RO=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 RA(t*.5,e,i,s,o,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function cm(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function OA(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 z7(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var RA=class extends _e{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,p=Math.PI/r,m=t*Math.cos(Math.PI/r),g=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,x=new E(0,-f,0),S=new E(0,f,0),w=new U(t,-f),A=new U(m,-f),M=new U(0,S.y).sub(A),b=new U(0,S.y).sub(w),T=new U(M.y,-M.x).normalize(),C=new U(b.y,-b.x).normalize(),D=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,D);let _;{let q=new E(T.x,T.y,0),K=new E(Math.cos(g)*q.x,q.y,Math.sin(g)*q.x);_=q.angleTo(K)}let I=o/Math.tan((Math.PI-M.angle())/2),L=o/Math.tan((Math.PI-_)/2),j=new E;if(!s){c.push(x.x,x.y,x.z),u.push(0,-1,0),h.push(0,0);let q=d++,K=[],G=w.clone(),Z=I/Math.cos(Math.PI/r);G.x-=Z;for(let te=0;te<r;te++){let $=te/r*Math.PI*2+p,Y=new U(Math.sin($),Math.cos($));cm(G,Y,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],q,K[(te+1)%K.length])}let V=[];{let q=new E,K=new E,G=new E,Z=new E,te=new E,$=new E;for(let Y=0;Y<r;Y++){let oe=Y/r*Math.PI*2+p,ie=(Y+.5)/r*Math.PI*2+p,re=(Y+1)/r*Math.PI*2+p,J=new U(Math.sin(oe),Math.cos(oe)),Ae=new U(Math.sin(ie),Math.cos(ie)),xe=new U(Math.sin(re),Math.cos(re));cm(w,J,K),cm(w,xe,G),cm(T,Ae,q),OA(S,K,G,L,L,Z),c.push(Z.x,Z.y,Z.z),OA(K,S,G,L,I,te),c.push(te.x,te.y,te.z),OA(G,K,S,I,L,$),c.push($.x,$.y,$.z),u.push(q.x,q.y,q.z),u.push(q.x,q.y,q.z),u.push(q.x,q.y,q.z),h.push(0,0),h.push(0,0),h.push(0,0);let de=d++,Ie=d++,Ce=d++;if(l.push(de,Ie,Ce),o>0){{let Ve=K.clone().add(G).multiplyScalar(.5),Oe=S.clone().sub(Ve).normalize(),F=x.clone().sub(Ve).normalize().add(Oe).normalize().multiplyScalar(-1),N=$.clone().sub(te);H(Ve,N,F,M.angle())}let ke,ze;{let Ve=new E;cm(C,xe,Ve);let Oe=$.clone().add(Z).multiplyScalar(.5);Oe=z7(Oe,G,S);let Ye=$.clone().sub(Z);[ke,ze]=H(Oe,Ye,Ve,_,Z.y)}{let Ve=ke,Oe=Ve.clone().setY(0).normalize(),Ye=new E(0,-1,0),F=Oe.clone().cross(Ye);W(Ve,Oe,Ye,F)}V.concat(ze);{let Ve=M.angle(),Oe=Math.PI-Ve,Ye=S.clone();Ye.y-=o/Math.sin(Ve-Math.PI/2);let F=new E,N=[];for(let ae=0;ae<a;ae++){let ge=[],me=Math.PI/2-Oe*ae/a,Le=Math.cos(me),Ne=Math.sin(me),Re=ie;for(let pe=0;pe<=ae;pe++){let nt=Math.cos(Re),Ge=Math.sin(Re);q.x=Le*Ge,q.y=Ne,q.z=Le*nt,F.copy(Ye).addScaledVector(q,o),c.push(F.x,F.y,F.z),u.push(q.x,q.y,q.z),h.push(0,0),ge.push(d++),Re+=Math.PI*2/ae/r}N.push(ge)}ze.reverse(),N.push(ze);let B=N.length-1;for(let ae=0;ae<B;ae++){let ge=N[ae],me=N[ae+1],Le=ge.length-1;l.push(me[1],ge[0],me[0]);for(let Ne=1;Ne<=Le;Ne++)l.push(ge[Ne],ge[Ne-1],me[Ne]),l.push(me[Ne+1],ge[Ne],me[Ne])}}}}}this.setIndex(l),this.setAttribute("position",new Me(c,3)),this.setAttribute("normal",new Me(u,3)),this.setAttribute("uv",new Me(h,2));function H(q,K,G,Z,te){let $=-Z/2,Y=(Math.PI-Z)/2,oe=K.clone().normalize().cross(G);q.addScaledVector(G,-o/Math.sin(Y));let ie=new E,re=new E,J=1,Ae=d,xe=[];for(let de=0;de<=a;de++){let Ie=$+de/a*Z;re.set(0,0,0),re.addScaledVector(oe,Math.sin(Ie)),re.addScaledVector(G,Math.cos(Ie));for(let Ce=0;Ce<=J;Ce++){let ke=Ce/J-.5;if(ie.copy(q),ie.addScaledVector(K,ke),ie.addScaledVector(re,o),te!=null){let ze=Math.max(0,ie.y-te);ie.addScaledVector(K,-ze/K.y)}c.push(ie.x,ie.y,ie.z),u.push(re.x,re.y,re.z),h.push(0,0),Ce===0&&xe.push(d),d++}}for(let de=0;de<a;de++)for(let Ie=0;Ie<J;Ie++){let Ce=Ae+Ie+(J+1)*de,ke=Ce+(J+1),ze=ke+1,Ve=Ce+1;l.push(Ce,ke,Ve),l.push(ke,ze,Ve)}return[q.clone().addScaledVector(K,.5),xe]}function W(q,K,G,Z){let te=Math.PI/2,$=b.angle()-te,Y=[],oe=new E,ie=new E;for(let J=0;J<=a;J++){let Ae=[],xe=J/a;for(let de=0;de<=J;de++){let Ce=((J?de/J:0)-.5)*v,ke=Math.cos(Ce),ze=Math.sin(Ce),Ve=Math.atan(Math.tan($)*ke),Oe=(te+Ve)*xe,Ye=Math.cos(Oe),F=Math.sin(Oe);oe.set(0,0,0),oe.addScaledVector(K,F*ke),oe.addScaledVector(G,Ye),oe.addScaledVector(Z,F*ze),ie.copy(q).addScaledVector(oe,o),c.push(ie.x,ie.y,ie.z),u.push(oe.x,oe.y,oe.z),h.push(0,0),Ae.push(d++)}Y.push(Ae)}let re=Y.length-1;for(let J=0;J<re;J++){let Ae=Y[J],xe=Y[J+1],de=Ae.length-1;l.push(Ae[0],xe[1],xe[0]);for(let Ie=1;Ie<=de;Ie++)l.push(Ae[Ie-1],Ae[Ie],xe[Ie]),l.push(Ae[Ie],xe[Ie+1],xe[Ie])}}}};var Td=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 qt?n.shape:new qt,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(S,w,A){return w>e&&A>r?Math.min(S*e/w,S*r/A):w>e?S*e/w:A>r?S*r/A:S}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 p=u.x,m=h.x,g=h.y,y=u.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let S=0,w=t.points.length;S<w;S++)t.points[S].roundness=f[S],S>0&&f[S]!==f[S-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Rn.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...n,type:"RectangleGeometry"}})}};var LO=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=we.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 _e,u.setAttribute("position",new Me([],3))):u=new Ls(.5*t,i,s,o,a,l,c*we.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var BO=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 Li(t,e,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var NO=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 LA(t,e,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},LA=class extends _e{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),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,S=+y,[w,A,M]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(ie,re=!1)=>Math.sin(ie-Math.PI/(1+ +re)),T=(ie,re=!1)=>Math.cos(ie-Math.PI/(1+ +re));M.y=Math.sin(i)*e-g;let C=Math.cos(i)*e-v,P=w.z-u;i<=d?(M.z=Math.min(C,P),M.z==P&&(M.y-=(C-P)/Math.tan(d-i))):A.z=Math.min(A.z-C-v,w.z-u),p.subVectors(w,A),m.subVectors(M,A);let D=Math.min(p.length(),m.length())*s/100,_=D*Math.tan(i/2),I=D/Math.cos(i/2),L=p.clone().normalize().add(m.normalize()).setLength(I).add(A);p.set(0,b(i,!0),T(i,!0)),h.push([M,p.clone()]);let j=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let re=d+i+ie*j;p.set(0,Math.sin(re)*_,Math.cos(re)*_),p.add(L),m.set(0,b(re),T(re)),h.push([p.clone(),m.clone()])}h.push([w,f(0,1,0)]);let V=Math.sin(j/2)*_*2,H=h.length-1,W=h[0][0].distanceTo(h[1][0]),q=h[H-1][0].distanceTo(h[H][0]),K=W+V*o+q;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(W+ie*V)/K);h[H].push(0);let[G,Z,te]=h[0],$,Y,oe;for(let ie=1;ie<h.length;ie++)[$,Y,oe]=h[ie],a.push(x,G.y,G.z,x,$.y,$.z,S,G.y,G.z,S,G.y,G.z,x,$.y,$.z,S,$.y,$.z),l.push(0,Z.y,Z.z,0,Y.y,Y.z,0,Z.y,Z.z,0,Z.y,Z.z,0,Y.y,Y.z,0,Y.y,Y.z),c.push(0,te,0,oe,1,te,1,te,0,oe,1,oe),[G,Z,te]=[$,Y,oe];this.setAttribute("position",new Me(a,3)),this.setAttribute("normal",new Me(l,3)),this.setAttribute("uv",new Me(c,2))}};var P0=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 qt?n.shape:new qt,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,p=0,m=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=h*r/100,v=d*r/100;if(i===3&&r===50){m=2*Math.PI/i;for(let S=0;S<i;S++){let w=m*S,A=f+Math.sin(w)*h,M=p+Math.cos(w)*d;u.addPoint(u.createPoint(A,M))}}else for(let S=0;S<i;S++){let w=f+Math.cos(g)*h,A=p+Math.sin(g)*d;u.addPoint(u.createPoint(w,A)),g+=m,w=f+Math.cos(g)*y,A=p+Math.sin(g)*v,S<=i,u.addPoint(u.createPoint(w,A)),g+=m}u.isClosed=!0;for(let S=0,w=u.points.length;S<w;S++)u.points[S].roundness=s;u.roundness=s,u.update();let x=Rn.create({shape:u,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(x,{userData:{...n,type:"StarGeometry"}})}};var FO=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 Li(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var VO=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),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=k7(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 k7(n,t,e,r,i,s,o,a,l,c,u){[t,e]=[e,t],o=t/2;let h=we.clamp(i/360,0,1);if(h===0){let d=new _e;return d.setAttribute("position",new Me([],3)),d}return h===1&&(c=0),new am(!0,n,t,e,r,h,s,o,a,l,c,u)}var UO=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 Gu(a,e,r,i,s,o);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var zO=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 qt?n.shape:new qt,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=Rn.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...n,type:"TriangleGeometry"}})}};function kO(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var BA=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)})}},NA=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+=`
3140
3140
  `;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)}}},G7=new BA;Object.assign(fe,{hooks:G7,plugins:new NA(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 Fc=n=>new fe(n).parse(),j7=Object.getOwnPropertyNames(fe);j7.forEach(n=>{Fc[n]===void 0&&n!=="prototype"&&(Fc[n]=fe[n])});Fc.Jsep=fe;var H7="ConditionalExpression",W7={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:H7,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 :")}})}};Fc.plugins.register(W7);var q7=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],Y7=["0","1","2","3","4","5","6","7","8","9","."],X7=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function Q7(n){return typeof n!="string"?!1:!isNaN(n)&&!isNaN(parseFloat(n))}Fc.addBinaryOp("^",11,!0);function _0(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){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("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=Br.getDisplayedValue(c);e==="number"&&Br.isTextValue(c)&&Array.isArray(c.textValue)&&c.textValue.length===1?u=parseFloat(u).toString():e==="boolean"&&Br.isBoolean(c)?u=c?"true":"false":e==="boolean"&&Br.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"&&!Q7(a.name)&&!Y7.includes(a.name)&&!q7.includes(a.name)&&!X7.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=Fc(r)}catch(o){console.error(r,o);return}let s;try{s=Ht(i)}catch(o){console.error(r,i,o)}return s}function Ht(n){switch(n.type){case"BinaryExpression":switch(n.operator){case"==":return Number(Ht(n.left)===Ht(n.right));case"!=":return Number(Ht(n.left)!==Ht(n.right));case">":return Number(Ht(n.left)>Ht(n.right));case">=":return Number(Ht(n.left)>=Ht(n.right));case"<":return Number(Ht(n.left)<Ht(n.right));case"<=":return Number(Ht(n.left)<=Ht(n.right));case"+":return Ht(n.left)+Ht(n.right);case"-":return Ht(n.left)-Ht(n.right);case"*":return Ht(n.left)*Ht(n.right);case"/":return Ht(n.left)/Ht(n.right);case"%":return Ht(n.left)%Ht(n.right);case"&&":return Ht(n.left)&&Ht(n.right);case"||":return Ht(n.left)||Ht(n.right);case"^":return Math.pow(Ht(n.left),Ht(n.right));default:throw new Error("Unknown operator: "+n.operator)}case"UnaryExpression":switch(n.operator){case"-":return-Ht(n.argument);case"!":return Number(!Ht(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=Ht(n.arguments[0])}catch(r){console.warn(r)}if(n.arguments.length>=2)try{e=Ht(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(Ht))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+n.type)}}var K7=new ue,Z7=new ue;function J7(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=we.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ue().makeBasis(r[0],r[1],r[2])}var GO=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??Ad.create({parameters:P1}).userData.shape;return{path:n.path??kh.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:s,extrusion:{...Vv,...e.extrusion}}),shapeData:o}}static build(n){if(n.path.points.length>=2){let e=new FA(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new _e,{userData:{...n,type:"PathGeometry"}})}},FA=class extends _e{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)||!kO(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 W=0;W<c;W++){let q=this.inputs.path.isClosed?(W+a)%e.length:Math.min(W+a,e.length-1);u.push(e[q].clone()),h.push(r[q].clone())}let d=(W,q,K)=>{u[W]=u[W].clone().lerp(u[q],K),h[W]=J7(h[W],h[q],K)},f=0,p=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&g&&(m=g,d(u.length-1,u.length-2,1-m)),i===0){let W=u.length-1;u[W].copy(u[0]),h[W].copy(h[0])}this._applyPathModifiers(h,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",S=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(S=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:w,infos:A,vertices:M}=this._computeShapePoints(S),b=0,T;x==="round"&&(T=new Rl(this.inputs.shapeData,2*y,y,S,v,void 0,!0),b=T.getAttribute("position").count);let C=0,P=0;A.sort((W,q)=>W.start-q.start),A.forEach(W=>{W.verticesStart=C,W.verticesCount=W.continuous.reduce((q,K,G)=>q+(G===0||!K?2:1),0),P+=W.verticesCount,C=P});let D=P*c,_,I=0;if(this._isOpenEnded()&&x==="flat"){try{_=Ws({windingRule:zt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:w})}catch{_=TA}I=_.vertexCount}let L=D+2*I+b*2,j=D+2*I,V={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},H=[];if(A.forEach(W=>{this._extrudeRegion(W,M,h,u,V,H,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,H,V,h[0],u[0],!1),this._closeEnd(_,D+I,H,V,h[h.length-1],u[u.length-1],!0)),T){V.positions.set(T.getAttribute("position").array,j*3),V.normals.set(T.getAttribute("normal").array,j*3),V.uvs.set(T.getAttribute("uv").array,j*2);for(let G=j;G<j+b;G++)V.uvs[G*2+1]=1e-4;let W=H.length;H.push(...T.getIndex().array.map(G=>G+j)),j+=b,V.positions.set(T.getAttribute("position").array,j*3),V.normals.set(T.getAttribute("normal").array,j*3),V.uvs.set(T.getAttribute("uv").array,j*2);let q=H.length;H.push(...T.getIndex().array.map(G=>G+j)),this.setAttribute("position",new Xe(V.positions,3)),this.setAttribute("normal",new Xe(V.normals,3)),this.setAttribute("uv",new Xe(V.uvs,2)),this.setIndex(H);let K=K7;K.copy(h[h.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(K,j,L),K.copy(h[0]).setPosition(u[0]).multiply(Z7.makeScale(1,1,-1)),this.applyMatrix4OnRange(K,j-b,j),this.reverseIndicesOnRange(W,q)}else this.setAttribute("position",new Xe(V.positions,3)),this.setAttribute("normal",new Xe(V.normals,3)),this.setAttribute("uv",new Xe(V.uvs,2)),this.setIndex(H)}_extractPathPoints(){let r=m0(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let i=[r[0]];return r.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_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],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===i-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let S=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),A=S.clone().add(w).normalize();l.copy(A),g===0&&(A.equals(u)||A.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(A).normalize(),b=A.clone().cross(M).normalize();u.copy(b),c.copy(M),g===0&&(o.copy(b),a.copy(A));let T=new ue().makeBasis(M,b,A);r.push(T)}let h=s?a:l,d=s?o:new E(0,1,0),f=h.clone().cross(c).normalize(),p=Math.acos(d.dot(f));if(isNaN(p))return r;let m=d.clone().cross(f);h.dot(m)>0&&(p*=-1);for(let g=1;g<r.length;g++){let y=new ue().makeRotationZ(p*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 p=f===0?0:f===s-1?1:(f-r)/(s-(i===0?0:1)-(r+(1-i)));u.makeRotationZ(we.lerp(o,o+a,p)*we.DEG2RAD);let m=we.lerp(l,c,p);h.makeScale(m,m,m),d.multiply(u).multiply(h)}),e}_computeShapePoints(e=12,r=zt.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],S=g[v-0];y.push(x,S)}return y}),a;try{a=Ws({windingRule:r,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=om}let l;try{l=Ws({windingRule:zt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=MA}if(!a)throw new Error("error generating geometry");let c=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let g=l.elements[m],y=m%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let m=0;m<l.vertexIndices.length;m++){let g=l.vertexIndices[m],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let m=0;m<l.vertices.length;m++){let g=l.vertices[m];a.vertices.push(g)}}let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let m=0,g=a.vertexCount;m<g;m++){let y=m*2,v=a.vertices[y+0],x=a.vertices[y+1];v<u&&(u=v),v>h&&(h=v),x<d&&(d=x),x>f&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=c,y=m*2,v=a.elements[y+0],x=a.elements[y+1],S=v+x,w={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(w);let A=v,M=S-1,b=v+1,T=i.roundedCurves.length;do{let C=A-v,P=a.vertices[M*2+0],D=a.vertices[M*2+1],_=a.vertices[A*2+0],I=a.vertices[A*2+1],L=a.vertices[b*2+0],j=a.vertices[b*2+1],V=_-P,H=I-D,W=Math.sqrt(V*V+H*H);V/=W,H/=W;let q=_-L,K=I-j,G=Math.sqrt(q*q+K*K);q/=G,K/=G,w.normals[C*2+0]=-K,w.normals[C*2+1]=q;let Z=a.vertexIndices[A];if(Array.isArray(Z))w.continuous[C]=!1;else{let[te,$]=i.getCurveIndexFromVertexId(Z-1,!0);if($>0&&$<1)w.continuous[C]=!0;else{let Y=$===1?te+1:te-1;Y=(Y+T)%T;let oe=$===1?0:1,ie=i.roundedCurves[te].getTangent($),re=i.roundedCurves[Y].getTangent(oe);w.continuous[C]=ie.dot(re)>.95}}g&&(w.normals[C*2+0]*=-1,w.normals[C*2+1]*=-1),[M,A,b]=[A,b,b+1],b>=S&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:p,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((m,g)=>{let y=s[g],v=e.verticesStart*i.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let S=(e.start+x)*2;if(c.set(r[S+0],r[S+1],0),h.copy(c).applyMatrix4(m).add(y),e.continuous[x])d.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let w=x===0?(e.start+e.count-1)*2:S-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(m).normalize(),f.set(x===0?1:x/e.count,g/(i.length-1)),this._insertVertex(o,v,h,d,f),v++,!e.continuous[x]||x===0){if(x===0)d.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(i.length-1));else{let w=x===e.count-1?e.start*2:S+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(m).normalize(),this._insertVertex(o,v,h,d,f),v++}}});let p=i.length-1;for(let m=0;m<p;m++){let g=e.verticesStart*i.length+e.verticesCount*m,y=e.verticesStart*i.length+e.verticesCount*(m+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let S=x===e.count-1?0:v+1,w=g+v,A=g+S,M=y+S,b=y+v;e.isHole?a.push(w,M,A,w,b,M):a.push(w,A,M,w,M,b),v++}}}_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 p=0;p<c;p++){let m=2*p;h.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(o).add(a),this._insertVertex(s,r+p,h,u,d)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let m=3*p,g=f[m+0]+r,y=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;i.push(g,y,v)}}applyMatrix4OnRange(e,r,i){let s=e.elements,o=new fr().getNormalMatrix(e).elements,a,l,c,u,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,p=d.array,m=h.itemSize;for(let g=r*m,y=i*m;g<y;g+=m){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=p[g+0],l=p[g+1],c=p[g+2],p[g+0]=o[0]*a+o[3]*l+o[6]*c,p[g+1]=o[1]*a+o[4]*l+o[7]*c,p[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 jO(){let n=new _e;return n.setAttribute("position",new Xe(new Float32Array([]),3)),n.setIndex(new Xe(new Uint16Array([]),1)),n}var eY=jO().attributes,tY=12,rY=1,Vc=class extends _e{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,eY),this.userData={parameters:e,type:"TextGeometry"};let i=r.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let i=r.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:c,textTransform:u}=e,h=Br.getDisplayedValue(c),d=u===2?h.toUpperCase():u===3?h.toLowerCase():h,f=iY(e,r,d),{shapes:p,charWidths:m,charCoords:g}=r.generateShapes(f,e),y=(typeof i=="number"?i:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(A=>new qt().fromShape(A,!0));this.vectorShapes=x;let S=x.map(A=>Rn.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?zt.NONZERO:zt.ODD,subdivisions:this.isLowResolution&&o>0?rY:tY}})),w=S.length?ks(S):jO();w.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([A,M])=>{this.setAttribute(A,M)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=qi(new _e,Vc.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){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}})}get text(){return this.userData.parameters.text??""}};function iY(n,t,e){let r=[""],i="";for(let s of e)i+=s,s===" "||s===`
3141
3141
  `?(r[r.length-1]+=i,i="",s===`
3142
- `&&r.push("")):t.getTextWidth(r[r.length-1]+i,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+i,n)>n.width&&(i.length===1?(r[r.length-1]+=i,i=""):(r[r.length-1]+=i.slice(0,-1),i=i[i.length-1],r.push(""))));return r[r.length-1]+=i,r}var WO,I0=new Promise(n=>{WO=n}),HO=!1;var D0;function qO(){if(HO)return;if(D0)return D0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.31/build",i=import("./process.js"),[s,o]=await Promise.all([i,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});WO(l),HO=!0}return D0=n(),D0}var nY=["font"];function Pa(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];x1(h)&&!nY.includes(i)&&(u[i]=t.getVariable(h,[r.uuid,"geometry",...c,i]),x1(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=qt.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 Xu().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 ni(s,e);return c.data=n,c}else{if(s.type==="TextGeometry")return new Vc(s,t);if(s.type==="InputGeometry")return new Vc(s,t);if(s.type==="UIGeometry")return Td.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=VA(a)}catch(c){console.error(c)}if(!l){let c=qt.createFromState(zh.defaultData(),100,100);a.shape=c,l=VA(a)}return l}var sY=new ue;function um(n,t,e,r){let i=n.position.array,s=n.normal.array,o=sY.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 O0=new jt,Cd=new E,lt;I0.then(n=>{lt=n});var YO=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),XO=new Uint32Array([0,1,2,3]),QO=new Uint8Array([4]),ni=class extends _e{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,s=Eo.div(r,i);this.subdividedGeometry&&um(this.subdividedGeometry.attributes,...s),this.originalGeometry&&um(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(Cd.fromArray(s));let a=Cd.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}=ni.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new mi(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&&(ni.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Or,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;O0.setFromBufferAttribute(r),O0.getCenter(i),e.boundingSphere.radius=i.distanceTo(O0.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),O0.getSize(Cd);let s={width:Cd.x,height:Cd.y,depth:Cd.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&&(lt.free_bvh(r),lt.free_subdivision_surface(r));try{o=ni.allocate(e,s)}catch(u){console.error(u,e),o=ni.allocate({positionWASM:YO,indexWASM:XO,verticesPerFaceWASM:QO},s)}if(lt.set_destination_refinement_level(o,0),a=ni.buildLevel(o,!0,c),e.subdivisions>0)try{lt.set_destination_refinement_level(o,e.subdivisions),l=ni.buildLevel(o,!1,c)}catch{try{lt.set_destination_refinement_level(o,e.subdivisions-1),l=ni.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:Pa(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=Uc(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}=GA(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=YO,s=XO,o=QO);let c=i.length,u=s.length,h=o.length,d=i.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=lt._malloc(p),v=new Float32Array(lt.HEAPF32.buffer,y,d),x=new Uint32Array(lt.HEAPU32.buffer,y+m,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let S;e?.scaleBaked?.some(A=>A!==1)&&(S=new ue().makeScale(...e.scaleBaked)),r&&(S?S.premultiply(r):S=r);let w=S?lt.alloc_subdivision_surface2(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,S.elements):lt.alloc_subdivision_surface(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return lt._free(y),w}static buildLevel(e,r,i,s,o){let a=o?lt.get_mesh_data2(e,r?lt.Level.CONTROL:lt.Level.REFINED,i,o.elements):lt.get_mesh_data(e,r?lt.Level.CONTROL:lt.Level.REFINED,i),l=8,c=lt.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=lt.HEAPU32[c[h]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let p=lt.HEAPU32[c[h]>>2],m=lt.HEAPF32.subarray(p>>2,(p>>2)+u[h]);h++;let g=lt.HEAPU32[c[h]>>2],y=lt.HEAPU32.subarray(g>>2,(g>>2)+u[h]);h++;let v=lt.HEAPU32[c[h]>>2],x=lt.HEAPU32.subarray(v>>2,(v>>2)+u[h]);if(h++,s===void 0){let S=new _e;if(S.setIndex(new ho(x,1)),S.setAttribute("position",new Me(f,3)),S.setAttribute("normal",new Me(m,3)),r){S.setAttribute("faceMap",new ho(y,1));let w=new Float32Array(m.length/3*4).fill(0);S.setAttribute("color",new Xe(w,4))}return lt.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,lt.free_mesh_data(a)}static freeSubdivPointer(e){lt.free_bvh(e),lt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let s=lt.get_wireframe_data_for_base_level(e),o=4,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=lt.HEAPU32[a[c]>>2],h=lt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=lt.HEAPU32[a[c]>>2],f=lt.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let p=new _e;p.setAttribute("position",new Me(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=i.r,m[g++]=i.g,m[g++]=i.b;return p.setAttribute("color",new Xe(m,3)),p.setIndex(new ho(f,1)),lt.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,lt.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,i){let s=r===0;s||lt.set_destination_refinement_level(e,r);let o=i?lt.get_topological_data2(e,s?lt.Level.CONTROL:lt.Level.REFINED,i.elements):lt.get_topological_data(e,s?lt.Level.CONTROL:lt.Level.REFINED),a=6,l=lt.HEAPU32.subarray(o>>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=lt.HEAPU32[l[u]>>2],d=new Float32Array(lt.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=lt.HEAPU32[l[u]>>2],p=new Uint32Array(lt.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=lt.HEAPU32[l[u]>>2],g=new Uint8Array(lt.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return lt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var KO=["getX","getY","getZ"];function Uc(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[KO[d]](u)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(n[KO[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 R0=new E,UA=new E,zA=new E,kA=new E;function GA(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,p)=>Math.floor(p/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]){R0.set(n[t[a]*3],n[t[a]*3+1],n[t[a]*3+2]),UA.set(n[t[a+1]*3],n[t[a+1]*3+1],n[t[a+1]*3+2]),zA.set(n[t[a+4]*3],n[t[a+4]*3+1],n[t[a+4]*3+2]),kA.set(n[t[a+5]*3],n[t[a+5]*3+1],n[t[a+5]*3+2]),UA.sub(R0).normalize(),zA.sub(R0).normalize(),kA.sub(R0).normalize();let l=UA.cross(zA).dot(kA);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:a>=r[u]&&a<r[u+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 ms={};uT(ms,{calcBoolean:()=>lY,calcBooleanTopological:()=>aY,freeMeshSet:()=>dY,getMeshSet:()=>cY,hasOpenEdges:()=>uY,transformMeshSet:()=>hY});var ZO,JO=new Promise(n=>{ZO=n});var L0;function $O(){if(L0)return L0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.9.31/build",i=import("./boolean.js"),[s,o]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});ZO(l)}return L0=n(),L0}var Tt,Pd;JO.then(n=>Tt=n);function oY(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}=Uc(n.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:c}=GA(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 eR(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=Tt._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(Tt.HEAPU32.buffer,s,t):new Float32Array(Tt.HEAPF32.buffer,s,t)).set(n,0),s}function tR(n){switch(n){case 0:return Tt.OP.UNION;case 1:return Tt.OP.INTERSECTION;case 2:return Tt.OP.A_MINUS_B;case 3:return Tt.OP.B_MINUS_A;case 4:return Tt.OP.SYMMETRIC_DIFFERENCE;case 5:return Tt.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function aY(n,t){Pd===void 0&&(Pd=Tt.init_csg());let e=eR(n),r=Tt.csg_calc_topological(Pd,e,n.length,tR(t));Tt._free(e);let i=6,s=Tt.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=Tt.HEAPU32[s[a]>>2],c=new Float32Array(Tt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=Tt.HEAPU32[s[a]>>2],h=new Uint32Array(Tt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=Tt.HEAPU32[s[a]>>2],f=new Uint8Array(Tt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return Tt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function lY(n,t,e,r){Pd===void 0&&(Pd=Tt.init_csg());let i=eR(n),s=Tt.csg_calc(Pd,i,n.length,r,tR(t));Tt._free(i);let o=5,a=Tt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=Tt.HEAPU32[a[c]>>2],h=Tt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Tt.HEAPU32[a[c]>>2],f=Tt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=l[c];e.setAttribute("position",new Me(h,3)),e.setAttribute("normal",new Me(f,3));let m=Tt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Or),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Tt.free_mesh_data(s),p}function cY(n,t,e){if(Tt===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((v,x)=>v+x,0)+s);for(let v=0,x=0,S=0;v<y.verticesPerFace.length;v++){i[S++]=y.verticesPerFace[v];for(let w=0;w<y.verticesPerFace[v];w++)i[S++]=y.indices[x++]}}else({positions:r,faceIndices:i,nFaces:s}=oY(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=Tt._malloc(u),p=new Float32Array(Tt.HEAPF32.buffer,f,l),m=new Uint32Array(Tt.HEAPU32.buffer,f+h,c);p.set(r,0),m.set(i,0);let g=Tt.get_csg_mesh(f,o,f+h,a,s);return Tt._free(f),g}function uY(n){return Tt.has_open_edges(n)}function hY(n,t){Tt.transform_csg_mesh(n,t.elements)}function dY(n){Tt.free_csg_mesh(n)}var fY={ConeGeometry:QI,CubeGeometry:KI,CylinderGeometry:g0,DodecahedronGeometry:ZI,EllipseGeometry:Ad,HelixGeometry:TO,IcosahedronGeometry:CO,LatheGeometry:PO,NonParametricGeometry:OO,PolygonGeometry:C0,PyramidGeometry:RO,RectangleGeometry:Td,SphereGeometry:LO,PlaneGeometry:BO,BackdropGeometry:NO,StarGeometry:P0,TextFrameGeometry:FO,TorusGeometry:VO,TorusKnotGeometry:UO,TriangleGeometry:zO,PathGeometry:GO,VectorGeometry:Rn},VA=n=>fY[n.type].create(n);function _d(n){return n!==null&&"booleanOp"in n}var Dd=class extends md(Ut){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ue}updateVisible(e){super.updateVisible(e),this.visible=!_d(this.parent)&&this.visible,_d(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(ms.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),_d(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Dd&&(e.freeBooleanPointer(),_d(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&_d(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),_d(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var B0=new jt;function hm(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),p=n.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>c&&(c=f),p>u&&(u=p)}B0.min.set(s,o,a),B0.max.set(l,c,u),B0.getCenter(r),B0.getSize(i).multiplyScalar(.5)}var pY=new _e,mY=new on,mr=class extends Dd{constructor(t,e){super(pY,mY),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?hm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var _a=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(_a.uuidContext===null)throw new Error("plz startContext");_a.uuidContext===_a.globalContext?this.uuid="_gid"+_a.uuidContext.nodeContextUuid++:this.uuid="_uid"+_a.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===_a.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}},sr=_a;sr.globalContext={nodeContextUuid:0},sr.uuidContext=_a.globalContext;var dm=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 jA=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}},_i=new jA;var tt=class extends sr{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=we.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 or=class extends tt{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 Hr=class extends or{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 Xi=class extends or{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 vr=class extends We{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 Ln=class extends or{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof vr?e:new vr(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 gY=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,rR=/[a-z_0-9]+/gi,Ee=class extends tt{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=rR.exec(this.src);)u.push(a);for(let h=0;h<u.length;h++){let d=u[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&_i.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=_i.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||_i.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&_i.contains(m)&&e.include(_i.get(m))}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=gY.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(rR);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 yY=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,HA=class extends tt{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||HA.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=yY.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)}},Wt=HA;Wt.PI="PI",Wt.PI2="PI2",Wt.RECIPROCAL_PI="RECIPROCAL_PI",Wt.RECIPROCAL_PI2="RECIPROCAL_PI2",Wt.LOG2="LOG2",Wt.EPSILON="EPSILON";var vY=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3142
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+i,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+i,n)>n.width&&(i.length===1?(r[r.length-1]+=i,i=""):(r[r.length-1]+=i.slice(0,-1),i=i[i.length-1],r.push(""))));return r[r.length-1]+=i,r}var WO,I0=new Promise(n=>{WO=n}),HO=!1;var D0;function qO(){if(HO)return;if(D0)return D0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.9.32/build",i=import("./process.js"),[s,o]=await Promise.all([i,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});WO(l),HO=!0}return D0=n(),D0}var nY=["font"];function Pa(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];x1(h)&&!nY.includes(i)&&(u[i]=t.getVariable(h,[r.uuid,"geometry",...c,i]),x1(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=qt.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 Xu().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 ni(s,e);return c.data=n,c}else{if(s.type==="TextGeometry")return new Vc(s,t);if(s.type==="InputGeometry")return new Vc(s,t);if(s.type==="UIGeometry")return Td.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=VA(a)}catch(c){console.error(c)}if(!l){let c=qt.createFromState(zh.defaultData(),100,100);a.shape=c,l=VA(a)}return l}var sY=new ue;function um(n,t,e,r){let i=n.position.array,s=n.normal.array,o=sY.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 O0=new jt,Cd=new E,lt;I0.then(n=>{lt=n});var YO=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),XO=new Uint32Array([0,1,2,3]),QO=new Uint8Array([4]),ni=class extends _e{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,s=Eo.div(r,i);this.subdividedGeometry&&um(this.subdividedGeometry.attributes,...s),this.originalGeometry&&um(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(Cd.fromArray(s));let a=Cd.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}=ni.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new mi(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&&(ni.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Or,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;O0.setFromBufferAttribute(r),O0.getCenter(i),e.boundingSphere.radius=i.distanceTo(O0.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),O0.getSize(Cd);let s={width:Cd.x,height:Cd.y,depth:Cd.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&&(lt.free_bvh(r),lt.free_subdivision_surface(r));try{o=ni.allocate(e,s)}catch(u){console.error(u,e),o=ni.allocate({positionWASM:YO,indexWASM:XO,verticesPerFaceWASM:QO},s)}if(lt.set_destination_refinement_level(o,0),a=ni.buildLevel(o,!0,c),e.subdivisions>0)try{lt.set_destination_refinement_level(o,e.subdivisions),l=ni.buildLevel(o,!1,c)}catch{try{lt.set_destination_refinement_level(o,e.subdivisions-1),l=ni.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:Pa(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=Uc(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}=GA(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=YO,s=XO,o=QO);let c=i.length,u=s.length,h=o.length,d=i.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=lt._malloc(p),v=new Float32Array(lt.HEAPF32.buffer,y,d),x=new Uint32Array(lt.HEAPU32.buffer,y+m,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let S;e?.scaleBaked?.some(A=>A!==1)&&(S=new ue().makeScale(...e.scaleBaked)),r&&(S?S.premultiply(r):S=r);let w=S?lt.alloc_subdivision_surface2(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,S.elements):lt.alloc_subdivision_surface(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return lt._free(y),w}static buildLevel(e,r,i,s,o){let a=o?lt.get_mesh_data2(e,r?lt.Level.CONTROL:lt.Level.REFINED,i,o.elements):lt.get_mesh_data(e,r?lt.Level.CONTROL:lt.Level.REFINED,i),l=8,c=lt.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=lt.HEAPU32[c[h]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let p=lt.HEAPU32[c[h]>>2],m=lt.HEAPF32.subarray(p>>2,(p>>2)+u[h]);h++;let g=lt.HEAPU32[c[h]>>2],y=lt.HEAPU32.subarray(g>>2,(g>>2)+u[h]);h++;let v=lt.HEAPU32[c[h]>>2],x=lt.HEAPU32.subarray(v>>2,(v>>2)+u[h]);if(h++,s===void 0){let S=new _e;if(S.setIndex(new ho(x,1)),S.setAttribute("position",new Me(f,3)),S.setAttribute("normal",new Me(m,3)),r){S.setAttribute("faceMap",new ho(y,1));let w=new Float32Array(m.length/3*4).fill(0);S.setAttribute("color",new Xe(w,4))}return lt.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,lt.free_mesh_data(a)}static freeSubdivPointer(e){lt.free_bvh(e),lt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let s=lt.get_wireframe_data_for_base_level(e),o=4,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=lt.HEAPU32[a[c]>>2],h=lt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=lt.HEAPU32[a[c]>>2],f=lt.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let p=new _e;p.setAttribute("position",new Me(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=i.r,m[g++]=i.g,m[g++]=i.b;return p.setAttribute("color",new Xe(m,3)),p.setIndex(new ho(f,1)),lt.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,lt.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,i){let s=r===0;s||lt.set_destination_refinement_level(e,r);let o=i?lt.get_topological_data2(e,s?lt.Level.CONTROL:lt.Level.REFINED,i.elements):lt.get_topological_data(e,s?lt.Level.CONTROL:lt.Level.REFINED),a=6,l=lt.HEAPU32.subarray(o>>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=lt.HEAPU32[l[u]>>2],d=new Float32Array(lt.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=lt.HEAPU32[l[u]>>2],p=new Uint32Array(lt.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=lt.HEAPU32[l[u]>>2],g=new Uint8Array(lt.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return lt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var KO=["getX","getY","getZ"];function Uc(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[KO[d]](u)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(n[KO[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 R0=new E,UA=new E,zA=new E,kA=new E;function GA(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,p)=>Math.floor(p/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]){R0.set(n[t[a]*3],n[t[a]*3+1],n[t[a]*3+2]),UA.set(n[t[a+1]*3],n[t[a+1]*3+1],n[t[a+1]*3+2]),zA.set(n[t[a+4]*3],n[t[a+4]*3+1],n[t[a+4]*3+2]),kA.set(n[t[a+5]*3],n[t[a+5]*3+1],n[t[a+5]*3+2]),UA.sub(R0).normalize(),zA.sub(R0).normalize(),kA.sub(R0).normalize();let l=UA.cross(zA).dot(kA);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:a>=r[u]&&a<r[u+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 ms={};uT(ms,{calcBoolean:()=>lY,calcBooleanTopological:()=>aY,freeMeshSet:()=>dY,getMeshSet:()=>cY,hasOpenEdges:()=>uY,transformMeshSet:()=>hY});var ZO,JO=new Promise(n=>{ZO=n});var L0;function $O(){if(L0)return L0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.9.32/build",i=import("./boolean.js"),[s,o]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});ZO(l)}return L0=n(),L0}var Tt,Pd;JO.then(n=>Tt=n);function oY(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}=Uc(n.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:c}=GA(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 eR(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=Tt._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(Tt.HEAPU32.buffer,s,t):new Float32Array(Tt.HEAPF32.buffer,s,t)).set(n,0),s}function tR(n){switch(n){case 0:return Tt.OP.UNION;case 1:return Tt.OP.INTERSECTION;case 2:return Tt.OP.A_MINUS_B;case 3:return Tt.OP.B_MINUS_A;case 4:return Tt.OP.SYMMETRIC_DIFFERENCE;case 5:return Tt.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function aY(n,t){Pd===void 0&&(Pd=Tt.init_csg());let e=eR(n),r=Tt.csg_calc_topological(Pd,e,n.length,tR(t));Tt._free(e);let i=6,s=Tt.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=Tt.HEAPU32[s[a]>>2],c=new Float32Array(Tt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=Tt.HEAPU32[s[a]>>2],h=new Uint32Array(Tt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=Tt.HEAPU32[s[a]>>2],f=new Uint8Array(Tt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return Tt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function lY(n,t,e,r){Pd===void 0&&(Pd=Tt.init_csg());let i=eR(n),s=Tt.csg_calc(Pd,i,n.length,r,tR(t));Tt._free(i);let o=5,a=Tt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=Tt.HEAPU32[a[c]>>2],h=Tt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Tt.HEAPU32[a[c]>>2],f=Tt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=l[c];e.setAttribute("position",new Me(h,3)),e.setAttribute("normal",new Me(f,3));let m=Tt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Or),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Tt.free_mesh_data(s),p}function cY(n,t,e){if(Tt===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((v,x)=>v+x,0)+s);for(let v=0,x=0,S=0;v<y.verticesPerFace.length;v++){i[S++]=y.verticesPerFace[v];for(let w=0;w<y.verticesPerFace[v];w++)i[S++]=y.indices[x++]}}else({positions:r,faceIndices:i,nFaces:s}=oY(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=Tt._malloc(u),p=new Float32Array(Tt.HEAPF32.buffer,f,l),m=new Uint32Array(Tt.HEAPU32.buffer,f+h,c);p.set(r,0),m.set(i,0);let g=Tt.get_csg_mesh(f,o,f+h,a,s);return Tt._free(f),g}function uY(n){return Tt.has_open_edges(n)}function hY(n,t){Tt.transform_csg_mesh(n,t.elements)}function dY(n){Tt.free_csg_mesh(n)}var fY={ConeGeometry:QI,CubeGeometry:KI,CylinderGeometry:g0,DodecahedronGeometry:ZI,EllipseGeometry:Ad,HelixGeometry:TO,IcosahedronGeometry:CO,LatheGeometry:PO,NonParametricGeometry:OO,PolygonGeometry:C0,PyramidGeometry:RO,RectangleGeometry:Td,SphereGeometry:LO,PlaneGeometry:BO,BackdropGeometry:NO,StarGeometry:P0,TextFrameGeometry:FO,TorusGeometry:VO,TorusKnotGeometry:UO,TriangleGeometry:zO,PathGeometry:GO,VectorGeometry:Rn},VA=n=>fY[n.type].create(n);function _d(n){return n!==null&&"booleanOp"in n}var Dd=class extends md(Ut){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ue}updateVisible(e){super.updateVisible(e),this.visible=!_d(this.parent)&&this.visible,_d(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(ms.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),_d(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Dd&&(e.freeBooleanPointer(),_d(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&_d(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),_d(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var B0=new jt;function hm(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),p=n.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>c&&(c=f),p>u&&(u=p)}B0.min.set(s,o,a),B0.max.set(l,c,u),B0.getCenter(r),B0.getSize(i).multiplyScalar(.5)}var pY=new _e,mY=new on,mr=class extends Dd{constructor(t,e){super(pY,mY),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?hm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var _a=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(_a.uuidContext===null)throw new Error("plz startContext");_a.uuidContext===_a.globalContext?this.uuid="_gid"+_a.uuidContext.nodeContextUuid++:this.uuid="_uid"+_a.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===_a.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}},sr=_a;sr.globalContext={nodeContextUuid:0},sr.uuidContext=_a.globalContext;var dm=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 jA=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}},_i=new jA;var tt=class extends sr{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=we.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 or=class extends tt{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 Hr=class extends or{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 Xi=class extends or{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 vr=class extends We{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 Ln=class extends or{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof vr?e:new vr(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 gY=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,rR=/[a-z_0-9]+/gi,Ee=class extends tt{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=rR.exec(this.src);)u.push(a);for(let h=0;h<u.length;h++){let d=u[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&_i.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=_i.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||_i.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&_i.contains(m)&&e.include(_i.get(m))}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=gY.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(rR);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 yY=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,HA=class extends tt{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||HA.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=yY.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)}},Wt=HA;Wt.PI="PI",Wt.PI2="PI2",Wt.RECIPROCAL_PI="RECIPROCAL_PI",Wt.RECIPROCAL_PI2="RECIPROCAL_PI2",Wt.LOG2="LOG2",Wt.EPSILON="EPSILON";var vY=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3143
3143
  )*?)}`,"gim"),xY=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Id=class extends tt{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=vY.exec(e);if(r){let i=r[2],s;for(;s=xY.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Od=class extends tt{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)}};_i.addKeyword("uv",function(){return new Od});_i.addKeyword("uv2",function(){return new Od(1)});var zc=class extends tt{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??zc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case mn:return["Linear"];case at:return["sRGB"];default:return[]}}generate(e,r){let i=this.input.build(e,"v4"),s=this.getType(e),o=zc.Nodes[this.method],a=e.include(o);if(a===zc.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=zc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=zc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},xn=zc;xn.Nodes={LinearToLinear:new Ee(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3144
3144
  `)),sRGBToLinear:new Ee(["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(`
3145
3145
  `)),LinearTosRGB:new Ee(["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(`
@@ -4958,7 +4958,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
4958
4958
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
4959
4959
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
4960
4960
  return displaced_position;
4961
- }`,[e,r])}}();var $e={normalRenderTarget:new bn,normalRenderTargetDepth:new bn,transmissionRenderTarget:new bn,aspectRatio:new Hr,transmissionSize:new Hr(2048,2048),transmissionRenderTargetDepth:new bn,aoRenderTarget:new bn,aoEnabled:new Kr,pixelRatioNode:new Fe(1),resolution:new Hr,penumbraSize:new Ys(5,.5),frameIndex:new It(0),transmissionLod:new It(2)};for(let n of Object.values($e))n.isRenderGlobal=!0;var z0={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.31/build/ui.wasm"};var Da=class extends sr{constructor(){super("basic");this.nodeType="Basic";this.color=new er(ii),this.shadingAlpha=new Fe(1),this.shadingBlend=new It(0),this.previousModelViewMatrix=new Qi,this.previouseProjectionMatrix=new Qi}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:$e.frameIndex}),e.mergeUniform({resolution:$e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Bs.merge([De.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
4961
+ }`,[e,r])}}();var $e={normalRenderTarget:new bn,normalRenderTargetDepth:new bn,transmissionRenderTarget:new bn,aspectRatio:new Hr,transmissionSize:new Hr(2048,2048),transmissionRenderTargetDepth:new bn,aoRenderTarget:new bn,aoEnabled:new Kr,pixelRatioNode:new Fe(1),resolution:new Hr,penumbraSize:new Ys(5,.5),frameIndex:new It(0),transmissionLod:new It(2)};for(let n of Object.values($e))n.isRenderGlobal=!0;var z0={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.9.32/build/ui.wasm"};var Da=class extends sr{constructor(){super("basic");this.nodeType="Basic";this.color=new er(ii),this.shadingAlpha=new Fe(1),this.shadingBlend=new It(0),this.previousModelViewMatrix=new Qi,this.previouseProjectionMatrix=new Qi}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:$e.frameIndex}),e.mergeUniform({resolution:$e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Bs.merge([De.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
4962
4962
  `));let s=["#include <beginnormal_vertex>",`
4963
4963
  #if !defined( USE_LAYER_DISPLACE )
4964
4964
  #include <defaultnormal_vertex>
@@ -7377,7 +7377,7 @@ void main() {
7377
7377
  gVelocity = vec4(0.0); // so it is ignored by TAA
7378
7378
  }`,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 We},covariancesTextureSize:{type:"v2",value:new U(1024,1024)},centersColorsTextureSize:{type:"v2",value:new U(1024,1024)},orthoZoom:{type:"f",value:-1}};return new it({uniforms:s,vertexShader:r,fragmentShader:i,transparent:!0,alphaTest:1,blending:Xa,depthTest:!0,depthWrite:!1,side:fi})}static buildGeomtery(e){let r=new _e;r.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),s=new Xe(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 bp().copy(r),a=new Uint32Array(e),l=new fo(a,1,!1);return l.setUsage(QC),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 p=0;p<this.covariances.length;p++)l[p]=uP.toHalfFloat(this.covariances[p]);a=new gi(l,s.x,s.y,Ju,Wn)}else l=new Float32Array(s.x*s.y*2),l.set(this.covariances),a=new gi(l,s.x,s.y,Ju,br);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 p=0;p<i;p++){let m=p*4,g=p*3,y=p*4;c[y]=$L(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[y+1]=Kx(this.centers[g]),c[y+2]=Kx(this.centers[g+1]),c[y+3]=Kx(this.centers[g+2])}let u=new gi(c,o.x,o.y,ww,Ds);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 p=0;p<this.meshMatrixWorlds.length;p++)d.set(this.meshMatrixWorlds[p].elements,p*16);let f=new gi(d,h,1,qr,br);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&&(Zx.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Zx),this.material.uniforms.basisViewport.value.set(2/Zx.x,2/Zx.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 tB,iM=new Promise(n=>{tB=n}),eB=!1;var $x;function nM(){if(eB)return;if($x)return $x;async function n(){let e=await import("./gaussian-splat-compression.js");tB(e),eB=!0}return $x=n(),$x}var rB;iM.then(n=>rB=n);var Vm=class{constructor(t={}){sc(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 Qe().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 rB.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 Qe,s=!1,o=1,a,l){this.splatMesh=$l.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=JL(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 _x=new on;_x.wireframe=!0;var iB=new E,Wl=class extends ei{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.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Qx;this.invisibleObjects=new ws("jflkdsafjasdifjaslk",{...Hv.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new cr("fdasfa",{...va.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=KL(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=QL(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 cr&&(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)=>rv(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===hs)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 cr&&r.uiScene){let i=r.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof cr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(i=>{r===void 0&&i instanceof Er&&(r=i.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof cr&&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(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,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(),cn(s)&&En(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");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),En(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),cn(i)&&(i.freeBooleanPointer(),s instanceof Fn&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof Ql&&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()),cn(i)&&(i.invalidateUpstreamBooleanData(),En(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Fn&&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 cr&&(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{qL(o,r,i,{scene:this,shared:s}),o instanceof lr&&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 Er||l instanceof cr)&&(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 wr&&s.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){yt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{yt.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=ml(u.data,h=>{let d=h.events.data(l.id),f=u.goUp(a);if(f){let p=[...tv(f.identity),e].join("-"),m=this.entityIdentityToEntity[p];if(m){let g=m.uuid,y=Sr.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 $s&&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=ml(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of Xh.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 $s&&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),kx(o)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof $s&&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)yt.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(yt.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(cn(a)||Pm(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),Fm(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;yt.is(o)&&(o.visible||a?.object.data.visible)&&((cn(o)||Pm(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),Fm(o,e,r,!0)),i(o))}};return i(this),r}forEachEntity(e){for(let r of this.children)yt.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)yt.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)yt.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(i=>{if(i instanceof lr&&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);let a=i.invalidateDownstreamBooleanData();En(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)dd.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)yt.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=Xx(e,r,l);return 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 lr&&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 lr&&h.bones&&h.boneInverses){let d=h.bones.map(m=>this.find(m)),f=h.boneInverses.map(m=>new ue().fromArray(m)),p=new el(d,f);u.bind(p,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 jt;return i.setFromPoints(r),i.getCenter(iB),iB}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 mr)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)r.material[i]instanceof Nn&&e(r.material[i]);else r.material instanceof Nn&&e(r.material)})}updateViewPlaneSize(e,r,i=!1){this.traverseConcreteEntity(s=>{s instanceof wr&&s.setViewplaneSize(e,r,i)})}initializeSplatViewer(){this.splatViewer=new Vm({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Um=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},nB=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return KK(Math.atan2(r,e))},sB=(n,t,e)=>{let r={x:0,y:0};return e=eb(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},eb=n=>n*(Math.PI/180),KK=n=>n*(180/Math.PI),oB=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,sM=new Map,oM=n=>{sM.has(n)&&clearTimeout(sM.get(n)),sM.set(n,setTimeout(n,100))},Cf=(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)},aM=(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 tb=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),lM=()=>{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}},rb=(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")},ib=(n,t,e)=>{let r=lB(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},aB=(n,t)=>{let e=lB(n);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},lB=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},nb=(n,t)=>{for(let e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n},cB=(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},zm=(n,t)=>{if(n.length)for(let e=0,r=n.length;e<r;e+=1)t(n[e]);else t(n)},uB=(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"&&(hB="ontouchstart"in window,dB=!!window.PointerEvent,fB=!!window.MSPointerEvent);var hB,dB,fB,km={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"}},Pf,Gm={};dB?Pf=km.pointer:fB?Pf=km.MSPointer:hB?(Pf=km.touch,Gm=km.mouse):Pf=km.mouse;function tu(){}tu.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};tu.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};tu.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)})};tu.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=cB(t.options,n))};tu.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.')},Cf(n,Pf[t],e._domHandlers_[t]),Gm[t]&&Cf(n,Gm[t],e._domHandlers_[t]),e};tu.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},aM(n,Pf[t],e._domHandlers_[t]),Gm[t]&&aM(n,Gm[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var _f=tu;function Di(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=Di.id,Di.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}Di.prototype=new _f;Di.constructor=Di;Di.id=0;Di.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)};Di.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=aB("borderRadius","50%"),e=ib("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)"},nb(r.el,e),this.options.shape==="circle"&&nb(r.back,t),nb(r.front,t),this.applyStyles(r),this};Di.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};Di.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Di.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Di.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Di.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};Di.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};Di.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=ib("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)};Di.prototype.restCallback=function(){var n=this,t={};t.front=ib("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};Di.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Di.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 pB=Di;function oi(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=oi.id,oi.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}oi.prototype=new _f;oi.constructor=oi;oi.id=0;oi.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}};oi.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};oi.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)}};oi.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 pB(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||(rb(c.ui.el,i),rb(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};oi.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};oi.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)};oi.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)};oi.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=tb(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 zm(n,i),t.manager.bindDocument(),!1};oi.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=Um(o,a.position);if(c<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(n);return}}return a};oi.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)};oi.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(!oB(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=Um(l,i.position),u=nB(l,i.position),h=eb(u),d=c/a,f={distance:c,position:l},p,m;if(i.options.shape==="circle"?(p=Math.min(c,a),m=sB(i.position,p,u)):(m=uB(l,i.position,a),p=Um(m,i.position)),e.follow){if(c>a){let x=l.x-m.x,S=l.y-m.y;i.position.x+=x,i.position.y+=S,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=Um(l,i.position)}}else l=m,c=p;var g=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:g,y},e.dataOnly||rb(i.ui.front,i.frontPosition);var v={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};v=i.computeDirection(v),v.angle={radian:eb(180-u),degree:180-u},i.trigger("move",v),t.trigger("move "+i.id+":move",v)};oi.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))};oi.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()};oi.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 mB=oi;function ji(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=lM(),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;Cf(window,"resize",function(){oM(e)});var r=function(){t.scroll=lM()};return Cf(window,"scroll",function(){oM(r)}),t.collections}ji.prototype=new _f;ji.constructor=ji;ji.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}};ji.prototype.create=function(n){return this.createCollection(n)};ji.prototype.createCollection=function(n){var t=this,e=new mB(t,n);return t.bindCollection(e),t.collections.push(e),e};ji.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)};ji.prototype.bindDocument=function(){var n=this;n.binded||(n.bindEvt(document,"move").bindEvt(document,"end"),n.binded=!0)};ji.prototype.unbindDocument=function(n){var t=this;(!Object.keys(t.ids).length||n===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};ji.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]};ji.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};ji.prototype.onmove=function(n){var t=this;return t.onAny("move",n),!1};ji.prototype.onend=function(n){var t=this;return t.onAny("end",n),!1};ji.prototype.oncancel=function(n){var t=this;return t.onAny("end",n),!1};ji.prototype.onAny=function(n,t){var e=this,r,i="processOn"+n.charAt(0).toUpperCase()+n.slice(1);t=tb(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),zm(e.collections,s.bind(null,a,r)),a._found_||e.removeIdentifier(r)};return zm(t,o),!1};ji.prototype.destroy=function(){var n=this;n.unbindDocument(!0),n.ids={},n.index=0,n.collections.forEach(function(t){t.destroy()}),n.off()};ji.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 gB=ji;var yB=new gB,vB={create:function(n){return yB.create(n)},factory:yB};var xB=new Map,jm=new Map,jo=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");let c=typeof s=="string"?i.getAudio(s).src:s.data;this.audioPlayer=new Ra({src:c,volume:o,delay:a,loop:l}),jm.has(r.uuid)?jm.get(r.uuid).push(this):jm.set(r.uuid,[this]),xB.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()}},Df=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=xB.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=jm.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=[...jm.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}},Hm=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new jo(t,e,r,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Df(e);else throw new Error("Missing property")}dispatchBasic(){if(wt(this.shared,this.condition)===!1)return!1;this.interaction instanceof jo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(wt(this.shared,this.condition)===!1)return!1;this.interaction instanceof jo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){if(wt(this.shared,this.condition)===!1)return!1;this.interaction instanceof jo&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var Wm=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(wt(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(wt(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(wt(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 ZK="text/plain",JK="us-ascii",bB=(n,t)=>t.some(e=>e instanceof RegExp?e.test(n):e===n),$K=(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(p=>p.trim());return d==="charset"&&(f=f.toLowerCase(),f===JK)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&u.push("base64"),(u.length>0||l&&l!==ZK)&&u.unshift(l),`data:${u.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function cM(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 $K(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];bB(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()])bB(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 ob=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:cM(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(wt(this.shared,this.condition)===!1)return!1;yo?window.location.assign(this.url):(this.context==="tab"||Zw&&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(Je[0]),q2())}};var qm=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(wt(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(wt(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 Ym=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(wt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),If(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}};var TB={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},fM={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},eZ=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],lb={CSS:{},springs:{}};function eo(n,t,e){return Math.min(Math.max(n,t),e)}function Xm(n,t){return n.indexOf(t)>-1}function uM(n,t){return n.apply(null,t)}var ht={arr:function(n){return Array.isArray(n)},obj:function(n){return Xm(Object.prototype.toString.call(n),"Object")},pth:function(n){return ht.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||ht.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 ht.hex(n)||ht.rgb(n)||ht.hsl(n)},key:function(n){return!TB.hasOwnProperty(n)&&!fM.hasOwnProperty(n)&&n!=="targets"&&n!=="keyframes"}};function CB(n){var t=/\(([^)]+)\)/.exec(n);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function PB(n,t){var e=CB(n),r=eo(ht.und(e[0])?1:e[0],.1,100),i=eo(ht.und(e[1])?100:e[1],.1,100),s=eo(ht.und(e[2])?10:e[2],.1,100),o=eo(ht.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(p){var m=t?t*p/1e3:p;return l<1?m=Math.exp(-m*l*a)*(u*Math.cos(c*m)+h*Math.sin(c*m)):m=(u+h*m)*Math.exp(-m*a),p===0||p===1?p:1-m}function f(){var p=lb.springs[n];if(p)return p;for(var m=1/6,g=0,y=0;;)if(g+=m,d(g)===1){if(y++,y>=16)break}else y=0;var v=g*m*1e3;return lb.springs[n]=v,v}return t?d:f}function tZ(n){return n===void 0&&(n=10),function(t){return Math.ceil(eo(t,1e-6,1)*n)*(1/n)}}var rZ=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,p){var m,g,y=0;do g=h+(d-h)/2,m=s(g,f,p)-u,m>0?d=g:h=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(u,h,d,f){for(var p=0;p<4;++p){var m=o(h,d,f);if(m===0)return h;var g=s(h,d,f)-u;h-=g/m}return h}function c(u,h,d,f){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var p=new Float32Array(n);if(u!==h||d!==f)for(var m=0;m<n;++m)p[m]=s(m*t,u,d);function g(y){for(var v=0,x=1,S=n-1;x!==S&&p[x]<=y;++x)v+=t;--x;var w=(y-p[x])/(p[x+1]-p[x]),A=v+w*t,M=o(A,u,d);return M>=.001?l(y,A,u,d):M===0?A:a(y,v,v+t,u,d)}return function(y){return u===h&&d===f||y===0||y===1?y:s(g(y),h,f)}}return c}(),_B=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=eo(r,1,10),o=eo(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 pM(n,t){if(ht.fnc(n))return n;var e=n.split("(")[0],r=_B[e],i=CB(n);switch(e){case"spring":return PB(n,t);case"cubicBezier":return uM(rZ,i);case"steps":return uM(tZ,i);default:return uM(r,i)}}function DB(n){try{var t=document.querySelectorAll(n);return t}catch{return}}function cb(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 ub(n){return n.reduce(function(t,e){return t.concat(ht.arr(e)?ub(e):e)},[])}function SB(n){return ht.arr(n)?n:(ht.str(n)&&(n=DB(n)||n),n instanceof NodeList||n instanceof HTMLCollection?[].slice.call(n):[n])}function mM(n,t){return n.some(function(e){return e===t})}function gM(n){var t={};for(var e in n)t[e]=n[e];return t}function hM(n,t){var e=gM(n);for(var r in n)e[r]=t.hasOwnProperty(r)?t[r]:n[r];return e}function hb(n,t){var e=gM(n);for(var r in t)e[r]=ht.und(n[r])?t[r]:n[r];return e}function iZ(n){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(n);return t?"rgba("+t[1]+",1)":n}function nZ(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 sZ(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,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?d+(f-d)*6*p:p<1/2?f:p<2/3?d+(f-d)*(2/3-p)*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 oZ(n){if(ht.rgb(n))return iZ(n);if(ht.hex(n))return nZ(n);if(ht.hsl(n))return sZ(n)}function Fa(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 aZ(n){if(Xm(n,"translate")||n==="perspective")return"px";if(Xm(n,"rotate")||Xm(n,"skew"))return"deg"}function dM(n,t){return ht.fnc(n)?n(t.target,t.id,t.total):n}function Ho(n,t){return n.getAttribute(t)}function yM(n,t,e){var r=Fa(t);if(mM([e,"deg","rad","turn"],r))return t;var i=lb.CSS[t+e];if(!ht.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 lb.CSS[t+e]=c,c}function IB(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?yM(n,i,e):i}}function vM(n,t){if(ht.dom(n)&&!ht.inp(n)&&(Ho(n,t)||ht.svg(n)&&n[t]))return"attribute";if(ht.dom(n)&&mM(eZ,t))return"transform";if(ht.dom(n)&&t!=="transform"&&IB(n,t))return"css";if(n[t]!=null)return"object"}function OB(n){if(!!ht.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 lZ(n,t,e,r){var i=Xm(t,"scale")?1:0+aZ(t),s=OB(n).get(t)||i;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),r?yM(n,s,r):s}function xM(n,t,e,r){switch(vM(n,t)){case"transform":return lZ(n,t,r,e);case"css":return IB(n,t,e);case"attribute":return Ho(n,t);default:return n[t]||0}}function bM(n,t){var e=/^(\*=|\+=|-=)/.exec(n);if(!e)return n;var r=Fa(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 RB(n,t){if(ht.col(n))return oZ(n);if(/\s/g.test(n))return n;var e=Fa(n),r=e?n.substr(0,n.length-e.length):n;return t?r+t:r}function SM(n,t){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))}function cZ(n){return Math.PI*2*Ho(n,"r")}function uZ(n){return Ho(n,"width")*2+Ho(n,"height")*2}function hZ(n){return SM({x:Ho(n,"x1"),y:Ho(n,"y1")},{x:Ho(n,"x2"),y:Ho(n,"y2")})}function LB(n){for(var t=n.points,e=0,r,i=0;i<t.numberOfItems;i++){var s=t.getItem(i);i>0&&(e+=SM(r,s)),r=s}return e}function dZ(n){var t=n.points;return LB(n)+SM(t.getItem(t.numberOfItems-1),t.getItem(0))}function BB(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return cZ(n);case"rect":return uZ(n);case"line":return hZ(n);case"polyline":return LB(n);case"polygon":return dZ(n)}}function fZ(n){var t=BB(n);return n.setAttribute("stroke-dasharray",t),t}function pZ(n){for(var t=n.parentNode;ht.svg(t)&&ht.svg(t.parentNode);)t=t.parentNode;return t}function NB(n,t){var e=t||{},r=e.el||pZ(n),i=r.getBoundingClientRect(),s=Ho(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 mZ(n,t){var e=ht.str(n)?DB(n)[0]:n,r=t||100;return function(i){return{property:i,el:e,svg:NB(e),totalLength:BB(e)*(r/100)}}}function gZ(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=NB(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 wB(n,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=RB(ht.pth(n)?n.totalLength:n,t)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:ht.str(n)||t?r.split(e):[]}}function FB(n){var t=n?ub(ht.arr(n)?n.map(SB):SB(n)):[];return cb(t,function(e,r,i){return i.indexOf(e)===r})}function VB(n){var t=FB(n);return t.map(function(e,r){return{target:e,id:r,total:t.length,transforms:{list:OB(e)}}})}function yZ(n,t){var e=gM(t);if(/^spring/.test(e.easing)&&(e.duration=PB(e.easing)),ht.arr(n)){var r=n.length,i=r===2&&!ht.obj(n[0]);i?n={value:n}:ht.fnc(t.duration)||(e.duration=t.duration/r)}var s=ht.arr(n)?n:[n];return s.map(function(o,a){var l=ht.obj(o)&&!ht.pth(o)?o:{value:o};return ht.und(l.delay)&&(l.delay=a?0:t.delay),ht.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return hb(o,e)})}function vZ(n){for(var t=cb(ub(n.map(function(s){return Object.keys(s)})),function(s){return ht.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)ht.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 xZ(n,t){var e=[],r=t.keyframes;r&&(t=hb(vZ(r),t));for(var i in t)ht.key(i)&&e.push({name:i,tweens:yZ(t[i],n)});return e}function bZ(n,t){var e={};for(var r in n){var i=dM(n[r],t);ht.arr(i)&&(i=i.map(function(s){return dM(s,t)}),i.length===1&&(i=i[0])),e[r]=i}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function SZ(n,t){var e;return n.tweens.map(function(r){var i=bZ(r,t),s=i.value,o=ht.arr(s)?s[1]:s,a=Fa(o),l=xM(t.target,n.name,a,t),c=e?e.to.original:l,u=ht.arr(s)?s[0]:c,h=Fa(u)||Fa(l),d=a||h;return ht.und(o)&&(o=c),i.from=wB(u,d),i.to=wB(bM(o,u),d),i.start=e?e.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=pM(i.easing,i.duration),i.isPath=ht.pth(s),i.isColor=ht.col(i.from.original),i.isColor&&(i.round=1),e=i,i})}var UB={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 zB(n,t){var e=VB(n);e.forEach(function(r){for(var i in t){var s=dM(t[i],r),o=r.target,a=Fa(s),l=xM(o,i,a,r),c=a||Fa(l),u=bM(RB(s,c),l),h=vM(o,i);UB[h](o,i,u,r.transforms,!0)}})}function wZ(n,t){var e=vM(n.target,t.name);if(e){var r=SZ(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 AZ(n,t){return cb(ub(n.map(function(e){return t.map(function(r){return wZ(e,r)})})),function(e){return!ht.und(e)})}function kB(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 AB=0;function EZ(n){var t=hM(TB,n),e=hM(fM,n),r=xZ(e,n),i=VB(n.targets),s=AZ(i,r),o=kB(s,e),a=AB;return AB++,hb(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 Es=[],EB=[],ab,MZ=function(){function n(){ab=requestAnimationFrame(t)}function t(e){var r=Es.length;if(r){for(var i=0;i<r;){var s=Es[i];s.paused?(Es.splice(i,1),r-=1):(s.tick(e),i++)}n()}else ab=cancelAnimationFrame(ab)}return n}();function TZ(n){document.hidden?(Es.forEach(function(t){return t.pause(n.timeStamp)}),EB=Es.slice(0),ai.running=Es=[]):EB.forEach(function(t){return t.play(n.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",TZ);function ai(n){n===void 0&&(n={});var t=0,e=0,r=0,i,s,o=0,a=null;function l(M){var b=window.Promise&&new Promise(function(T){return a=T});return M.finished=b,b}var c=EZ(n),u=l(c);function h(){var M=c.direction;M!=="alternate"&&(c.direction=M!=="normal"?"normal":"reverse"),c.reversed=!c.reversed,s.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=c.reversed)})}function d(){c.direction="normal",c.reversed=!1,s.forEach(function(M){return M.reversed=!1})}function f(M){return c.reversed?c.duration-M:M}function p(){t=0,e=f(c.currentTime)*(1/ai.speed)}function m(M,b,T=!1){b&&(c.reversed?b.seek(b.duration*b.loop-(M-b.timelineOffset-b.pingPongDelayCorrection),T):b.seek(M-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection,T))}function g(M,b=!1){if(c.reversed)for(var C=o;C--;)m(M,s[C],b);else for(var T=0;T<o;T++)m(M,s[T],b)}function y(M){var b=0,T=c.animations,C=T.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"?M=c.duration-c.delay+c.endDelay-M:M=c.duration+c.delay-c.endDelay-M):w(!1,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)&&(c.parent?.reversed&&c.direction==="alternate"?M=c.duration-c.delay+c.endDelay-M:M=c.duration+c.delay-c.endDelay-M);b<C;){var P=T[b],D=P.animatable,_=P.tweens,I=_.length-1,L=_[I];I&&(L=cb(_,function(J){return M<J.end})[0]||L);let re;c.parent?.reversed&&c.direction==="alternate"?re=eo(M-L.start-L.endDelay,0,L.duration)/L.duration:re=eo(M-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,W=[],q=L.to.numbers.length,K=void 0,G=0;G<q;G++){var Z=void 0;let J,Ae;c.direction!=="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1?(J=L.to.numbers[G],Ae=L.from.numbers[G]||0):(Ae=L.to.numbers[G],J=L.from.numbers[G]||0):w(!0,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)?(J=L.to.numbers[G],Ae=L.from.numbers[G]||0):(Ae=L.to.numbers[G],J=L.from.numbers[G]||0),L.isPath?Z=gZ(L.value,j*Ae):Z=J+j*(Ae-J),H&&(L.isColor&&G>2||(Z=Math.round(Z*H)/H)),W.push(Z)}var te=V.length;if(!te)K=W[0];else{K=V[0];for(var $=0;$<te;$++){var Y=V[$],oe=V[$+1],ie=W[$];isNaN(ie)||(oe?K+=ie+oe:K+=ie+" ")}}UB[P.type](D.target,P.property,K,D.transforms),P.currentValue=K,b++}}function v(M){c[M]&&!c.passThrough&&c[M](c)}function x(){c.remaining&&c.remaining!==!0&&c.remaining--}let S={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(M,b,T,C,P){return S[M<<4|b<<3|T<<2|C<<1|P]}function A(M,b=!1){var T=c.duration;let C=c.delay,P=T-c.endDelay;c.parent?.reversed&&c.direction==="alternate"&&(C=c.endDelay,P=T-c.delay);var D=f(M);if(c.progress=eo(D/T*100,0,100),b||(c.reversePlayback=D<c.currentTime),o&&g(D,b),!c.began&&c.currentTime>=0&&(c.began=!0,v("begin")),!c.loopBegan&&c.currentTime>0&&(c.loopBegan=!0,v("loopBegin")),(c.reversed||D>=0)&&D<=C&&c.currentTime!==0&&(y(0),v("change")),(D>=P&&c.currentTime!==T+c.pingPongDelayCorrection||!T)&&(y(T),v("change")),D>C&&D<P?(c.changeBegan||(c.changeBegan=!0,c.changeCompleted=!1,v("changeBegin")),y(D),v("change")):c.changeBegan?(c.changeCompleted=!0,c.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):c.began&&D>P&&v("changeComplete"),c.currentTime=eo(D,0,T+c.pingPongDelayCorrection),c.began&&v("update"),M>=T)if(x(),!c.remaining)c.paused=!0,c.completed||(c.completed=!0,v("loopComplete"),v("complete"),!c.passThrough&&"Promise"in window&&(a(),u=l(c)));else{o?t+=c.duration/ai.speed:t+=c.duration;for(let _ of s)_.setStartTime(0),_.remaining=_.loop;v("loopComplete"),c.loopBegan=!1,c.direction==="alternate"?h():o&&d()}}return c.reset=function(){var M=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.reversePlayback=!1,c.reversed=M==="reverse",c.remaining=c.loop,s=c.children,o=s.length;for(var b=o;b--;)c.children[b].reset();y(c.reversed?c.duration:0)},c.setStartTime=function(M){t=M},c.set=function(M,b){return zB(M,b),c},c.tick=function(M){r=M,t||(t=r),A((r+(e-t))*ai.speed)},c.seek=function(M,b=!1){A(M-t,b)},c.pause=function(M){c.paused=!0,o&&(i=M??performance.now())},c.play=function(M){!c.paused||(c.completed&&c.reset(),c.paused=!1,Es.push(c),o&&i!==void 0&&(t+=(M??performance.now())-i),ab||MZ())},c.reverse=function(){h(),c.completed=!c.reversed,p()},c.restart=function(){c.reset(),c.play()},c.reset(),c.autoplay&&c.play(),c}function MB(n,t){for(var e=t.length;e--;)mM(n,t[e].animatable.target)&&t.splice(e,1)}function CZ(n){for(var t=FB(n),e=Es.length;e--;){var r=Es[e],i=r.animations,s=r.children;MB(t,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;MB(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&r.pause()}}function PZ(n,t){t===void 0&&(t={});var e=t.direction||"normal",r=t.easing?pM(t.easing):null,i=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",c=o==="last",u=ht.arr(n),h=parseFloat(u?n[0]:n),d=u?parseFloat(n[1]):0,f=Fa(u?n[1]:n)||0,p=t.start||0+(u?h:0),m=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),c&&(o=x-1),!m.length){for(var S=0;S<x;S++){if(!i)m.push(Math.abs(o-S));else{var w=l?(i[0]-1)/2:o%i[0],A=l?(i[1]-1)/2:Math.floor(o/i[0]),M=S%i[0],b=Math.floor(S/i[0]),T=w-M,C=A-b,P=Math.sqrt(T*T+C*C);s==="x"&&(P=-T),s==="y"&&(P=-C),m.push(P)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(_){return r(_/g)*g})),e==="reverse"&&(m=m.map(function(_){return s?_<0?_*-1:-_:Math.abs(g-_)}))}var D=u?(d-h)/g:h;return p+D*(Math.round(m[v]*100)/100)+f}}function _Z(n){n===void 0&&(n={});var t=ai(n);return t.duration=0,t.add=function(e,r){var i=Es.indexOf(t),s=t.children;i>-1&&Es.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=hb(e,hM(fM,n));l.targets=l.targets||n.targets;var c=t.duration;l.autoplay=!1,l.timelineOffset=ht.und(r)?c:bM(r,c),o(t);var u=ai(l);o(u),s.push(u),u.parent=t;var h=kB(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}ai.version="3.2.0";ai.speed=1;ai.running=Es;ai.remove=CZ;ai.get=xM;ai.set=zB;ai.convertPx=yM;ai.path=mZ;ai.setDashoffset=fZ;ai.stagger=PZ;ai.timeline=_Z;ai.easing=pM;ai.penner=_B;ai.random=function(n,t){return Math.floor(Math.random()*(t-n+1))+n};var db=ai;var GB=new E,jB=new E,HB=new Qe;function qB(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 Zr(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=we.lerp(l,c,u);s?t[n]=Math.trunc(h):t[n]=h},start:()=>{t[n]=l},end:()=>{t[n]=c}}}function Km(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||Cc(c,u)))return{update:h=>{c.forEach((d,f)=>{let p=we.lerp(d,u[f],h);t[n][f]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[n],c)},end:()=>{Object.assign(t[n],u)}}}function Qm(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function wM(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?Qm(new E,s,i):a.clone(),c=Qm(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 WB(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function Of(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?WB(new U,s,i):c.clone(),h=WB(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 YB(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 Qe,u=new E;a.decompose(l,c,u);let h=new ue().fromArray(s),d=new E,f=new Qe,p=new E;if(h.decompose(d,f,p),!a.equals(h))return{update:m=>{HB.slerpQuaternions(c,f,m),GB.lerpVectors(l,d,m),jB.lerpVectors(u,p,m),o.compose(GB,HB,jB)},start:()=>{o.compose(l,c,u)},end:()=>{o.compose(d,f,p)}}}function XB(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 We().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new We().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 Zm(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 vr(a.r,a.g,a.b,a.a),c=s?typeof s=="string"?i.getColor(s).clone():new vr(s.r,s.g,s.b,s.a):l.clone(),u=typeof o=="string"?i.getColor(o).clone():new vr(o.r,o.g,o.b,o.a);if(!c.equals(u))return{update:h=>{l.lerpColors(c,u,h);let d=we.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 Wo(n,t,e,r,i){if(typeof t[n]=="number")return Zr(n,t,e??{},r,i);if(Array.isArray(t[n]))return Km(n,t,e??{},r,i)}function QB(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=we.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=Zr("targetOffset",n,t,e,r);a&&i.push(a)}return i}function DZ(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.getVariable(a)??0):a),s=e.scaleBaked.map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a);if(Eo.isEqual(i,s))return;let o=[];return o.push({update:a=>{n.updateGeometryInteractions({scaleBaked:[we.lerp(i[0],s[0],a),we.lerp(i[1],s[1],a),we.lerp(i[2],s[2],a)]},r),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions()},start:()=>{n.updateGeometryInteractions({scaleBaked:i},r),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions()},end:()=>{n.updateGeometryInteractions({scaleBaked:s},r),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions()}}),o}function IZ(n,t,e,r){if(!e.extrusion)return;let i=n.extrusion,s=t.extrusion??{},o=e.extrusion,a=[];return _1.forEach(l=>{let c=Wo(l,i,s,o,r);c&&a.push(c)}),a}function KB(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 Ks){let l=DZ(n,o,a,r);l&&i.push(...l)}else{let l={};if(Object.assign(l,Pn(s,zv),Pn(o,zv)),zv.forEach(c=>{let u=Wo(c,l,o,a,r);u&&i.push(u)}),n instanceof Ql){Object.assign(l,{extrusion:{...s.extrusion}});let c=IZ(l,o,a,r);c&&i.push(...c)}i.length&&i.push({update:c=>{n.updateGeometryInteractions(l,r),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions()},start:c=>{n.updateGeometryInteractions(l,r),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions()},end:c=>{n.updateGeometryInteractions(l,r),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions()}})}return i}function ZB(n,t,e,r){let i=[];if(e.intensity!==void 0){let s=Zr("intensity",n,t,e,r);s&&i.push(s)}if(e.color!==void 0){let s=XB("color",n,t,e,r);s&&i.push(s)}return i}function $B(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(...JB(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(...JB(n.material,s,o,r))}return i}function JB(n,t,e,r){let i=[],s=Wc(e,r)||!!t.layers&&Wc(t,r);i.push(zZ(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=>!Nv.some(h=>u.includes(h)));for(let u of c)try{let h=o.getValue(u),d;if(u==="colors")d=VZ(o,a,l,u);else if(Array.isArray(h))u==="steps"&&(d=FZ(o,a,l,u));else if(typeof h=="number")d=OZ(o,a,l,u,r);else{if(typeof h=="boolean")continue;h instanceof U?d=RZ(o,a,l,u):h instanceof E?d=LZ(o,a,l,u,r):h instanceof vr?d=NZ(o,a,l,u,r):h instanceof We?d=BZ(o,a,l,u,r):"isTexture"in h&&(d=UZ(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 OZ(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,we.lerp(a,l,c))},start:()=>{n.setValue(r,a)},end:()=>{n.setValue(r,l)}}}function RZ(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 LZ(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?Qm(new E,o,i):s.clone(),c=Qm(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 BZ(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 We().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new We().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 NZ(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 We().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new vr(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 FZ(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 Cc(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]=we.lerp(h,d,l)}n.setValue(r,c)},start:()=>{n.setValue(r,o)},end:()=>{n.setValue(r,a)}}),i.length?i:void 0}function VZ(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]];Gp.isEqual(c,u)||i.push({update:h=>{s[l].fromArray(Gp.lerp(c,u,h))},start:()=>{s[l].fromArray(c)},end:()=>{s[l].fromArray(u)}})}return i.length?i:void 0}function UZ(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=we.lerp(s,o,g)*we.DEG2RAD},start:()=>{i.value=s*we.DEG2RAD},end:()=>{i.value=o*we.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],p=l.rotation??0,m=c.rotation??0;if(!Fs.isEqual(u,d)||!Fs.isEqual(h,f)||p!==m)return{update:g=>{a.repeat=Fs.lerp(u,d,g),a.offset=Fs.lerp(h,f,g),a.rotation=we.lerp(p,m,g),a.updateMatrix()},start:()=>{a.repeat=[...u],a.offset=[...h],a.rotation=p,a.updateMatrix()},end:()=>{a.repeat=[...d],a.offset=[...f],a.rotation=m,a.updateMatrix()}}}function zZ(n,t){return{update:()=>{n.transparent=t}}}var AM=new E,eN=new ir;function tN(n,t,e,r,i){let s=[],o,a,l,c,u,h,d,f;if(n instanceof tr?(o=Of("position",n,t,e,i),o&&s.push(o),l=Zr("rotation",n,t,e,i),l&&s.push(l),c=Of("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=Zr("slide",f,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),h&&s.push(h),d=Zr("offset",f,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),d&&s.push(d),!h&&!d&&(o=wM("position",n,t,e,i),o&&s.push(o),a=wM("scale",n,t,e,i),a&&s.push(a),l=kZ(n,t,e,r,i),l&&s.push(l),u=YB("hiddenMatrix",n,t,e),u&&s.push(u))),o||a||l||u||h||d){let p=n instanceof tr?()=>{n.updateWorldMatrix(!0)}:()=>{n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n.parent?.matrixWorldFusedFalse&&(n.matrixWorld.multiplyMatrices(n.parent.matrixWorldFusedFalse,n.matrix),n.matrixWorldNeedsUpdate=!1),cn(n)&&En(n.parent)&&n.invalidateDownstreamBooleanData(!0),n.updatePathSnapping(Object.assign({},t.pathSnapping,f))};s.push({update:p,start:p,end:p})}return s}function kZ(n,t,e,r,i){let s=t?.rotation?t.rotation.map(u=>(typeof u=="string"?Number(i.getVariable(u)??0):u)*we.DEG2RAD):void 0,o=e.rotation?.map(u=>(typeof u=="string"?Number(i.getVariable(u)??0):u)*we.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=AM.subVectors(l,a);if(r&&c.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new Qe().setFromEuler(eN.setFromVector3(a)),h=new Qe().setFromEuler(eN.setFromVector3(l));return{update:d=>{qB(u,h,n.quaternion,d)},start:()=>{n.rotation.setFromVector3(a)},end:()=>{n.rotation.setFromVector3(l)}}}else return{update:u=>{AM.lerpVectors(a,l,u),n.rotation.setFromVector3(AM)},start:()=>{n.rotation.setFromVector3(a)},end:()=>{n.rotation.setFromVector3(l)}}}function rN(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;b1.forEach(f=>{let p;f==="count"?p=Zr("count",s.parameters,o,a,r,!0):p=Wo(f,s.parameters,o??{},a,r),p&&i.push(p)});let l=GZ(s,o,a,r);l?.length&&i.push(...l);let c=jZ(s,o,a,r);c?.length&&i.push(...c);let u=HZ(s,o,a,r);u?.length&&i.push(...u);let h=WZ(s,o,a,r);h?.length&&i.push(...h);let d=qZ(s,o,a,r);return d?.length&&i.push(...d),i.length&&i.push({update:()=>{s.update()}}),i}function GZ(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 S1.forEach(l=>{let c=Wo(l,o,i??{},s,r);c&&a.push(c)}),a}function jZ(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 w1.forEach(l=>{let c=Wo(l,a,i??{},s,r);c&&o.push(c)}),o}function HZ(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 A1.forEach(l=>{let c;l==="count"?c=Km(l,a,i??{},s,r,!0):c=Wo(l,a,i??{},s,r),c&&o.push(c)}),o}function WZ(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 E1.forEach(l=>{let c;l==="count"?c=Zr(l,a,i??{},s,r,!0):c=Wo(l,a,i??{},s,r),c&&o.push(c)}),o}function qZ(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 M1.forEach(l=>{let c=Wo(l,a,i??{},s,r);c&&o.push(c)}),o}function YZ(n,t){return{update:()=>{n instanceof Ar&&(n.fill.enabled=t)}}}function XZ(n,t){return{update:()=>{n instanceof Ar&&(n.stroke.enabled=t)}}}function QZ(n,t){return{update:()=>{n instanceof Ar&&(n.dropShadow.enabled=t)}}}function KZ(n,t){return{update:()=>{n instanceof Ar&&(n.innerShadow.enabled=t)}}}function ZZ(n,t){return{update:()=>{n instanceof Ar&&(n.backgroundBlur.enabled=t)}}}function JZ(n,t){return{update:()=>{n instanceof Ar&&(n.layerBlur.enabled=t)}}}function iN(n,t,e,r,i){let s=[],o,a,l,c,u,h,d,f,p,m,g,y,v,x,S;if("width"in n&&(o=Zr("width",n,t,e,i),o&&s.push(o)),"height"in n&&(a=Zr("height",n,t,e,i),a&&s.push(a)),n instanceof Ar||n instanceof Ji){let w={...t.fill},A={...e.fill};w.enabled!==void 0&&w.enabled!==A.enabled&&(s.push(YZ(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=Zm("color",n.fill,w,A,i),l&&s.push(l)}if(n instanceof Ar){let w={...t.stroke},A={...e.stroke};(w.enabled||A.enabled)&&(s.push(XZ(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=Zm("color",n.stroke,w,A,i),c&&s.push(c),u=Zr("thickness",n.stroke,w,A,i),u&&s.push(u)}if(n instanceof Ar){let w={...t.dropShadow},A={...e.dropShadow};(w.enabled||A.enabled)&&(s.push(QZ(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=Zm("color",n.dropShadow,w,A,i),h&&s.push(h),d=Zr("blurRadius",n.dropShadow,w,A,i),d&&s.push(d),p=Zr("spread",n.dropShadow,w,A,i),p&&s.push(p),f=Of("offset",n.dropShadow,w,A,i),f&&s.push(f)}if(n instanceof Ar){let w={...t.innerShadow},A={...e.innerShadow};(w.enabled||A.enabled)&&(s.push(KZ(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}})),m=Zm("color",n.innerShadow,w,A,i),m&&s.push(m),g=Zr("blurRadius",n.innerShadow,w,A,i),g&&s.push(g),v=Zr("spread",n.innerShadow,w,A,i),v&&s.push(v),y=Of("offset",n.innerShadow,w,A,i),y&&s.push(y)}if(n instanceof Ar||n instanceof Ji){let w={...t.backgroundBlur},A={...e.backgroundBlur};(w.enabled||A.enabled)&&(s.push(ZZ(n,!0)),w.enabled||Object.assign(w,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),x=Zr("radius",n.backgroundBlur,w,A,i),x&&s.push(x)}if(n instanceof Ar){let w={...t.layerBlur},A={...e.layerBlur};(w.enabled||A.enabled)&&(s.push(JZ(n,!0)),w.enabled||Object.assign(w,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),S=Zr("radius",n.layerBlur,w,A,i),S&&s.push(S)}if(n instanceof Ji||n instanceof As){let w=Km("cornerRadius",n,t,e,i);w&&s.push(w)}return s}function EM(n,t,e,r,i){let s=[];return n.data.visible&&s.push(...tN(n,t,e,i,r)),n instanceof tr?s.push(...iN(n,t,e,i,r)):(n.data.visible&&s.push(...rN(n,t,e,r)),cn(n)?(n instanceof lr&&n.data.visible&&s.push(...KB(n,t,e,r)),n.data.visible&&s.push(...$B(n,t,e,r))):f3(n)?n.data.visible&&s.push(...ZB(n,t,e,r)):d3(n)&&s.push(...QB(n,t,e,r))),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}var nN=new E;function If(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]=Ea.patch(o,l)}oN(n.scene,s,null,t,o.events.find(a=>a.data.type==="Follow"||a.data.type==="LookAt")!==void 0),sN(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(nN,!0),s.rigidBody?.setAngvel(nN,!0)),!yt.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,s.uuid===hs)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]=xa.patch(a,u)}oN(n.scene,s,null,t,a.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),sN(n),s instanceof Er&&s.frame&&(s.frame.traverse(c=>i(c)),s.uiCanvas?.applySize())}),n.frame&&(n.frame.traverse(s=>i(s)),n.uiCanvas?.applySize())}function sN(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 oN(n,t,e,r,i=!1){if(t instanceof lr&&t.removeInteractionGeometry(r),t instanceof tr?t.changeSelectedState(e,{shared:r},i):t.changeSelectedState(e,{scene:n,shared:r},i),t instanceof lr&&t.updateGeometryGroupsIfNeeded(),t instanceof wr&&t.updateCameraState(t.dataPatched,{scene:n,shared:r}),!(t instanceof tr)){if(t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}}function TM(n){let t;if(n.easing===5){let{control1:e,control2:r}=n;t=`cubicBezier(
7379
7379
  ${e[0]}, ${e[1]}, ${r[0]}, ${r[1]}
7380
- )`}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=ga.linear;break;case 1:e=ga.ease;break;case 2:e=ga.easeIn;break;case 3:e=ga.easeOut;break;case 4:e=ga.easeInOut;break;default:e=ga.linear}let[r,i,s,o]=e;t=`cubicBezier( ${r}, ${i}, ${s}, ${o} )`}return{duration:Math.max(n.duration,1e-4),easing:t}}function MM(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 $Z={type:"beginState"},eJ={type:"completeState",isfromEntity:!1},pb=class{constructor(t,e,r,i,s,o){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;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 tr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof wr&&e.dispatchEvent($Z)})};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 tr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof wr&&e.dispatchEvent(eJ)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=EM(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=fb(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=fb(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=fb(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...MM(i),...TM(i),change:this.onChange},this.callback=EM(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Jm=class extends pr{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.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())};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=fb(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&v1(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:i=!1}={}){try{let s=MM(this.data.tweens[0].data);i&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=db.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 wr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new pb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1);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 wr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new pb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,c.data,this.shared,this.data.allowSlerp??!1);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(wt(this.shared,this.condition)===!1||v1(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;clearTimeout(this.timeoutId);let e=MM(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof tr?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(wt(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(wt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function fb(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 tJ={type:"beginState"},aN={type:"completeState",isfromEntity:!1},lN={type:"requestRender"},$m=class extends pr{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 Qe;this.qEnd=new Qe;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=db({targets:i,t:1,...TM(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(tJ));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(lN),i.t===1&&s.dispatchEvent(aN)}})}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(wt(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(wt(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(aN),this.page.activeCamera.dispatchEvent(lN))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function CM(n){let t=n?.tracks.filter(e=>e.ValueTypeName==="vector"||e.ValueTypeName==="quaternion").map(e=>e.times.length);if(t?.length){let e=Qw(t);return e&&e>2?e:2}return 2}var eg=class extends pr{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=CM(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(wt(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&&s.isRunning()&&(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=we.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(wt(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 tg=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(wt(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))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),If(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var rg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=wt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=_0(this.data.expression,this.shared,Br.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var ig=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.timeoutId=null}dispatchInner(){if(wt(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 mb=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(wt(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(ix(e))})}dispose(){}};var gb=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(wt(this.shared,this.condition)===!1)return!1;this.data.userAPIId&&this.shared.getUserAPI(this.data.userAPIId)?.callUserAPI(this.shared)}dispose(){}};function wt(n,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=_0(t.expression,n,"boolean");return t.negate?!e:!!e}function Kt(n,t,e,r,i,s){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},a=l=>({id:c,data:u})=>{try{u.type==="Audio"?Yi[n.type].includes("Audio")&&o.Audio.push(new Hm(c,u,s,r,l)):u.type==="Video"&&!(s instanceof tr)?Yi[n.type].includes("Video")&&o.Video.push(new ng(c,u,s,r,l)):u.type==="Particles"?Yi[n.type].includes("Particles")&&o.Particles.push(new Wm(u,e,r,l)):u.type==="Link"?Yi[n.type].includes("Link")&&o.Link.push(new ob(u,i.controlsManager,r,l)):u.type==="Create"?Yi[n.type].includes("Create")&&o.Create.push(new sg(u,e,i.controlsManager,r,l)):u.type==="Destroy"?Yi[n.type].includes("Destroy")&&o.Destroy.push(new qm(u,e,i.controlsManager,r,l)):u.type==="Reset"?Yi[n.type].includes("Reset")&&o.Reset.push(new Ym(u,e,r,i,l)):u.type==="Transition"?Yi[n.type].includes("Transition")&&o.Transition.push(new Jm(n.type,u,e,r,l)):u.type==="SwitchCamera"?Yi[n.type].includes("SwitchCamera")&&o.SwitchCamera.push(new $m(u,e,r,l)):u.type==="SceneTransition"?Yi[n.type].includes("SceneTransition")&&o.SceneTransition.push(new tg(u,e,i,r,l)):u.type==="Animation"?Yi[n.type].includes("Animation")&&o.Animation.push(new eg(u,e,i.animationControls,r,l)):u.type==="SetVariable"?Yi[n.type].includes("SetVariable")&&o.SetVariable.push(new rg(u,e,r,l)):u.type==="DynamicVariablePlay"?Yi[n.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new ig(u,e,r,l)):u.type==="Conditional"?Yi[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"?Yi[n.type].includes("ClearLocalStorage")&&o.ClearLocalStorage.push(new mb(u,e,r,l)):u.type==="UserAPI"&&Yi[n.type].includes("UserAPI")&&o.UserAPI.push(new gb(u,e,r,l))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function ur(n){Object.values(n).forEach(t=>{t.forEach(e=>{(e instanceof Hm||e instanceof ng||e instanceof Wm||e instanceof eg||e instanceof Jm||e instanceof sg||e instanceof qm||e instanceof $m||e instanceof tg||e instanceof Ym||e instanceof rg||e instanceof ig)&&e.dispose()})})}function cN(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 uN=new Map,og=new Map,Va=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=cN(r,i);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,yo&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),og.has(r.uuid)?og.get(r.uuid).push(this):og.set(r.uuid,[this]),uN.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())}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)}},Rf=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=uN.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=og.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=[...og.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}},ng=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new Va(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Rf(e);else throw new Error("Missing property")}dispatchBasic(){if(wt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Va?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(wt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Va?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var hN=(()=>{let n,t,e,r;function i(a){!n&&!dN()&&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(p=>p.bvhGeometry!==void 0)),h--,r())}n=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){dN()?n&&(cancelAnimationFrame(n),n=void 0,e=void 0):i()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),i})();function dN(){return!!document&&document.hidden}var fN=new Qe,rJ=new E,iJ=new E,sg=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=we.generateUUID();this.dispatch=()=>{if(wt(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(wt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Kw(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 Nr(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),t.rotation.fromArray(this.data.rotation),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),hN(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Gi)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 Nr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Gi)return;t instanceof Nr?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),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(rJ,fN,iJ),r.applyQuaternion(fN),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");hN(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 IM=200,PM=.02,_M=.3,nJ=65,f5e=new E,pN=new E,mN=new E,sJ=new E,Mn=new E,zn=new E,ec=new E,DM=new ue,gN=new ue,oJ=new ue,p5e=new ue,to=new Qe,Ua=new Qe,qo=new ir(0,0,0,"YXZ"),aJ=new E(1,0,0),ro=new E(0,1,0),lJ=new E(0,0,1),yN=new E(1,1,1),m5e=new Or,cJ=1,uJ=.025,hJ=16e-6,vN=12,dJ=20,Hi=new Mi,Ms=new jt,fJ={type:"requestRender"},pJ={type:"updateMatrix"},xN=Math.PI/6,yb=class extends pr{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=IM;this.euler0=new ir(0,0,0,"YXZ");this.position0Cam=new E;this.quat0Cam=new Qe;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 Mi(new E(0,-40,0),new E(0,40,0)),matrix:new ue,position:new E,rotation:new Qe};this.euler=new ir(0,0,0,"YXZ");this.eulerDelta=new E;this.lastPosition=new E;this.lastCameraQuaternion=new Qe;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 Qe;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 Qe;this.objXZQuatInv=new Qe;this.objXZRotMat=new ue;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new E;this.pushedVelocity=new E;this.groundYRotation=0;this.objectRealQuat=new Qe;this.colliderWorldQuat=new Qe;this.groundNormal=new E;this.groundTilt=new Qe;this.groundTiltInv=new Qe;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new E;this.quaternion=new Qe;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"&&!Ci&&!Jw&&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"&&(Jw&&j2<15.5&&!Ci?(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?yb.isLocked=!0:yb.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 v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let S=new ir().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof wr&&(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)*cJ,this.speedOrbit=(i.speedRotate??100)*uJ,this.mouseOrbitSensitivity=(i.speedRotate??100)*hJ,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??Al.defaultData.gravity)*vN,this.usePhysics=this.gloabalPhysics.usePhysics??Al.defaultData.usePhysics,this.jumpPower=i.jumpPower*dJ,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??Qh.defaultDataThirdPerson.orientWith,this.slopeThresh=nJ*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*PM/this.pixelsPerMeter,this.stepThresh=i.collider.height*_M/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*PM/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*_M/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*PM/this.pixelsPerMeter,this.stepThresh=i.collider.height*_M/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let f=new E().fromArray(i.collider.position),p=new Qe().setFromEuler(new ir().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,yN),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 m=i.navmesh.destinationHelperRadius*2;if(m>0){let g=new Ue;g.push({fi:0,data:{...Gr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...Gr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let y=new Oa({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Ut(g0.create({parameters:{width:m,height:m/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 ir().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 wr?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={},Xh.list.forEach(i=>{this.actions[i]=Kt({...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"),ur(this.actions.idle),ur(this.actions.move),ur(this.actions.run),ur(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].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].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 Mn.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){let c=zn.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*vN),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(Mn,Ua,zn),this.groundVelocity.subVectors(Mn,d.prevT),this.object.getWorldPosition(zn).add(this.collider.position).sub(Mn),this.groundYRotation=qo.setFromQuaternion(Ua).y-d.prevR.y,ec.copy(zn).applyAxisAngle(ro,this.groundYRotation),this.groundVelocity.add(ec.sub(zn)).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=Mn.subVectors(this.path[1],this.position),h=zn.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.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=sJ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let c=zn.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=Mn;this.camera.getWorldDirection(c);let u=ec.copy(ro).multiplyScalar(c.dot(ro));c.sub(u);let h=zn.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(qo.setFromVector3(this.rot),this.moveMode==="walk"&&(qo.x=0),l.applyEuler(qo),a&&(Ua.setFromUnitVectors(ro,this.groundNormal),l.applyQuaternion(Ua)),i){let c=qo.set(0,this.vrEulerYOffset*xN,0);i.applyEuler(c),l.x+=i.x,l.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*s}if(this.usePhysics===!0){let c=zn;this.pushedVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=ec.setFromMatrixPosition(u.matrixWorld).sub(u.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=u.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Mn.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=yt.is(u)?u:u.object;if(d!==null&&this.lastHitObj!==f){let p;u instanceof Nr&&(p=u);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(vb));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(ro,this.euler.y-this.euler0.y);let c=zn.copy(this.objectToCamXZ).normalize(),u=ec.copy(l).multiplyScalar(s);u.y=0;let h=u.sub(Mn.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=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=we.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(qo.copy(r),qo.y=0):(qo.copy(this.euler),qo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(qo)),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*xN),to.setFromAxisAngle(aJ,this.rot.x),Ua.setFromAxisAngle(ro,this.rot.y),Ua.multiply(to),to.setFromAxisAngle(lJ,this.rot.z),Ua.multiply(to),this.quaternion.copy(Ua),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let c=zn.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(),p=ec.copy(c).normalize();if(u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),u!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(u.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let S of x)if(S.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(u.collider.handle))._parent,A;if(m.cloner){for(let M of m.cloner.children)if(M.rigidBody===w){A=M;break}}S.dispatch(A),m.dispatchEvent(vb)}}}let g=pN.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat),y=mN.copy(p).multiplyScalar(u.toi).dot(g),v=u.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=u.toi*(y-this.offset)/y,h.addScaledVector(p,v)),c.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),S=ec.copy(u.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let w=x.add(S);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(Mn.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(to.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);DM.lookAt(u,c,ro).setPosition(u),DM.decompose(this.targetPos,this.targetQuat,Mn),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=we.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=we.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(pJ),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(fJ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=to.setFromAxisAngle(ro,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?we.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=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mn.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let s=Ua.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){ro.angleTo(e)*180/Math.PI<15||ro.angleTo(e)*180/Math.PI>85?to.identity():to.setFromUnitVectors(ro,e),this.groundTilt.slerp(to,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=mN.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=DM.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mn,to,zn).compose(Mn,to,yN);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;Ms.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=gN.copy(a).invert(),c=oJ.copy(gN).multiply(i);Hi.copy(this.collider.segment),Hi.start.applyMatrix4(c),Hi.end.applyMatrix4(c);let u=pN.copy(this.position).applyMatrix4(l);Ms.expandByPoint(Hi.start),Ms.expandByPoint(Hi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Hi.end)},intersectsBounds:h=>h.intersectsBox(Ms),intersectsTriangle:h=>{let d=Mn,f=zn,p=h.closestPointToSegment(Hi,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=ec.copy(u);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);r.add(v),Hi.start.addScaledVector(g,m),Hi.end.addScaledVector(g,m)}}})}),Ms.makeEmpty(),Hi.copy(this.collider.segment),Hi.start.applyMatrix4(i),Hi.end.applyMatrix4(i),Ms.expandByPoint(Hi.start),Ms.expandByPoint(Hi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(Hi.end)},intersectsBounds:o=>o.intersectsBox(Ms),intersectsTriangle:o=>{let a=Mn,l=zn,c=o.closestPointToSegment(Hi,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),Hi.start.addScaledVector(h,u),Hi.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)}},ag=yb;ag.isLocked=!1;var bN=$o(iA());function io(n,t){let e=new _e;if(t){let s=t.elements,o=s[0]**2+s[1]**2+s[2]**2,a=s[4]**2+s[5]**2+s[6]**2,l=s[8]**2+s[9]**2+s[10]**2,c=s[0]**2+s[4]**2+s[8]**2,u=s[1]**2+s[5]**2+s[9]**2,h=s[2]**2+s[6]**2+s[10]**2,d=1e-8;if(o<d||a<d||l<d||c<d||u<d||h<d)return e.setAttribute("position",new Me([],3)),e.setIndex([]),e}if(!n.getAttribute("position"))return e.setAttribute("position",new Me([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Uc(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new Me(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var mJ=new ue,gJ=new ue,Yo=[[0,0,0],[0,0,0],[0,0,0]];function OM(n){let t=n.elements;Yo[0][0]=t[0],Yo[0][1]=t[4],Yo[0][2]=t[8],Yo[1][0]=t[1],Yo[1][1]=t[5],Yo[1][2]=t[9],Yo[2][0]=t[2],Yo[2][1]=t[6],Yo[2][2]=t[10];let{u:e,v:r}=(0,bN.SVD)(Yo),i=mJ.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=gJ.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 xb=class extends Qu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}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 ss({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 _e;return o.setFromPoints([e,s]),new gc(o,t)}};var SN=n=>n instanceof ws||n instanceof $s;function yJ(n,t){return n.distance-t.distance}function wN(n,t,e){if(!(!Io(t)||!t.visible)){cn(t)&&t.raycast(n,e);for(let r of t.children)wN(n,r,e)}}function Lf(n,t,e,r=!1){if(!r&&!e.some(s=>Bf(n,s)!==void 0))return[];let i=[];return t.children.forEach(s=>wN(n,s,i)),i.sort(yJ),i}function lg(n){let t=[];if(n.length){let e=n[0].object;Io(e)&&t.push(e);let r=e.parent;for(;r;)SN(r)&&t.push(r),r=r.parent}return t}function no(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 Bf(n,t){if(cn(t)){if(t.visible){let e=[];return t.raycast(n,e),e.length?e[0]:void 0}}else if(SN(t))return AN(n,t)}function AN(n,t){if(!(!Io(t)||!t.visible)){if(cn(t)){let e=[];if(t.raycast(n,e),e.length)return e[0]}for(let e of t.children){let r=AN(n,e);if(r)return r}}}function vJ(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 xJ(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width,y:1-(t-(e.top+window.scrollY))/e.height}}var bb=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 xb;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=vJ(e,r,this._domRect),this.pointerScreen=xJ(e,r,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}};var hr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var RM=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],EN=n=>RM.find(([t,e])=>e===n)?.[0],Xo=n=>RM.find(([t])=>t===n)?.[1],bJ=(n,t)=>{let e=EN(n);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Sb=class extends hr{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[EN(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 RM)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=bJ(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 LM=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=Kt(e,e.actions,i,s,o,r)}disconnect(){ur(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.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.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.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.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())}},wb=class extends hr{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=Lf(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=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{Je.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=Xo(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.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];o.data.events.filter(({data:h})=>h.type===c&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new LM(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(p=>p.id===f.id)||u[o.uuid].push(f):u[o.uuid]=[f]}catch(f){!1&&console.log(f)}}),u[o.uuid]?.length&&this.objectsPerTypes[c].push(o instanceof tr&&(c==="MouseDown"||c==="MouseUp"||c==="MousePress")?a:o)}};e.traverseEntity(o=>{(o instanceof Er||o instanceof cr)&&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)})})}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)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:i,page:s,pointerScreen:o}=this.eventContext,a=this.objectsPerTypes[e],l=a.filter(c=>!(c instanceof tr));if(!(!a.length&&!this.useForRaycastProperty)&&!(s.uiCanvas&&no(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=Lf(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];lg(c).forEach(h=>{h instanceof Er&&no(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=Bf(i,c);u&&(this.handleObjectMouseEventDispatch(c,e),c instanceof Er&&no(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 tr)),o=[];if(!!i.length){if(!e){let{stopRaycast:a,raycaster:l,page:c,pointerScreen:u}=this.eventContext,h=!1;if(c.uiCanvas&&(h=no(c,[u.x,u.y],Object.keys(this.eventsPerObjects[r]),d=>{o.push(d)})),a&&!h){let d=Lf(l,c,s);o=lg(d),d.forEach(f=>{f.object instanceof Er&&no(f.object,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)})})}else s.forEach(d=>{let f=Bf(l,d);f&&(o.push(d),d instanceof Er&&no(d,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)}))})}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 SJ=new E,wJ=new E;var Ab=class{constructor(t,e,r,i,s){this.actionsIn=Kt(t,t.inActions,r,i,s,e),this.actionsOut=Kt(t,t.outActions,r,i,s,e)}disconnect(){ur(this.actionsIn),ur(this.actionsOut)}};var BM=class extends Ab{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=SJ.setFromMatrixPosition(this.objects[0].matrixWorld),r=wJ.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.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)})}},NM=class extends Ab{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.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.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(){ls(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),ls(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),ls(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),ls(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Eb=class extends hr{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 BM(s,o,i,e,r,this.eventManager):o.condition.type==="State"&&(a=new NM(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.log(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 cg=new E,tc=new E,iu=new E,MN=new Ur,AJ=.01,rr=new E,Ii=new E,TN=new E,nu=new Qe,FM=new ir,EJ=new ue,VM=new fr,Nf=new E,Qo=new E,Ff=.2;function UM(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 MJ=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"&&UM(i.position,t.limits),i.position.applyMatrix4(n),t.reference==="parent"?UM(i.position,t.limits):t.reference==="local"&&(nu.copy(t.quat0).invert(),i.position.sub(t.position0),i.position.applyQuaternion(nu),UM(i.position,t.limits),nu.invert(),i.position.applyQuaternion(nu),i.position.add(t.position0)),n.multiply(r??i.matrixWorld).decompose(rr,i.quaternion,Ii),i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i instanceof mr&&En(i.parent)&&i.invalidateDownstreamBooleanData(!0)}}(),zM=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=Kt(r,r.dragDropActions.drag,i,s,o,this.object),this.actionsDrop=Kt(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 Qe().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(){ur(this.actionsDrag),ur(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()})}},Mb=class extends hr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(Je.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||yt.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(rr,nu,Ii),FM.setFromQuaternion(nu),h.prevR===void 0?(h.prevR=FM.clone(),h.prevT=rr.clone()):(h.prevR.copy(FM),h.prevT.copy(rr)),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(Je.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if(Je.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||yt.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 ws)&&(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=TN.copy(a.face.normal).applyMatrix3(VM.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"){rr.copy(l).applyMatrix3(VM.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;rr.x>Ff?Ii.x=-c.recursiveBBox.min.x:rr.x<-Ff&&(Ii.x=-c.recursiveBBox.max.x),rr.y>Ff?Ii.y=-c.recursiveBBox.min.y:rr.y<-Ff&&(Ii.y=-c.recursiveBBox.max.y),rr.z>Ff?Ii.z=-c.recursiveBBox.min.z:rr.z<-Ff&&(Ii.z=-c.recursiveBBox.max.z),Ii.applyMatrix3(VM.invert())}else Ii.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Ii)}this.activeEvent.data.autoOrient&&(rr.set(0,1,0).cross(l),rr.length()<1e-4&&rr.set(-1,0,0).cross(l),Ii.crossVectors(TN,rr),o.orientationMatrix.makeBasis(rr,Ii,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 zM(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(tc),tc.negate();let l=nu.identity();switch(s==="parent"?EJ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(rr,l,Ii):s==="local"&&e.matrixWorld.decompose(rr,l,Ii),i){case"x":rr.set(1,0,0).applyQuaternion(l),Nf.copy(tc).cross(rr),Qo.copy(rr).cross(Nf);break;case"y":rr.set(0,1,0).applyQuaternion(l),Nf.copy(tc).cross(rr),Qo.copy(rr).cross(Nf);break;case"z":rr.set(0,0,1).applyQuaternion(l),Nf.copy(tc).cross(rr),Qo.copy(rr).cross(Nf);break;case"xy":Qo.set(0,0,1).applyQuaternion(l);break;case"yz":Qo.set(1,0,0).applyQuaternion(l);break;case"xz":Qo.set(0,1,0).applyQuaternion(l);break;case"adaptive":tc.angleTo(Ii.set(0,1,0))>Math.PI/6?(rr.crossVectors(Ii.set(0,1,0),tc),Qo.crossVectors(rr,Ii)):Qo.set(0,1,0);break;default:Qo.copy(tc);break}iu.setFromMatrixPosition(e.matrixWorld);let c=e.userData.lockedPlane?e.userData.worldPosition0:iu;if(MN.setFromNormalAndCoplanarPoint(Qo,c),!!a.ray.intersectPlane(MN,r)&&(i==="x"||i==="y"||i==="z")){let u=Ii.subVectors(r,c).dot(rr);r.copy(c).addScaledVector(rr,u)}}updateDragItem(e,r=!1){iu.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?cg.subVectors(e.fromPosition,iu).divideScalar(e.currentDampingFactor):e.reset==="original"?(cg.subVectors(e.obj.userData.worldPosition0,iu).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):cg.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(iu).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?cg.length()<AJ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&MJ(e,cg.add(iu),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var Vf=new E,kM=new E,za=new E,ka=new E,CN=new Ur,TJ=.01,CJ={type:"requestRender"},PJ=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}(),PN=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 mr&&En(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),GM=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={...Cv.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=Kt(t,t.actions,i,s,o,r)}},Tb=class extends hr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(Je.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 GM(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(),Ci&&(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(),Ci&&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,ur(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(za),e.isReset)ka.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ka);else{let{getCamera:l,raycaster:c}=this.eventContext;if(i==="custom"?(l().getWorldDirection(kM),kM.negate(),Vf.copy(kM)):i==="xy"?Vf.set(0,0,1):i==="xz"?Vf.set(0,1,0):i==="yz"&&Vf.set(1,0,0),CN.setFromNormalAndCoplanarPoint(Vf,za),!c.ray.intersectPlane(CN,ka))return}if(!e.isReset){if(ka.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)ka.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&&(ka.x=za.x),e.data.enabledTranslation[1]===!1&&(ka.y=za.y),e.data.enabledTranslation[2]===!1&&(ka.z=za.z);let a=PJ(za,ka,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Vf.subVectors(a,za).divideScalar(e.currentDampingFactor);za.add(l),r&&PN(e.object,za),e.paused=l.length()<TJ}else PN(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(CJ)}};var ug=new E,Cb=new E,hg=new ue,Uf=new Qe,rc=new Qe,dg=new E,fg=new E,su=new E,Ga=new E,jM=new Ur,_J=1e-6,DJ={type:"requestRender"},IJ={type:"changeRotation"},_N=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(OM(n).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof mr&&En(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),HM=class{constructor(t,e,r,i){this.id=e;this.object=r;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Qe;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Pv.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),this.resetDampingFactor=80/this.data.resetSpeed+1}},Pb=class extends hr{constructor(){super(...arguments);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(Je.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=Xo(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 HM(o.data,o.id,s,e))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Ci&&(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(),Ci&&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(dg),!e.isReset)if(e.target)e.target.getWorldPosition(fg);else{if(o==="custom"?(u().getWorldDirection(Cb),Cb.negate(),jM.setFromNormalAndCoplanarPoint(Cb,dg)):(o==="xy"?ug.set(0,0,1):o==="xz"?ug.set(0,1,0):o==="yz"&&ug.set(1,0,0),jM.setFromNormalAndCoplanarPoint(ug,dg)),!h.ray.intersectPlane(jM,fg))return;s>0&&(o==="custom"||o===void 0)&&fg.addScaledVector(Cb,s)}if(e.isReset||(f?r==="target"?su.copy(f.up).applyMatrix4(hg.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(i==="x"?(Ga.set(0,0,1),l[2]===!1&&Ga.set(0,1,0)):i==="y"?(Ga.set(1,0,0),l[0]===!1&&Ga.set(0,0,1)):(Ga.set(0,1,0),l[1]===!1&&Ga.set(1,0,0)),su.copy(Ga).applyQuaternion(e.worldQuaternion0).normalize()):su.set(0,1,0):o==="custom"?su.set(0,1,0):su.copy(ug)),e.isReset)rc.copy(e.worldQuaternion0);else if(dg.distanceTo(fg)>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)rc.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;OJ(hg,fg,dg,su,i,Ga),rc.setFromRotationMatrix(hg),Uf.setFromUnitVectors(Ga.applyQuaternion(rc),su),l.some(p=>p===!1)&&r!=="target"&&rc.premultiply(Uf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Uf.setFromRotationMatrix(OM(d.matrixWorld)),Uf.slerp(rc,1/e.currentDampingFactor),_N(d,hg.makeRotationFromQuaternion(Uf)),e.paused=8*(1-Uf.dot(rc))<_J):(_N(d,hg.makeRotationFromQuaternion(rc)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(DJ),d.dispatchEvent(IJ)}},Ts=new E,Oi=new E,li=new E;function OJ(n,t,e,r,i,s){let o=n.elements;li.subVectors(t,e),li.lengthSq()===0&&(li.z=1),li.normalize(),Oi.crossVectors(r,li),Oi.lengthSq()===0&&(Math.abs(r.z)===1?li.x+=1e-4:li.z+=1e-4,li.normalize(),Oi.crossVectors(r,li)),Oi.normalize(),Ts.crossVectors(li,Oi),i==="x"?s.z===1?[Oi,Ts,li]=[li,Oi,Ts]:(Oi.negate(),[Oi,li]=[li,Oi]):i==="y"?s.x===1?[Oi,Ts,li]=[Ts,li,Oi]:(Oi.negate(),[Ts,li]=[li,Ts]):s.x===1&&(Oi.negate(),[Oi,Ts]=[Ts,Oi]),o[0]=Oi.x,o[4]=Ts.x,o[8]=li.x,o[1]=Oi.y,o[5]=Ts.y,o[9]=li.y,o[2]=Oi.z,o[6]=Ts.z,o[10]=li.z}var WM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=Kt(e,e.actions,i,s,o,r)}disconnect(){ur(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.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.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.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.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())}},_b=class extends hr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObjects={};this.objects=[];this.objects2D=[];this._prevObjects=[];this.onMouseDown=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{Je.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Xo(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 WM(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.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o instanceof tr?a:o)}};if(e.traverseEntity(o=>{(o instanceof Er||o instanceof cr)&&o.frame?.traverse(a=>{i(a,o)}),i(o)}),!this.objects.length)return;let{domElement:s}=this.eventContext;this.domEventsNeeded.clear(),Ci&&(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(),Ci&&(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=no(o,[a.x,a.y],Object.keys(this.eventsPerObjects),c=>{r.push(c)})),i&&!l){let c=Lf(s,o,this.objects);r=lg(c),c.forEach(u=>{u.object instanceof Er&&no(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=Bf(s,c);u&&(r.push(c),c instanceof Er&&no(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 qM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=Kt(e,e.actions,i,s,o,r)}connect(){this.scrollCounter=0}disconnect(){ur(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.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.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.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())}},YM=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=Kt(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),p=parseFloat(h.bottom),m=u.height-d;if(!isNaN(f))r.top===f?(i.top+=u.top-f,i.bottom+=u.top-f):r.top<0&&(i.top-=m-r.height,i.bottom-=m-r.height);else if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,y=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);r.bottom===g-p?(i.top+=u.top-r.height+p+y,i.bottom+=u.top-r.height+p+y):r.bottom<g-p&&(i.top-=m-r.height,i.bottom-=m-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(){ur(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.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.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.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())}},Db=class extends hr{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=Xo(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 qM(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 YM(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 Er||a instanceof cr)&&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 XM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Kt(e,e.actions,i,s,o,r)}disconnect(){ur(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.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 jo?e.interaction.audioPlayer.play():e.interaction instanceof Df&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof Va?e.interaction.play(r==="autoplay"):e.interaction instanceof Rf&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}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.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.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 jo?e.interaction.audioPlayer.play():e.interaction instanceof Df&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Va?e.interaction.play():e.interaction instanceof Rf&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},Ib=class extends hr{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 jo&&s.interaction.audioPlayer.play()}),i.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Va&&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.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Xo(e);s&&s==="Start"&&(r instanceof tr||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 XM(o,a,s,r,e,this.eventManager);(l.actions.Transition.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 Er||s instanceof cr)&&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 Ob=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.initialDisabled=!1;this.actions=Kt(e,e.actions,i,s,o,r),this.target=e.target}disconnect(){ur(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.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 Rb=class extends hr{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),p=Dv.propertyPaths[h];if(p[0]==="width"||p[0]==="height"||p[0]==="depth")f=f.geometry.userData.parameters[p[0]];else for(let m=0;m<p.length;m++)f=f[p[m]];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:p,startValue:m}=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)!==m&&(r.updateVariable(u,m),this.eventManager.requestRender()),(f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==m&&(this.dynamicVars[c].timerSeconds=m,r.updateVariable(u,vn.getFormattedTimerTime(m,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),v=f.decimals;y=Math.round(y*Math.pow(10,v))/Math.pow(10,v),r.updateVariable(u,y),s.push(u),this.eventManager.requestRender()}else if(f.dynamicVariableType==="counter"){let y=r.getVariable(u),v=r.getDynamicVariableToggleIsForward(u)??!0,x=r.getVariable(u)+f.increment*(v?1:-1);f.hasEnd&&(x=f.increment>0?we.clamp(x,m,f.endValue):we.clamp(x,f.endValue,m),x===m&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?x===f.endValue&&(x=m):(x===m||x===f.endValue)&&r.setDynamicVariablePlayState(u,"Paused")),x!==y&&(s.push(u),r.updateVariable(u,x),this.eventManager.requestRender())}else if(f.dynamicVariableType==="time"){let y=r.getVariable(u),v=dE(i,f);if(typeof y=="object"&&"textValue"in y&&typeof v=="object"&&"textValue"in v){if(Array.isArray(y.textValue)&&Array.isArray(v.textValue)){if(y.textValue.every((x,S)=>x===v.textValue[S]))continue}else if(y.textValue===v.textValue)continue}else if(y===v)continue;r.updateVariable(u,v),s.push(u),this.eventManager.requestRender()}else{let y=Br.isTextValue(f.endValue)?DN(f.endValue.textValue):f.endValue,v=r.getDynamicVariableToggleIsForward(u)??!0,x=p+(e-d)/1e3*(f.dynamicVariableType==="timer"?-1:1)*(v?1:-1);x=Math.max(x,0),f.hasEnd&&(x=f.dynamicVariableType==="stopwatch"?we.clamp(x,m,y):we.clamp(x,y,m),x===m&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?Math.abs(x-y)<(f.format==="number3decimal"?1e-4:.1)&&(x=m):(Math.abs(x-m)<(f.format==="number3decimal"?1e-4:.1)||Math.abs(x-y)<(f.format==="number3decimal"?1e-4:.1))&&r.setDynamicVariablePlayState(u,"Paused")),x!==p&&(s.push(u),this.dynamicVars[c].timerSeconds=x,r.updateVariable(u,vn.getFormattedTimerTime(x,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 QM(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(Br.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,dE(new Date,i)),i.dynamicVariableType==="counter"&&(s=Br.isTextValue(i.value)?DN(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())}},QM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Kt(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(){ur(this.actions)}};function DN(n){return n.length===3?n[2]+n[1]*60+n[0]*3600:n[1]+n[0]*60}var ON=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@1.9.31/build/",RJ=!1?ON:"https://unpkg.com/@splinetool/navmesh-wasm@1.9.31/build/",LJ=`
7380
+ )`}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=ga.linear;break;case 1:e=ga.ease;break;case 2:e=ga.easeIn;break;case 3:e=ga.easeOut;break;case 4:e=ga.easeInOut;break;default:e=ga.linear}let[r,i,s,o]=e;t=`cubicBezier( ${r}, ${i}, ${s}, ${o} )`}return{duration:Math.max(n.duration,1e-4),easing:t}}function MM(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 $Z={type:"beginState"},eJ={type:"completeState",isfromEntity:!1},pb=class{constructor(t,e,r,i,s,o){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;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 tr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof wr&&e.dispatchEvent($Z)})};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 tr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof wr&&e.dispatchEvent(eJ)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=EM(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=fb(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=fb(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=fb(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...MM(i),...TM(i),change:this.onChange},this.callback=EM(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Jm=class extends pr{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.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())};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=fb(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&v1(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:i=!1}={}){try{let s=MM(this.data.tweens[0].data);i&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=db.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 wr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new pb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1);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 wr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new pb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,c.data,this.shared,this.data.allowSlerp??!1);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(wt(this.shared,this.condition)===!1||v1(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;clearTimeout(this.timeoutId);let e=MM(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof tr?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(wt(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(wt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function fb(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 tJ={type:"beginState"},aN={type:"completeState",isfromEntity:!1},lN={type:"requestRender"},$m=class extends pr{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 Qe;this.qEnd=new Qe;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=db({targets:i,t:1,...TM(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(tJ));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(lN),i.t===1&&s.dispatchEvent(aN)}})}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(wt(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(wt(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(aN),this.page.activeCamera.dispatchEvent(lN))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function CM(n){let t=n?.tracks.filter(e=>e.ValueTypeName==="vector"||e.ValueTypeName==="quaternion").map(e=>e.times.length);if(t?.length){let e=Qw(t);return e&&e>2?e:2}return 2}var eg=class extends pr{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=CM(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(wt(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&&s.isRunning()&&(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=we.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(wt(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 tg=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(wt(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))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),If(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var rg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=wt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=_0(this.data.expression,this.shared,Br.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var ig=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.timeoutId=null}dispatchInner(){if(wt(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 mb=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(wt(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(ix(e))})}dispose(){}};var gb=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(wt(this.shared,this.condition)===!1)return!1;this.data.userAPIId&&this.shared.getUserAPI(this.data.userAPIId)?.callUserAPI(this.shared)}dispose(){}};function wt(n,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=_0(t.expression,n,"boolean");return t.negate?!e:!!e}function Kt(n,t,e,r,i,s){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},a=l=>({id:c,data:u})=>{try{u.type==="Audio"?Yi[n.type].includes("Audio")&&o.Audio.push(new Hm(c,u,s,r,l)):u.type==="Video"&&!(s instanceof tr)?Yi[n.type].includes("Video")&&o.Video.push(new ng(c,u,s,r,l)):u.type==="Particles"?Yi[n.type].includes("Particles")&&o.Particles.push(new Wm(u,e,r,l)):u.type==="Link"?Yi[n.type].includes("Link")&&o.Link.push(new ob(u,i.controlsManager,r,l)):u.type==="Create"?Yi[n.type].includes("Create")&&o.Create.push(new sg(u,e,i.controlsManager,r,l)):u.type==="Destroy"?Yi[n.type].includes("Destroy")&&o.Destroy.push(new qm(u,e,i.controlsManager,r,l)):u.type==="Reset"?Yi[n.type].includes("Reset")&&o.Reset.push(new Ym(u,e,r,i,l)):u.type==="Transition"?Yi[n.type].includes("Transition")&&o.Transition.push(new Jm(n.type,u,e,r,l)):u.type==="SwitchCamera"?Yi[n.type].includes("SwitchCamera")&&o.SwitchCamera.push(new $m(u,e,r,l)):u.type==="SceneTransition"?Yi[n.type].includes("SceneTransition")&&o.SceneTransition.push(new tg(u,e,i,r,l)):u.type==="Animation"?Yi[n.type].includes("Animation")&&o.Animation.push(new eg(u,e,i.animationControls,r,l)):u.type==="SetVariable"?Yi[n.type].includes("SetVariable")&&o.SetVariable.push(new rg(u,e,r,l)):u.type==="DynamicVariablePlay"?Yi[n.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new ig(u,e,r,l)):u.type==="Conditional"?Yi[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"?Yi[n.type].includes("ClearLocalStorage")&&o.ClearLocalStorage.push(new mb(u,e,r,l)):u.type==="UserAPI"&&Yi[n.type].includes("UserAPI")&&o.UserAPI.push(new gb(u,e,r,l))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function ur(n){Object.values(n).forEach(t=>{t.forEach(e=>{(e instanceof Hm||e instanceof ng||e instanceof Wm||e instanceof eg||e instanceof Jm||e instanceof sg||e instanceof qm||e instanceof $m||e instanceof tg||e instanceof Ym||e instanceof rg||e instanceof ig)&&e.dispose()})})}function cN(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 uN=new Map,og=new Map,Va=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=cN(r,i);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,yo&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),og.has(r.uuid)?og.get(r.uuid).push(this):og.set(r.uuid,[this]),uN.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())}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)}},Rf=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=uN.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=og.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=[...og.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}},ng=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new Va(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Rf(e);else throw new Error("Missing property")}dispatchBasic(){if(wt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Va?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(wt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Va?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var hN=(()=>{let n,t,e,r;function i(a){!n&&!dN()&&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(p=>p.bvhGeometry!==void 0)),h--,r())}n=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){dN()?n&&(cancelAnimationFrame(n),n=void 0,e=void 0):i()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),i})();function dN(){return!!document&&document.hidden}var fN=new Qe,rJ=new E,iJ=new E,sg=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=we.generateUUID();this.dispatch=()=>{if(wt(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(wt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Kw(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 Nr(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),t.rotation.fromArray(this.data.rotation),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),hN(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Gi)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 Nr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Gi)return;t instanceof Nr?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),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(rJ,fN,iJ),r.applyQuaternion(fN),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");hN(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 IM=200,PM=.02,_M=.3,nJ=65,f5e=new E,pN=new E,mN=new E,sJ=new E,Mn=new E,zn=new E,ec=new E,DM=new ue,gN=new ue,oJ=new ue,p5e=new ue,to=new Qe,Ua=new Qe,qo=new ir(0,0,0,"YXZ"),aJ=new E(1,0,0),ro=new E(0,1,0),lJ=new E(0,0,1),yN=new E(1,1,1),m5e=new Or,cJ=1,uJ=.025,hJ=16e-6,vN=12,dJ=20,Hi=new Mi,Ms=new jt,fJ={type:"requestRender"},pJ={type:"updateMatrix"},xN=Math.PI/6,yb=class extends pr{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=IM;this.euler0=new ir(0,0,0,"YXZ");this.position0Cam=new E;this.quat0Cam=new Qe;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 Mi(new E(0,-40,0),new E(0,40,0)),matrix:new ue,position:new E,rotation:new Qe};this.euler=new ir(0,0,0,"YXZ");this.eulerDelta=new E;this.lastPosition=new E;this.lastCameraQuaternion=new Qe;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 Qe;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 Qe;this.objXZQuatInv=new Qe;this.objXZRotMat=new ue;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new E;this.pushedVelocity=new E;this.groundYRotation=0;this.objectRealQuat=new Qe;this.colliderWorldQuat=new Qe;this.groundNormal=new E;this.groundTilt=new Qe;this.groundTiltInv=new Qe;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new E;this.quaternion=new Qe;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"&&!Ci&&!Jw&&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"&&(Jw&&j2<15.5&&!Ci?(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?yb.isLocked=!0:yb.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 v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let S=new ir().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof wr&&(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)*cJ,this.speedOrbit=(i.speedRotate??100)*uJ,this.mouseOrbitSensitivity=(i.speedRotate??100)*hJ,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??Al.defaultData.gravity)*vN,this.usePhysics=this.gloabalPhysics.usePhysics??Al.defaultData.usePhysics,this.jumpPower=i.jumpPower*dJ,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??Qh.defaultDataThirdPerson.orientWith,this.slopeThresh=nJ*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*PM/this.pixelsPerMeter,this.stepThresh=i.collider.height*_M/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*PM/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*_M/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*PM/this.pixelsPerMeter,this.stepThresh=i.collider.height*_M/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let f=new E().fromArray(i.collider.position),p=new Qe().setFromEuler(new ir().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,yN),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 m=i.navmesh.destinationHelperRadius*2;if(m>0){let g=new Ue;g.push({fi:0,data:{...Gr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...Gr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let y=new Oa({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Ut(g0.create({parameters:{width:m,height:m/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 ir().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 wr?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={},Xh.list.forEach(i=>{this.actions[i]=Kt({...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"),ur(this.actions.idle),ur(this.actions.move),ur(this.actions.run),ur(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].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].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 Mn.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){let c=zn.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*vN),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(Mn,Ua,zn),this.groundVelocity.subVectors(Mn,d.prevT),this.object.getWorldPosition(zn).add(this.collider.position).sub(Mn),this.groundYRotation=qo.setFromQuaternion(Ua).y-d.prevR.y,ec.copy(zn).applyAxisAngle(ro,this.groundYRotation),this.groundVelocity.add(ec.sub(zn)).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=Mn.subVectors(this.path[1],this.position),h=zn.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.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=sJ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let c=zn.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=Mn;this.camera.getWorldDirection(c);let u=ec.copy(ro).multiplyScalar(c.dot(ro));c.sub(u);let h=zn.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(qo.setFromVector3(this.rot),this.moveMode==="walk"&&(qo.x=0),l.applyEuler(qo),a&&(Ua.setFromUnitVectors(ro,this.groundNormal),l.applyQuaternion(Ua)),i){let c=qo.set(0,this.vrEulerYOffset*xN,0);i.applyEuler(c),l.x+=i.x,l.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*s}if(this.usePhysics===!0){let c=zn;this.pushedVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=ec.setFromMatrixPosition(u.matrixWorld).sub(u.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=u.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Mn.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=yt.is(u)?u:u.object;if(d!==null&&this.lastHitObj!==f){let p;u instanceof Nr&&(p=u);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(vb));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(ro,this.euler.y-this.euler0.y);let c=zn.copy(this.objectToCamXZ).normalize(),u=ec.copy(l).multiplyScalar(s);u.y=0;let h=u.sub(Mn.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=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=we.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(qo.copy(r),qo.y=0):(qo.copy(this.euler),qo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(qo)),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*xN),to.setFromAxisAngle(aJ,this.rot.x),Ua.setFromAxisAngle(ro,this.rot.y),Ua.multiply(to),to.setFromAxisAngle(lJ,this.rot.z),Ua.multiply(to),this.quaternion.copy(Ua),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let c=zn.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(),p=ec.copy(c).normalize();if(u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),u!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(u.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let S of x)if(S.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(u.collider.handle))._parent,A;if(m.cloner){for(let M of m.cloner.children)if(M.rigidBody===w){A=M;break}}S.dispatch(A),m.dispatchEvent(vb)}}}let g=pN.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat),y=mN.copy(p).multiplyScalar(u.toi).dot(g),v=u.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=u.toi*(y-this.offset)/y,h.addScaledVector(p,v)),c.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),S=ec.copy(u.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let w=x.add(S);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(Mn.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(to.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);DM.lookAt(u,c,ro).setPosition(u),DM.decompose(this.targetPos,this.targetQuat,Mn),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=we.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=we.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(pJ),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(fJ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=to.setFromAxisAngle(ro,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?we.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=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mn.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let s=Ua.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){ro.angleTo(e)*180/Math.PI<15||ro.angleTo(e)*180/Math.PI>85?to.identity():to.setFromUnitVectors(ro,e),this.groundTilt.slerp(to,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=mN.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=DM.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mn,to,zn).compose(Mn,to,yN);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;Ms.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=gN.copy(a).invert(),c=oJ.copy(gN).multiply(i);Hi.copy(this.collider.segment),Hi.start.applyMatrix4(c),Hi.end.applyMatrix4(c);let u=pN.copy(this.position).applyMatrix4(l);Ms.expandByPoint(Hi.start),Ms.expandByPoint(Hi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Hi.end)},intersectsBounds:h=>h.intersectsBox(Ms),intersectsTriangle:h=>{let d=Mn,f=zn,p=h.closestPointToSegment(Hi,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=ec.copy(u);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);r.add(v),Hi.start.addScaledVector(g,m),Hi.end.addScaledVector(g,m)}}})}),Ms.makeEmpty(),Hi.copy(this.collider.segment),Hi.start.applyMatrix4(i),Hi.end.applyMatrix4(i),Ms.expandByPoint(Hi.start),Ms.expandByPoint(Hi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(Hi.end)},intersectsBounds:o=>o.intersectsBox(Ms),intersectsTriangle:o=>{let a=Mn,l=zn,c=o.closestPointToSegment(Hi,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),Hi.start.addScaledVector(h,u),Hi.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)}},ag=yb;ag.isLocked=!1;var bN=$o(iA());function io(n,t){let e=new _e;if(t){let s=t.elements,o=s[0]**2+s[1]**2+s[2]**2,a=s[4]**2+s[5]**2+s[6]**2,l=s[8]**2+s[9]**2+s[10]**2,c=s[0]**2+s[4]**2+s[8]**2,u=s[1]**2+s[5]**2+s[9]**2,h=s[2]**2+s[6]**2+s[10]**2,d=1e-8;if(o<d||a<d||l<d||c<d||u<d||h<d)return e.setAttribute("position",new Me([],3)),e.setIndex([]),e}if(!n.getAttribute("position"))return e.setAttribute("position",new Me([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Uc(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new Me(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var mJ=new ue,gJ=new ue,Yo=[[0,0,0],[0,0,0],[0,0,0]];function OM(n){let t=n.elements;Yo[0][0]=t[0],Yo[0][1]=t[4],Yo[0][2]=t[8],Yo[1][0]=t[1],Yo[1][1]=t[5],Yo[1][2]=t[9],Yo[2][0]=t[2],Yo[2][1]=t[6],Yo[2][2]=t[10];let{u:e,v:r}=(0,bN.SVD)(Yo),i=mJ.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=gJ.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 xb=class extends Qu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}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 ss({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 _e;return o.setFromPoints([e,s]),new gc(o,t)}};var SN=n=>n instanceof ws||n instanceof $s;function yJ(n,t){return n.distance-t.distance}function wN(n,t,e){if(!(!Io(t)||!t.visible)){cn(t)&&t.raycast(n,e);for(let r of t.children)wN(n,r,e)}}function Lf(n,t,e,r=!1){if(!r&&!e.some(s=>Bf(n,s)!==void 0))return[];let i=[];return t.children.forEach(s=>wN(n,s,i)),i.sort(yJ),i}function lg(n){let t=[];if(n.length){let e=n[0].object;Io(e)&&t.push(e);let r=e.parent;for(;r;)SN(r)&&t.push(r),r=r.parent}return t}function no(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 Bf(n,t){if(cn(t)){if(t.visible){let e=[];return t.raycast(n,e),e.length?e[0]:void 0}}else if(SN(t))return AN(n,t)}function AN(n,t){if(!(!Io(t)||!t.visible)){if(cn(t)){let e=[];if(t.raycast(n,e),e.length)return e[0]}for(let e of t.children){let r=AN(n,e);if(r)return r}}}function vJ(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 xJ(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width,y:1-(t-(e.top+window.scrollY))/e.height}}var bb=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 xb;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=vJ(e,r,this._domRect),this.pointerScreen=xJ(e,r,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}};var hr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var RM=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],EN=n=>RM.find(([t,e])=>e===n)?.[0],Xo=n=>RM.find(([t])=>t===n)?.[1],bJ=(n,t)=>{let e=EN(n);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Sb=class extends hr{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[EN(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 RM)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=bJ(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 LM=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=Kt(e,e.actions,i,s,o,r)}disconnect(){ur(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.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.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.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.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())}},wb=class extends hr{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=Lf(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=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{Je.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=Xo(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.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];o.data.events.filter(({data:h})=>h.type===c&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new LM(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(p=>p.id===f.id)||u[o.uuid].push(f):u[o.uuid]=[f]}catch(f){!1&&console.log(f)}}),u[o.uuid]?.length&&this.objectsPerTypes[c].push(o instanceof tr&&(c==="MouseDown"||c==="MouseUp"||c==="MousePress")?a:o)}};e.traverseEntity(o=>{(o instanceof Er||o instanceof cr)&&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)})})}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)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:i,page:s,pointerScreen:o}=this.eventContext,a=this.objectsPerTypes[e],l=a.filter(c=>!(c instanceof tr));if(!(!a.length&&!this.useForRaycastProperty)&&!(s.uiCanvas&&no(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=Lf(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];lg(c).forEach(h=>{h instanceof Er&&no(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=Bf(i,c);u&&(this.handleObjectMouseEventDispatch(c,e),c instanceof Er&&no(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 tr)),o=[];if(!!i.length){if(!e){let{stopRaycast:a,raycaster:l,page:c,pointerScreen:u}=this.eventContext,h=!1;if(c.uiCanvas&&(h=no(c,[u.x,u.y],Object.keys(this.eventsPerObjects[r]),d=>{o.push(d)})),a&&!h){let d=Lf(l,c,s);o=lg(d),d.forEach(f=>{f.object instanceof Er&&no(f.object,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)})})}else s.forEach(d=>{let f=Bf(l,d);f&&(o.push(d),d instanceof Er&&no(d,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)}))})}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 SJ=new E,wJ=new E;var Ab=class{constructor(t,e,r,i,s){this.actionsIn=Kt(t,t.inActions,r,i,s,e),this.actionsOut=Kt(t,t.outActions,r,i,s,e)}disconnect(){ur(this.actionsIn),ur(this.actionsOut)}};var BM=class extends Ab{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=SJ.setFromMatrixPosition(this.objects[0].matrixWorld),r=wJ.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.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)})}},NM=class extends Ab{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.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.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(){ls(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),ls(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),ls(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),ls(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Eb=class extends hr{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 BM(s,o,i,e,r,this.eventManager):o.condition.type==="State"&&(a=new NM(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.log(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 cg=new E,tc=new E,iu=new E,MN=new Ur,AJ=.01,rr=new E,Ii=new E,TN=new E,nu=new Qe,FM=new ir,EJ=new ue,VM=new fr,Nf=new E,Qo=new E,Ff=.2;function UM(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 MJ=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"&&UM(i.position,t.limits),i.position.applyMatrix4(n),t.reference==="parent"?UM(i.position,t.limits):t.reference==="local"&&(nu.copy(t.quat0).invert(),i.position.sub(t.position0),i.position.applyQuaternion(nu),UM(i.position,t.limits),nu.invert(),i.position.applyQuaternion(nu),i.position.add(t.position0)),n.multiply(r??i.matrixWorld).decompose(rr,i.quaternion,Ii),i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i instanceof mr&&En(i.parent)&&i.invalidateDownstreamBooleanData(!0)}}(),zM=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=Kt(r,r.dragDropActions.drag,i,s,o,this.object),this.actionsDrop=Kt(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 Qe().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(){ur(this.actionsDrag),ur(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()})}},Mb=class extends hr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(Je.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||yt.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(rr,nu,Ii),FM.setFromQuaternion(nu),h.prevR===void 0?(h.prevR=FM.clone(),h.prevT=rr.clone()):(h.prevR.copy(FM),h.prevT.copy(rr)),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(Je.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if(Je.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||yt.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 ws)&&(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=TN.copy(a.face.normal).applyMatrix3(VM.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"){rr.copy(l).applyMatrix3(VM.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;rr.x>Ff?Ii.x=-c.recursiveBBox.min.x:rr.x<-Ff&&(Ii.x=-c.recursiveBBox.max.x),rr.y>Ff?Ii.y=-c.recursiveBBox.min.y:rr.y<-Ff&&(Ii.y=-c.recursiveBBox.max.y),rr.z>Ff?Ii.z=-c.recursiveBBox.min.z:rr.z<-Ff&&(Ii.z=-c.recursiveBBox.max.z),Ii.applyMatrix3(VM.invert())}else Ii.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Ii)}this.activeEvent.data.autoOrient&&(rr.set(0,1,0).cross(l),rr.length()<1e-4&&rr.set(-1,0,0).cross(l),Ii.crossVectors(TN,rr),o.orientationMatrix.makeBasis(rr,Ii,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 zM(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(tc),tc.negate();let l=nu.identity();switch(s==="parent"?EJ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(rr,l,Ii):s==="local"&&e.matrixWorld.decompose(rr,l,Ii),i){case"x":rr.set(1,0,0).applyQuaternion(l),Nf.copy(tc).cross(rr),Qo.copy(rr).cross(Nf);break;case"y":rr.set(0,1,0).applyQuaternion(l),Nf.copy(tc).cross(rr),Qo.copy(rr).cross(Nf);break;case"z":rr.set(0,0,1).applyQuaternion(l),Nf.copy(tc).cross(rr),Qo.copy(rr).cross(Nf);break;case"xy":Qo.set(0,0,1).applyQuaternion(l);break;case"yz":Qo.set(1,0,0).applyQuaternion(l);break;case"xz":Qo.set(0,1,0).applyQuaternion(l);break;case"adaptive":tc.angleTo(Ii.set(0,1,0))>Math.PI/6?(rr.crossVectors(Ii.set(0,1,0),tc),Qo.crossVectors(rr,Ii)):Qo.set(0,1,0);break;default:Qo.copy(tc);break}iu.setFromMatrixPosition(e.matrixWorld);let c=e.userData.lockedPlane?e.userData.worldPosition0:iu;if(MN.setFromNormalAndCoplanarPoint(Qo,c),!!a.ray.intersectPlane(MN,r)&&(i==="x"||i==="y"||i==="z")){let u=Ii.subVectors(r,c).dot(rr);r.copy(c).addScaledVector(rr,u)}}updateDragItem(e,r=!1){iu.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?cg.subVectors(e.fromPosition,iu).divideScalar(e.currentDampingFactor):e.reset==="original"?(cg.subVectors(e.obj.userData.worldPosition0,iu).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):cg.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(iu).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?cg.length()<AJ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&MJ(e,cg.add(iu),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var Vf=new E,kM=new E,za=new E,ka=new E,CN=new Ur,TJ=.01,CJ={type:"requestRender"},PJ=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}(),PN=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 mr&&En(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),GM=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={...Cv.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=Kt(t,t.actions,i,s,o,r)}},Tb=class extends hr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(Je.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 GM(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(),Ci&&(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(),Ci&&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,ur(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(za),e.isReset)ka.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ka);else{let{getCamera:l,raycaster:c}=this.eventContext;if(i==="custom"?(l().getWorldDirection(kM),kM.negate(),Vf.copy(kM)):i==="xy"?Vf.set(0,0,1):i==="xz"?Vf.set(0,1,0):i==="yz"&&Vf.set(1,0,0),CN.setFromNormalAndCoplanarPoint(Vf,za),!c.ray.intersectPlane(CN,ka))return}if(!e.isReset){if(ka.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)ka.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&&(ka.x=za.x),e.data.enabledTranslation[1]===!1&&(ka.y=za.y),e.data.enabledTranslation[2]===!1&&(ka.z=za.z);let a=PJ(za,ka,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Vf.subVectors(a,za).divideScalar(e.currentDampingFactor);za.add(l),r&&PN(e.object,za),e.paused=l.length()<TJ}else PN(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(CJ)}};var ug=new E,Cb=new E,hg=new ue,Uf=new Qe,rc=new Qe,dg=new E,fg=new E,su=new E,Ga=new E,jM=new Ur,_J=1e-6,DJ={type:"requestRender"},IJ={type:"changeRotation"},_N=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(OM(n).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof mr&&En(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),HM=class{constructor(t,e,r,i){this.id=e;this.object=r;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Qe;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Pv.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),this.resetDampingFactor=80/this.data.resetSpeed+1}},Pb=class extends hr{constructor(){super(...arguments);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(Je.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=Xo(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 HM(o.data,o.id,s,e))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Ci&&(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(),Ci&&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(dg),!e.isReset)if(e.target)e.target.getWorldPosition(fg);else{if(o==="custom"?(u().getWorldDirection(Cb),Cb.negate(),jM.setFromNormalAndCoplanarPoint(Cb,dg)):(o==="xy"?ug.set(0,0,1):o==="xz"?ug.set(0,1,0):o==="yz"&&ug.set(1,0,0),jM.setFromNormalAndCoplanarPoint(ug,dg)),!h.ray.intersectPlane(jM,fg))return;s>0&&(o==="custom"||o===void 0)&&fg.addScaledVector(Cb,s)}if(e.isReset||(f?r==="target"?su.copy(f.up).applyMatrix4(hg.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(i==="x"?(Ga.set(0,0,1),l[2]===!1&&Ga.set(0,1,0)):i==="y"?(Ga.set(1,0,0),l[0]===!1&&Ga.set(0,0,1)):(Ga.set(0,1,0),l[1]===!1&&Ga.set(1,0,0)),su.copy(Ga).applyQuaternion(e.worldQuaternion0).normalize()):su.set(0,1,0):o==="custom"?su.set(0,1,0):su.copy(ug)),e.isReset)rc.copy(e.worldQuaternion0);else if(dg.distanceTo(fg)>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)rc.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;OJ(hg,fg,dg,su,i,Ga),rc.setFromRotationMatrix(hg),Uf.setFromUnitVectors(Ga.applyQuaternion(rc),su),l.some(p=>p===!1)&&r!=="target"&&rc.premultiply(Uf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Uf.setFromRotationMatrix(OM(d.matrixWorld)),Uf.slerp(rc,1/e.currentDampingFactor),_N(d,hg.makeRotationFromQuaternion(Uf)),e.paused=8*(1-Uf.dot(rc))<_J):(_N(d,hg.makeRotationFromQuaternion(rc)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(DJ),d.dispatchEvent(IJ)}},Ts=new E,Oi=new E,li=new E;function OJ(n,t,e,r,i,s){let o=n.elements;li.subVectors(t,e),li.lengthSq()===0&&(li.z=1),li.normalize(),Oi.crossVectors(r,li),Oi.lengthSq()===0&&(Math.abs(r.z)===1?li.x+=1e-4:li.z+=1e-4,li.normalize(),Oi.crossVectors(r,li)),Oi.normalize(),Ts.crossVectors(li,Oi),i==="x"?s.z===1?[Oi,Ts,li]=[li,Oi,Ts]:(Oi.negate(),[Oi,li]=[li,Oi]):i==="y"?s.x===1?[Oi,Ts,li]=[Ts,li,Oi]:(Oi.negate(),[Ts,li]=[li,Ts]):s.x===1&&(Oi.negate(),[Oi,Ts]=[Ts,Oi]),o[0]=Oi.x,o[4]=Ts.x,o[8]=li.x,o[1]=Oi.y,o[5]=Ts.y,o[9]=li.y,o[2]=Oi.z,o[6]=Ts.z,o[10]=li.z}var WM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=Kt(e,e.actions,i,s,o,r)}disconnect(){ur(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.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.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.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.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())}},_b=class extends hr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObjects={};this.objects=[];this.objects2D=[];this._prevObjects=[];this.onMouseDown=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{Je.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Xo(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 WM(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.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o instanceof tr?a:o)}};if(e.traverseEntity(o=>{(o instanceof Er||o instanceof cr)&&o.frame?.traverse(a=>{i(a,o)}),i(o)}),!this.objects.length)return;let{domElement:s}=this.eventContext;this.domEventsNeeded.clear(),Ci&&(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(),Ci&&(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=no(o,[a.x,a.y],Object.keys(this.eventsPerObjects),c=>{r.push(c)})),i&&!l){let c=Lf(s,o,this.objects);r=lg(c),c.forEach(u=>{u.object instanceof Er&&no(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=Bf(s,c);u&&(r.push(c),c instanceof Er&&no(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 qM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=Kt(e,e.actions,i,s,o,r)}connect(){this.scrollCounter=0}disconnect(){ur(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.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.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.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())}},YM=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=Kt(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),p=parseFloat(h.bottom),m=u.height-d;if(!isNaN(f))r.top===f?(i.top+=u.top-f,i.bottom+=u.top-f):r.top<0&&(i.top-=m-r.height,i.bottom-=m-r.height);else if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,y=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);r.bottom===g-p?(i.top+=u.top-r.height+p+y,i.bottom+=u.top-r.height+p+y):r.bottom<g-p&&(i.top-=m-r.height,i.bottom-=m-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(){ur(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.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.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.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())}},Db=class extends hr{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=Xo(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 qM(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 YM(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 Er||a instanceof cr)&&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 XM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Kt(e,e.actions,i,s,o,r)}disconnect(){ur(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.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 jo?e.interaction.audioPlayer.play():e.interaction instanceof Df&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof Va?e.interaction.play(r==="autoplay"):e.interaction instanceof Rf&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}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.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.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 jo?e.interaction.audioPlayer.play():e.interaction instanceof Df&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Va?e.interaction.play():e.interaction instanceof Rf&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},Ib=class extends hr{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 jo&&s.interaction.audioPlayer.play()}),i.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Va&&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.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Xo(e);s&&s==="Start"&&(r instanceof tr||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 XM(o,a,s,r,e,this.eventManager);(l.actions.Transition.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 Er||s instanceof cr)&&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 Ob=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.initialDisabled=!1;this.actions=Kt(e,e.actions,i,s,o,r),this.target=e.target}disconnect(){ur(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.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 Rb=class extends hr{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),p=Dv.propertyPaths[h];if(p[0]==="width"||p[0]==="height"||p[0]==="depth")f=f.geometry.userData.parameters[p[0]];else for(let m=0;m<p.length;m++)f=f[p[m]];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:p,startValue:m}=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)!==m&&(r.updateVariable(u,m),this.eventManager.requestRender()),(f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==m&&(this.dynamicVars[c].timerSeconds=m,r.updateVariable(u,vn.getFormattedTimerTime(m,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),v=f.decimals;y=Math.round(y*Math.pow(10,v))/Math.pow(10,v),r.updateVariable(u,y),s.push(u),this.eventManager.requestRender()}else if(f.dynamicVariableType==="counter"){let y=r.getVariable(u),v=r.getDynamicVariableToggleIsForward(u)??!0,x=r.getVariable(u)+f.increment*(v?1:-1);f.hasEnd&&(x=f.increment>0?we.clamp(x,m,f.endValue):we.clamp(x,f.endValue,m),x===m&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?x===f.endValue&&(x=m):(x===m||x===f.endValue)&&r.setDynamicVariablePlayState(u,"Paused")),x!==y&&(s.push(u),r.updateVariable(u,x),this.eventManager.requestRender())}else if(f.dynamicVariableType==="time"){let y=r.getVariable(u),v=dE(i,f);if(typeof y=="object"&&"textValue"in y&&typeof v=="object"&&"textValue"in v){if(Array.isArray(y.textValue)&&Array.isArray(v.textValue)){if(y.textValue.every((x,S)=>x===v.textValue[S]))continue}else if(y.textValue===v.textValue)continue}else if(y===v)continue;r.updateVariable(u,v),s.push(u),this.eventManager.requestRender()}else{let y=Br.isTextValue(f.endValue)?DN(f.endValue.textValue):f.endValue,v=r.getDynamicVariableToggleIsForward(u)??!0,x=p+(e-d)/1e3*(f.dynamicVariableType==="timer"?-1:1)*(v?1:-1);x=Math.max(x,0),f.hasEnd&&(x=f.dynamicVariableType==="stopwatch"?we.clamp(x,m,y):we.clamp(x,y,m),x===m&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?Math.abs(x-y)<(f.format==="number3decimal"?1e-4:.1)&&(x=m):(Math.abs(x-m)<(f.format==="number3decimal"?1e-4:.1)||Math.abs(x-y)<(f.format==="number3decimal"?1e-4:.1))&&r.setDynamicVariablePlayState(u,"Paused")),x!==p&&(s.push(u),this.dynamicVars[c].timerSeconds=x,r.updateVariable(u,vn.getFormattedTimerTime(x,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 QM(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(Br.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,dE(new Date,i)),i.dynamicVariableType==="counter"&&(s=Br.isTextValue(i.value)?DN(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())}},QM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Kt(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(){ur(this.actions)}};function DN(n){return n.length===3?n[2]+n[1]*60+n[0]*3600:n[1]+n[0]*60}var ON=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@1.9.32/build/",RJ=!1?ON:"https://unpkg.com/@splinetool/navmesh-wasm@1.9.32/build/",LJ=`
7381
7381
  (async function() {
7382
7382
  const [wasmImport, wasmBinary] = await Promise.all([
7383
7383
  import('${ON}' + 'navmesh.js'),
@@ -7445,4 +7445,4 @@ onmessage = function(messageEvent) {
7445
7445
  `),T.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),T.addEventListener("touchend",P=>P.preventDefault()),this.joysticks[p]=[void 0,m];return}let M={zone:m,mode:"static",position:S,size:g};v==="hide"&&(M.restOpacity=0);let b=vB.create(M);b.on("move",(T,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()}),b.on("end",(T,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[p]=[b,m]}),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 kt.World(new kt.Vector3(0,this.gravity,0)),this.events=new kt.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof Gi)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 Nr)l=a.object;else{if(a instanceof Jl||a instanceof Gl)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=pg(c),d=!1,f=l.userData.hasDestroy,p=l.userData.hasDrag,m=!1;for(let y of c.events)if(y.data.disabled!==!0){if(y.data.type==="Collision"){d=!0;let v=new Ob(y.id,y.data,l,this.page,this.sharedAssets,this.eventManager);v.initialDisabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(x=>x.id!==y.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[v]}else if(y.data.type==="Follow"){m=!0;let v=y.data.target;a.traverseVisible(x=>{x.userData.isFollowingObj=v})}}c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(u!==void 0){let y=kt.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(bi,so,ic),a.position0=bi.clone().divideScalar(this.pixelsPerMeter),a.rotation0=so.clone(),bi.divideScalar(this.pixelsPerMeter),y.setTranslation(bi.x,bi.y,bi.z).setRotation(so);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=v;let x;u.collider.type==="sphere"?x=kt.ColliderDesc.ball(u.collider.radius/this.pixelsPerMeter):u.collider.type==="capsule"?x=kt.ColliderDesc.capsule((u.collider.height/2-u.collider.radius)/this.pixelsPerMeter,u.collider.radius/this.pixelsPerMeter):x=kt.ColliderDesc.cuboid(u.collider.width/this.pixelsPerMeter/2,u.collider.height/this.pixelsPerMeter/2,u.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(kt.CoefficientCombineRule.Average).setRestitutionCombineRule(kt.CoefficientCombineRule.Average).setDensity(c.physics.density).setFriction(c.physics.friction).setRestitution(c.physics.restitution);let S=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(S.handle,l),bi.fromArray(u.collider.position).multiply(ic.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),S.setTranslationWrtParent(bi);let w=new Qe().setFromEuler(new ir().setFromVector3(new E().fromArray(u.collider.rotation)));S.setRotationWrtParent(w),S.setActiveEvents(kt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else c.physics.rigidBody==="dynamic"||h||m||f||p||d?(this.addRigidBody(a,l,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(l,c.physics.fusedBody)):(g&&t.push(io(g,a.matrixWorld)),c.physics.fusedBody&&a.traverseObject((y,v)=>{if(v===0)return;let x;if(y instanceof Gi)if(y.objectForSample){if(y.objectForSample.dataPatched.physics.fusedBody)return;x=y.object}else return y.object.dataPatched.physics.fusedBody===!0&&y.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(y instanceof Jl||y instanceof Gl)return;if(y instanceof Nr)x=y.object;else if(x=y,x.dataPatched.cloner?.hideBase)return!0}let S=x.dataPatched;if(S.physics.enabled==="visibility"?!S.visible:!S.physics.enabled)return!0;let w=y.geometry;w?.getAttribute("position")!==void 0&&t.push(io(w,y.matrixWorld))}),this.generateSensorColliderDescs(l,c.physics.fusedBody,e));if(c.physics?.fusedBody===!0||u)return!0}),t.length===0)return;let r=ks(t);r.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let i=kt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(i),o=kt.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array).setFrictionCombineRule(kt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(kt.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 mg(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),i=new ue().compose(oo.fromArray(e.data.position),kf.setFromEuler(VN.fromArray(e.data.rotation)),iT);if(e.data.triggerZone==="box"){let s=new jt;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).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&&(i=!this.orbitControls.update()),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}}return i}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(bi,so,ic),tT.setFromQuaternion(so);let r=e;r.prevR===void 0?(r.prevR=tT.clone(),r.prevT=bi.clone()):(r.prevR.copy(tT),r.prevT.copy(bi)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(bi.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(so))}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(vb)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,r){let i=UN.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 mg(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),c;if(a.data.triggerZone==="box"?c=kt.ColliderDesc.cuboid(...a.data.size.map(u=>u/(2*this.pixelsPerMeter))):c=kt.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),c.setDensity(0).setSensor(!0).setActiveEvents(kt.ActiveEvents.COLLISION_EVENTS),oo.fromArray(a.data.position),kf.setFromEuler(VN.fromArray(a.data.rotation)),Fb.compose(oo,kf,iT).premultiply(s.matrixWorld),r?(Fb.decompose(oo,kf,rT),c.setActiveCollisionTypes(kt.ActiveCollisionTypes.KINEMATIC_FIXED|kt.ActiveCollisionTypes.DYNAMIC_FIXED)):(Fb.premultiply(i).decompose(oo,kf,rT),t.rigidBody.bodyType()===kt.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===kt.RigidBodyType.Fixed?c.setActiveCollisionTypes(kt.ActiveCollisionTypes.KINEMATIC_FIXED|kt.ActiveCollisionTypes.DYNAMIC_FIXED):c.setActiveCollisionTypes(kt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|kt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),oo.divideScalar(this.pixelsPerMeter),c.setTranslation(oo.x,oo.y,oo.z),c.setRotation(kf),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(yt.is(l)?l:l.object)===!1)continue;let c=UN.copy(s.matrixWorld).decompose(oo,zN,rT).compose(oo,zN,iT).multiply(i),u=Fb.copy(l.matrixWorld).invert().multiply(c);r instanceof jt?t=l.bvhGeometry.boundsTree.intersectsBox(r,u):(nT.radius=r,nT.center.setFromMatrixPosition(u),t=l.bvhGeometry.boundsTree.intersectsSphere(nT)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(YJ)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(h=>h!==l)}}}};function GN(n){let t=this._clip.duration,e=this._clip.start??0,r=this.loop,i=this.time+n,s=this._loopCount,o=r===wp;if(n===0)return s===-1?i:o&&(s&1)===1?t-(i-e):i;if(r===Aw){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 jN=!1,Ub=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=qu.parse(JSON.parse(e[2]));t.animations[r]=s;let o=this.mixer.clipAction(s,t);jN===!1&&(Object.getPrototypeOf(o)._updateTime=GN,jN=!0),o.clampWhenFinished=!0,this.clipIdToAction[i]=o})};this.mixer=new vy(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=Ew}),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=wp)),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 CM(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 sT=new WeakMap,zb=class extends sl{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 Yu(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(sT.has(t)){let l=sT.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)}),sT.set(t,{key:r,promise:a}),a}_createGeometry(t){let e=new _e;t.index&&e.setIndex(new Xe(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 Xe(o,a))}return e}_loadLibrary(t,e){let r=new Yu(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=XJ.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
7446
7446
  `);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 XJ(){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 p=e(h,d,f,c),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,c){let u=c.attributeIDs,h=c.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===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 m={index:null,attributes:[]};for(let g in u){let y=self[h[g]],v,x;if(c.useUniqueIDs)x=u[g],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[u[g]]),x===-1)continue;v=a.GetAttribute(d,x)}m.attributes.push(i(o,a,d,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=r(o,a,d)),o.destroy(d),m}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(),p=l.num_points()*d,m=p*u.BYTES_PER_ELEMENT,g=s(o,u),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,g,m,y);let v=new u(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:c,array:v,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 nc;function HN(){return nc||(nc=new zb,nc.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),nc.decoderPending}async function QJ(n){if(nc){let t={attributeIDs:nc.defaultAttributeIDs,attributeTypes:nc.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await nc.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 WN(n,t){let[e,r]=n1(Mv.deserialize(new Uint8Array(n)));return Xv(e),t&&t(e),r.result().data}function qN(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 YN(n){for(let t of n){let e=await QJ(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 kb=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 oT=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=Kt(i,r.actions,o,a,l,s)}disconnect(){ur(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()})}},Gb=class extends hr{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(i=>{let s=_v.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 oT(l,u,c,a,o,e,r,this.eventManager);this.breakpoints.push(h)}catch(h){!1&&console.log(h)}})};e.traverseEntity(o=>{(o instanceof Er||o instanceof cr)&&o.frame?.traverse(a=>{s(a)}),s(o)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var jb=class extends hr{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 aT(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)})}},aT=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.successActions=Kt(e,e.successActions,i,s,o,r),this.errorActions=Kt(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 Hb=class extends hr{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 lT(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()})}},lT=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=Kt(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 KJ(){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 ZJ=new E(0,0,1),XN=new E,QN=new E,KN=new fr,Wb=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 Sf;this.doubleClickHandler=new kb;this.isDragging=!1;this.plane=new Ur;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=$3(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=KJ(),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)]===`
7447
7447
  `&&(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]===`
7448
- `&&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 Kl)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&&(KN.getNormalMatrix(this.virtualInput.matrixWorld),XN.copy(ZJ).applyMatrix3(KN).normalize(),this.virtualInput.localToWorld(QN.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(XN,QN))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),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=JJ(t.geometry.horizontalAlign))}};function JJ(n){return n===4?"justify":n===2?"right":n===3?"center":"left"}var JN=(n,t)=>{if(typeof n=="string"){let e=t.data(n);if(e)return JN(e.value,t)}return Br.getDisplayedValue(n)};function ZN(n,t){let e=n.text,r="";if(typeof e=="string"){let i=t.variables.data(r);i&&(r=JN(i.value,t.variables))}else r=e.textValue.toString();return r}var qb=class extends hr{constructor(e,r){super(e);this.eventManager=r;this._textInputs=[];this.sceneHelpers=new ei;this.helper=new Sf;this._onMouseDownFocusIn=e=>{if(Je.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).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 Wb(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(s=>{s instanceof Kl&&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}=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(i=>{let s=ZN(i.data.geometry,this.eventContext.sharedAssets.data);i.textGeometry.setText(s)}),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=ZN(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 Yb=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(){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 Sb(this.eventContext),["VariableChange"]:new Rb(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["API"]:new jb(this.eventContext,this),["WEBHOOK"]:new Hb(this.eventContext,this),["Conditional"]:new Eb(this.eventContext,this),["Start"]:new Ib(this.eventContext,this),Basic:new wb(this.eventContext,this,this.needsRaycast),["MouseHover"]:new _b(this.eventContext,this),["Scroll"]:new Db(this.eventContext,this),["Follow"]:new Tb(this.eventContext,this),["DragDrop"]:new Mb(this.eventContext,this),["LookAt"]:new Pb(this.eventContext),["Resize"]:new Gb(this.eventContext,this),Textfields:new qb(this.eventContext,this)};let{page:t,domElement:e}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(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 Xb=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=$J(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 $J(n,t,e,r,i){return(n-t)/(e-t)*(i-r)+r}var Qb=class{get sharedAssets(){return this.shared}constructor(t,e={},r=!0){this.shared=new Xc(t.shared,e,!0,r),this.scene=new Wl(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 cr&&!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 lr&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Kb=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 e$(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 gg(n){return n instanceof Ks?"SubdivObject":n.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function t$(n,t){let e={};return n.traverseEntity(r=>{if(!r.visible||!(r instanceof mr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let i=r.parent;for(;i;){if(i instanceof mr&&r.states&&Object.keys(r.states).length)return;i=i.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!Qr.isMergable(o))return}else{let c=t.scene.objects.get(r.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!Qr.isMergable(c.material))return;s=Qr.getHash(c.material)}}e[s]||(e[s]={});let l=e[s][gg(r)];if(l){if(l.push(r),r.cloner)for(let c of r.cloner.children)l.push(c)}else if(e[s][gg(r)]=[r],r.cloner)for(let c of r.cloner.children)e[s][gg(r)].push(c)}),e}function r$(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 $N(n,t){let e=t$(t,n),r=r$(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 p of Object.values(f)){if(a=0,c=0,p.forEach(g=>{g instanceof mr&&(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&&e$(o[g]);let m=ks(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Ut(m,l[0].material);break}default:{g=new Ut(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof mr&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][gg(x)]&&e[x.material.uuid][gg(x)].length>1||(u[h++]=x));for(let x=0;x<h;x++)t.attach(u[x])};for(let v=0;v<c;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let d=0;d<s;d++)i[d].removeFromParent()}var rF=$o(tF(),1);var n$=new U;function s$(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)}var cT=class{constructor(t,{renderOnDemand:e,renderMode:r="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._variablesCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=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)),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=n$.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=go(this._resize,10);this._onScroll=t=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())};this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Kb({x:10,y:10})),Q2(t)}async load(t,e,r){s$(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 WN(t);this._data=i;let s=qN(i);i.version&&(0,rF.default)(i.version,"1.9.31")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([s.length&&HN(),DE(i)&&$O(),QR(i)&&qO(),Ml.physicsEnabled(i.scene.objects)&&rD(),wE(i)&&zR(),Jx(i)&&nM(),FR(i)&&BR(),GE(i)&&fL(),ZM(i)&&$2()].filter(Boolean)),s.length&&await YN(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let o=new Qb(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();$N(i,o.scene);let u=performance.now();console.log("Merged geometries in ",u-c," ms")}DE(i)&&this._scene.traverse(c=>{En(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{c instanceof Gi&&c.pendingMediaLoad&&c.update()})}),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()}),wE(i)&&kN(i)&&await Promise.all(a),GE(i)){let c=[];this._scene.traverseEntity(u=>{(u instanceof Er||u instanceof cr)&&u.uiCanvas&&c.push(u.uiCanvas)}),await Promise.all(c.map(u=>u.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),If(this._scene.activePage,this._sharedAssetsManager),!this._renderer&&(this._renderer=new Px({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),i.shared.images.SplineWatermark)){let c=this._sharedAssetsManager.getImage("SplineWatermark");await c.loadPromise;let u=c.getTexture(1001);this._renderer.pipeline.setWatermark(u)}Jx(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 Xb(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 bb(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,l);this._scene.updateMatrixWorld(!0),this._controls=new Vb(c),this._animationControls=new Ub(this._scene,this._requestRenderAutoMode),this._eventManager=new Yb(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"&&Br.isTextValue(t)?Br.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}}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!==hs&&!this._scene.isInvisibleObjects(e)&&!(e instanceof cr)){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 zf&&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{r:e,g:r,b:i,a:s}={r:0,g:0,b:0,a:1},o=new vr(e,r,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Gw.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,K2(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(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof cr&&(e=s.name)});let r={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:e,parentUuid:t.parent instanceof cr||t instanceof Wl?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},i=Gw(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,i),i}setUIWasmUrl(t){z0.skiaWasmUrl=t}};
7448
+ `&&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 Kl)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&&(KN.getNormalMatrix(this.virtualInput.matrixWorld),XN.copy(ZJ).applyMatrix3(KN).normalize(),this.virtualInput.localToWorld(QN.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(XN,QN))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),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=JJ(t.geometry.horizontalAlign))}};function JJ(n){return n===4?"justify":n===2?"right":n===3?"center":"left"}var JN=(n,t)=>{if(typeof n=="string"){let e=t.data(n);if(e)return JN(e.value,t)}return Br.getDisplayedValue(n)};function ZN(n,t){let e=n.text,r="";if(typeof e=="string"){let i=t.variables.data(r);i&&(r=JN(i.value,t.variables))}else r=e.textValue.toString();return r}var qb=class extends hr{constructor(e,r){super(e);this.eventManager=r;this._textInputs=[];this.sceneHelpers=new ei;this.helper=new Sf;this._onMouseDownFocusIn=e=>{if(Je.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).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 Wb(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(s=>{s instanceof Kl&&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}=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(i=>{let s=ZN(i.data.geometry,this.eventContext.sharedAssets.data);i.textGeometry.setText(s)}),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=ZN(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 Yb=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(){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 Sb(this.eventContext),["VariableChange"]:new Rb(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["API"]:new jb(this.eventContext,this),["WEBHOOK"]:new Hb(this.eventContext,this),["Conditional"]:new Eb(this.eventContext,this),["Start"]:new Ib(this.eventContext,this),Basic:new wb(this.eventContext,this,this.needsRaycast),["MouseHover"]:new _b(this.eventContext,this),["Scroll"]:new Db(this.eventContext,this),["Follow"]:new Tb(this.eventContext,this),["DragDrop"]:new Mb(this.eventContext,this),["LookAt"]:new Pb(this.eventContext),["Resize"]:new Gb(this.eventContext,this),Textfields:new qb(this.eventContext,this)};let{page:t,domElement:e}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(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 Xb=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=$J(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 $J(n,t,e,r,i){return(n-t)/(e-t)*(i-r)+r}var Qb=class{get sharedAssets(){return this.shared}constructor(t,e={},r=!0){this.shared=new Xc(t.shared,e,!0,r),this.scene=new Wl(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 cr&&!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 lr&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Kb=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 e$(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 gg(n){return n instanceof Ks?"SubdivObject":n.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function t$(n,t){let e={};return n.traverseEntity(r=>{if(!r.visible||!(r instanceof mr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let i=r.parent;for(;i;){if(i instanceof mr&&r.states&&Object.keys(r.states).length)return;i=i.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!Qr.isMergable(o))return}else{let c=t.scene.objects.get(r.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!Qr.isMergable(c.material))return;s=Qr.getHash(c.material)}}e[s]||(e[s]={});let l=e[s][gg(r)];if(l){if(l.push(r),r.cloner)for(let c of r.cloner.children)l.push(c)}else if(e[s][gg(r)]=[r],r.cloner)for(let c of r.cloner.children)e[s][gg(r)].push(c)}),e}function r$(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 $N(n,t){let e=t$(t,n),r=r$(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 p of Object.values(f)){if(a=0,c=0,p.forEach(g=>{g instanceof mr&&(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&&e$(o[g]);let m=ks(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Ut(m,l[0].material);break}default:{g=new Ut(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof mr&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][gg(x)]&&e[x.material.uuid][gg(x)].length>1||(u[h++]=x));for(let x=0;x<h;x++)t.attach(u[x])};for(let v=0;v<c;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let d=0;d<s;d++)i[d].removeFromParent()}var rF=$o(tF(),1);var n$=new U;function s$(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)}var cT=class{constructor(t,{renderOnDemand:e,renderMode:r="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._variablesCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=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)),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=n$.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=go(this._resize,10);this._onScroll=t=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())};this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Kb({x:10,y:10})),Q2(t)}async load(t,e,r){s$(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 WN(t);this._data=i;let s=qN(i);i.version&&(0,rF.default)(i.version,"1.9.32")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([s.length&&HN(),DE(i)&&$O(),QR(i)&&qO(),Ml.physicsEnabled(i.scene.objects)&&rD(),wE(i)&&zR(),Jx(i)&&nM(),FR(i)&&BR(),GE(i)&&fL(),ZM(i)&&$2()].filter(Boolean)),s.length&&await YN(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let o=new Qb(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();$N(i,o.scene);let u=performance.now();console.log("Merged geometries in ",u-c," ms")}DE(i)&&this._scene.traverse(c=>{En(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{c instanceof Gi&&c.pendingMediaLoad&&c.update()})}),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()}),wE(i)&&kN(i)&&await Promise.all(a),GE(i)){let c=[];this._scene.traverseEntity(u=>{(u instanceof Er||u instanceof cr)&&u.uiCanvas&&c.push(u.uiCanvas)}),await Promise.all(c.map(u=>u.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),If(this._scene.activePage,this._sharedAssetsManager),!this._renderer&&(this._renderer=new Px({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),i.shared.images.SplineWatermark)){let c=this._sharedAssetsManager.getImage("SplineWatermark");await c.loadPromise;let u=c.getTexture(1001);this._renderer.pipeline.setWatermark(u)}Jx(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 Xb(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 bb(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,l);this._scene.updateMatrixWorld(!0),this._controls=new Vb(c),this._animationControls=new Ub(this._scene,this._requestRenderAutoMode),this._eventManager=new Yb(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"&&Br.isTextValue(t)?Br.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}}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!==hs&&!this._scene.isInvisibleObjects(e)&&!(e instanceof cr)){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 zf&&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{r:e,g:r,b:i,a:s}={r:0,g:0,b:0,a:1},o=new vr(e,r,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Gw.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,K2(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(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof cr&&(e=s.name)});let r={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:e,parentUuid:t.parent instanceof cr||t instanceof Wl?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},i=Gw(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,i),i}setUIWasmUrl(t){z0.skiaWasmUrl=t}};