@splinetool/viewer 1.12.54 → 1.12.56

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.
@@ -3172,7 +3172,7 @@ void main() {
3172
3172
  squared_mean = squared_mean / samples;
3173
3173
  float std_dev = sqrt( squared_mean - mean * mean );
3174
3174
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3175
- }`;function dN(e,t,i){let r=new Zb,a=new ae,s=new ae,n=new Lt,o=new j3({depthPacking:C3}),l=new lN,h={},c=i.maxTextureSize,d={[nn]:na,[na]:nn,[Pa]:Pa},u=new di({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ae},radius:{value:4}},vertexShader:hN,fragmentShader:cN}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new vt;f.setAttribute("position",new Pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Fi(f,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Wb,this.render=function(_,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||_.length===0)return;let E=e.getRenderTarget(),M=e.getActiveCubeFace(),T=e.getActiveMipmapLevel(),P=e.state;P.setBlending(Ir),P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);for(let R=0,z=_.length;R<z;R++){let U=_[R],L=U.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",U,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;a.copy(L.mapSize);let j=L.getFrameExtents();if(a.multiply(j),s.copy(L.mapSize),(a.x>c||a.y>c)&&(a.x>c&&(s.x=Math.floor(c/j.x),a.x=s.x*j.x,L.mapSize.x=s.x),a.y>c&&(s.y=Math.floor(c/j.y),a.y=s.y*j.y,L.mapSize.y=s.y)),L.map===null){let Q=this.type!==Xu?{minFilter:ei,magFilter:ei}:{};L.map=new ci(a.x,a.y,Q),L.map.texture.name=U.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let q=L.getViewportCount();for(let Q=0;Q<q;Q++){let X=L.getViewport(Q);n.set(s.x*X.x,s.y*X.y,s.x*X.z,s.y*X.w),P.viewport(n),L.updateMatrices(U,Q),r=L.getFrustum(),b(S,A,L.camera,U,this.type)}L.isPointLightShadow!==!0&&this.type===Xu&&y(L,A),L.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(E,M,T)};function y(_,S){let A=t.update(m);u.defines.VSM_SAMPLES!==_.blurSamples&&(u.defines.VSM_SAMPLES=_.blurSamples,p.defines.VSM_SAMPLES=_.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new ci(a.x,a.y)),u.uniforms.shadow_pass.value=_.map.texture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,e.setRenderTarget(_.mapPass),e.clear(),e.renderBufferDirect(S,null,A,u,m,null),p.uniforms.shadow_pass.value=_.mapPass.texture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,e.setRenderTarget(_.map),e.clear(),e.renderBufferDirect(S,null,A,p,m,null)}function x(_,S,A,E,M,T){let P=null,R=A.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)P=R;else if(P=A.isPointLight===!0?l:o,e.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let z=P.uuid,U=S.uuid,L=h[z];L===void 0&&(L={},h[z]=L);let j=L[U];j===void 0&&(j=P.clone(),L[U]=j),P=j}return P.visible=S.visible,P.wireframe=S.wireframe,T===Xu?P.side=S.shadowSide!==null?S.shadowSide:S.side:P.side=S.shadowSide!==null?S.shadowSide:d[S.side],P.alphaMap=S.alphaMap,P.alphaTest=S.alphaTest,P.map=S.map,P.clipShadows=S.clipShadows,P.clippingPlanes=S.clippingPlanes,P.clipIntersection=S.clipIntersection,P.displacementMap=S.displacementMap,P.displacementScale=S.displacementScale,P.displacementBias=S.displacementBias,P.wireframeLinewidth=S.wireframeLinewidth,P.linewidth=S.linewidth,A.isPointLight===!0&&P.isMeshDistanceMaterial===!0&&(P.referencePosition.setFromMatrixPosition(A.matrixWorld),P.nearDistance=E,P.farDistance=M),P}function b(_,S,A,E,M){if(_.visible===!1)return;if(_.layers.test(S.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&M===Xu)&&(!_.frustumCulled||r.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,_.matrixWorld);let P=t.update(_),R=_.material;if(Array.isArray(R)){let z=P.groups;for(let U=0,L=z.length;U<L;U++){let j=z[U],q=R[j.materialIndex];if(q&&q.visible){let Q=x(_,q,E,A.near,A.far,M);e.renderBufferDirect(A,null,P,Q,_,j)}}}else if(R.visible){let z=x(_,R,E,A.near,A.far,M);e.renderBufferDirect(A,null,P,z,_,null)}}let T=_.children;for(let P=0,R=T.length;P<R;P++)b(T[P],S,A,E,M)}}function uN(e,t,i){let r=i.isWebGL2;function a(){let me=!1,Ee=new Lt,Xe=null,Ze=new Lt(0,0,0,0);return{setMask:function(yt){Xe!==yt&&!me&&(e.colorMask(yt,yt,yt,yt),Xe=yt)},setLocked:function(yt){me=yt},setClear:function(yt,Tt,Si,Gi,Br){Br===!0&&(yt*=Gi,Tt*=Gi,Si*=Gi),Ee.set(yt,Tt,Si,Gi),Ze.equals(Ee)===!1&&(e.clearColor(yt,Tt,Si,Gi),Ze.copy(Ee))},reset:function(){me=!1,Xe=null,Ze.set(-1,0,0,0)}}}function s(){let me=!1,Ee=null,Xe=null,Ze=null;return{setTest:function(yt){yt?Pe(2929):ve(2929)},setMask:function(yt){Ee!==yt&&!me&&(e.depthMask(yt),Ee=yt)},setFunc:function(yt){if(Xe!==yt){switch(yt){case Rz:e.depthFunc(512);break;case Lz:e.depthFunc(519);break;case Bz:e.depthFunc(513);break;case By:e.depthFunc(515);break;case zz:e.depthFunc(514);break;case kz:e.depthFunc(518);break;case Fz:e.depthFunc(516);break;case Uz:e.depthFunc(517);break;default:e.depthFunc(515)}Xe=yt}},setLocked:function(yt){me=yt},setClear:function(yt){Ze!==yt&&(e.clearDepth(yt),Ze=yt)},reset:function(){me=!1,Ee=null,Xe=null,Ze=null}}}function n(){let me=!1,Ee=null,Xe=null,Ze=null,yt=null,Tt=null,Si=null,Gi=null,Br=null;return{setTest:function(Ti){me||(Ti?Pe(2960):ve(2960))},setMask:function(Ti){Ee!==Ti&&!me&&(e.stencilMask(Ti),Ee=Ti)},setFunc:function(Ti,da,zr){(Xe!==Ti||Ze!==da||yt!==zr)&&(e.stencilFunc(Ti,da,zr),Xe=Ti,Ze=da,yt=zr)},setOp:function(Ti,da,zr){(Tt!==Ti||Si!==da||Gi!==zr)&&(e.stencilOp(Ti,da,zr),Tt=Ti,Si=da,Gi=zr)},setLocked:function(Ti){me=Ti},setClear:function(Ti){Br!==Ti&&(e.clearStencil(Ti),Br=Ti)},reset:function(){me=!1,Ee=null,Xe=null,Ze=null,yt=null,Tt=null,Si=null,Gi=null,Br=null}}}let o=new a,l=new s,h=new n,c=new WeakMap,d=new WeakMap,u={},p={},f=new WeakMap,m=[],g=null,y=!1,x=null,b=null,_=null,S=null,A=null,E=null,M=null,T=!1,P=null,R=null,z=null,U=null,L=null,j=e.getParameter(35661),q=!1,Q=0,X=e.getParameter(7938);X.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(X)[1]),q=Q>=1):X.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),q=Q>=2);let ie=null,oe={},te=e.getParameter(3088),re=e.getParameter(2978),fe=new Lt().fromArray(te),ce=new Lt().fromArray(re);function de(me,Ee,Xe){let Ze=new Uint8Array(4),yt=e.createTexture();e.bindTexture(me,yt),e.texParameteri(me,10241,9728),e.texParameteri(me,10240,9728);for(let Tt=0;Tt<Xe;Tt++)e.texImage2D(Ee+Tt,0,6408,1,1,0,6408,5121,Ze);return yt}let se={};se[3553]=de(3553,3553,1),se[34067]=de(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),Pe(2929),l.setFunc(By),st(!1),ot(sS),Pe(2884),rt(Ir);function Pe(me){u[me]!==!0&&(e.enable(me),u[me]=!0)}function ve(me){u[me]!==!1&&(e.disable(me),u[me]=!1)}function Ae(me,Ee){return p[me]!==Ee?(e.bindFramebuffer(me,Ee),p[me]=Ee,r&&(me===36009&&(p[36160]=Ee),me===36160&&(p[36009]=Ee)),!0):!1}function ye(me,Ee){let Xe=m,Ze=!1;if(me)if(Xe=f.get(Ee),Xe===void 0&&(Xe=[],f.set(Ee,Xe)),me.isWebGLMultipleRenderTargets){let yt=me.texture;if(Xe.length!==yt.length||Xe[0]!==36064){for(let Tt=0,Si=yt.length;Tt<Si;Tt++)Xe[Tt]=36064+Tt;Xe.length=yt.length,Ze=!0}}else Xe[0]!==36064&&(Xe[0]=36064,Ze=!0);else Xe[0]!==1029&&(Xe[0]=1029,Ze=!0);Ze&&(i.isWebGL2?e.drawBuffers(Xe):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Xe))}function Ve(me){return g!==me?(e.useProgram(me),g=me,!0):!1}let Ie={[qc]:32774,[_z]:32778,[Sz]:32779};if(r)Ie[hS]=32775,Ie[cS]=32776;else{let me=t.get("EXT_blend_minmax");me!==null&&(Ie[hS]=me.MIN_EXT,Ie[cS]=me.MAX_EXT)}let Ce={[Az]:0,[Mz]:1,[Ez]:768,[x3]:770,[Oz]:776,[Dz]:774,[Tz]:772,[Cz]:769,[b3]:771,[Iz]:775,[Pz]:773};function rt(me,Ee,Xe,Ze,yt,Tt,Si,Gi){if(me===Ir){y===!0&&(ve(3042),y=!1);return}if(y===!1&&(Pe(3042),y=!0),me!==wz){if(me!==x||Gi!==T){if((b!==qc||A!==qc)&&(e.blendEquation(32774),b=qc,A=qc),Gi)switch(me){case Dh:e.blendFuncSeparate(1,771,1,771);break;case nS:e.blendFunc(1,1);break;case oS:e.blendFuncSeparate(0,769,0,1);break;case lS:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}else switch(me){case Dh:e.blendFuncSeparate(770,771,1,771);break;case nS:e.blendFunc(770,1);break;case oS:e.blendFuncSeparate(0,769,0,1);break;case lS:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}_=null,S=null,E=null,M=null,x=me,T=Gi}return}yt=yt||Ee,Tt=Tt||Xe,Si=Si||Ze,(Ee!==b||yt!==A)&&(e.blendEquationSeparate(Ie[Ee],Ie[yt]),b=Ee,A=yt),(Xe!==_||Ze!==S||Tt!==E||Si!==M)&&(e.blendFuncSeparate(Ce[Xe],Ce[Ze],Ce[Tt],Ce[Si]),_=Xe,S=Ze,E=Tt,M=Si),x=me,T=!1}function Je(me,Ee){me.side===Pa?ve(2884):Pe(2884);let Xe=me.side===na;Ee&&(Xe=!Xe),st(Xe),me.blending===Dh&&me.transparent===!1?rt(Ir):rt(me.blending,me.blendEquation,me.blendSrc,me.blendDst,me.blendEquationAlpha,me.blendSrcAlpha,me.blendDstAlpha,me.premultipliedAlpha),l.setFunc(me.depthFunc),l.setTest(me.depthTest),l.setMask(me.depthWrite),o.setMask(me.colorWrite);let Ze=me.stencilWrite;h.setTest(Ze),Ze&&(h.setMask(me.stencilWriteMask),h.setFunc(me.stencilFunc,me.stencilRef,me.stencilFuncMask),h.setOp(me.stencilFail,me.stencilZFail,me.stencilZPass)),Qe(me.polygonOffset,me.polygonOffsetFactor,me.polygonOffsetUnits),me.alphaToCoverage===!0?Pe(32926):ve(32926)}function st(me){P!==me&&(me?e.frontFace(2304):e.frontFace(2305),P=me)}function ot(me){me!==yz?(Pe(2884),me!==R&&(me===sS?e.cullFace(1029):me===xz?e.cullFace(1028):e.cullFace(1032))):ve(2884),R=me}function Ke(me){me!==z&&(q&&e.lineWidth(me),z=me)}function Qe(me,Ee,Xe){me?(Pe(32823),(U!==Ee||L!==Xe)&&(e.polygonOffset(Ee,Xe),U=Ee,L=Xe)):ve(32823)}function ft(me){me?Pe(3089):ve(3089)}function St(me){me===void 0&&(me=33984+j-1),ie!==me&&(e.activeTexture(me),ie=me)}function ee(me,Ee,Xe){Xe===void 0&&(ie===null?Xe=33984+j-1:Xe=ie);let Ze=oe[Xe];Ze===void 0&&(Ze={type:void 0,texture:void 0},oe[Xe]=Ze),(Ze.type!==me||Ze.texture!==Ee)&&(ie!==Xe&&(e.activeTexture(Xe),ie=Xe),e.bindTexture(me,Ee||se[me]),Ze.type=me,Ze.texture=Ee)}function W(){let me=oe[ie];me!==void 0&&me.type!==void 0&&(e.bindTexture(me.type,null),me.type=void 0,me.texture=void 0)}function _e(){try{e.compressedTexImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function We(){try{e.compressedTexImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function V(){try{e.texSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function Oe(){try{e.texSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function dt(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function He(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ze(){try{e.texStorage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function Fe(){try{e.texStorage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ut(){try{e.texImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function lt(){try{e.texImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function At(me){fe.equals(me)===!1&&(e.scissor(me.x,me.y,me.z,me.w),fe.copy(me))}function _t(me){ce.equals(me)===!1&&(e.viewport(me.x,me.y,me.z,me.w),ce.copy(me))}function ai(me,Ee){let Xe=d.get(Ee);Xe===void 0&&(Xe=new WeakMap,d.set(Ee,Xe));let Ze=Xe.get(me);Ze===void 0&&(Ze=e.getUniformBlockIndex(Ee,me.name),Xe.set(me,Ze))}function yi(me,Ee){let Xe=d.get(Ee).get(me);c.get(Ee)!==Xe&&(e.uniformBlockBinding(Ee,Xe,me.__bindingPointIndex),c.set(Ee,Xe))}function ri(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),u={},ie=null,oe={},p={},f=new WeakMap,m=[],g=null,y=!1,x=null,b=null,_=null,S=null,A=null,E=null,M=null,T=!1,P=null,R=null,z=null,U=null,L=null,fe.set(0,0,e.canvas.width,e.canvas.height),ce.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:Pe,disable:ve,bindFramebuffer:Ae,drawBuffers:ye,useProgram:Ve,setBlending:rt,setMaterial:Je,setFlipSided:st,setCullFace:ot,setLineWidth:Ke,setPolygonOffset:Qe,setScissorTest:ft,activeTexture:St,bindTexture:ee,unbindTexture:W,compressedTexImage2D:_e,compressedTexImage3D:We,texImage2D:ut,texImage3D:lt,updateUBOMapping:ai,uniformBlockBinding:yi,texStorage2D:ze,texStorage3D:Fe,texSubImage2D:V,texSubImage3D:Oe,compressedTexSubImage2D:dt,compressedTexSubImage3D:He,scissor:At,viewport:_t,reset:ri}}function pN(e,t,i,r,a,s,n){let o=a.isWebGL2,l=a.maxTextures,h=a.maxCubemapSize,c=a.maxTextureSize,d=a.maxSamples,u=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(ee,W){return y?new OffscreenCanvas(ee,W):_p("canvas")}function b(ee,W,_e,We){let V=1;if((ee.width>We||ee.height>We)&&(V=We/Math.max(ee.width,ee.height)),V<1||W===!0)if(typeof HTMLImageElement<"u"&&ee instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&ee instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&ee instanceof ImageBitmap){let Oe=W?_g:Math.floor,dt=Oe(V*ee.width),He=Oe(V*ee.height);m===void 0&&(m=x(dt,He));let ze=_e?x(dt,He):m;return ze.width=dt,ze.height=He,ze.getContext("2d").drawImage(ee,0,0,dt,He),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ee.width+"x"+ee.height+") to ("+dt+"x"+He+")."),ze}else return"data"in ee&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ee.width+"x"+ee.height+")."),ee;return ee}function _(ee){return jy(ee.width)&&jy(ee.height)}function S(ee){return o?!1:ee.wrapS!==qi||ee.wrapT!==qi||ee.minFilter!==ei&&ee.minFilter!==Yt}function A(ee,W){return ee.generateMipmaps&&W&&ee.minFilter!==ei&&ee.minFilter!==Yt}function E(ee){e.generateMipmap(ee)}function M(ee,W,_e,We,V=!1){if(o===!1)return W;if(ee!==null){if(e[ee]!==void 0)return e[ee];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+ee+"'")}let Oe=W;return W===6403&&(_e===5126&&(Oe=33326),_e===5131&&(Oe=33325),_e===5121&&(Oe=33321)),W===33319&&(_e===5126&&(Oe=33328),_e===5131&&(Oe=33327),_e===5121&&(Oe=33323)),W===6408&&(_e===5126&&(Oe=34836),_e===5131&&(Oe=34842),_e===5121&&(Oe=We===Wt&&V===!1?35907:32856),_e===32819&&(Oe=32854),_e===32820&&(Oe=32855)),(Oe===33325||Oe===33326||Oe===33327||Oe===33328||Oe===34842||Oe===34836)&&t.get("EXT_color_buffer_float"),Oe}function T(ee,W,_e){return A(ee,_e)===!0||ee.isFramebufferTexture&&ee.minFilter!==ei&&ee.minFilter!==Yt?Math.log2(Math.max(W.width,W.height))+1:ee.mipmaps!==void 0&&ee.mipmaps.length>0?ee.mipmaps.length:ee.isCompressedTexture&&Array.isArray(ee.image)?W.mipmaps.length:1}function P(ee){return ee===ei||ee===dS||ee===C0?9728:9729}function R(ee){let W=ee.target;W.removeEventListener("dispose",R),U(W),W.isVideoTexture&&f.delete(W)}function z(ee){let W=ee.target;W.removeEventListener("dispose",z),j(W)}function U(ee){let W=r.get(ee);if(W.__webglInit===void 0)return;let _e=ee.source,We=g.get(_e);if(We){let V=We[W.__cacheKey];V.usedTimes--,V.usedTimes===0&&L(ee),Object.keys(We).length===0&&g.delete(_e)}r.remove(ee)}function L(ee){let W=r.get(ee);e.deleteTexture(W.__webglTexture);let _e=ee.source,We=g.get(_e);delete We[W.__cacheKey],n.memory.textures--}function j(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);if(We.__webglTexture!==void 0&&(e.deleteTexture(We.__webglTexture),n.memory.textures--),ee.depthTexture&&ee.depthTexture.dispose(),ee.isWebGLCubeRenderTarget)for(let V=0;V<6;V++)e.deleteFramebuffer(_e.__webglFramebuffer[V]),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer[V]);else{if(e.deleteFramebuffer(_e.__webglFramebuffer),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer),_e.__webglMultisampledFramebuffer&&e.deleteFramebuffer(_e.__webglMultisampledFramebuffer),_e.__webglColorRenderbuffer)for(let V=0;V<_e.__webglColorRenderbuffer.length;V++)_e.__webglColorRenderbuffer[V]&&e.deleteRenderbuffer(_e.__webglColorRenderbuffer[V]);_e.__webglDepthRenderbuffer&&e.deleteRenderbuffer(_e.__webglDepthRenderbuffer)}if(ee.isWebGLMultipleRenderTargets)for(let V=0,Oe=W.length;V<Oe;V++){let dt=r.get(W[V]);dt.__webglTexture&&(e.deleteTexture(dt.__webglTexture),n.memory.textures--),r.remove(W[V])}r.remove(W),r.remove(ee)}let q=0;function Q(){q=0}function X(){let ee=q;return ee>=l&&console.warn("THREE.WebGLTextures: Trying to use "+ee+" texture units while this GPU supports only "+l),q+=1,ee}function ie(ee){let W=[];return W.push(ee.wrapS),W.push(ee.wrapT),W.push(ee.wrapR||0),W.push(ee.magFilter),W.push(ee.minFilter),W.push(ee.anisotropy),W.push(ee.internalFormat),W.push(ee.format),W.push(ee.type),W.push(ee.generateMipmaps),W.push(ee.premultiplyAlpha),W.push(ee.flipY),W.push(ee.unpackAlignment),W.push(ee.encoding),W.join()}function oe(ee,W){let _e=r.get(ee);if(ee.isVideoTexture&&ft(ee),ee.isRenderTargetTexture===!1&&ee.version>0&&_e.__version!==ee.version){let We=ee.image;if(We===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(We.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ve(_e,ee,W);return}}i.bindTexture(3553,_e.__webglTexture,33984+W)}function te(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(35866,_e.__webglTexture,33984+W)}function re(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(32879,_e.__webglTexture,33984+W)}function fe(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){Ae(_e,ee,W);return}i.bindTexture(34067,_e.__webglTexture,33984+W)}let ce={[Io]:10497,[qi]:33071,[Fy]:33648},de={[ei]:9728,[dS]:9984,[C0]:9986,[Yt]:9729,[Xz]:9985,[wd]:9987};function se(ee,W,_e){if(_e?(e.texParameteri(ee,10242,ce[W.wrapS]),e.texParameteri(ee,10243,ce[W.wrapT]),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,ce[W.wrapR]),e.texParameteri(ee,10240,de[W.magFilter]),e.texParameteri(ee,10241,de[W.minFilter])):(e.texParameteri(ee,10242,33071),e.texParameteri(ee,10243,33071),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,33071),(W.wrapS!==qi||W.wrapT!==qi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(ee,10240,P(W.magFilter)),e.texParameteri(ee,10241,P(W.minFilter)),W.minFilter!==ei&&W.minFilter!==Yt&&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 We=t.get("EXT_texture_filter_anisotropic");if(W.magFilter===ei||W.minFilter!==C0&&W.minFilter!==wd||W.type===Di&&t.has("OES_texture_float_linear")===!1||o===!1&&W.type===No&&t.has("OES_texture_half_float_linear")===!1)return;(W.anisotropy>1||r.get(W).__currentAnisotropy)&&(e.texParameterf(ee,We.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(W.anisotropy,a.getMaxAnisotropy())),r.get(W).__currentAnisotropy=W.anisotropy)}}function Pe(ee,W){let _e=!1;ee.__webglInit===void 0&&(ee.__webglInit=!0,W.addEventListener("dispose",R));let We=W.source,V=g.get(We);V===void 0&&(V={},g.set(We,V));let Oe=ie(W);if(Oe!==ee.__cacheKey){V[Oe]===void 0&&(V[Oe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,_e=!0),V[Oe].usedTimes++;let dt=V[ee.__cacheKey];dt!==void 0&&(V[ee.__cacheKey].usedTimes--,dt.usedTimes===0&&L(W)),ee.__cacheKey=Oe,ee.__webglTexture=V[Oe].texture}return _e}function ve(ee,W,_e){let We=3553;(W.isDataArrayTexture||W.isCompressedArrayTexture)&&(We=35866),W.isData3DTexture&&(We=32879);let V=Pe(ee,W),Oe=W.source;i.bindTexture(We,ee.__webglTexture,33984+_e);let dt=r.get(Oe);if(Oe.version!==dt.__version||V===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let He=S(W)&&_(W.image)===!1,ze=b(W.image,He,!1,c);ze=St(W,ze);let Fe=_(ze)||o,ut=s.convert(W.format,W.encoding),lt=s.convert(W.type),At=M(W.internalFormat,ut,lt,W.encoding,W.isVideoTexture);se(We,W,Fe);let _t,ai=W.mipmaps,yi=o&&W.isVideoTexture!==!0,ri=dt.__version===void 0||V===!0,me=T(W,ze,Fe);if(W.isDepthTexture)At=6402,o?W.type===Di?At=36012:W.type===Oo?At=33190:W.type===Ih?At=35056:At=33189:W.type===Di&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),W.format===Oh&&At===6402&&W.type!==S3&&W.type!==Oo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),W.type=Oo,lt=s.convert(W.type)),W.format===Uh&&At===6402&&(At=34041,W.type!==Ih&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),W.type=Ih,lt=s.convert(W.type))),ri&&(yi?i.texStorage2D(3553,1,At,ze.width,ze.height):i.texImage2D(3553,0,At,ze.width,ze.height,0,ut,lt,null));else if(W.isDataTexture)if(ai.length>0&&Fe){yi&&ri&&i.texStorage2D(3553,me,At,ai[0].width,ai[0].height);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],yi?i.texSubImage2D(3553,Ee,0,0,_t.width,_t.height,ut,lt,_t.data):i.texImage2D(3553,Ee,At,_t.width,_t.height,0,ut,lt,_t.data);W.generateMipmaps=!1}else yi?(ri&&i.texStorage2D(3553,me,At,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,ze.width,ze.height,ut,lt,ze.data)):i.texImage2D(3553,0,At,ze.width,ze.height,0,ut,lt,ze.data);else if(W.isCompressedTexture)if(W.isCompressedArrayTexture){yi&&ri&&i.texStorage3D(35866,me,At,ai[0].width,ai[0].height,ze.depth);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],W.format!==Ki?ut!==null?yi?i.compressedTexSubImage3D(35866,Ee,0,0,0,_t.width,_t.height,ze.depth,ut,_t.data,0,0):i.compressedTexImage3D(35866,Ee,At,_t.width,_t.height,ze.depth,0,_t.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):yi?i.texSubImage3D(35866,Ee,0,0,0,_t.width,_t.height,ze.depth,ut,lt,_t.data):i.texImage3D(35866,Ee,At,_t.width,_t.height,ze.depth,0,ut,lt,_t.data)}else{yi&&ri&&i.texStorage2D(3553,me,At,ai[0].width,ai[0].height);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],W.format!==Ki?ut!==null?yi?i.compressedTexSubImage2D(3553,Ee,0,0,_t.width,_t.height,ut,_t.data):i.compressedTexImage2D(3553,Ee,At,_t.width,_t.height,0,_t.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):yi?i.texSubImage2D(3553,Ee,0,0,_t.width,_t.height,ut,lt,_t.data):i.texImage2D(3553,Ee,At,_t.width,_t.height,0,ut,lt,_t.data)}else if(W.isDataArrayTexture)yi?(ri&&i.texStorage3D(35866,me,At,ze.width,ze.height,ze.depth),i.texSubImage3D(35866,0,0,0,0,ze.width,ze.height,ze.depth,ut,lt,ze.data)):i.texImage3D(35866,0,At,ze.width,ze.height,ze.depth,0,ut,lt,ze.data);else if(W.isData3DTexture)yi?(ri&&i.texStorage3D(32879,me,At,ze.width,ze.height,ze.depth),i.texSubImage3D(32879,0,0,0,0,ze.width,ze.height,ze.depth,ut,lt,ze.data)):i.texImage3D(32879,0,At,ze.width,ze.height,ze.depth,0,ut,lt,ze.data);else if(W.isFramebufferTexture){if(ri)if(yi)i.texStorage2D(3553,me,At,ze.width,ze.height);else{let Ee=ze.width,Xe=ze.height;for(let Ze=0;Ze<me;Ze++)i.texImage2D(3553,Ze,At,Ee,Xe,0,ut,lt,null),Ee>>=1,Xe>>=1}}else if(ai.length>0&&Fe){yi&&ri&&i.texStorage2D(3553,me,At,ai[0].width,ai[0].height);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],yi?i.texSubImage2D(3553,Ee,0,0,ut,lt,_t):i.texImage2D(3553,Ee,At,ut,lt,_t);W.generateMipmaps=!1}else yi?(ri&&i.texStorage2D(3553,me,At,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,ut,lt,ze)):i.texImage2D(3553,0,At,ut,lt,ze);A(W,Fe)&&E(We),dt.__version=Oe.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function Ae(ee,W,_e){if(W.image.length!==6)return;let We=Pe(ee,W),V=W.source;i.bindTexture(34067,ee.__webglTexture,33984+_e);let Oe=r.get(V);if(V.version!==Oe.__version||We===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let dt=W.isCompressedTexture||W.image[0].isCompressedTexture,He=W.image[0]&&W.image[0].isDataTexture,ze=[];for(let Ee=0;Ee<6;Ee++)!dt&&!He?ze[Ee]=b(W.image[Ee],!1,!0,h):ze[Ee]=He?W.image[Ee].image:W.image[Ee],ze[Ee]=St(W,ze[Ee]);let Fe=ze[0],ut=_(Fe)||o,lt=s.convert(W.format,W.encoding),At=s.convert(W.type),_t=M(W.internalFormat,lt,At,W.encoding),ai=o&&W.isVideoTexture!==!0,yi=Oe.__version===void 0||We===!0,ri=T(W,Fe,ut);se(34067,W,ut);let me;if(dt){ai&&yi&&i.texStorage2D(34067,ri,_t,Fe.width,Fe.height);for(let Ee=0;Ee<6;Ee++){me=ze[Ee].mipmaps;for(let Xe=0;Xe<me.length;Xe++){let Ze=me[Xe];W.format!==Ki?lt!==null?ai?i.compressedTexSubImage2D(34069+Ee,Xe,0,0,Ze.width,Ze.height,lt,Ze.data):i.compressedTexImage2D(34069+Ee,Xe,_t,Ze.width,Ze.height,0,Ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ai?i.texSubImage2D(34069+Ee,Xe,0,0,Ze.width,Ze.height,lt,At,Ze.data):i.texImage2D(34069+Ee,Xe,_t,Ze.width,Ze.height,0,lt,At,Ze.data)}}}else{me=W.mipmaps,ai&&yi&&(me.length>0&&ri++,i.texStorage2D(34067,ri,_t,ze[0].width,ze[0].height));for(let Ee=0;Ee<6;Ee++)if(He){ai?i.texSubImage2D(34069+Ee,0,0,0,ze[Ee].width,ze[Ee].height,lt,At,ze[Ee].data):i.texImage2D(34069+Ee,0,_t,ze[Ee].width,ze[Ee].height,0,lt,At,ze[Ee].data);for(let Xe=0;Xe<me.length;Xe++){let Ze=me[Xe].image[Ee].image;ai?i.texSubImage2D(34069+Ee,Xe+1,0,0,Ze.width,Ze.height,lt,At,Ze.data):i.texImage2D(34069+Ee,Xe+1,_t,Ze.width,Ze.height,0,lt,At,Ze.data)}}else{ai?i.texSubImage2D(34069+Ee,0,0,0,lt,At,ze[Ee]):i.texImage2D(34069+Ee,0,_t,lt,At,ze[Ee]);for(let Xe=0;Xe<me.length;Xe++){let Ze=me[Xe];ai?i.texSubImage2D(34069+Ee,Xe+1,0,0,lt,At,Ze.image[Ee]):i.texImage2D(34069+Ee,Xe+1,_t,lt,At,Ze.image[Ee])}}}A(W,ut)&&E(34067),Oe.__version=V.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function ye(ee,W,_e,We,V){let Oe=s.convert(_e.format,_e.encoding),dt=s.convert(_e.type),He=M(_e.internalFormat,Oe,dt,_e.encoding);r.get(W).__hasExternalTextures||(V===32879||V===35866?i.texImage3D(V,0,He,W.width,W.height,W.depth,0,Oe,dt,null):i.texImage2D(V,0,He,W.width,W.height,0,Oe,dt,null)),i.bindFramebuffer(36160,ee),Qe(W)?u.framebufferTexture2DMultisampleEXT(36160,We,V,r.get(_e).__webglTexture,0,Ke(W)):(V===3553||V>=34069&&V<=34074)&&e.framebufferTexture2D(36160,We,V,r.get(_e).__webglTexture,0),i.bindFramebuffer(36160,null)}function Ve(ee,W,_e){if(e.bindRenderbuffer(36161,ee),W.depthBuffer&&!W.stencilBuffer){let We=33189;if(_e||Qe(W)){let V=W.depthTexture;V&&V.isDepthTexture&&(V.type===Di?We=36012:V.type===Oo&&(We=33190));let Oe=Ke(W);Qe(W)?u.renderbufferStorageMultisampleEXT(36161,Oe,We,W.width,W.height):e.renderbufferStorageMultisample(36161,Oe,We,W.width,W.height)}else e.renderbufferStorage(36161,We,W.width,W.height);e.framebufferRenderbuffer(36160,36096,36161,ee)}else if(W.depthBuffer&&W.stencilBuffer){let We=Ke(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,We,35056,W.width,W.height):Qe(W)?u.renderbufferStorageMultisampleEXT(36161,We,35056,W.width,W.height):e.renderbufferStorage(36161,34041,W.width,W.height),e.framebufferRenderbuffer(36160,33306,36161,ee)}else{let We=W.isWebGLMultipleRenderTargets===!0?W.texture:[W.texture];for(let V=0;V<We.length;V++){let Oe=We[V],dt=s.convert(Oe.format,Oe.encoding),He=s.convert(Oe.type),ze=M(Oe.internalFormat,dt,He,Oe.encoding),Fe=Ke(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,Fe,ze,W.width,W.height):Qe(W)?u.renderbufferStorageMultisampleEXT(36161,Fe,ze,W.width,W.height):e.renderbufferStorage(36161,ze,W.width,W.height)}}e.bindRenderbuffer(36161,null)}function Ie(ee,W){if(W&&W.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,ee),!(W.depthTexture&&W.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(W.depthTexture).__webglTexture||W.depthTexture.image.width!==W.width||W.depthTexture.image.height!==W.height)&&(W.depthTexture.image.width=W.width,W.depthTexture.image.height=W.height,W.depthTexture.needsUpdate=!0),oe(W.depthTexture,0);let _e=r.get(W.depthTexture).__webglTexture,We=Ke(W);if(W.depthTexture.format===Oh)Qe(W)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,_e,0,We):e.framebufferTexture2D(36160,36096,3553,_e,0);else if(W.depthTexture.format===Uh)Qe(W)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,_e,0,We):e.framebufferTexture2D(36160,33306,3553,_e,0);else throw new Error("Unknown depthTexture format")}function Ce(ee){let W=r.get(ee),_e=ee.isWebGLCubeRenderTarget===!0;if(ee.depthTexture&&!W.__autoAllocateDepthBuffer){if(_e)throw new Error("target.depthTexture not supported in Cube render targets");Ie(W.__webglFramebuffer,ee)}else if(_e){W.__webglDepthbuffer=[];for(let We=0;We<6;We++)i.bindFramebuffer(36160,W.__webglFramebuffer[We]),W.__webglDepthbuffer[We]=e.createRenderbuffer(),Ve(W.__webglDepthbuffer[We],ee,!1)}else i.bindFramebuffer(36160,W.__webglFramebuffer),W.__webglDepthbuffer=e.createRenderbuffer(),Ve(W.__webglDepthbuffer,ee,!1);i.bindFramebuffer(36160,null)}function rt(ee,W,_e){let We=r.get(ee);W!==void 0&&ye(We.__webglFramebuffer,ee,ee.texture,36064,3553),_e!==void 0&&Ce(ee)}function Je(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);ee.addEventListener("dispose",z),ee.isWebGLMultipleRenderTargets!==!0&&(We.__webglTexture===void 0&&(We.__webglTexture=e.createTexture()),We.__version=W.version,n.memory.textures++);let V=ee.isWebGLCubeRenderTarget===!0,Oe=ee.isWebGLMultipleRenderTargets===!0,dt=_(ee)||o;if(V){_e.__webglFramebuffer=[];for(let He=0;He<6;He++)_e.__webglFramebuffer[He]=e.createFramebuffer()}else{if(_e.__webglFramebuffer=e.createFramebuffer(),Oe)if(a.drawBuffers){let He=ee.texture;for(let ze=0,Fe=He.length;ze<Fe;ze++){let ut=r.get(He[ze]);ut.__webglTexture===void 0&&(ut.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&ee.samples>0&&Qe(ee)===!1){let He=Oe?W:[W];_e.__webglMultisampledFramebuffer=e.createFramebuffer(),_e.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,_e.__webglMultisampledFramebuffer);for(let ze=0;ze<He.length;ze++){let Fe=He[ze];_e.__webglColorRenderbuffer[ze]=e.createRenderbuffer(),e.bindRenderbuffer(36161,_e.__webglColorRenderbuffer[ze]);let ut=s.convert(Fe.format,Fe.encoding),lt=s.convert(Fe.type),At=M(Fe.internalFormat,ut,lt,Fe.encoding,ee.isXRRenderTarget===!0),_t=Ke(ee);e.renderbufferStorageMultisample(36161,_t,At,ee.width,ee.height),e.framebufferRenderbuffer(36160,36064+ze,36161,_e.__webglColorRenderbuffer[ze])}e.bindRenderbuffer(36161,null),ee.depthBuffer&&(_e.__webglDepthRenderbuffer=e.createRenderbuffer(),Ve(_e.__webglDepthRenderbuffer,ee,!0)),i.bindFramebuffer(36160,null)}}if(V){i.bindTexture(34067,We.__webglTexture),se(34067,W,dt);for(let He=0;He<6;He++)ye(_e.__webglFramebuffer[He],ee,W,36064,34069+He);A(W,dt)&&E(34067),i.unbindTexture()}else if(Oe){let He=ee.texture;for(let ze=0,Fe=He.length;ze<Fe;ze++){let ut=He[ze],lt=r.get(ut);i.bindTexture(3553,lt.__webglTexture),se(3553,ut,dt),ye(_e.__webglFramebuffer,ee,ut,36064+ze,3553),A(ut,dt)&&E(3553)}i.unbindTexture()}else{let He=3553;(ee.isWebGL3DRenderTarget||ee.isWebGLArrayRenderTarget)&&(o?He=ee.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(He,We.__webglTexture),se(He,W,dt),ye(_e.__webglFramebuffer,ee,W,36064,He),A(W,dt)&&E(He),i.unbindTexture()}ee.depthBuffer&&Ce(ee)}function st(ee){let W=_(ee)||o,_e=ee.isWebGLMultipleRenderTargets===!0?ee.texture:[ee.texture];for(let We=0,V=_e.length;We<V;We++){let Oe=_e[We];if(A(Oe,W)){let dt=ee.isWebGLCubeRenderTarget?34067:3553,He=r.get(Oe).__webglTexture;i.bindTexture(dt,He),E(dt),i.unbindTexture()}}}function ot(ee){if(o&&ee.samples>0&&Qe(ee)===!1){let W=ee.isWebGLMultipleRenderTargets?ee.texture:[ee.texture],_e=ee.width,We=ee.height,V=16384,Oe=[],dt=ee.stencilBuffer?33306:36096,He=r.get(ee),ze=ee.isWebGLMultipleRenderTargets===!0;if(ze)for(let Fe=0;Fe<W.length;Fe++)i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,null),i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,null,0);i.bindFramebuffer(36008,He.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,He.__webglFramebuffer);for(let Fe=0;Fe<W.length;Fe++){Oe.push(36064+Fe),ee.depthBuffer&&Oe.push(dt);let ut=He.__ignoreDepthValues!==void 0?He.__ignoreDepthValues:!1;if(ut===!1&&(ee.depthBuffer&&(V|=256),ee.stencilBuffer&&(V|=1024)),ze&&e.framebufferRenderbuffer(36008,36064,36161,He.__webglColorRenderbuffer[Fe]),ut===!0&&(e.invalidateFramebuffer(36008,[dt]),e.invalidateFramebuffer(36009,[dt])),ze){let lt=r.get(W[Fe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,lt,0)}e.blitFramebuffer(0,0,_e,We,0,0,_e,We,V,9728),p&&e.invalidateFramebuffer(36008,Oe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ze)for(let Fe=0;Fe<W.length;Fe++){i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,He.__webglColorRenderbuffer[Fe]);let ut=r.get(W[Fe]).__webglTexture;i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,ut,0)}i.bindFramebuffer(36009,He.__webglMultisampledFramebuffer)}}function Ke(ee){return Math.min(d,ee.samples)}function Qe(ee){let W=r.get(ee);return o&&ee.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&W.__useRenderToTexture!==!1}function ft(ee){let W=n.render.frame;f.get(ee)!==W&&(f.set(ee,W),ee.update())}function St(ee,W){let _e=ee.encoding,We=ee.format,V=ee.type;return ee.isCompressedTexture===!0||ee.isVideoTexture===!0||ee.format===Vy||_e!==on&&(_e===Wt?o===!1?t.has("EXT_sRGB")===!0&&We===Ki?(ee.format=Vy,ee.minFilter=Yt,ee.generateMipmaps=!1):W=I3.sRGBToLinear(W):(We!==Ki||V!==Da)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",_e)),W}this.allocateTextureUnit=X,this.resetTextureUnits=Q,this.setTexture2D=oe,this.setTexture2DArray=te,this.setTexture3D=re,this.setTextureCube=fe,this.rebindTextures=rt,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=st,this.updateMultisampleRenderTarget=ot,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=Qe}function fN(e,t,i){let r=i.isWebGL2;function a(s,n=null){let o;if(s===Da)return 5121;if(s===Zz)return 32819;if(s===Jz)return 32820;if(s===Yz)return 5120;if(s===Qz)return 5122;if(s===S3)return 5123;if(s===Kz)return 5124;if(s===Oo)return 5125;if(s===Di)return 5126;if(s===No)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===$z)return 6406;if(s===Ki)return 6408;if(s===e5)return 6409;if(s===t5)return 6410;if(s===Oh)return 6402;if(s===Uh)return 34041;if(s===Vy)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===$m)return 6403;if(s===i5)return 36244;if(s===vg)return 33319;if(s===r5)return 33320;if(s===A3)return 36249;if(s===T0||s===P0||s===D0||s===I0)if(n===Wt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===T0)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===P0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===D0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===I0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===T0)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===P0)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===D0)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===I0)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===uS||s===pS||s===fS||s===mS)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===uS)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===pS)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===fS)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===mS)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===a5)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===gS||s===vS)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(s===gS)return n===Wt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===vS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===yS||s===xS||s===bS||s===wS||s===_S||s===SS||s===AS||s===MS||s===ES||s===CS||s===TS||s===PS||s===DS||s===IS)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(s===yS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===xS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===bS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===wS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===_S)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===SS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===AS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===MS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===ES)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===CS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===TS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===PS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===DS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===IS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===O0)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(s===O0)return n===Wt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===s5||s===OS||s===RS||s===LS)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(s===O0)return o.COMPRESSED_RED_RGTC1_EXT;if(s===OS)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===RS)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===LS)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ih?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[s]!==void 0?e[s]:null}return{convert:a}}var mN=class extends Ea{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Lo=class extends Ci{constructor(){super(),this.isGroup=!0,this.type="Group"}},gN={type:"move"},a1=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lo,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 Lo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,s=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){s=!0;for(let f of e.hand.values()){let m=t.getJointPose(f,i),g=this._getHandJoint(l,f);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==null}let h=l.joints["index-finger-tip"],c=l.joints["thumb-tip"],d=h.position.distanceTo(c.position),u=.02,p=.005;l.inputState.pinching&&d>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=u-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(o.matrix.fromArray(a.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),a.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(a.linearVelocity)):o.hasLinearVelocity=!1,a.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(a.angularVelocity)):o.hasAngularVelocity=!1));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(gN)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=a!==null),l!==null&&(l.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Lo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Sd=class extends Zi{constructor(e,t,i,r,a,s,n,o,l,h){if(h=h!==void 0?h:Oh,h!==Oh&&h!==Uh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===Oh&&(i=Oo),i===void 0&&h===Uh&&(i=Ih),super(null,r,a,s,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:ei,this.minFilter=o!==void 0?o:ei,this.flipY=!1,this.generateMipmaps=!1}},vN=class extends ha{constructor(e,t){super();let i=this,r=null,a=1,s=null,n="local-floor",o=1,l=null,h=null,c=null,d=null,u=null,p=null,f=t.getContextAttributes(),m=null,g=null,y=[],x=[],b=new Set,_=new Map,S=new Ea;S.layers.enable(1),S.viewport=new Lt;let A=new Ea;A.layers.enable(2),A.viewport=new Lt;let E=[S,A],M=new mN;M.layers.enable(1),M.layers.enable(2);let T=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let re=y[te];return re===void 0&&(re=new a1,y[te]=re),re.getTargetRaySpace()},this.getControllerGrip=function(te){let re=y[te];return re===void 0&&(re=new a1,y[te]=re),re.getGripSpace()},this.getHand=function(te){let re=y[te];return re===void 0&&(re=new a1,y[te]=re),re.getHandSpace()};function R(te){let re=x.indexOf(te.inputSource);if(re===-1)return;let fe=y[re];fe!==void 0&&fe.dispatchEvent({type:te.type,data:te.inputSource})}function z(){r.removeEventListener("select",R),r.removeEventListener("selectstart",R),r.removeEventListener("selectend",R),r.removeEventListener("squeeze",R),r.removeEventListener("squeezestart",R),r.removeEventListener("squeezeend",R),r.removeEventListener("end",z),r.removeEventListener("inputsourceschange",U);for(let te=0;te<y.length;te++){let re=x[te];re!==null&&(x[te]=null,y[te].disconnect(re))}T=null,P=null,e.setRenderTarget(m),u=null,d=null,c=null,r=null,g=null,oe.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){a=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){n=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(te){l=te},this.getBaseLayer=function(){return d!==null?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(te){if(r=te,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",R),r.addEventListener("selectstart",R),r.addEventListener("selectend",R),r.addEventListener("squeeze",R),r.addEventListener("squeezestart",R),r.addEventListener("squeezeend",R),r.addEventListener("end",z),r.addEventListener("inputsourceschange",U),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let re={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:a};u=new XRWebGLLayer(r,t,re),r.updateRenderState({baseLayer:u}),g=new ci(u.framebufferWidth,u.framebufferHeight,{format:Ki,type:Da,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let re=null,fe=null,ce=null;f.depth&&(ce=f.stencil?35056:33190,re=f.stencil?Uh:Oh,fe=f.stencil?Ih:Oo);let de={colorFormat:32856,depthFormat:ce,scaleFactor:a};c=new XRWebGLBinding(r,t),d=c.createProjectionLayer(de),r.updateRenderState({layers:[d]}),g=new ci(d.textureWidth,d.textureHeight,{format:Ki,type:Da,depthTexture:new Sd(d.textureWidth,d.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let se=e.properties.get(g);se.__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await r.requestReferenceSpace(n),oe.setContext(r),oe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function U(te){for(let re=0;re<te.removed.length;re++){let fe=te.removed[re],ce=x.indexOf(fe);ce>=0&&(x[ce]=null,y[ce].disconnect(fe))}for(let re=0;re<te.added.length;re++){let fe=te.added[re],ce=x.indexOf(fe);if(ce===-1){for(let se=0;se<y.length;se++)if(se>=x.length){x.push(fe),ce=se;break}else if(x[se]===null){x[se]=fe,ce=se;break}if(ce===-1)break}let de=y[ce];de&&de.connect(fe)}}let L=new O,j=new O;function q(te,re,fe){L.setFromMatrixPosition(re.matrixWorld),j.setFromMatrixPosition(fe.matrixWorld);let ce=L.distanceTo(j),de=re.projectionMatrix.elements,se=fe.projectionMatrix.elements,Pe=de[14]/(de[10]-1),ve=de[14]/(de[10]+1),Ae=(de[9]+1)/de[5],ye=(de[9]-1)/de[5],Ve=(de[8]-1)/de[0],Ie=(se[8]+1)/se[0],Ce=Pe*Ve,rt=Pe*Ie,Je=ce/(-Ve+Ie),st=Je*-Ve;re.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(st),te.translateZ(Je),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();let ot=Pe+Je,Ke=ve+Je,Qe=Ce-st,ft=rt+(ce-st),St=Ae*ve/Ke*ot,ee=ye*ve/Ke*ot;te.projectionMatrix.makePerspective(Qe,ft,St,ee,ot,Ke)}function Q(te,re){re===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(re.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(r===null)return;M.near=A.near=S.near=te.near,M.far=A.far=S.far=te.far,(T!==M.near||P!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,P=M.far);let re=te.parent,fe=M.cameras;Q(M,re);for(let de=0;de<fe.length;de++)Q(fe[de],re);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),te.matrix.copy(M.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale);let ce=te.children;for(let de=0,se=ce.length;de<se;de++)ce[de].updateMatrixWorld(!0);fe.length===2?q(M,S,A):M.projectionMatrix.copy(S.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&u===null))return o},this.setFoveation=function(te){o=te,d!==null&&(d.fixedFoveation=te),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=te)},this.getPlanes=function(){return b};let X=null;function ie(te,re){if(h=re.getViewerPose(l||s),p=re,h!==null){let fe=h.views;u!==null&&(e.setRenderTargetFramebuffer(g,u.framebuffer),e.setRenderTarget(g));let ce=!1;fe.length!==M.cameras.length&&(M.cameras.length=0,ce=!0);for(let de=0;de<fe.length;de++){let se=fe[de],Pe=null;if(u!==null)Pe=u.getViewport(se);else{let Ae=c.getViewSubImage(d,se);Pe=Ae.viewport,de===0&&(e.setRenderTargetTextures(g,Ae.colorTexture,d.ignoreDepthValues?void 0:Ae.depthStencilTexture),e.setRenderTarget(g))}let ve=E[de];ve===void 0&&(ve=new Ea,ve.layers.enable(de),ve.viewport=new Lt,E[de]=ve),ve.matrix.fromArray(se.transform.matrix),ve.projectionMatrix.fromArray(se.projectionMatrix),ve.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),de===0&&M.matrix.copy(ve.matrix),ce===!0&&M.cameras.push(ve)}}for(let fe=0;fe<y.length;fe++){let ce=x[fe],de=y[fe];ce!==null&&de!==void 0&&de.update(ce,re,l||s)}if(X&&X(te,re),re.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:re.detectedPlanes});let fe=null;for(let ce of b)re.detectedPlanes.has(ce)||(fe===null&&(fe=[]),fe.push(ce));if(fe!==null)for(let ce of fe)b.delete(ce),_.delete(ce),i.dispatchEvent({type:"planeremoved",data:ce});for(let ce of re.detectedPlanes)if(!b.has(ce))b.add(ce),_.set(ce,re.lastChangedTime),i.dispatchEvent({type:"planeadded",data:ce});else{let de=_.get(ce);ce.lastChangedTime>de&&(_.set(ce,ce.lastChangedTime),i.dispatchEvent({type:"planechanged",data:ce}))}}p=null}let oe=new k3;oe.setAnimationLoop(ie),this.setAnimationLoop=function(te){X=te},this.dispose=function(){}}};function yN(e,t){function i(m,g){g.color.getRGB(m.fogColor.value,z3(e)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,x,b){g.isMeshBasicMaterial||g.isMeshLambertMaterial?a(m,g):g.isMeshToonMaterial?(a(m,g),c(m,g)):g.isMeshPhongMaterial?(a(m,g),h(m,g)):g.isMeshStandardMaterial?(a(m,g),d(m,g),g.isMeshPhysicalMaterial&&u(m,g,b)):g.isMeshMatcapMaterial?(a(m,g),p(m,g)):g.isMeshDepthMaterial?a(m,g):g.isMeshDistanceMaterial?(a(m,g),f(m,g)):g.isMeshNormalMaterial?a(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&n(m,g)):g.isPointsMaterial?o(m,g,y,x):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function a(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===na&&(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===na&&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 _=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*_}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let x;g.map?x=g.map:g.specularMap?x=g.specularMap:g.displacementMap?x=g.displacementMap:g.normalMap?x=g.normalMap:g.bumpMap?x=g.bumpMap:g.roughnessMap?x=g.roughnessMap:g.metalnessMap?x=g.metalnessMap:g.alphaMap?x=g.alphaMap:g.emissiveMap?x=g.emissiveMap:g.clearcoatMap?x=g.clearcoatMap:g.clearcoatNormalMap?x=g.clearcoatNormalMap:g.clearcoatRoughnessMap?x=g.clearcoatRoughnessMap:g.iridescenceMap?x=g.iridescenceMap:g.iridescenceThicknessMap?x=g.iridescenceThicknessMap:g.specularIntensityMap?x=g.specularIntensityMap:g.specularColorMap?x=g.specularColorMap:g.transmissionMap?x=g.transmissionMap:g.thicknessMap?x=g.thicknessMap:g.sheenColorMap?x=g.sheenColorMap:g.sheenRoughnessMap&&(x=g.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function n(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,y,x){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=x*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.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 h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(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 u(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===na&&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 p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function f(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function xN(e,t,i,r){let a={},s={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(x,b){let _=b.program;r.uniformBlockBinding(x,_)}function h(x,b){let _=a[x.id];_===void 0&&(f(x),_=c(x),a[x.id]=_,x.addEventListener("dispose",g));let S=b.program;r.updateUBOMapping(x,S);let A=t.render.frame;s[x.id]!==A&&(u(x),s[x.id]=A)}function c(x){let b=d();x.__bindingPointIndex=b;let _=e.createBuffer(),S=x.__size,A=x.usage;return e.bindBuffer(35345,_),e.bufferData(35345,S,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,_),_}function d(){for(let x=0;x<o;x++)if(n.indexOf(x)===-1)return n.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){let b=a[x.id],_=x.uniforms,S=x.__cache;e.bindBuffer(35345,b);for(let A=0,E=_.length;A<E;A++){let M=_[A];if(p(M,A,S)===!0){let T=M.__offset,P=Array.isArray(M.value)?M.value:[M.value],R=0;for(let z=0;z<P.length;z++){let U=P[z],L=m(U);typeof U=="number"?(M.__data[0]=U,e.bufferSubData(35345,T+R,M.__data)):U.isMatrix3?(M.__data[0]=U.elements[0],M.__data[1]=U.elements[1],M.__data[2]=U.elements[2],M.__data[3]=U.elements[0],M.__data[4]=U.elements[3],M.__data[5]=U.elements[4],M.__data[6]=U.elements[5],M.__data[7]=U.elements[0],M.__data[8]=U.elements[6],M.__data[9]=U.elements[7],M.__data[10]=U.elements[8],M.__data[11]=U.elements[0]):(U.toArray(M.__data,R),R+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,T,M.__data)}}e.bindBuffer(35345,null)}function p(x,b,_){let S=x.value;if(_[b]===void 0){if(typeof S=="number")_[b]=S;else{let A=Array.isArray(S)?S:[S],E=[];for(let M=0;M<A.length;M++)E.push(A[M].clone());_[b]=E}return!0}else if(typeof S=="number"){if(_[b]!==S)return _[b]=S,!0}else{let A=Array.isArray(_[b])?_[b]:[_[b]],E=Array.isArray(S)?S:[S];for(let M=0;M<A.length;M++){let T=A[M];if(T.equals(E[M])===!1)return T.copy(E[M]),!0}}return!1}function f(x){let b=x.uniforms,_=0,S=16,A=0;for(let E=0,M=b.length;E<M;E++){let T=b[E],P={boundary:0,storage:0},R=Array.isArray(T.value)?T.value:[T.value];for(let z=0,U=R.length;z<U;z++){let L=R[z],j=m(L);P.boundary+=j.boundary,P.storage+=j.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=_,E>0){A=_%S;let z=S-A;A!==0&&z-P.boundary<0&&(_+=S-A,T.__offset=_)}_+=P.storage}return A=_%S,A>0&&(_+=S-A),x.__size=_,x.__cache={},this}function m(x){let b={boundary:0,storage:0};return typeof x=="number"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),b}function g(x){let b=x.target;b.removeEventListener("dispose",g);let _=n.indexOf(b.__bindingPointIndex);n.splice(_,1),e.deleteBuffer(a[b.id]),delete a[b.id],delete s[b.id]}function y(){for(let x in a)e.deleteBuffer(a[x]);n=[],a={},s={}}return{bind:l,update:h,dispose:y}}function bN(){let e=_p("canvas");return e.style.display="block",e}function H3(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:bN(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,a=e.stencil!==void 0?e.stencil:!0,s=e.antialias!==void 0?e.antialias:!1,n=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,c;i!==null?c=i.getContextAttributes().alpha:c=e.alpha!==void 0?e.alpha:!1;let d=null,u=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=on,this.physicallyCorrectLights=!1,this.toneMapping=Nn,this.toneMappingExposure=1;let m=this,g=!1,y=0,x=0,b=null,_=-1,S=null,A=new Lt,E=new Lt,M=null,T=t.width,P=t.height,R=1,z=null,U=null,L=new Lt(0,0,T,P),j=new Lt(0,0,T,P),q=!1,Q=new Zb,X=!1,ie=!1,oe=null,te=new je,re=new ae,fe=new O,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function de(){return b===null?R:1}let se=i;function Pe(J,Se){for(let Te=0;Te<J.length;Te++){let be=J[Te],Be=t.getContext(be,Se);if(Be!==null)return Be}return null}try{let J={alpha:!0,depth:r,stencil:a,antialias:s,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Fd}`),t.addEventListener("webglcontextlost",At,!1),t.addEventListener("webglcontextrestored",_t,!1),t.addEventListener("webglcontextcreationerror",ai,!1),se===null){let Se=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&Se.shift(),se=Pe(Se,J),se===null)throw Pe(Se)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}se.getShaderPrecisionFormat===void 0&&(se.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(J){throw console.error("THREE.WebGLRenderer: "+J.message),J}let ve,Ae,ye,Ve,Ie,Ce,rt,Je,st,ot,Ke,Qe,ft,St,ee,W,_e,We,V,Oe,dt,He,ze,Fe;function ut(){ve=new RU(se),Ae=new CU(se,ve,e),ve.init(Ae),He=new fN(se,ve,Ae),ye=new uN(se,ve,Ae),Ve=new zU,Ie=new $6,Ce=new pN(se,ve,ye,Ie,Ae,He,Ve),rt=new PU(m),Je=new OU(m),st=new W5(se,Ae),ze=new MU(se,ve,st,Ae),ot=new LU(se,st,Ve,ze),Ke=new NU(se,ot,st,Ve),V=new UU(se,Ae,Ce),W=new TU(Ie),Qe=new J6(m,rt,Je,ve,Ae,ze,W),ft=new yN(m,Ie),St=new tN,ee=new oN(ve,Ae),We=new AU(m,rt,Je,ye,Ke,c,n),_e=new dN(m,Ke,Ae),Fe=new xN(se,Ve,Ae,ye),Oe=new EU(se,ve,Ve,Ae),dt=new BU(se,ve,Ve,Ae),Ve.programs=Qe.programs,m.capabilities=Ae,m.extensions=ve,m.properties=Ie,m.renderLists=St,m.shadowMap=_e,m.state=ye,m.info=Ve}ut();let lt=new vN(m,se);this.xr=lt,this.getContext=function(){return se},this.getContextAttributes=function(){return se.getContextAttributes()},this.forceContextLoss=function(){let J=ve.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){let J=ve.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return R},this.setPixelRatio=function(J){J!==void 0&&(R=J,this.setSize(T,P,!1))},this.getSize=function(J){return J.set(T,P)},this.setSize=function(J,Se,Te){if(lt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=J,P=Se,t.width=Math.floor(J*R),t.height=Math.floor(Se*R),Te!==!1&&(t.style.width=J+"px",t.style.height=Se+"px"),this.setViewport(0,0,J,Se)},this.getDrawingBufferSize=function(J){return J.set(T*R,P*R).floor()},this.setDrawingBufferSize=function(J,Se,Te){T=J,P=Se,R=Te,t.width=Math.floor(J*Te),t.height=Math.floor(Se*Te),this.setViewport(0,0,J,Se)},this.getCurrentViewport=function(J){return J.copy(A)},this.getViewport=function(J){return J.copy(L)},this.setViewport=function(J,Se,Te,be){J.isVector4?L.set(J.x,J.y,J.z,J.w):L.set(J,Se,Te,be),ye.viewport(A.copy(L).multiplyScalar(R).floor())},this.getScissor=function(J){return J.copy(j)},this.setScissor=function(J,Se,Te,be){J.isVector4?j.set(J.x,J.y,J.z,J.w):j.set(J,Se,Te,be),ye.scissor(E.copy(j).multiplyScalar(R).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(J){ye.setScissorTest(q=J)},this.setOpaqueSort=function(J){z=J},this.setTransparentSort=function(J){U=J},this.getClearColor=function(J){return J.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor.apply(We,arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha.apply(We,arguments)},this.clear=function(J=!0,Se=!0,Te=!0){let be=0;J&&(be|=16384),Se&&(be|=256),Te&&(be|=1024),se.clear(be)},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",At,!1),t.removeEventListener("webglcontextrestored",_t,!1),t.removeEventListener("webglcontextcreationerror",ai,!1),St.dispose(),ee.dispose(),Ie.dispose(),rt.dispose(),Je.dispose(),Ke.dispose(),ze.dispose(),Fe.dispose(),Qe.dispose(),lt.dispose(),lt.removeEventListener("sessionstart",Ze),lt.removeEventListener("sessionend",yt),oe&&(oe.dispose(),oe=null),Tt.stop()};function At(J){J.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function _t(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let J=Ve.autoReset,Se=_e.enabled,Te=_e.autoUpdate,be=_e.needsUpdate,Be=_e.type;ut(),Ve.autoReset=J,_e.enabled=Se,_e.autoUpdate=Te,_e.needsUpdate=be,_e.type=Be}function ai(J){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function yi(J){let Se=J.target;Se.removeEventListener("dispose",yi),ri(Se)}function ri(J){me(J),Ie.remove(J)}function me(J){let Se=Ie.get(J).programs;Se!==void 0&&(Se.forEach(function(Te){Qe.releaseProgram(Te)}),J.isShaderMaterial&&Qe.releaseShaderCache(J))}this.renderBufferDirect=function(J,Se,Te,be,Be,at){Se===null&&(Se=ce);let kt=Be.isMesh&&Be.matrixWorld.determinant()<0,Ut=au(J,Se,Te,be,Be);ye.setMaterial(be,kt);let Ft=Te.index,li=1;be.wireframe===!0&&(Ft=ot.getWireframeAttribute(Te),li=2);let Jt=Te.drawRange,jt=Te.attributes.position,vi=Jt.start*li,rr=(Jt.start+Jt.count)*li;at!==null&&(vi=Math.max(vi,at.start*li),rr=Math.min(rr,(at.start+at.count)*li)),Ft!==null?(vi=Math.max(vi,0),rr=Math.min(rr,Ft.count)):jt!=null&&(vi=Math.max(vi,0),rr=Math.min(rr,jt.count));let Yi=rr-vi;if(Yi<0||Yi===1/0)return;ze.setup(Be,be,Ut,Te,Ft);let ar,Ui=Oe;if(Ft!==null&&(ar=st.get(Ft),Ui=dt,Ui.setIndex(ar)),Be.isMesh)be.wireframe===!0?(ye.setLineWidth(be.wireframeLinewidth*de()),Ui.setMode(1)):Ui.setMode(4);else if(Be.isLine){let Mt=be.linewidth;Mt===void 0&&(Mt=1),ye.setLineWidth(Mt*de()),Be.isLineSegments?Ui.setMode(1):Be.isLineLoop?Ui.setMode(2):Ui.setMode(3)}else Be.isPoints?Ui.setMode(0):Be.isSprite&&Ui.setMode(4);if(Be.isInstancedMesh)Ui.renderInstances(vi,Yi,Be.count);else if(Te.isInstancedBufferGeometry){let Mt=Te._maxInstanceCount!==void 0?Te._maxInstanceCount:1/0,dn=Math.min(Te.instanceCount,Mt);Ui.renderInstances(vi,Yi,dn)}else Ui.render(vi,Yi)},this.compile=function(J,Se){function Te(be,Be,at){be.transparent===!0&&be.side===Pa&&be.forceSinglePass===!1?(be.side=na,be.needsUpdate=!0,zr(be,Be,at),be.side=nn,be.needsUpdate=!0,zr(be,Be,at),be.side=Pa):zr(be,Be,at)}u=ee.get(J),u.init(),f.push(u),J.traverseVisible(function(be){be.isLight&&be.layers.test(Se.layers)&&(u.pushLight(be),be.castShadow&&u.pushShadow(be))}),u.setupLights(m.physicallyCorrectLights),J.traverse(function(be){let Be=be.material;if(Be)if(Array.isArray(Be))for(let at=0;at<Be.length;at++){let kt=Be[at];Te(kt,J,be)}else Te(Be,J,be)}),f.pop(),u=null};let Ee=null;function Xe(J){Ee&&Ee(J)}function Ze(){Tt.stop()}function yt(){Tt.start()}let Tt=new k3;Tt.setAnimationLoop(Xe),typeof self<"u"&&Tt.setContext(self),this.setAnimationLoop=function(J){Ee=J,lt.setAnimationLoop(J),J===null?Tt.stop():Tt.start()},lt.addEventListener("sessionstart",Ze),lt.addEventListener("sessionend",yt),this.render=function(J,Se){if(Se!==void 0&&Se.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),Se.parent===null&&Se.matrixWorldAutoUpdate===!0&&Se.updateMatrixWorld(),lt.enabled===!0&&lt.isPresenting===!0&&(lt.cameraAutoUpdate===!0&&lt.updateCamera(Se),Se=lt.getCamera()),J.isScene===!0&&J.onBeforeRender(m,J,Se,b),u=ee.get(J,f.length),u.init(),f.push(u),te.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),Q.setFromProjectionMatrix(te),ie=this.localClippingEnabled,X=W.init(this.clippingPlanes,ie),d=St.get(J,p.length),d.init(),p.push(d),Si(J,Se,0,m.sortObjects),d.finish(),m.sortObjects===!0&&d.sort(z,U),X===!0&&W.beginShadows();let Te=u.state.shadowsArray;if(_e.render(Te,J,Se),X===!0&&W.endShadows(),this.info.autoReset===!0&&this.info.reset(),We.render(d,J),u.setupLights(m.physicallyCorrectLights),Se.isArrayCamera){let be=Se.cameras;for(let Be=0,at=be.length;Be<at;Be++){let kt=be[Be];Gi(d,J,kt,kt.viewport)}}else Gi(d,J,Se);b!==null&&(Ce.updateMultisampleRenderTarget(b),Ce.updateRenderTargetMipmap(b)),J.isScene===!0&&J.onAfterRender(m,J,Se),ze.resetDefaultState(),_=-1,S=null,f.pop(),f.length>0?u=f[f.length-1]:u=null,p.pop(),p.length>0?d=p[p.length-1]:d=null};function Si(J,Se,Te,be){if(J.visible===!1)return;if(J.layers.test(Se.layers)){if(J.isGroup)Te=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(Se);else if(J.isLight)u.pushLight(J),J.castShadow&&u.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||Q.intersectsSprite(J)){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let at=Ke.update(J),kt=J.material;kt.visible&&d.push(J,at,kt,Te,fe.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(J.isSkinnedMesh&&J.skeleton.frame!==Ve.render.frame&&(J.skeleton.update(),J.skeleton.frame=Ve.render.frame),!J.frustumCulled||Q.intersectsObject(J))){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let at=Ke.update(J),kt=J.material;if(Array.isArray(kt)){let Ut=at.groups;for(let Ft=0,li=Ut.length;Ft<li;Ft++){let Jt=Ut[Ft],jt=kt[Jt.materialIndex];jt&&jt.visible&&d.push(J,at,jt,Te,fe.z,Jt)}}else kt.visible&&d.push(J,at,kt,Te,fe.z,null)}}let Be=J.children;for(let at=0,kt=Be.length;at<kt;at++)Si(Be[at],Se,Te,be)}function Gi(J,Se,Te,be){let Be=J.opaque,at=J.transmissive,kt=J.transparent;u.setupLightsView(Te),X===!0&&W.setGlobalState(m.clippingPlanes,Te),at.length>0&&Br(Be,Se,Te),be&&ye.viewport(A.copy(be)),Be.length>0&&Ti(Be,Se,Te),at.length>0&&Ti(at,Se,Te),kt.length>0&&Ti(kt,Se,Te),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function Br(J,Se,Te){let be=Ae.isWebGL2;oe===null&&(oe=new ci(1,1,{generateMipmaps:!0,type:ve.has("EXT_color_buffer_half_float")?No:Da,minFilter:wd,samples:be&&s===!0?4:0})),m.getDrawingBufferSize(re),be?oe.setSize(re.x,re.y):oe.setSize(_g(re.x),_g(re.y));let Be=m.getRenderTarget();m.setRenderTarget(oe),m.clear();let at=m.toneMapping;m.toneMapping=Nn,Ti(J,Se,Te),m.toneMapping=at,Ce.updateMultisampleRenderTarget(oe),Ce.updateRenderTargetMipmap(oe),m.setRenderTarget(Be)}function Ti(J,Se,Te){let be=Se.isScene===!0?Se.overrideMaterial:null;for(let Be=0,at=J.length;Be<at;Be++){let kt=J[Be],Ut=kt.object,Ft=kt.geometry,li=be===null?kt.material:be,Jt=kt.group;Ut.layers.test(Te.layers)&&da(Ut,Se,Te,Ft,li,Jt)}}function da(J,Se,Te,be,Be,at){J.onBeforeRender(m,Se,Te,be,Be,at),J.modelViewMatrix.multiplyMatrices(Te.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),Be.onBeforeRender(m,Se,Te,be,J,at),Be.transparent===!0&&Be.side===Pa&&Be.forceSinglePass===!1?(Be.side=na,Be.needsUpdate=!0,m.renderBufferDirect(Te,Se,be,Be,J,at),Be.side=nn,Be.needsUpdate=!0,m.renderBufferDirect(Te,Se,be,Be,J,at),Be.side=Pa):m.renderBufferDirect(Te,Se,be,Be,J,at),J.onAfterRender(m,Se,Te,be,Be,at)}function zr(J,Se,Te){Se.isScene!==!0&&(Se=ce);let be=Ie.get(J),Be=u.state.lights,at=u.state.shadowsArray,kt=Be.state.version,Ut=Qe.getParameters(J,Be.state,at,Se,Te),Ft=Qe.getProgramCacheKey(Ut),li=be.programs;be.environment=J.isMeshStandardMaterial?Se.environment:null,be.fog=Se.fog,be.envMap=(J.isMeshStandardMaterial?Je:rt).get(J.envMap||be.environment),li===void 0&&(J.addEventListener("dispose",yi),li=new Map,be.programs=li);let Jt=li.get(Ft);if(Jt!==void 0){if(be.currentProgram===Jt&&be.lightsStateVersion===kt)return Qo(J,Ut),Jt}else Ut.uniforms=Qe.getUniforms(J),J.onBuild(Te,Ut,m),J.onBeforeCompile(Ut,m),Jt=Qe.acquireProgram(Ut,Ft),li.set(Ft,Jt),be.uniforms=Ut.uniforms;let jt=be.uniforms;(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(jt.clippingPlanes=W.uniform),Qo(J,Ut),be.needsLights=ac(J),be.lightsStateVersion=kt,be.needsLights&&(jt.ambientLightColor.value=Be.state.ambient,jt.lightProbe.value=Be.state.probe,jt.directionalLights.value=Be.state.directional,jt.directionalLightShadows.value=Be.state.directionalShadow,jt.spotLights.value=Be.state.spot,jt.spotLightShadows.value=Be.state.spotShadow,jt.rectAreaLights.value=Be.state.rectArea,jt.ltc_1.value=Be.state.rectAreaLTC1,jt.ltc_2.value=Be.state.rectAreaLTC2,jt.pointLights.value=Be.state.point,jt.pointLightShadows.value=Be.state.pointShadow,jt.hemisphereLights.value=Be.state.hemi,jt.directionalShadowMap.value=Be.state.directionalShadowMap,jt.directionalShadowMatrix.value=Be.state.directionalShadowMatrix,jt.spotShadowMap.value=Be.state.spotShadowMap,jt.spotLightMatrix.value=Be.state.spotLightMatrix,jt.spotLightMap.value=Be.state.spotLightMap,jt.pointShadowMap.value=Be.state.pointShadowMap,jt.pointShadowMatrix.value=Be.state.pointShadowMatrix);let vi=Jt.getUniforms(),rr=tg.seqWithValue(vi.seq,jt);return be.currentProgram=Jt,be.uniformsList=rr,Jt}function Qo(J,Se){let Te=Ie.get(J);Te.outputEncoding=Se.outputEncoding,Te.instancing=Se.instancing,Te.skinning=Se.skinning,Te.morphTargets=Se.morphTargets,Te.morphNormals=Se.morphNormals,Te.morphColors=Se.morphColors,Te.morphTargetsCount=Se.morphTargetsCount,Te.numClippingPlanes=Se.numClippingPlanes,Te.numIntersection=Se.numClipIntersection,Te.vertexAlphas=Se.vertexAlphas,Te.vertexTangents=Se.vertexTangents,Te.toneMapping=Se.toneMapping}function au(J,Se,Te,be,Be){Se.isScene!==!0&&(Se=ce),Ce.resetTextureUnits();let at=Se.fog,kt=be.isMeshStandardMaterial?Se.environment:null,Ut=b===null?m.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:on,Ft=(be.isMeshStandardMaterial?Je:rt).get(be.envMap||kt),li=be.vertexColors===!0&&!!Te.attributes.color&&Te.attributes.color.itemSize===4,Jt=!!be.normalMap&&!!Te.attributes.tangent,jt=!!Te.morphAttributes.position,vi=!!Te.morphAttributes.normal,rr=!!Te.morphAttributes.color,Yi=be.toneMapped?m.toneMapping:Nn,ar=Te.morphAttributes.position||Te.morphAttributes.normal||Te.morphAttributes.color,Ui=ar!==void 0?ar.length:0,Mt=Ie.get(be),dn=u.state.lights;if(X===!0&&(ie===!0||J!==S)){let Ji=J===S&&be.id===_;W.setState(be,J,Ji)}let ps=!1;be.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==dn.state.version||Mt.outputEncoding!==Ut||Be.isInstancedMesh&&Mt.instancing===!1||!Be.isInstancedMesh&&Mt.instancing===!0||Be.isSkinnedMesh&&Mt.skinning===!1||!Be.isSkinnedMesh&&Mt.skinning===!0||Mt.envMap!==Ft||be.fog===!0&&Mt.fog!==at||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==W.numPlanes||Mt.numIntersection!==W.numIntersection)||Mt.vertexAlphas!==li||Mt.vertexTangents!==Jt||Mt.morphTargets!==jt||Mt.morphNormals!==vi||Mt.morphColors!==rr||Mt.toneMapping!==Yi||Ae.isWebGL2===!0&&Mt.morphTargetsCount!==Ui)&&(ps=!0):(ps=!0,Mt.__version=be.version);let fs=Mt.currentProgram;ps===!0&&(fs=zr(be,Se,Be));let ti=!1,Sr=!1,Jn=!1,ur=fs.getUniforms(),ms=Mt.uniforms;if(ye.useProgram(fs.program)&&(ti=!0,Sr=!0,Jn=!0),be.id!==_&&(_=be.id,Sr=!0),ti||S!==J){if(ur.setValue(se,"projectionMatrix",J.projectionMatrix),Ae.logarithmicDepthBuffer&&ur.setValue(se,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),S!==J&&(S=J,Sr=!0,Jn=!0),be.isShaderMaterial||be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshStandardMaterial||be.envMap){let Ji=ur.map.cameraPosition;Ji!==void 0&&Ji.setValue(se,fe.setFromMatrixPosition(J.matrixWorld))}(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial)&&ur.setValue(se,"isOrthographic",J.isOrthographicCamera===!0),(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial||be.isShadowMaterial||Be.isSkinnedMesh)&&ur.setValue(se,"viewMatrix",J.matrixWorldInverse)}if(Be.isSkinnedMesh){ur.setOptional(se,Be,"bindMatrix"),ur.setOptional(se,Be,"bindMatrixInverse");let Ji=Be.skeleton;Ji&&(Ae.floatVertexTextures?(Ji.boneTexture===null&&Ji.computeBoneTexture(),ur.setValue(se,"boneTexture",Ji.boneTexture,Ce),ur.setValue(se,"boneTextureSize",Ji.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 $n=Te.morphAttributes;if(($n.position!==void 0||$n.normal!==void 0||$n.color!==void 0&&Ae.isWebGL2===!0)&&V.update(Be,Te,be,fs),(Sr||Mt.receiveShadow!==Be.receiveShadow)&&(Mt.receiveShadow=Be.receiveShadow,ur.setValue(se,"receiveShadow",Be.receiveShadow)),be.isMeshGouraudMaterial&&be.envMap!==null&&(ms.envMap.value=Ft,ms.flipEnvMap.value=Ft.isCubeTexture&&Ft.isRenderTargetTexture===!1?-1:1),Sr&&(ur.setValue(se,"toneMappingExposure",m.toneMappingExposure),Mt.needsLights&&$l(ms,Jn),at&&be.fog===!0&&ft.refreshFogUniforms(ms,at),ft.refreshMaterialUniforms(ms,be,R,P,oe),tg.upload(se,Mt.uniformsList,ms,Ce)),be.isShaderMaterial&&be.uniformsNeedUpdate===!0&&(tg.upload(se,Mt.uniformsList,ms,Ce),be.uniformsNeedUpdate=!1),be.isSpriteMaterial&&ur.setValue(se,"center",Be.center),ur.setValue(se,"modelViewMatrix",Be.modelViewMatrix),ur.setValue(se,"normalMatrix",Be.normalMatrix),ur.setValue(se,"modelMatrix",Be.matrixWorld),Be.previousModelViewMatrix&&ur.setValue(se,"previousModelViewMatrix",Be.previousModelViewMatrix),J.previousProjectionMatrix&&ur.setValue(se,"previousProjectionMatrix",J.previousProjectionMatrix),be.isShaderMaterial||be.isRawShaderMaterial){let Ji=be.uniformsGroups;for(let Qt=0,su=Ji.length;Qt<su;Qt++)if(Ae.isWebGL2){let eo=Ji[Qt];Fe.update(eo,fs),Fe.bind(eo,fs)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fs}function $l(J,Se){J.ambientLightColor.needsUpdate=Se,J.lightProbe.needsUpdate=Se,J.directionalLights.needsUpdate=Se,J.directionalLightShadows.needsUpdate=Se,J.pointLights.needsUpdate=Se,J.pointLightShadows.needsUpdate=Se,J.spotLights.needsUpdate=Se,J.spotLightShadows.needsUpdate=Se,J.rectAreaLights.needsUpdate=Se,J.hemisphereLights.needsUpdate=Se}function ac(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(J,Se,Te){Ie.get(J.texture).__webglTexture=Se,Ie.get(J.depthTexture).__webglTexture=Te;let be=Ie.get(J);be.__hasExternalTextures=!0,be.__hasExternalTextures&&(be.__autoAllocateDepthBuffer=Te===void 0,be.__autoAllocateDepthBuffer||ve.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),be.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(J,Se){let Te=Ie.get(J);Te.__webglFramebuffer=Se,Te.__useDefaultFramebuffer=Se===void 0},this.setRenderTarget=function(J,Se=0,Te=0){b=J,y=Se,x=Te;let be=!0,Be=null,at=!1,kt=!1;if(J){let Ut=Ie.get(J);Ut.__useDefaultFramebuffer!==void 0?(ye.bindFramebuffer(36160,null),be=!1):Ut.__webglFramebuffer===void 0?Ce.setupRenderTarget(J):Ut.__hasExternalTextures&&Ce.rebindTextures(J,Ie.get(J.texture).__webglTexture,Ie.get(J.depthTexture).__webglTexture);let Ft=J.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(kt=!0);let li=Ie.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Be=li[Se],at=!0):Ae.isWebGL2&&J.samples>0&&Ce.useMultisampledRTT(J)===!1?Be=Ie.get(J).__webglMultisampledFramebuffer:Be=li,A.copy(J.viewport),E.copy(J.scissor),M=J.scissorTest}else A.copy(L).multiplyScalar(R).floor(),E.copy(j).multiplyScalar(R).floor(),M=q;if(ye.bindFramebuffer(36160,Be)&&Ae.drawBuffers&&be&&ye.drawBuffers(J,Be),ye.viewport(A),ye.scissor(E),ye.setScissorTest(M),at){let Ut=Ie.get(J.texture);se.framebufferTexture2D(36160,36064,34069+Se,Ut.__webglTexture,Te)}else if(kt){let Ut=Ie.get(J.texture),Ft=Se||0;se.framebufferTextureLayer(36160,36064,Ut.__webglTexture,Te||0,Ft)}_=-1},this.readRenderTargetPixels=function(J,Se,Te,be,Be,at,kt){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ut=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&kt!==void 0&&(Ut=Ut[kt]),Ut){ye.bindFramebuffer(36160,Ut);try{let Ft=J.texture,li=Ft.format,Jt=Ft.type;if(li!==Ki&&He.convert(li)!==se.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let jt=Jt===No&&(ve.has("EXT_color_buffer_half_float")||Ae.isWebGL2&&ve.has("EXT_color_buffer_float"));if(Jt!==Da&&He.convert(Jt)!==se.getParameter(35738)&&!(Jt===Di&&(Ae.isWebGL2||ve.has("OES_texture_float")||ve.has("WEBGL_color_buffer_float")))&&!jt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be&&se.readPixels(Se,Te,be,Be,He.convert(li),He.convert(Jt),at)}finally{let Ft=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(36160,Ft)}}},this.readRenderTargetPixelsAsync=async function(J,Se,Te,be,Be,at,kt){if(!(J&&J.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ut=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&kt!==void 0&&(Ut=Ut[kt]),Ut){let Ft=J.texture,li=Ft.format,Jt=Ft.type;if(Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be){ye.bindFramebuffer(se.FRAMEBUFFER,Ut);let jt=se.createBuffer();se.bindBuffer(se.PIXEL_PACK_BUFFER,jt),se.bufferData(se.PIXEL_PACK_BUFFER,at.byteLength,se.STREAM_READ),se.readPixels(Se,Te,be,Be,He.convert(li),He.convert(Jt),0);let vi=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(se.FRAMEBUFFER,vi);let rr=se.fenceSync(se.SYNC_GPU_COMMANDS_COMPLETE,0);return se.flush(),await M5(se,rr,4),se.bindBuffer(se.PIXEL_PACK_BUFFER,jt),se.getBufferSubData(se.PIXEL_PACK_BUFFER,0,at),se.deleteBuffer(jt),se.deleteSync(rr),at}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(J,Se,Te=0){let be=Math.pow(2,-Te),Be=Math.floor(Se.image.width*be),at=Math.floor(Se.image.height*be);Ce.setTexture2D(Se,0),se.copyTexSubImage2D(3553,Te,0,0,J.x,J.y,Be,at),ye.unbindTexture()},this.copyTextureToTexture=function(J,Se,Te,be=0){let Be=Se.image.width,at=Se.image.height,kt=He.convert(Te.format),Ut=He.convert(Te.type);Ce.setTexture2D(Te,0),se.pixelStorei(37440,Te.flipY),se.pixelStorei(37441,Te.premultiplyAlpha),se.pixelStorei(3317,Te.unpackAlignment),Se.isDataTexture?se.texSubImage2D(3553,be,J.x,J.y,Be,at,kt,Ut,Se.image.data):Se.isCompressedTexture?se.compressedTexSubImage2D(3553,be,J.x,J.y,Se.mipmaps[0].width,Se.mipmaps[0].height,kt,Se.mipmaps[0].data):se.texSubImage2D(3553,be,J.x,J.y,kt,Ut,Se.image),be===0&&Te.generateMipmaps&&se.generateMipmap(3553),ye.unbindTexture()},this.copyTextureToTexture3D=function(J,Se,Te,be,Be=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let at=J.max.x-J.min.x+1,kt=J.max.y-J.min.y+1,Ut=J.max.z-J.min.z+1,Ft=He.convert(be.format),li=He.convert(be.type),Jt;if(be.isData3DTexture)Ce.setTexture3D(be,0),Jt=32879;else if(be.isDataArrayTexture)Ce.setTexture2DArray(be,0),Jt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}se.pixelStorei(37440,be.flipY),se.pixelStorei(37441,be.premultiplyAlpha),se.pixelStorei(3317,be.unpackAlignment);let jt=se.getParameter(3314),vi=se.getParameter(32878),rr=se.getParameter(3316),Yi=se.getParameter(3315),ar=se.getParameter(32877),Ui=Te.isCompressedTexture?Te.mipmaps[0]:Te.image;se.pixelStorei(3314,Ui.width),se.pixelStorei(32878,Ui.height),se.pixelStorei(3316,J.min.x),se.pixelStorei(3315,J.min.y),se.pixelStorei(32877,J.min.z),Te.isDataTexture||Te.isData3DTexture?se.texSubImage3D(Jt,Be,Se.x,Se.y,Se.z,at,kt,Ut,Ft,li,Ui.data):Te.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),se.compressedTexSubImage3D(Jt,Be,Se.x,Se.y,Se.z,at,kt,Ut,Ft,Ui.data)):se.texSubImage3D(Jt,Be,Se.x,Se.y,Se.z,at,kt,Ut,Ft,li,Ui),se.pixelStorei(3314,jt),se.pixelStorei(32878,vi),se.pixelStorei(3316,rr),se.pixelStorei(3315,Yi),se.pixelStorei(32877,ar),Be===0&&be.generateMipmaps&&se.generateMipmap(Jt),ye.unbindTexture()},this.initRenderTarget=function(J){Ie.get(J).__webglFramebuffer===void 0&&Ce.setupRenderTarget(J)},this.initTexture=function(J){J.isCubeTexture?Ce.setTextureCube(J,0):J.isData3DTexture?Ce.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?Ce.setTexture2DArray(J,0):Ce.setTexture2D(J,0),ye.unbindTexture()},this.resetState=function(){y=0,x=0,b=null,ye.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var wN=class extends H3{};wN.prototype.isWebGL1Renderer=!0;var G3=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ct(e),this.near=t,this.far=i}clone(){return new G3(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},is=class extends Ci{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},_N=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Uy,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Bs()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;r<a;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bs()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bs()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ba=new O,Gy=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ba.fromBufferAttribute(this,t),Ba.applyMatrix4(e),this.setXYZ(t,Ba.x,Ba.y,Ba.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ba.fromBufferAttribute(this,t),Ba.applyNormalMatrix(e),this.setXYZ(t,Ba.x,Ba.y,Ba.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ba.fromBufferAttribute(this,t),Ba.transformDirection(e),this.setXYZ(t,Ba.x,Ba.y,Ba.z);return this}setX(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ro(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ro(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ro(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ro(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ki(t,this.array),i=ki(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ki(t,this.array),i=ki(i,this.array),r=ki(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=ki(t,this.array),i=ki(i,this.array),r=ki(r,this.array),a=ki(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return new Pt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Gy(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},W3=class extends Ci{constructor(){super(),this.isBone=!0,this.type="Bone"}},ja=class extends Zi{constructor(e=null,t=1,i=1,r,a,s,n,o,l=ei,h=ei,c,d){super(null,s,n,o,l,h,r,a,c,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},fA=new je,SN=new je,$b=class{constructor(e=[],t=[]){this.uuid=Bs(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new je;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){let n=e[a]?e[a].matrixWorld:SN;fA.multiplyMatrices(n,t[a]),fA.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new $b(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=T3(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new ja(t,e,e,Ki,Di);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let a=e.bones[i],s=t[a];s===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",a),s=new W3),this.bones.push(s),this.boneInverses.push(new je().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){let s=t[r];e.bones.push(s.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},Sp=class extends Pt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},mA=new je,gA=new je,qf=[],AN=new je,wu=new Fi,MN=class extends Fi{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Sp(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1;for(let r=0;r<i;r++)this.setMatrixAt(r,AN)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){let i=this.matrixWorld,r=this.count;if(wu.geometry=this.geometry,wu.material=this.material,wu.material!==void 0)for(let a=0;a<r;a++){this.getMatrixAt(a,mA),gA.multiplyMatrices(i,mA),wu.matrixWorld=gA,wu.raycast(e,qf);for(let s=0,n=qf.length;s<n;s++){let o=qf[s];o.instanceId=a,o.object=this,t.push(o)}qf.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Sp(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},Ql=class extends Wp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ct(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},vA=new O,yA=new O,xA=new je,s1=new Ud,Xf=new cs,Sg=class extends Ci{constructor(e=new vt,t=new Ql){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,a=t.count;r<a;r++)vA.fromBufferAttribute(t,r-1),yA.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=vA.distanceTo(yA);e.setAttribute("lineDistance",new nt(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Xf.copy(i.boundingSphere),Xf.applyMatrix4(r),Xf.radius+=a,e.ray.intersectsSphere(Xf)===!1)return;xA.copy(r).invert(),s1.copy(e.ray).applyMatrix4(xA);let n=a/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new O,h=new O,c=new O,d=new O,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,s.start),g=Math.min(p.count,s.start+s.count);for(let y=m,x=g-1;y<x;y+=u){let b=p.getX(y),_=p.getX(y+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),s1.distanceSqToSegment(l,h,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);let S=e.ray.origin.distanceTo(d);S<e.near||S>e.far||t.push({distance:S,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,s.start),g=Math.min(f.count,s.start+s.count);for(let y=m,x=g-1;y<x;y+=u){if(l.fromBufferAttribute(f,y),h.fromBufferAttribute(f,y+1),s1.distanceSqToSegment(l,h,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(d);b<e.near||b>e.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){let s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}},bA=new O,wA=new O,qp=class extends Sg{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,a=t.count;r<a;r+=2)bA.fromBufferAttribute(t,r),wA.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+bA.distanceTo(wA);e.setAttribute("lineDistance",new nt(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},EN=class extends Zi{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isVideoTexture=!0,this.minFilter=s!==void 0?s:Yt,this.magFilter=a!==void 0?a:Yt,this.generateMipmaps=!1;let h=this;function c(){h.needsUpdate=!0,e.requestVideoFrameCallback(c)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(c)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},CN=class extends Zi{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Qn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let n=0,o=a-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-s,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===s)return r/(a-1);let h=i[r],c=i[r+1]-h,d=(s-h)/c;return(r+d)/(a-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),s=this.getPoint(r),n=t||(a.isVector2?new ae:new O);return n.copy(s).sub(a).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new O,r=[],a=[],s=[],n=new O,o=new je;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new O)}a[0]=new O,s[0]=new O;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),d<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],n),s[0].crossVectors(r[0],a[0]);for(let u=1;u<=e;u++){if(a[u]=a[u-1].clone(),s[u]=s[u-1].clone(),n.crossVectors(r[u-1],r[u]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(Tr(r[u-1].dot(r[u]),-1,1));a[u].applyMatrix4(o.makeRotationAxis(n,p))}s[u].crossVectors(r[u],a[u])}if(t===!0){let u=Math.acos(Tr(a[0].dot(a[e]),-1,1));u/=e,r[0].dot(n.crossVectors(a[0],a[e]))>0&&(u=-u);for(let p=1;p<=e;p++)a[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),s[p].crossVectors(r[p],a[p])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Tv=class extends Qn{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new ae,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let n=this.aStartAngle+e*a,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),d=o-this.aX,u=l-this.aY;o=d*h-u*c+this.aX,l=d*c+u*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},TN=class extends Tv{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function ew(){let e=0,t=0,i=0,r=0;function a(s,n,o,l){e=s,t=o,i=-3*s+3*n-2*o-l,r=2*s-2*n+o+l}return{initCatmullRom:function(s,n,o,l,h){a(n,o,h*(o-s),h*(l-n))},initNonuniformCatmullRom:function(s,n,o,l,h,c,d){let u=(n-s)/h-(o-s)/(h+c)+(o-n)/c,p=(o-n)/c-(l-n)/(c+d)+(l-o)/d;u*=c,p*=c,a(n,o,u,p)},calc:function(s){let n=s*s,o=n*s;return e+t*s+i*n+r*o}}}var Yf=new O,n1=new ew,o1=new ew,l1=new ew,PN=class extends Qn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new O){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,n=Math.floor(s),o=s-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/a)+1)*a:o===0&&n===a-1&&(n=a-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%a]:(Yf.subVectors(r[0],r[1]).add(r[0]),l=Yf);let c=r[n%a],d=r[(n+1)%a];if(this.closed||n+2<a?h=r[(n+2)%a]:(Yf.subVectors(r[a-1],r[a-2]).add(r[a-1]),h=Yf),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(c),u),f=Math.pow(c.distanceToSquared(d),u),m=Math.pow(d.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),n1.initNonuniformCatmullRom(l.x,c.x,d.x,h.x,p,f,m),o1.initNonuniformCatmullRom(l.y,c.y,d.y,h.y,p,f,m),l1.initNonuniformCatmullRom(l.z,c.z,d.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(n1.initCatmullRom(l.x,c.x,d.x,h.x,this.tension),o1.initCatmullRom(l.y,c.y,d.y,h.y,this.tension),l1.initCatmullRom(l.z,c.z,d.z,h.z,this.tension));return i.set(n1.calc(o),o1.calc(o),l1.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new O().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function _A(e,t,i,r,a){let s=(r-t)*.5,n=(a-i)*.5,o=e*e,l=e*o;return(2*i-2*r+s+n)*l+(-3*i+3*r-2*s-n)*o+s*e+i}function DN(e,t){let i=1-e;return i*i*t}function IN(e,t){return 2*(1-e)*e*t}function ON(e,t){return e*e*t}function sp(e,t,i,r){return DN(e,t)+IN(e,i)+ON(e,r)}function RN(e,t){let i=1-e;return i*i*i*t}function LN(e,t){let i=1-e;return 3*i*i*e*t}function BN(e,t){return 3*(1-e)*e*e*t}function zN(e,t){return e*e*e*t}function np(e,t,i,r,a){return RN(e,t)+LN(e,i)+BN(e,r)+zN(e,a)}var tn=class extends Qn{constructor(e=new ae,t=new ae,i=new ae,r=new ae){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(np(e,r.x,a.x,s.x,n.x),np(e,r.y,a.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ig=class extends Qn{constructor(e=new O,t=new O,i=new O,r=new O){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(np(e,r.x,a.x,s.x,n.x),np(e,r.y,a.y,s.y,n.y),np(e,r.z,a.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},sn=class extends Qn{constructor(e=new ae,t=new ae){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ae){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new ae;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},q3=class extends Qn{constructor(e=new O,t=new O){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new O){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Hl=class extends Qn{constructor(e=new ae,t=new ae,i=new ae){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(sp(e,r.x,a.x,s.x),sp(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},kN=class extends Qn{constructor(e=new O,t=new O,i=new O){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(sp(e,r.x,a.x,s.x),sp(e,r.y,a.y,s.y),sp(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},tw=class extends Qn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ae){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),n=a-s,o=r[s===0?s:s-1],l=r[s],h=r[s>r.length-2?r.length-1:s+1],c=r[s>r.length-3?r.length-1:s+2];return i.set(_A(n,o.x,l.x,h.x,c.x),_A(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ae().fromArray(r))}return this}},FN=Object.freeze({__proto__:null,ArcCurve:TN,CatmullRomCurve3:PN,CubicBezierCurve:tn,CubicBezierCurve3:ig,EllipseCurve:Tv,LineCurve:sn,LineCurve3:q3,QuadraticBezierCurve:Hl,QuadraticBezierCurve3:kN,SplineCurve:tw}),X3=class extends Qn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new sn(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,n=this.curves[a],o=n.getLength(),l=o===0?0:1-s/o;return n.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],n=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,o=s.getPoints(n);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new FN[r.type]().fromJSON(r))}return this}},Ag=class extends X3{constructor(e){super(),this.type="Path",this.currentPoint=new ae,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new sn(this.currentPoint.clone(),new ae(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new Hl(this.currentPoint.clone(),new ae(e,t),new ae(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let n=new tn(this.currentPoint.clone(),new ae(e,t),new ae(i,r),new ae(a,s));return this.curves.push(n),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new tw(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,a,s,n,o),this}absellipse(e,t,i,r,a,s,n,o){let l=new Tv(e,t,i,r,a,s,n,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Y3=class extends vt{constructor(e=[new ae(0,-.5),new ae(.5,0),new ae(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Tr(r,0,Math.PI*2);let a=[],s=[],n=[],o=[],l=[],h=1/t,c=new O,d=new ae,u=new O,p=new O,f=new O,m=0,g=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,u.x=g*1,u.y=-m,u.z=g*0,f.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,u.x=g*1,u.y=-m,u.z=g*0,p.copy(u),u.x+=f.x,u.y+=f.y,u.z+=f.z,u.normalize(),o.push(u.x,u.y,u.z),f.copy(p)}for(let y=0;y<=t;y++){let x=i+y*h*r,b=Math.sin(x),_=Math.cos(x);for(let S=0;S<=e.length-1;S++){c.x=e[S].x*b,c.y=e[S].y,c.z=e[S].x*_,s.push(c.x,c.y,c.z),d.x=y/t,d.y=S/(e.length-1),n.push(d.x,d.y);let A=o[3*S+0]*b,E=o[3*S+1],M=o[3*S+0]*_;l.push(A,E,M)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){let b=x+y*e.length,_=b,S=b+e.length,A=b+e.length+1,E=b+1;a.push(_,S,E),a.push(A,E,S)}this.setIndex(a),this.setAttribute("position",new nt(s,3)),this.setAttribute("uv",new nt(n,2)),this.setAttribute("normal",new nt(l,3))}static fromJSON(e){return new Y3(e.points,e.segments,e.phiStart,e.phiLength)}},iw=class extends vt{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),a=Math.floor(a);let h=[],c=[],d=[],u=[],p=0,f=[],m=i/2,g=0;y(),s===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new nt(c,3)),this.setAttribute("normal",new nt(d,3)),this.setAttribute("uv",new nt(u,2));function y(){let b=new O,_=new O,S=0,A=(t-e)/i;for(let E=0;E<=a;E++){let M=[],T=E/a,P=T*(t-e)+e;for(let R=0;R<=r;R++){let z=R/r,U=z*o+n,L=Math.sin(U),j=Math.cos(U);_.x=P*L,_.y=-T*i+m,_.z=P*j,c.push(_.x,_.y,_.z),b.set(L,A,j).normalize(),d.push(b.x,b.y,b.z),u.push(z,1-T),M.push(p++)}f.push(M)}for(let E=0;E<r;E++)for(let M=0;M<a;M++){let T=f[M][E],P=f[M+1][E],R=f[M+1][E+1],z=f[M][E+1];h.push(T,P,z),h.push(P,R,z),S+=6}l.addGroup(g,S,0),g+=S}function x(b){let _=p,S=new ae,A=new O,E=0,M=b===!0?e:t,T=b===!0?1:-1;for(let R=1;R<=r;R++)c.push(0,m*T,0),d.push(0,T,0),u.push(.5,.5),p++;let P=p;for(let R=0;R<=r;R++){let z=R/r*o+n,U=Math.cos(z),L=Math.sin(z);A.x=M*L,A.y=m*T,A.z=M*U,c.push(A.x,A.y,A.z),d.push(0,T,0),S.x=U*.5+.5,S.y=L*.5*T+.5,u.push(S.x,S.y),p++}for(let R=0;R<r;R++){let z=_+R,U=P+R;b===!0?h.push(U,U+1,z):h.push(U+1,U,z),E+=3}l.addGroup(g,E,b===!0?1:2),g+=E}}static fromJSON(e){return new iw(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},rw=class extends iw{constructor(e=1,t=1,i=32,r=1,a=!1,s=0,n=Math.PI*2){super(0,e,t,i,r,a,s,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:n}}static fromJSON(e){return new rw(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},aw=class extends vt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let a=[],s=[];n(r),l(i),h(),this.setAttribute("position",new nt(a,3)),this.setAttribute("normal",new nt(a.slice(),3)),this.setAttribute("uv",new nt(s,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(y){let x=new O,b=new O,_=new O;for(let S=0;S<t.length;S+=3)u(t[S+0],x),u(t[S+1],b),u(t[S+2],_),o(x,b,_,y)}function o(y,x,b,_){let S=_+1,A=[];for(let E=0;E<=S;E++){A[E]=[];let M=y.clone().lerp(b,E/S),T=x.clone().lerp(b,E/S),P=S-E;for(let R=0;R<=P;R++)R===0&&E===S?A[E][R]=M:A[E][R]=M.clone().lerp(T,R/P)}for(let E=0;E<S;E++)for(let M=0;M<2*(S-E)-1;M++){let T=Math.floor(M/2);M%2===0?(d(A[E][T+1]),d(A[E+1][T]),d(A[E][T])):(d(A[E][T+1]),d(A[E+1][T+1]),d(A[E+1][T]))}}function l(y){let x=new O;for(let b=0;b<a.length;b+=3)x.x=a[b+0],x.y=a[b+1],x.z=a[b+2],x.normalize().multiplyScalar(y),a[b+0]=x.x,a[b+1]=x.y,a[b+2]=x.z}function h(){let y=new O;for(let x=0;x<a.length;x+=3){y.x=a[x+0],y.y=a[x+1],y.z=a[x+2];let b=m(y)/2/Math.PI+.5,_=g(y)/Math.PI+.5;s.push(b,1-_)}p(),c()}function c(){for(let y=0;y<s.length;y+=6){let x=s[y+0],b=s[y+2],_=s[y+4],S=Math.max(x,b,_),A=Math.min(x,b,_);S>.9&&A<.1&&(x<.2&&(s[y+0]+=1),b<.2&&(s[y+2]+=1),_<.2&&(s[y+4]+=1))}}function d(y){a.push(y.x,y.y,y.z)}function u(y,x){let b=y*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function p(){let y=new O,x=new O,b=new O,_=new O,S=new ae,A=new ae,E=new ae;for(let M=0,T=0;M<a.length;M+=9,T+=6){y.set(a[M+0],a[M+1],a[M+2]),x.set(a[M+3],a[M+4],a[M+5]),b.set(a[M+6],a[M+7],a[M+8]),S.set(s[T+0],s[T+1]),A.set(s[T+2],s[T+3]),E.set(s[T+4],s[T+5]),_.copy(y).add(x).add(b).divideScalar(3);let P=m(_);f(S,T+0,y,P),f(A,T+2,x,P),f(E,T+4,b,P)}}function f(y,x,b,_){_<0&&y.x===1&&(s[x]=y.x-1),b.x===0&&b.z===0&&(s[x]=_/2/Math.PI+.5)}function m(y){return Math.atan2(y.z,-y.x)}function g(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new aw(e.vertices,e.indices,e.radius,e.details)}},Q3=class extends aw{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],s=[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(a,s,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Q3(e.radius,e.detail)}},Mg=class extends Ag{constructor(e){super(e),this.uuid=Bs(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Ag().fromJSON(r))}return this}},UN={triangulate:function(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length,s=K3(e,0,a,i,!0),n=[];if(!s||s.next===s.prev)return n;let o,l,h,c,d,u,p;if(r&&(s=GN(e,t,s,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let f=i;f<a;f+=i)d=e[f],u=e[f+1],d<o&&(o=d),u<l&&(l=u),d>h&&(h=d),u>c&&(c=u);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return Ap(s,n,i,o,l,p,0),n}};function K3(e,t,i,r,a){let s,n;if(a===t8(e,t,i,r)>0)for(s=t;s<i;s+=r)n=SA(s,e[s],e[s+1],n);else for(s=i-r;s>=t;s-=r)n=SA(s,e[s],e[s+1],n);return n&&Pv(n,n.next)&&(Ep(n),n=n.next),n}function Nh(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Pv(i,i.next)||ir(i.prev,i,i.next)===0)){if(Ep(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function Ap(e,t,i,r,a,s,n){if(!e)return;!n&&s&&QN(e,r,a,s);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,s?VN(e,r,a,s):NN(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Ep(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=jN(Nh(e),t,i),Ap(e,t,i,r,a,s,2)):n===2&&HN(e,t,i,r,a,s):Ap(Nh(e),t,i,r,a,s,1);break}}}function NN(e){let t=e.prev,i=e,r=e.next;if(ir(t,i,r)>=0)return!1;let a=t.x,s=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=a<s?a<n?a:n:s<n?s:n,d=o<l?o<h?o:h:l<h?l:h,u=a>s?a>n?a:n:s>n?s:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&rd(a,o,s,l,n,h,f.x,f.y)&&ir(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function VN(e,t,i,r){let a=e.prev,s=e,n=e.next;if(ir(a,s,n)>=0)return!1;let o=a.x,l=s.x,h=n.x,c=a.y,d=s.y,u=n.y,p=o<l?o<h?o:h:l<h?l:h,f=c<d?c<u?c:u:d<u?d:u,m=o>l?o>h?o:h:l>h?l:h,g=c>d?c>u?c:u:d>u?d:u,y=Wy(p,f,t,i,r),x=Wy(m,g,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&rd(o,c,l,d,h,u,b.x,b.y)&&ir(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&rd(o,c,l,d,h,u,_.x,_.y)&&ir(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&rd(o,c,l,d,h,u,b.x,b.y)&&ir(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&rd(o,c,l,d,h,u,_.x,_.y)&&ir(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function jN(e,t,i){let r=e;do{let a=r.prev,s=r.next.next;!Pv(a,s)&&Z3(a,r,r.next,s)&&Mp(a,s)&&Mp(s,a)&&(t.push(a.i/i|0),t.push(r.i/i|0),t.push(s.i/i|0),Ep(r),Ep(r.next),r=e=s),r=r.next}while(r!==e);return Nh(r)}function HN(e,t,i,r,a,s){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&JN(n,o)){let l=J3(n,o);n=Nh(n,n.next),l=Nh(l,l.next),Ap(n,t,i,r,a,s,0),Ap(l,t,i,r,a,s,0);return}o=o.next}n=n.next}while(n!==e)}function GN(e,t,i,r){let a=[],s,n,o,l,h;for(s=0,n=t.length;s<n;s++)o=t[s]*r,l=s<n-1?t[s+1]*r:e.length,h=K3(e,o,l,r,!1),h===h.next&&(h.steiner=!0),a.push(ZN(h));for(a.sort(WN),s=0;s<a.length;s++)i=qN(a[s],i);return i}function WN(e,t){return e.x-t.x}function qN(e,t){let i=XN(e,t);if(!i)return t;let r=J3(i,e);return Nh(r,r.next),Nh(i,i.next)}function XN(e,t){let i=t,r=-1/0,a,s=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let u=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=s&&u>r&&(r=u,a=i.x<i.next.x?i:i.next,u===s))return a}i=i.next}while(i!==t);if(!a)return null;let o=a,l=a.x,h=a.y,c=1/0,d;i=a;do s>=i.x&&i.x>=l&&s!==i.x&&rd(n<h?s:r,n,l,h,n<h?r:s,n,i.x,i.y)&&(d=Math.abs(n-i.y)/(s-i.x),Mp(i,e)&&(d<c||d===c&&(i.x>a.x||i.x===a.x&&YN(a,i)))&&(a=i,c=d)),i=i.next;while(i!==o);return a}function YN(e,t){return ir(e.prev,e,t.prev)<0&&ir(t.next,e,e.next)<0}function QN(e,t,i,r){let a=e;do a.z===0&&(a.z=Wy(a.x,a.y,t,i,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,KN(a)}function KN(e){let t,i,r,a,s,n,o,l,h=1;do{for(i=e,e=null,s=null,n=0;i;){for(n++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(a=i,i=i.nextZ,o--):(a=r,r=r.nextZ,l--),s?s.nextZ=a:e=a,a.prevZ=s,s=a;i=r}s.nextZ=null,h*=2}while(n>1);return e}function Wy(e,t,i,r,a){return e=(e-i)*a|0,t=(t-r)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function ZN(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function rd(e,t,i,r,a,s,n,o){return(a-n)*(t-o)>=(e-n)*(s-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(s-o)>=(a-n)*(r-o)}function JN(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!$N(e,t)&&(Mp(e,t)&&Mp(t,e)&&e8(e,t)&&(ir(e.prev,e,t.prev)||ir(e,t.prev,t))||Pv(e,t)&&ir(e.prev,e,e.next)>0&&ir(t.prev,t,t.next)>0)}function ir(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Pv(e,t){return e.x===t.x&&e.y===t.y}function Z3(e,t,i,r){let a=Kf(ir(e,t,i)),s=Kf(ir(e,t,r)),n=Kf(ir(i,r,e)),o=Kf(ir(i,r,t));return!!(a!==s&&n!==o||a===0&&Qf(e,i,t)||s===0&&Qf(e,r,t)||n===0&&Qf(i,e,r)||o===0&&Qf(i,t,r))}function Qf(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Kf(e){return e>0?1:e<0?-1:0}function $N(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Z3(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Mp(e,t){return ir(e.prev,e,e.next)<0?ir(e,t,e.next)>=0&&ir(e,e.prev,t)>=0:ir(e,t,e.prev)<0||ir(e,e.next,t)<0}function e8(e,t){let i=e,r=!1,a=(e.x+t.x)/2,s=(e.y+t.y)/2;do i.y>s!=i.next.y>s&&i.next.y!==i.y&&a<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function J3(e,t){let i=new qy(e.i,e.x,e.y),r=new qy(t.i,t.x,t.y),a=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function SA(e,t,i,r){let a=new qy(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function Ep(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function qy(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function t8(e,t,i,r){let a=0;for(let s=t,n=i-r;s<i;s+=r)a+=(e[n]-e[s])*(e[s+1]+e[n+1]),n=s;return a}var $3=class{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return $3.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];AA(e),MA(i,e);let s=e.length;t.forEach(AA);for(let o=0;o<t.length;o++)r.push(s),s+=t[o].length,MA(i,t[o]);let n=UN.triangulate(i,r);for(let o=0;o<n.length;o+=3)a.push(n.slice(o,o+3));return a}};function AA(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function MA(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var eP=class extends aw{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,a,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new eP(e.radius,e.detail)}},ld=class extends vt{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(s+n,Math.PI),l=0,h=[],c=new O,d=new O,u=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let y=[],x=g/i,b=0;g==0&&s==0?b=.5/t:g==i&&o==Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let S=_/t;c.x=-e*Math.cos(r+S*a)*Math.sin(s+x*n),c.y=e*Math.cos(s+x*n),c.z=e*Math.sin(r+S*a)*Math.sin(s+x*n),p.push(c.x,c.y,c.z),d.copy(c).normalize(),f.push(d.x,d.y,d.z),m.push(S+b,1-x),y.push(l++)}h.push(y)}for(let g=0;g<i;g++)for(let y=0;y<t;y++){let x=h[g][y+1],b=h[g][y],_=h[g+1][y],S=h[g+1][y+1];(g!==0||s>0)&&u.push(x,b,S),(g!==i-1||o<Math.PI)&&u.push(b,_,S)}this.setIndex(u),this.setAttribute("position",new nt(p,3)),this.setAttribute("normal",new nt(f,3)),this.setAttribute("uv",new nt(m,2))}static fromJSON(e){return new ld(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},tP=class extends vt{constructor(e=1,t=.4,i=12,r=48,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:a},i=Math.floor(i),r=Math.floor(r);let s=[],n=[],o=[],l=[],h=new O,c=new O,d=new O;for(let u=0;u<=i;u++)for(let p=0;p<=r;p++){let f=p/r*a,m=u/i*Math.PI*2;c.x=(e+t*Math.cos(m))*Math.cos(f),c.y=(e+t*Math.cos(m))*Math.sin(f),c.z=t*Math.sin(m),n.push(c.x,c.y,c.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),d.subVectors(c,h).normalize(),o.push(d.x,d.y,d.z),l.push(p/r),l.push(u/i)}for(let u=1;u<=i;u++)for(let p=1;p<=r;p++){let f=(r+1)*u+p-1,m=(r+1)*(u-1)+p-1,g=(r+1)*(u-1)+p,y=(r+1)*u+p;s.push(f,m,y),s.push(m,g,y)}this.setIndex(s),this.setAttribute("position",new nt(n,3)),this.setAttribute("normal",new nt(o,3)),this.setAttribute("uv",new nt(l,2))}static fromJSON(e){return new tP(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},iP=class extends vt{constructor(e=1,t=.4,i=64,r=8,a=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:a,q:s},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],c=new O,d=new O,u=new O,p=new O,f=new O,m=new O,g=new O;for(let x=0;x<=i;++x){let b=x/i*a*Math.PI*2;y(b,a,s,e,u),y(b+.01,a,s,e,p),m.subVectors(p,u),g.addVectors(p,u),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let _=0;_<=r;++_){let S=_/r*Math.PI*2,A=-t*Math.cos(S),E=t*Math.sin(S);c.x=u.x+(A*g.x+E*f.x),c.y=u.y+(A*g.y+E*f.y),c.z=u.z+(A*g.z+E*f.z),o.push(c.x,c.y,c.z),d.subVectors(c,u).normalize(),l.push(d.x,d.y,d.z),h.push(x/i),h.push(_/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let _=(r+1)*(x-1)+(b-1),S=(r+1)*x+(b-1),A=(r+1)*x+b,E=(r+1)*(x-1)+b;n.push(_,S,E),n.push(S,A,E)}this.setIndex(n),this.setAttribute("position",new nt(o,3)),this.setAttribute("normal",new nt(l,3)),this.setAttribute("uv",new nt(h,2));function y(x,b,_,S,A){let E=Math.cos(x),M=Math.sin(x),T=_/b*x,P=Math.cos(T);A.x=S*(2+P)*.5*E,A.y=S*(2+P)*M*.5,A.z=S*Math.sin(T)*.5}}static fromJSON(e){return new iP(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},i8=class extends di{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};function nl(e,t,i){return rP(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Zf(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function rP(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function r8(e){function t(a,s){return e[a]-e[s]}let i=e.length,r=new Array(i);for(let a=0;a!==i;++a)r[a]=a;return r.sort(t),r}function EA(e,t,i){let r=e.length,a=new e.constructor(r);for(let s=0,n=0;n!==r;++s){let o=i[s]*t;for(let l=0;l!==t;++l)a[n++]=e[o+l]}return a}function aP(e,t,i,r){let a=1,s=e[0];for(;s!==void 0&&s[r]===void 0;)s=e[a++];if(s===void 0)return;let n=s[r];if(n!==void 0)if(Array.isArray(n))do n=s[r],n!==void 0&&(t.push(s.time),i.push.apply(i,n)),s=e[a++];while(s!==void 0);else if(n.toArray!==void 0)do n=s[r],n!==void 0&&(t.push(s.time),n.toArray(i,i.length)),s=e[a++];while(s!==void 0);else do n=s[r],n!==void 0&&(t.push(s.time),i.push(n)),s=e[a++];while(s!==void 0)}var Dv=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<a)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break i}if(!(e>=a)){let n=t[1];e<n&&(i=2,a=n);for(let o=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break i}break e}for(;i<s;){let n=i+s>>>1;e<t[n]?s=n:i=n+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},a8=class extends Dv{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ed,endingEnd:ed}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,n=r[a],o=r[s];if(n===void 0)switch(this.getSettings_().endingStart){case td:a=e,n=2*t-i;break;case bg:a=r.length-2,n=t+r[a]-r[a+1];break;default:a=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case td:s=e,o=2*i-t;break;case bg:s=1,o=i+r[1]-r[0];break;default:s=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=a*h,this._offsetNext=s*h}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,c=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-d*m+2*d*f-d*p,y=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,x=(-1-u)*m+(1.5+u)*f+.5*p,b=u*m-u*f;for(let _=0;_!==n;++_)a[_]=g*s[h+_]+y*s[l+_]+x*s[o+_]+b*s[c+_];return a}},sP=class extends Dv{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),c=1-h;for(let d=0;d!==n;++d)a[d]=s[l+d]*c+s[o+d]*h;return a}},s8=class extends Dv{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Kn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Zf(t,this.TimeBufferType),this.values=Zf(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Zf(e.times,Array),values:Zf(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new s8(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new sP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new a8(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case yg:t=this.InterpolantFactoryMethodDiscrete;break;case xg:t=this.InterpolantFactoryMethodLinear;break;case R0:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yg;case this.InterpolantFactoryMethodLinear:return xg;case this.InterpolantFactoryMethodSmooth:return R0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let n=this.getValueSize();this.times=nl(i,a,s),this.values=nl(this.values,a*n,s*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let n=0;n!==a;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(s!==null&&s>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,s),e=!1;break}s=o}if(r!==void 0&&rP(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=nl(this.times),t=nl(this.values),i=this.getValueSize(),r=this.getInterpolation()===R0,a=e.length-1,s=1;for(let n=1;n<a;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let c=n*i,d=c-i,u=c+i;for(let p=0;p!==i;++p){let f=t[c+p];if(f!==t[d+p]||f!==t[u+p]){o=!0;break}}}if(o){if(n!==s){e[s]=e[n];let c=n*i,d=s*i;for(let u=0;u!==i;++u)t[d+u]=t[c+u]}++s}}if(a>0){e[s]=e[a];for(let n=a*i,o=s*i,l=0;l!==i;++l)t[o+l]=t[n+l];++s}return s!==e.length?(this.times=nl(e,0,s),this.values=nl(t,0,s*i)):(this.times=e,this.values=t),this}clone(){let e=nl(this.times,0),t=nl(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Kn.prototype.TimeBufferType=Float32Array;Kn.prototype.ValueBufferType=Float32Array;Kn.prototype.DefaultInterpolation=xg;var jd=class extends Kn{};jd.prototype.ValueTypeName="bool";jd.prototype.ValueBufferType=Array;jd.prototype.DefaultInterpolation=yg;jd.prototype.InterpolantFactoryMethodLinear=void 0;jd.prototype.InterpolantFactoryMethodSmooth=void 0;var nP=class extends Kn{};nP.prototype.ValueTypeName="color";var Eg=class extends Kn{};Eg.prototype.ValueTypeName="number";var n8=class extends Dv{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)Rt.slerpFlat(a,0,s,l-n,s,l,o);return a}},Xp=class extends Kn{InterpolantFactoryMethodLinear(e){return new n8(this.times,this.values,this.getValueSize(),e)}};Xp.prototype.ValueTypeName="quaternion";Xp.prototype.DefaultInterpolation=xg;Xp.prototype.InterpolantFactoryMethodSmooth=void 0;var Hd=class extends Kn{};Hd.prototype.ValueTypeName="string";Hd.prototype.ValueBufferType=Array;Hd.prototype.DefaultInterpolation=yg;Hd.prototype.InterpolantFactoryMethodLinear=void 0;Hd.prototype.InterpolantFactoryMethodSmooth=void 0;var Cg=class extends Kn{};Cg.prototype.ValueTypeName="vector";var Xy=class{constructor(e,t=-1,i,r=Xb){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Bs(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let s=0,n=i.length;s!==n;++s)t.push(l8(i[s]).scale(r));let a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let a=0,s=i.length;a!==s;++a)t.push(Kn.toJSON(i[a]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let a=t.length,s=[];for(let n=0;n<a;n++){let o=[],l=[];o.push((n+a-1)%a,n,(n+1)%a),l.push(0,1,0);let h=r8(o);o=EA(o,1,h),l=EA(l,1,h),!r&&o[0]===0&&(o.push(a),l.push(l[0])),s.push(new Eg(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},a=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(a);if(h&&h.length>1){let c=h[1],d=r[c];d||(r[c]=d=[]),d.push(l)}}let s=[];for(let n in r)s.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,d,u,p){if(d.length!==0){let f=[],m=[];aP(d,f,m,u),f.length!==0&&p.push(new h(c,f,m))}},r=[],a=e.name||"default",s=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let c=l[h].keys;if(!(!c||c.length===0))if(c[0].morphTargets){let d={},u;for(u=0;u<c.length;u++)if(c[u].morphTargets)for(let p=0;p<c[u].morphTargets.length;p++)d[c[u].morphTargets[p]]=-1;for(let p in d){let f=[],m=[];for(let g=0;g!==c[u].morphTargets.length;++g){let y=c[u];f.push(y.time),m.push(y.morphTarget===p?1:0)}r.push(new Eg(".morphTargetInfluence["+p+"]",f,m))}o=d.length*s}else{let d=".bones["+t[h].name+"]";i(Cg,d+".position",c,"pos",r),i(Xp,d+".quaternion",c,"rot",r),i(Cg,d+".scale",c,"scl",r)}}return r.length===0?null:new this(a,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let a=this.tracks[i];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function o8(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Eg;case"vector":case"vector2":case"vector3":case"vector4":return Cg;case"color":return nP;case"quaternion":return Xp;case"bool":case"boolean":return jd;case"string":return Hd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function l8(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=o8(e.type);if(e.times===void 0){let i=[],r=[];aP(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var Tg={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},oP=class{constructor(e,t,i){let r=this,a=!1,s=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,a===!1&&r.onStart!==void 0&&r.onStart(h,s,n),a=!0},this.itemEnd=function(h){s++,r.onProgress!==void 0&&r.onProgress(h,s,n),s===n&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,d=l.length;c<d;c+=2){let u=l[c],p=l[c+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},h8=new oP,Yp=class{constructor(e){this.manager=e!==void 0?e:h8,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},uo={},c8=class extends Error{constructor(e,t){super(e),this.response=t}},Yy=class extends Yp{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=Tg.get(e);if(a!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0),a;if(uo[e]!==void 0){uo[e].push({onLoad:t,onProgress:i,onError:r});return}uo[e]=[],uo[e].push({onLoad:t,onProgress:i,onError:r});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(s).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=uo[e],c=l.body.getReader(),d=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=d?parseInt(d):0,p=u!==0,f=0,m=new ReadableStream({start(g){y();function y(){c.read().then(({done:x,value:b})=>{if(x)g.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let S=0,A=h.length;S<A;S++){let E=h[S];E.onProgress&&E.onProgress(_)}g.enqueue(b),y()}})}}});return new Response(m)}else throw new c8(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(c);return l.arrayBuffer().then(u=>d.decode(u))}}}).then(l=>{Tg.add(e,l);let h=uo[e];delete uo[e];for(let c=0,d=h.length;c<d;c++){let u=h[c];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=uo[e];if(h===void 0)throw this.manager.itemError(e),l;delete uo[e];for(let c=0,d=h.length;c<d;c++){let u=h[c];u.onError&&u.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},d8=class extends Yp{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,s=Tg.get(e);if(s!==void 0)return a.manager.itemStart(e),setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0),s;let n=_p("img");function o(){h(),Tg.add(e,this),t&&t(this),a.manager.itemEnd(e)}function l(c){h(),r&&r(c),a.manager.itemError(e),a.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),a.manager.itemStart(e),n.src=e,n}},u8=class extends Yp{constructor(e){super(e)}load(e,t,i,r){let a=new Zi,s=new d8(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(n){a.image=n,a.needsUpdate=!0,t!==void 0&&t(a)},i,r),a}},Qp=class extends Ci{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ct(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},p8=class extends Qp{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ct(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},h1=new je,CA=new O,TA=new O,sw=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ae(512,512),this.map=null,this.mapPass=null,this.matrix=new je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zb,this._frameExtents=new ae(1,1),this._viewportCount=1,this._viewports=[new Lt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;CA.setFromMatrixPosition(e.matrixWorld),t.position.copy(CA),TA.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(TA),t.updateMatrixWorld(),h1.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(h1),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(h1)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},f8=class extends sw{constructor(){super(new Ea(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=wp*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||t.far;(i!==t.fov||r!==t.aspect||a!==t.far)&&(t.fov=i,t.aspect=r,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},m8=class extends Qp{constructor(e,t,i=0,r=Math.PI/3,a=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.target=new Ci,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new f8}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},PA=new je,_u=new O,c1=new O,g8=class extends sw{constructor(){super(new Ea(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ae(4,2),this._viewportCount=6,this._viewports=[new Lt(2,1,1,1),new Lt(0,1,1,1),new Lt(3,1,1,1),new Lt(1,1,1,1),new Lt(3,0,1,1),new Lt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),_u.setFromMatrixPosition(e.matrixWorld),i.position.copy(_u),c1.copy(i.position),c1.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(c1),i.updateMatrixWorld(),r.makeTranslation(-_u.x,-_u.y,-_u.z),PA.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(PA)}},v8=class extends Qp{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new g8}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},y8=class extends sw{constructor(){super(new Ev(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},x8=class extends Qp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.target=new Ci,this.shadow=new y8}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},lP=class extends vt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},hP=class extends Yp{constructor(e){super(e)}load(e,t,i,r){let a=this,s=new Yy(a.manager);s.setPath(a.path),s.setRequestHeader(a.requestHeader),s.setWithCredentials(a.withCredentials),s.load(e,function(n){try{t(a.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),a.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(d,u){if(t[u]!==void 0)return t[u];let p=d.interleavedBuffers[u],f=a(d,p.buffer),m=Cf(p.type,f),g=new _N(m,p.stride);return g.uuid=p.uuid,t[u]=g,g}function a(d,u){if(i[u]!==void 0)return i[u];let p=d.arrayBuffers[u],f=new Uint32Array(p).buffer;return i[u]=f,f}let s=e.isInstancedBufferGeometry?new lP:new vt,n=e.data.index;if(n!==void 0){let d=Cf(n.type,n.array);s.setIndex(new Pt(d,1))}let o=e.data.attributes;for(let d in o){let u=o[d],p;if(u.isInterleavedBufferAttribute){let f=r(e.data,u.data);p=new Gy(f,u.itemSize,u.offset,u.normalized)}else{let f=Cf(u.type,u.array),m=u.isInstancedBufferAttribute?Sp:Pt;p=new m(f,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),s.setAttribute(d,p)}let l=e.data.morphAttributes;if(l)for(let d in l){let u=l[d],p=[];for(let f=0,m=u.length;f<m;f++){let g=u[f],y;if(g.isInterleavedBufferAttribute){let x=r(e.data,g.data);y=new Gy(x,g.itemSize,g.offset,g.normalized)}else{let x=Cf(g.type,g.array);y=new Pt(x,g.itemSize,g.normalized)}g.name!==void 0&&(y.name=g.name),p.push(y)}s.morphAttributes[d]=p}e.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let d=0,u=h.length;d!==u;++d){let p=h[d];s.addGroup(p.start,p.count,p.materialIndex)}let c=e.data.boundingSphere;if(c!==void 0){let d=new O;c.center!==void 0&&d.fromArray(c.center),s.boundingSphere=new cs(d,c.radius)}return e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}},b8=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=DA(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=DA();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function DA(){return(typeof performance>"u"?Date:performance).now()}var w8=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,a,s;switch(t){case"quaternion":r=this._slerp,a=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,a=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,a=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=a,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,a=e*r+r,s=this.cumulativeWeight;if(s===0){for(let n=0;n!==r;++n)i[a+n]=i[n];s=t}else{s+=t;let n=t/s;this._mixBufferRegion(i,a,0,n,r)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,a=this.cumulativeWeight,s=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,a<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-a,t)}s>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let a=i,s=r;a!==s;++a)t[a]=t[r+a%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,a){if(r>=.5)for(let s=0;s!==a;++s)e[t+s]=e[i+s]}_slerp(e,t,i,r){Rt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,a){let s=this._workIndex*a;Rt.multiplyQuaternionsFlat(e,s,e,t,e,i),Rt.slerpFlat(e,t,e,t,e,s,r)}_lerp(e,t,i,r,a){let s=1-r;for(let n=0;n!==a;++n){let o=t+n;e[o]=e[o]*s+e[i+n]*r}}_lerpAdditive(e,t,i,r,a){for(let s=0;s!==a;++s){let n=t+s;e[n]=e[n]+e[i+s]*r}}},nw="\\[\\]\\.:\\/",_8=new RegExp("["+nw+"]","g"),ow="[^"+nw+"]",S8="[^"+nw.replace("\\.","")+"]",A8=/((?:WC+[\/:])*)/.source.replace("WC",ow),M8=/(WCOD+)?/.source.replace("WCOD",S8),E8=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ow),C8=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ow),T8=new RegExp("^"+A8+M8+E8+C8+"$"),P8=["material","materials","bones","map"],D8=class{constructor(e,t,i){let r=i||Ri.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Ri=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Ri.parseTrackName(t),this.node=Ri.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Ri.Composite(e,t,i):new Ri(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_8,"")}static parseTrackName(e){let t=T8.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);P8.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let n=a[s];if(n.name===t||n.uuid===t)return n;let o=i(n.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=Ri.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ri.Composite=D8;Ri.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ri.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ri.prototype.GetterByBindingType=[Ri.prototype._getValue_direct,Ri.prototype._getValue_array,Ri.prototype._getValue_arrayElement,Ri.prototype._getValue_toArray];Ri.prototype.SetterByBindingTypeAndVersioning=[[Ri.prototype._setValue_direct,Ri.prototype._setValue_direct_setNeedsUpdate,Ri.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_array,Ri.prototype._setValue_array_setNeedsUpdate,Ri.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_arrayElement,Ri.prototype._setValue_arrayElement_setNeedsUpdate,Ri.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_fromArray,Ri.prototype._setValue_fromArray_setNeedsUpdate,Ri.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var I8=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let a=t.tracks,s=a.length,n=new Array(s),o={endingStart:ed,endingEnd:ed};for(let l=0;l!==s;++l){let h=a[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=E3,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,a=e._clip.duration,s=a/r,n=r/a;e.warp(1,s,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,a=r.time,s=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=a,o[1]=a+i,l[0]=e/s,l[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let a=this._startTime;if(a!==null){let o=(e-a)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let s=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case n5:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulateAdditive(n);break;case Xb:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,a=this._loopCount,s=i===qb;if(e===0)return a===-1?r:s&&(a&1)===1?t-r:r;if(i===M3){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,a+=Math.abs(n);let o=this.repetitions-a;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,s)}else this._setEndings(!1,!1,s);this._loopCount=a,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(s&&(a&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=td,r.endingEnd=td):(e?r.endingStart=this.zeroSlopeAtStart?td:ed:r.endingStart=bg,t?r.endingEnd=this.zeroSlopeAtEnd?td:ed:r.endingEnd=bg)}_scheduleFading(e,t,i){let r=this._mixer,a=r.time,s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);let n=s.parameterPositions,o=s.sampleValues;return n[0]=a,o[0]=t,n[1]=a+e,o[1]=i,this}},O8=new Float32Array(1),R8=class extends ha{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,a=r.length,s=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==a;++c){let d=r[c],u=d.name,p=h[u];if(p!==void 0)++p.referenceCount,s[c]=p;else{if(p=s[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new w8(Ri.create(i,u,f),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),s[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,a=this._actionsByClip[r];this._bindAction(e,a&&a.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];a.useCount++===0&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.useCount===0&&(a.restoreOriginalState(),this._takeBackBinding(a))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,a=this._actionsByClip,s=a[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,a[t]=s;else{let n=s.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let a=e._clip.uuid,s=this._actionsByClip,n=s[a],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let c=n.actionByRoot,d=(e._localRoot||this._root).uuid;delete c[d],o.length===0&&delete s[a],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.referenceCount===0&&this._removeInactiveBinding(a)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,a=this._bindings,s=r[t];s===void 0&&(s={},r[t]=s),s[i]=e,e._cacheIndex=a.length,a.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,a=i.path,s=this._bindingsByRootAndName,n=s[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[a],Object.keys(n).length===0&&delete s[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new sP(new Float32Array(2),new Float32Array(2),1,O8),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,a=t[r];e.__cacheIndex=r,t[r]=e,a.__cacheIndex=i,t[i]=a}clipAction(e,t,i){let r=t||this._root,a=r.uuid,s=typeof e=="string"?Xy.findByName(r,e):e,n=s!==null?s.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(s!==null?i=s.blendMode:i=Xb),o!==void 0){let c=o.actionByRoot[a];if(c!==void 0&&c.blendMode===i)return c;l=o.knownActions[0],s===null&&(s=l._clip)}if(s===null)return null;let h=new I8(this,s,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,a),h}existingAction(e,t){let i=t||this._root,r=i.uuid,a=typeof e=="string"?Xy.findByName(i,e):e,s=a?a.uuid:e,n=this._actionsByClip[s];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,a=Math.sign(e),s=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,a,s);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,a=r[i];if(a!==void 0){let s=a.knownActions;for(let n=0,o=s.length;n!==o;++n){let l=s[n];this._deactivateAction(l);let h=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=h,t[h]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let s in i){let n=i[s].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,a=r[t];if(a!==void 0)for(let s in a){let n=a[s];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},ke=class{constructor(e){this.value=e}clone(){return new ke(this.value.clone===void 0?this.value:this.value.clone())}},cP=class{constructor(e,t,i=0,r=1/0){this.ray=new Ud(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Qb,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return Qy(e,this,i,t),i.sort(IA),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)Qy(e[r],this,i,t);return i.sort(IA),i}};function IA(e,t){return e.distance-t.distance}function Qy(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let a=e.children;for(let s=0,n=a.length;s<n;s++)Qy(a[s],t,i,!0)}}var OA=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Tr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},RA=new ae,lw=class{constructor(e=new ae(1/0,1/0),t=new ae(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=RA.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return RA.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},LA=new O,Jf=new O,zs=class{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){LA.subVectors(e,this.start),Jf.subVectors(this.end,this.start);let i=Jf.dot(Jf),r=Jf.dot(LA)/i;return t&&(r=Tr(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},BA=new O,L8=class extends Ci{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new vt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,n=1,o=32;s<o;s++,n++){let l=s/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new nt(r,3));let a=new Ql({fog:!1,toneMapped:!1});this.cone=new qp(i,a),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),BA.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(BA),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},B8=class extends Fi{constructor(e,t,i){let r=new ld(t,4,2),a=new Vo({wireframe:!0,fog:!1,toneMapped:!1});super(r,a),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},zA=new O,$f=new O,kA=new O,z8=class extends Ci{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new vt;r.setAttribute("position",new nt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let a=new Ql({fog:!1,toneMapped:!1});this.lightPlane=new Sg(r,a),this.add(this.lightPlane),r=new vt,r.setAttribute("position",new nt([0,0,0,0,0,1],3)),this.targetLine=new Sg(r,a),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),zA.setFromMatrixPosition(this.light.matrixWorld),$f.setFromMatrixPosition(this.light.target.matrixWorld),kA.subVectors($f,zA),this.lightPlane.lookAt($f),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($f),this.targetLine.scale.z=kA.length()}},em=new O,nr=new Yl,Pg=class extends qp{constructor(e){let t=new vt,i=new Ql({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],a=[],s={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),a.push(0,0,0),s[p]===void 0&&(s[p]=[]),s[p].push(r.length/3-1)}t.setAttribute("position",new nt(r,3)),t.setAttribute("color",new nt(a,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();let l=new Ct(16755200),h=new Ct(16711680),c=new Ct(43775),d=new Ct(16777215),u=new Ct(3355443);this.setColors(l,h,c,d,u)}setColors(e,t,i,r,a){let s=this.geometry.getAttribute("color");s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,r.r,r.g,r.b),s.setXYZ(39,r.r,r.g,r.b),s.setXYZ(40,a.r,a.g,a.b),s.setXYZ(41,a.r,a.g,a.b),s.setXYZ(42,a.r,a.g,a.b),s.setXYZ(43,a.r,a.g,a.b),s.setXYZ(44,a.r,a.g,a.b),s.setXYZ(45,a.r,a.g,a.b),s.setXYZ(46,a.r,a.g,a.b),s.setXYZ(47,a.r,a.g,a.b),s.setXYZ(48,a.r,a.g,a.b),s.setXYZ(49,a.r,a.g,a.b),s.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;nr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mr("c",t,e,nr,0,0,-1),mr("t",t,e,nr,0,0,1),mr("n1",t,e,nr,-i,-r,-1),mr("n2",t,e,nr,i,-r,-1),mr("n3",t,e,nr,-i,r,-1),mr("n4",t,e,nr,i,r,-1),mr("f1",t,e,nr,-i,-r,1),mr("f2",t,e,nr,i,-r,1),mr("f3",t,e,nr,-i,r,1),mr("f4",t,e,nr,i,r,1),mr("u1",t,e,nr,i*.7,r*1.1,-1),mr("u2",t,e,nr,-i*.7,r*1.1,-1),mr("u3",t,e,nr,0,r*2,-1),mr("cf1",t,e,nr,-i,0,1),mr("cf2",t,e,nr,i,0,1),mr("cf3",t,e,nr,0,-r,1),mr("cf4",t,e,nr,0,r,1),mr("cn1",t,e,nr,-i,0,-1),mr("cn2",t,e,nr,i,0,-1),mr("cn3",t,e,nr,0,-r,-1),mr("cn4",t,e,nr,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mr(e,t,i,r,a,s,n){em.set(a,s,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],em.x,em.y,em.z)}}var Dg=class extends qp{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],a=new vt;a.setIndex(new Pt(i,1)),a.setAttribute("position",new nt(r,3)),super(a,new Ql({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},k8=class extends qp{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new vt;r.setAttribute("position",new nt(t,3)),r.setAttribute("color",new nt(i,3));let a=new Ql({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,t,i){let r=new Ct,a=this.geometry.attributes.color.array;return r.set(e),r.toArray(a,0),r.toArray(a,3),r.set(t),r.toArray(a,6),r.toArray(a,9),r.set(i),r.toArray(a,12),r.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},To=F8();function F8(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),a=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,a[l]=24,a[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,a[l]=-h-1,a[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,a[l]=13,a[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,a[l]=24,a[l|256]=24):(r[l]=31744,r[l|256]=64512,a[l]=13,a[l|256]=13)}let s=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,s[l]=h|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:a,mantissaTable:s,exponentTable:n,offsetTable:o}}function U8(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Tr(e,-65504,65504),To.floatView[0]=e;let t=To.uint32View[0],i=t>>23&511;return To.baseTable[i]+((t&8388607)>>To.shiftTable[i])}function N8(e){let t=e>>10;return To.uint32View[0]=To.mantissaTable[To.offsetTable[t]+(e&1023)]+To.exponentTable[t],To.floatView[0]}var V8=Object.freeze({__proto__:null,fromHalfFloat:N8,toHalfFloat:U8});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Fd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Fd);var Su=".",hw=Symbol("target"),dP=Symbol("unsubscribe");function Ky(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function j8(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Rn=Array.isArray;function cw(e){return typeof e=="symbol"}var H8={after:(e,t)=>Rn(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Rn(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Su),cw(t)?e+t.toString():e+t):e,initial:e=>{if(Rn(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Su);return t===-1?"":e.slice(0,t)},last:e=>{if(Rn(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Su);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Rn(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Su);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(Su,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Ps=H8;function G8(e){return typeof e=="object"&&typeof e.next=="function"}function W8(e,t,i,r,a){let s=e.next;if(t.name==="entries")e.next=function(){let n=s.call(this);return n.done===!1&&(n.value[0]=a(n.value[0],t,n.value[0],r),n.value[1]=a(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[hw].keys();e.next=function(){let o=s.call(this);return o.done===!1&&(o.value=a(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=s.call(this);return n.done===!1&&(n.value=a(n.value,t,n.value,r)),n};return e}function FA(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&cw(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var q8=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let a=e[r],s=a||e;this._pathCache.set(s,t);let n=this._proxyCache.get(s);return n===void 0&&(n=a===void 0?new Proxy(e,i):e,this._proxyCache.set(s,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Ps.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,a){if(!this._equals(a,i)||!(t in e)){let s=this._getOwnPropertyDescriptor(e,t);return s!==void 0&&"set"in s?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Zy(e){return toString.call(e)==="[object Object]"}function tm(){return!0}function Cc(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var uP=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),X8=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),pP={push:tm,pop:tm,shift:tm,unshift:tm,copyWithin:Cc,reverse:Cc,sort:Cc,splice:Cc,flat:Cc,fill:Cc},Y8=new Set([...uP,...X8,...Object.keys(pP)]);function im(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var fP=["keys","values","entries"],mP=new Set(["has","toString"]),gP={add:im,clear:im,delete:im,forEach:im},Q8=new Set([...mP,...Object.keys(gP),...fP]);function rm(e,t){if(e.size!==t.size)return!0;let i;for(let[r,a]of e)if(i=t.get(r),i!==a||i===void 0&&!t.has(r))return!0;return!1}var K8=new Set([...mP,"get"]),vP={set:rm,clear:rm,delete:rm,forEach:rm},Z8=new Set([...K8,...Object.keys(vP),...fP]),Gl=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return uP.has(e)}_shallowClone(e){let t=e;if(Zy(e))t={...e};else if(Rn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(Rn(r)?this._onIsChanged=pP[t]:r instanceof Set?this._onIsChanged=gP[t]:r instanceof Map&&(this._onIsChanged=vP[t]),r):i}update(e,t,i){let r=Ps.after(e,this._path);if(t!=="length"){let a=this.clone;Ps.walk(r,s=>{a&&a[s]&&(this._clonedCache.has(a[s])||(a[s]=this._shallowClone(a[s])),a=a[s])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),a&&a[t]&&(a[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],Ps.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},UA=class extends Gl{static isHandledMethod(e){return Y8.has(e)}},J8=class extends Gl{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},NA=class extends Gl{static isHandledMethod(e){return Q8.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},VA=class extends Gl{static isHandledMethod(e){return Z8.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},$8=class extends Gl{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},eV=class extends Gl{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Xc=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Zy(e)||Rn(e)||Ky(e)}static isHandledMethod(e,t){return Zy(e)?Gl.isHandledMethod(t):Rn(e)?UA.isHandledMethod(t):e instanceof Set?NA.isHandledMethod(t):e instanceof Map?VA.isHandledMethod(t):Ky(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Gl;Rn(e)?r=UA:e instanceof Date?r=J8:e instanceof Set?r=NA:e instanceof Map?r=VA:e instanceof WeakSet?r=$8:e instanceof WeakMap&&(r=eV),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,a=Xc.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(a,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},tV={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},dw=(e,t,i={})=>{i={...tV,...i};let r=Symbol("ProxyTarget"),{equals:a,isShallow:s,ignoreDetached:n,details:o}=i,l=new q8(a),h=typeof i.onValidate=="function",c=new Xc(h),d=(x,b,_,S,A)=>!h||c.isCloning||i.onValidate(Ps.concat(l.getPath(x),b),_,S,A)===!0,u=(x,b,_,S)=>{!FA(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,S)},p=(x,b,_,S,A)=>{c.isCloning?c.update(x,b,S):t(Ps.concat(x,b),_,S,A)},f=x=>x&&(x[r]||x),m=(x,b,_,S)=>j8(x)||_==="constructor"||s&&!Xc.isHandledMethod(b,_)||FA(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(S===void 0&&(S=l.getPath(b)),l.getProxy(x,Ps.concat(S,_),g,r)),g={get(x,b,_){if(cw(b)){if(b===r||b===hw)return x;if(b===dP&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let S=Ky(x)?Reflect.get(x,b):Reflect.get(x,b,_);return m(S,x,b)},set(x,b,_,S){_=f(_);let A=x[r]||x,E=A[b];if(a(E,_)&&b in x)return!0;let M=d(x,b,_,E);return M&&l.setProperty(A,b,_,S,E)?(u(x,b,x[b],E),!0):!M},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let S=x[b];d(x,b,_.value,S)&&l.defineProperty(x,b,_,S)&&u(x,b,_.value,S)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),S=d(x,b,void 0,_);return S&&l.deleteProperty(x,b,_)?(u(x,b,void 0,_),!0):!S},apply(x,b,_){let S=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,S,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Xc.isHandledType(S)){let A=Ps.initial(l.getPath(x)),E=Xc.isHandledMethod(S,x.name);c.start(S,A,_);let M=Reflect.apply(x,c.preferredThisArg(x,b,S),E?_.map(R=>f(R)):_),T=c.isChanged(S,a),P=c.stop();if(Xc.isHandledType(M)&&E&&(b instanceof Map&&x.name==="get"&&(A=Ps.concat(A,_[0])),M=l.getProxy(M,A,g)),T){let R={name:x.name,args:_,result:M},z=c.isCloning?Ps.initial(A):A,U=c.isCloning?Ps.last(A):"";d(Ps.get(e,z),U,S,P,R)?p(z,U,S,P,R):c.undo(S)}return(b instanceof Map||b instanceof Set)&&G8(M)?W8(M,x,b,A,m):M}return Reflect.apply(x,b,_)}},y=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};dw.target=e=>e&&e[hw]||e;dw.unsubscribe=e=>e[dP]||e;var jA=dw,iV=typeof global=="object"&&global&&global.Object===Object&&global,yP=iV,rV=typeof self=="object"&&self&&self.Object===Object&&self,aV=yP||rV||Function("return this")(),hn=aV,sV=hn.Symbol,ks=sV,xP=Object.prototype,nV=xP.hasOwnProperty,oV=xP.toString,Au=ks?ks.toStringTag:void 0;function lV(e){var t=nV.call(e,Au),i=e[Au];try{e[Au]=void 0;var r=!0}catch{}var a=oV.call(e);return r&&(t?e[Au]=i:delete e[Au]),a}var hV=lV,cV=Object.prototype,dV=cV.toString;function uV(e){return dV.call(e)}var pV=uV,fV="[object Null]",mV="[object Undefined]",HA=ks?ks.toStringTag:void 0;function gV(e){return e==null?e===void 0?mV:fV:HA&&HA in Object(e)?hV(e):pV(e)}var Xh=gV;function vV(e){return e!=null&&typeof e=="object"}var jo=vV,yV="[object Symbol]";function xV(e){return typeof e=="symbol"||jo(e)&&Xh(e)==yV}var Kp=xV;function bV(e,t){for(var i=-1,r=e==null?0:e.length,a=Array(r);++i<r;)a[i]=t(e[i],i,e);return a}var bP=bV,wV=Array.isArray,Wn=wV,_V=1/0,GA=ks?ks.prototype:void 0,WA=GA?GA.toString:void 0;function wP(e){if(typeof e=="string")return e;if(Wn(e))return bP(e,wP)+"";if(Kp(e))return WA?WA.call(e):"";var t=e+"";return t=="0"&&1/e==-_V?"-0":t}var _P=wP,SV=/\s/;function AV(e){for(var t=e.length;t--&&SV.test(e.charAt(t)););return t}var SP=AV,MV=/^\s+/;function EV(e){return e&&e.slice(0,SP(e)+1).replace(MV,"")}var CV=EV;function TV(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ds=TV,qA=0/0,PV=/^[-+]0x[0-9a-f]+$/i,DV=/^0b[01]+$/i,IV=/^0o[0-7]+$/i,OV=parseInt;function RV(e){if(typeof e=="number")return e;if(Kp(e))return qA;if(ds(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ds(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=CV(e);var i=DV.test(e);return i||IV.test(e)?OV(e.slice(2),i?2:8):PV.test(e)?qA:+e}var XA=RV;function LV(e){return e}var AP=LV,BV="[object AsyncFunction]",zV="[object Function]",kV="[object GeneratorFunction]",FV="[object Proxy]";function UV(e){if(!ds(e))return!1;var t=Xh(e);return t==zV||t==kV||t==BV||t==FV}var MP=UV,NV=hn["__core-js_shared__"],d1=NV,YA=function(){var e=/[^.]+$/.exec(d1&&d1.keys&&d1.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function VV(e){return!!YA&&YA in e}var jV=VV,HV=Function.prototype,GV=HV.toString;function WV(e){if(e!=null){try{return GV.call(e)}catch{}try{return e+""}catch{}}return""}var Yh=WV,qV=/[\\^$.*+?()[\]{}|]/g,XV=/^\[object .+?Constructor\]$/,YV=Function.prototype,QV=Object.prototype,KV=YV.toString,ZV=QV.hasOwnProperty,JV=RegExp("^"+KV.call(ZV).replace(qV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $V(e){if(!ds(e)||jV(e))return!1;var t=MP(e)?JV:XV;return t.test(Yh(e))}var ej=$V;function tj(e,t){return e?.[t]}var ij=tj;function rj(e,t){var i=ij(e,t);return ej(i)?i:void 0}var Qh=rj,aj=Qh(hn,"WeakMap"),Jy=aj,QA=Object.create,sj=function(){function e(){}return function(t){if(!ds(t))return{};if(QA)return QA(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),nj=sj;function oj(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var lj=oj;function hj(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var cj=hj,dj=800,uj=16,pj=Date.now;function fj(e){var t=0,i=0;return function(){var r=pj(),a=uj-(r-i);if(i=r,a>0){if(++t>=dj)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var mj=fj;function gj(e){return function(){return e}}var vj=gj,yj=function(){try{var e=Qh(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Ig=yj,xj=Ig?function(e,t){return Ig(e,"toString",{configurable:!0,enumerable:!1,value:vj(t),writable:!0})}:AP,bj=xj,wj=mj(bj),_j=wj;function Sj(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var Aj=Sj;function Mj(e,t,i,r){for(var a=e.length,s=i+(r?1:-1);r?s--:++s<a;)if(t(e[s],s,e))return s;return-1}var Ej=Mj;function Cj(e){return e!==e}var Tj=Cj;function Pj(e,t,i){for(var r=i-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}var Dj=Pj;function Ij(e,t,i){return t===t?Dj(e,t,i):Ej(e,Tj,i)}var Oj=Ij,Rj=9007199254740991,Lj=/^(?:0|[1-9]\d*)$/;function Bj(e,t){var i=typeof e;return t=t??Rj,!!t&&(i=="number"||i!="symbol"&&Lj.test(e))&&e>-1&&e%1==0&&e<t}var uw=Bj;function zj(e,t,i){t=="__proto__"&&Ig?Ig(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var EP=zj;function kj(e,t){return e===t||e!==e&&t!==t}var pw=kj,Fj=Object.prototype,Uj=Fj.hasOwnProperty;function Nj(e,t,i){var r=e[t];(!(Uj.call(e,t)&&pw(r,i))||i===void 0&&!(t in e))&&EP(e,t,i)}var fw=Nj;function Vj(e,t,i,r){var a=!i;i||(i={});for(var s=-1,n=t.length;++s<n;){var o=t[s],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),a?EP(i,o,l):fw(i,o,l)}return i}var Zp=Vj,KA=Math.max;function jj(e,t,i){return t=KA(t===void 0?e.length-1:t,0),function(){for(var r=arguments,a=-1,s=KA(r.length-t,0),n=Array(s);++a<s;)n[a]=r[t+a];a=-1;for(var o=Array(t+1);++a<t;)o[a]=r[a];return o[t]=i(n),lj(e,this,o)}}var Hj=jj,Gj=9007199254740991;function Wj(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Gj}var mw=Wj;function qj(e){return e!=null&&mw(e.length)&&!MP(e)}var CP=qj,Xj=Object.prototype;function Yj(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||Xj;return e===i}var gw=Yj;function Qj(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var Kj=Qj,Zj="[object Arguments]";function Jj(e){return jo(e)&&Xh(e)==Zj}var ZA=Jj,TP=Object.prototype,$j=TP.hasOwnProperty,eH=TP.propertyIsEnumerable,tH=ZA(function(){return arguments}())?ZA:function(e){return jo(e)&&$j.call(e,"callee")&&!eH.call(e,"callee")},vw=tH;function iH(){return!1}var rH=iH,PP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,JA=PP&&typeof module=="object"&&module&&!module.nodeType&&module,aH=JA&&JA.exports===PP,$A=aH?hn.Buffer:void 0,sH=$A?$A.isBuffer:void 0,nH=sH||rH,Og=nH,oH="[object Arguments]",lH="[object Array]",hH="[object Boolean]",cH="[object Date]",dH="[object Error]",uH="[object Function]",pH="[object Map]",fH="[object Number]",mH="[object Object]",gH="[object RegExp]",vH="[object Set]",yH="[object String]",xH="[object WeakMap]",bH="[object ArrayBuffer]",wH="[object DataView]",_H="[object Float32Array]",SH="[object Float64Array]",AH="[object Int8Array]",MH="[object Int16Array]",EH="[object Int32Array]",CH="[object Uint8Array]",TH="[object Uint8ClampedArray]",PH="[object Uint16Array]",DH="[object Uint32Array]",Wi={};Wi[_H]=Wi[SH]=Wi[AH]=Wi[MH]=Wi[EH]=Wi[CH]=Wi[TH]=Wi[PH]=Wi[DH]=!0;Wi[oH]=Wi[lH]=Wi[bH]=Wi[hH]=Wi[wH]=Wi[cH]=Wi[dH]=Wi[uH]=Wi[pH]=Wi[fH]=Wi[mH]=Wi[gH]=Wi[vH]=Wi[yH]=Wi[xH]=!1;function IH(e){return jo(e)&&mw(e.length)&&!!Wi[Xh(e)]}var OH=IH;function RH(e){return function(t){return e(t)}}var yw=RH,DP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,op=DP&&typeof module=="object"&&module&&!module.nodeType&&module,LH=op&&op.exports===DP,u1=LH&&yP.process,BH=function(){try{var e=op&&op.require&&op.require("util").types;return e||u1&&u1.binding&&u1.binding("util")}catch{}}(),Ad=BH,eM=Ad&&Ad.isTypedArray,zH=eM?yw(eM):OH,IP=zH,kH=Object.prototype,FH=kH.hasOwnProperty;function UH(e,t){var i=Wn(e),r=!i&&vw(e),a=!i&&!r&&Og(e),s=!i&&!r&&!a&&IP(e),n=i||r||a||s,o=n?Kj(e.length,String):[],l=o.length;for(var h in e)(t||FH.call(e,h))&&!(n&&(h=="length"||a&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||uw(h,l)))&&o.push(h);return o}var OP=UH;function NH(e,t){return function(i){return e(t(i))}}var RP=NH,VH=RP(Object.keys,Object),jH=VH,HH=Object.prototype,GH=HH.hasOwnProperty;function WH(e){if(!gw(e))return jH(e);var t=[];for(var i in Object(e))GH.call(e,i)&&i!="constructor"&&t.push(i);return t}var qH=WH;function XH(e){return CP(e)?OP(e):qH(e)}var xw=XH;function YH(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var QH=YH,KH=Object.prototype,ZH=KH.hasOwnProperty;function JH(e){if(!ds(e))return QH(e);var t=gw(e),i=[];for(var r in e)r=="constructor"&&(t||!ZH.call(e,r))||i.push(r);return i}var $H=JH;function e9(e){return CP(e)?OP(e,!0):$H(e)}var Sh=e9,t9=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i9=/^\w*$/;function r9(e,t){if(Wn(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Kp(e)?!0:i9.test(e)||!t9.test(e)||t!=null&&e in Object(t)}var a9=r9,s9=Qh(Object,"create"),Cp=s9;function n9(){this.__data__=Cp?Cp(null):{},this.size=0}var o9=n9;function l9(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var h9=l9,c9="__lodash_hash_undefined__",d9=Object.prototype,u9=d9.hasOwnProperty;function p9(e){var t=this.__data__;if(Cp){var i=t[e];return i===c9?void 0:i}return u9.call(t,e)?t[e]:void 0}var f9=p9,m9=Object.prototype,g9=m9.hasOwnProperty;function v9(e){var t=this.__data__;return Cp?t[e]!==void 0:g9.call(t,e)}var y9=v9,x9="__lodash_hash_undefined__";function b9(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Cp&&t===void 0?x9:t,this}var w9=b9;function Gd(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Gd.prototype.clear=o9;Gd.prototype.delete=h9;Gd.prototype.get=f9;Gd.prototype.has=y9;Gd.prototype.set=w9;var tM=Gd;function _9(){this.__data__=[],this.size=0}var S9=_9;function A9(e,t){for(var i=e.length;i--;)if(pw(e[i][0],t))return i;return-1}var Iv=A9,M9=Array.prototype,E9=M9.splice;function C9(e){var t=this.__data__,i=Iv(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():E9.call(t,i,1),--this.size,!0}var T9=C9;function P9(e){var t=this.__data__,i=Iv(t,e);return i<0?void 0:t[i][1]}var D9=P9;function I9(e){return Iv(this.__data__,e)>-1}var O9=I9;function R9(e,t){var i=this.__data__,r=Iv(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var L9=R9;function Wd(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Wd.prototype.clear=S9;Wd.prototype.delete=T9;Wd.prototype.get=D9;Wd.prototype.has=O9;Wd.prototype.set=L9;var Ov=Wd,B9=Qh(hn,"Map"),Tp=B9;function z9(){this.size=0,this.__data__={hash:new tM,map:new(Tp||Ov),string:new tM}}var k9=z9;function F9(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var U9=F9;function N9(e,t){var i=e.__data__;return U9(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Rv=N9;function V9(e){var t=Rv(this,e).delete(e);return this.size-=t?1:0,t}var j9=V9;function H9(e){return Rv(this,e).get(e)}var G9=H9;function W9(e){return Rv(this,e).has(e)}var q9=W9;function X9(e,t){var i=Rv(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Y9=X9;function qd(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}qd.prototype.clear=k9;qd.prototype.delete=j9;qd.prototype.get=G9;qd.prototype.has=q9;qd.prototype.set=Y9;var Lv=qd,Q9="Expected a function";function bw(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Q9);var i=function(){var r=arguments,a=t?t.apply(this,r):r[0],s=i.cache;if(s.has(a))return s.get(a);var n=e.apply(this,r);return i.cache=s.set(a,n)||s,n};return i.cache=new(bw.Cache||Lv),i}bw.Cache=Lv;var K9=bw,Z9=500;function J9(e){var t=K9(e,function(r){return i.size===Z9&&i.clear(),r}),i=t.cache;return t}var $9=J9,e7=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t7=/\\(\\)?/g,i7=$9(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(e7,function(i,r,a,s){t.push(a?s.replace(t7,"$1"):r||i)}),t}),r7=i7;function a7(e){return e==null?"":_P(e)}var LP=a7;function s7(e,t){return Wn(e)?e:a9(e,t)?[e]:r7(LP(e))}var Xd=s7,n7=1/0;function o7(e){if(typeof e=="string"||Kp(e))return e;var t=e+"";return t=="0"&&1/e==-n7?"-0":t}var Bv=o7;function l7(e,t){t=Xd(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Bv(t[i++])];return i&&i==r?e:void 0}var BP=l7;function h7(e,t){for(var i=-1,r=t.length,a=e.length;++i<r;)e[a+i]=t[i];return e}var ww=h7,iM=ks?ks.isConcatSpreadable:void 0;function c7(e){return Wn(e)||vw(e)||!!(iM&&e&&e[iM])}var d7=c7;function zP(e,t,i,r,a){var s=-1,n=e.length;for(i||(i=d7),a||(a=[]);++s<n;){var o=e[s];t>0&&i(o)?t>1?zP(o,t-1,i,r,a):ww(a,o):r||(a[a.length]=o)}return a}var u7=zP;function p7(e){var t=e==null?0:e.length;return t?u7(e,1):[]}var f7=p7;function m7(e){return _j(Hj(e,void 0,f7),e+"")}var kP=m7,g7=RP(Object.getPrototypeOf,Object),_w=g7,v7="[object Object]",y7=Function.prototype,x7=Object.prototype,FP=y7.toString,b7=x7.hasOwnProperty,w7=FP.call(Object);function _7(e){if(!jo(e)||Xh(e)!=v7)return!1;var t=_w(e);if(t===null)return!0;var i=b7.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&FP.call(i)==w7}var S7=_7;function A7(e,t,i){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),i=i>a?a:i,i<0&&(i+=a),a=t>i?0:i-t>>>0,t>>>=0;for(var s=Array(a);++r<a;)s[r]=e[r+t];return s}var UP=A7;function M7(e,t,i){var r=e.length;return i=i===void 0?r:i,!t&&i>=r?e:UP(e,t,i)}var E7=M7,C7="\\ud800-\\udfff",T7="\\u0300-\\u036f",P7="\\ufe20-\\ufe2f",D7="\\u20d0-\\u20ff",I7=T7+P7+D7,O7="\\ufe0e\\ufe0f",R7="\\u200d",L7=RegExp("["+R7+C7+I7+O7+"]");function B7(e){return L7.test(e)}var z7=B7;function k7(e){return e.split("")}var F7=k7,NP="\\ud800-\\udfff",U7="\\u0300-\\u036f",N7="\\ufe20-\\ufe2f",V7="\\u20d0-\\u20ff",j7=U7+N7+V7,H7="\\ufe0e\\ufe0f",G7="["+NP+"]",$y="["+j7+"]",ex="\\ud83c[\\udffb-\\udfff]",W7="(?:"+$y+"|"+ex+")",VP="[^"+NP+"]",jP="(?:\\ud83c[\\udde6-\\uddff]){2}",HP="[\\ud800-\\udbff][\\udc00-\\udfff]",q7="\\u200d",GP=W7+"?",WP="["+H7+"]?",X7="(?:"+q7+"(?:"+[VP,jP,HP].join("|")+")"+WP+GP+")*",Y7=WP+GP+X7,Q7="(?:"+[VP+$y+"?",$y,jP,HP,G7].join("|")+")",K7=RegExp(ex+"(?="+ex+")|"+Q7+Y7,"g");function Z7(e){return e.match(K7)||[]}var J7=Z7;function $7(e){return z7(e)?J7(e):F7(e)}var rM=$7;function eG(){this.__data__=new Ov,this.size=0}var tG=eG;function iG(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var rG=iG;function aG(e){return this.__data__.get(e)}var sG=aG;function nG(e){return this.__data__.has(e)}var oG=nG,lG=200;function hG(e,t){var i=this.__data__;if(i instanceof Ov){var r=i.__data__;if(!Tp||r.length<lG-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Lv(r)}return i.set(e,t),this.size=i.size,this}var cG=hG;function Yd(e){var t=this.__data__=new Ov(e);this.size=t.size}Yd.prototype.clear=tG;Yd.prototype.delete=rG;Yd.prototype.get=sG;Yd.prototype.has=oG;Yd.prototype.set=cG;var rg=Yd;function dG(e,t){return e&&Zp(t,xw(t),e)}var uG=dG;function pG(e,t){return e&&Zp(t,Sh(t),e)}var fG=pG,qP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,aM=qP&&typeof module=="object"&&module&&!module.nodeType&&module,mG=aM&&aM.exports===qP,sM=mG?hn.Buffer:void 0,nM=sM?sM.allocUnsafe:void 0;function gG(e,t){if(t)return e.slice();var i=e.length,r=nM?nM(i):new e.constructor(i);return e.copy(r),r}var vG=gG;function yG(e,t){for(var i=-1,r=e==null?0:e.length,a=0,s=[];++i<r;){var n=e[i];t(n,i,e)&&(s[a++]=n)}return s}var xG=yG;function bG(){return[]}var XP=bG,wG=Object.prototype,_G=wG.propertyIsEnumerable,oM=Object.getOwnPropertySymbols,SG=oM?function(e){return e==null?[]:(e=Object(e),xG(oM(e),function(t){return _G.call(e,t)}))}:XP,Sw=SG;function AG(e,t){return Zp(e,Sw(e),t)}var MG=AG,EG=Object.getOwnPropertySymbols,CG=EG?function(e){for(var t=[];e;)ww(t,Sw(e)),e=_w(e);return t}:XP,YP=CG;function TG(e,t){return Zp(e,YP(e),t)}var PG=TG;function DG(e,t,i){var r=t(e);return Wn(e)?r:ww(r,i(e))}var QP=DG;function IG(e){return QP(e,xw,Sw)}var tx=IG;function OG(e){return QP(e,Sh,YP)}var KP=OG,RG=Qh(hn,"DataView"),ix=RG,LG=Qh(hn,"Promise"),rx=LG,BG=Qh(hn,"Set"),ax=BG,lM="[object Map]",zG="[object Object]",hM="[object Promise]",cM="[object Set]",dM="[object WeakMap]",uM="[object DataView]",kG=Yh(ix),FG=Yh(Tp),UG=Yh(rx),NG=Yh(ax),VG=Yh(Jy),fh=Xh;(ix&&fh(new ix(new ArrayBuffer(1)))!=uM||Tp&&fh(new Tp)!=lM||rx&&fh(rx.resolve())!=hM||ax&&fh(new ax)!=cM||Jy&&fh(new Jy)!=dM)&&(fh=function(e){var t=Xh(e),i=t==zG?e.constructor:void 0,r=i?Yh(i):"";if(r)switch(r){case kG:return uM;case FG:return lM;case UG:return hM;case NG:return cM;case VG:return dM}return t});var Pp=fh,jG=Object.prototype,HG=jG.hasOwnProperty;function GG(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&HG.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var WG=GG,qG=hn.Uint8Array,Rg=qG;function XG(e){var t=new e.constructor(e.byteLength);return new Rg(t).set(new Rg(e)),t}var Aw=XG;function YG(e,t){var i=t?Aw(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var QG=YG,KG=/\w*$/;function ZG(e){var t=new e.constructor(e.source,KG.exec(e));return t.lastIndex=e.lastIndex,t}var JG=ZG,pM=ks?ks.prototype:void 0,fM=pM?pM.valueOf:void 0;function $G(e){return fM?Object(fM.call(e)):{}}var eW=$G;function tW(e,t){var i=t?Aw(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var iW=tW,rW="[object Boolean]",aW="[object Date]",sW="[object Map]",nW="[object Number]",oW="[object RegExp]",lW="[object Set]",hW="[object String]",cW="[object Symbol]",dW="[object ArrayBuffer]",uW="[object DataView]",pW="[object Float32Array]",fW="[object Float64Array]",mW="[object Int8Array]",gW="[object Int16Array]",vW="[object Int32Array]",yW="[object Uint8Array]",xW="[object Uint8ClampedArray]",bW="[object Uint16Array]",wW="[object Uint32Array]";function _W(e,t,i){var r=e.constructor;switch(t){case dW:return Aw(e);case rW:case aW:return new r(+e);case uW:return QG(e,i);case pW:case fW:case mW:case gW:case vW:case yW:case xW:case bW:case wW:return iW(e,i);case sW:return new r;case nW:case hW:return new r(e);case oW:return JG(e);case lW:return new r;case cW:return eW(e)}}var SW=_W;function AW(e){return typeof e.constructor=="function"&&!gw(e)?nj(_w(e)):{}}var MW=AW,EW="[object Map]";function CW(e){return jo(e)&&Pp(e)==EW}var TW=CW,mM=Ad&&Ad.isMap,PW=mM?yw(mM):TW,DW=PW,IW="[object Set]";function OW(e){return jo(e)&&Pp(e)==IW}var RW=OW,gM=Ad&&Ad.isSet,LW=gM?yw(gM):RW,BW=LW,zW=1,kW=2,FW=4,ZP="[object Arguments]",UW="[object Array]",NW="[object Boolean]",VW="[object Date]",jW="[object Error]",JP="[object Function]",HW="[object GeneratorFunction]",GW="[object Map]",WW="[object Number]",$P="[object Object]",qW="[object RegExp]",XW="[object Set]",YW="[object String]",QW="[object Symbol]",KW="[object WeakMap]",ZW="[object ArrayBuffer]",JW="[object DataView]",$W="[object Float32Array]",eq="[object Float64Array]",tq="[object Int8Array]",iq="[object Int16Array]",rq="[object Int32Array]",aq="[object Uint8Array]",sq="[object Uint8ClampedArray]",nq="[object Uint16Array]",oq="[object Uint32Array]",Vi={};Vi[ZP]=Vi[UW]=Vi[ZW]=Vi[JW]=Vi[NW]=Vi[VW]=Vi[$W]=Vi[eq]=Vi[tq]=Vi[iq]=Vi[rq]=Vi[GW]=Vi[WW]=Vi[$P]=Vi[qW]=Vi[XW]=Vi[YW]=Vi[QW]=Vi[aq]=Vi[sq]=Vi[nq]=Vi[oq]=!0;Vi[jW]=Vi[JP]=Vi[KW]=!1;function ag(e,t,i,r,a,s){var n,o=t&zW,l=t&kW,h=t&FW;if(i&&(n=a?i(e,r,a,s):i(e)),n!==void 0)return n;if(!ds(e))return e;var c=Wn(e);if(c){if(n=WG(e),!o)return cj(e,n)}else{var d=Pp(e),u=d==JP||d==HW;if(Og(e))return vG(e,o);if(d==$P||d==ZP||u&&!a){if(n=l||u?{}:MW(e),!o)return l?PG(e,fG(n,e)):MG(e,uG(n,e))}else{if(!Vi[d])return a?e:{};n=SW(e,d,o)}}s||(s=new rg);var p=s.get(e);if(p)return p;s.set(e,n),BW(e)?e.forEach(function(g){n.add(ag(g,t,i,g,e,s))}):DW(e)&&e.forEach(function(g,y){n.set(y,ag(g,t,i,y,e,s))});var f=h?l?KP:tx:l?Sh:xw,m=c?void 0:f(e);return Aj(m||e,function(g,y){m&&(y=g,g=e[y]),fw(n,y,ag(g,t,i,y,e,s))}),n}var eD=ag,lq=1,hq=4;function cq(e){return eD(e,lq|hq)}var zv=cq,dq="__lodash_hash_undefined__";function uq(e){return this.__data__.set(e,dq),this}var pq=uq;function fq(e){return this.__data__.has(e)}var mq=fq;function Lg(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Lv;++t<i;)this.add(e[t])}Lg.prototype.add=Lg.prototype.push=pq;Lg.prototype.has=mq;var gq=Lg;function vq(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var yq=vq;function xq(e,t){return e.has(t)}var bq=xq,wq=1,_q=2;function Sq(e,t,i,r,a,s){var n=i&wq,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=s.get(e),c=s.get(t);if(h&&c)return h==t&&c==e;var d=-1,u=!0,p=i&_q?new gq:void 0;for(s.set(e,t),s.set(t,e);++d<o;){var f=e[d],m=t[d];if(r)var g=n?r(m,f,d,t,e,s):r(f,m,d,e,t,s);if(g!==void 0){if(g)continue;u=!1;break}if(p){if(!yq(t,function(y,x){if(!bq(p,x)&&(f===y||a(f,y,i,r,s)))return p.push(x)})){u=!1;break}}else if(!(f===m||a(f,m,i,r,s))){u=!1;break}}return s.delete(e),s.delete(t),u}var tD=Sq;function Aq(e){var t=-1,i=Array(e.size);return e.forEach(function(r,a){i[++t]=[a,r]}),i}var Mq=Aq;function Eq(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var Cq=Eq,Tq=1,Pq=2,Dq="[object Boolean]",Iq="[object Date]",Oq="[object Error]",Rq="[object Map]",Lq="[object Number]",Bq="[object RegExp]",zq="[object Set]",kq="[object String]",Fq="[object Symbol]",Uq="[object ArrayBuffer]",Nq="[object DataView]",vM=ks?ks.prototype:void 0,p1=vM?vM.valueOf:void 0;function Vq(e,t,i,r,a,s,n){switch(i){case Nq:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Uq:return!(e.byteLength!=t.byteLength||!s(new Rg(e),new Rg(t)));case Dq:case Iq:case Lq:return pw(+e,+t);case Oq:return e.name==t.name&&e.message==t.message;case Bq:case kq:return e==t+"";case Rq:var o=Mq;case zq:var l=r&Tq;if(o||(o=Cq),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=Pq,n.set(e,t);var c=tD(o(e),o(t),r,a,s,n);return n.delete(e),c;case Fq:if(p1)return p1.call(e)==p1.call(t)}return!1}var jq=Vq,Hq=1,Gq=Object.prototype,Wq=Gq.hasOwnProperty;function qq(e,t,i,r,a,s){var n=i&Hq,o=tx(e),l=o.length,h=tx(t),c=h.length;if(l!=c&&!n)return!1;for(var d=l;d--;){var u=o[d];if(!(n?u in t:Wq.call(t,u)))return!1}var p=s.get(e),f=s.get(t);if(p&&f)return p==t&&f==e;var m=!0;s.set(e,t),s.set(t,e);for(var g=n;++d<l;){u=o[d];var y=e[u],x=t[u];if(r)var b=n?r(x,y,u,t,e,s):r(y,x,u,e,t,s);if(!(b===void 0?y===x||a(y,x,i,r,s):b)){m=!1;break}g||(g=u=="constructor")}if(m&&!g){var _=e.constructor,S=t.constructor;_!=S&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof S=="function"&&S instanceof S)&&(m=!1)}return s.delete(e),s.delete(t),m}var Xq=qq,Yq=1,yM="[object Arguments]",xM="[object Array]",am="[object Object]",Qq=Object.prototype,bM=Qq.hasOwnProperty;function Kq(e,t,i,r,a,s){var n=Wn(e),o=Wn(t),l=n?xM:Pp(e),h=o?xM:Pp(t);l=l==yM?am:l,h=h==yM?am:h;var c=l==am,d=h==am,u=l==h;if(u&&Og(e)){if(!Og(t))return!1;n=!0,c=!1}if(u&&!c)return s||(s=new rg),n||IP(e)?tD(e,t,i,r,a,s):jq(e,t,l,i,r,a,s);if(!(i&Yq)){var p=c&&bM.call(e,"__wrapped__"),f=d&&bM.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return s||(s=new rg),a(m,g,i,r,s)}}return u?(s||(s=new rg),Xq(e,t,i,r,a,s)):!1}var Zq=Kq;function iD(e,t,i,r,a){return e===t?!0:e==null||t==null||!jo(e)&&!jo(t)?e!==e&&t!==t:Zq(e,t,i,r,iD,a)}var Jq=iD;function $q(e,t){return e!=null&&t in Object(e)}var eX=$q;function tX(e,t,i){t=Xd(t,e);for(var r=-1,a=t.length,s=!1;++r<a;){var n=Bv(t[r]);if(!(s=e!=null&&i(e,n)))break;e=e[n]}return s||++r!=a?s:(a=e==null?0:e.length,!!a&&mw(a)&&uw(n,a)&&(Wn(e)||vw(e)))}var iX=tX;function rX(e,t){return e!=null&&iX(e,t,eX)}var aX=rX,sX=function(){return hn.Date.now()},f1=sX,nX="Expected a function",oX=Math.max,lX=Math.min;function hX(e,t,i){var r,a,s,n,o,l,h=0,c=!1,d=!1,u=!0;if(typeof e!="function")throw new TypeError(nX);t=XA(t)||0,ds(i)&&(c=!!i.leading,d="maxWait"in i,s=d?oX(XA(i.maxWait)||0,t):s,u="trailing"in i?!!i.trailing:u);function p(A){var E=r,M=a;return r=a=void 0,h=A,n=e.apply(M,E),n}function f(A){return h=A,o=setTimeout(y,t),c?p(A):n}function m(A){var E=A-l,M=A-h,T=t-E;return d?lX(T,s-M):T}function g(A){var E=A-l,M=A-h;return l===void 0||E>=t||E<0||d&&M>=s}function y(){var A=f1();if(g(A))return x(A);o=setTimeout(y,m(A))}function x(A){return o=void 0,u&&r?p(A):(r=a=void 0,n)}function b(){o!==void 0&&clearTimeout(o),h=0,r=l=a=o=void 0}function _(){return o===void 0?n:x(f1())}function S(){var A=f1(),E=g(A);if(r=arguments,a=this,l=A,E){if(o===void 0)return f(l);if(d)return clearTimeout(o),o=setTimeout(y,t),p(l)}return o===void 0&&(o=setTimeout(y,t)),n}return S.cancel=b,S.flush=_,S}var Dp=hX;function cX(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var dX=cX;function uX(e,t){return e>t}var pX=uX;function fX(e,t){return t.length<2?e:BP(e,UP(t,0,-1))}var mX=fX;function gX(e,t){return Jq(e,t)}var Mw=gX;function vX(e,t,i){for(var r=-1,a=e.length;++r<a;){var s=e[r],n=t(s);if(n!=null&&(o===void 0?n===n&&!Kp(n):i(n,o)))var o=n,l=s}return l}var yX=vX;function xX(e){return e&&e.length?yX(e,AP,pX):void 0}var bX=xX;function wX(e,t){return t=Xd(t,e),e=mX(e,t),e==null||delete e[Bv(dX(t))]}var _X=wX;function SX(e){return S7(e)?void 0:e}var AX=SX,MX=1,EX=2,CX=4,TX=kP(function(e,t){var i={};if(e==null)return i;var r=!1;t=bP(t,function(s){return s=Xd(s,e),r||(r=s.length>1),s}),Zp(e,KP(e),i),r&&(i=eD(i,MX|EX|CX,AX));for(var a=t.length;a--;)_X(i,t[a]);return i}),sx=TX;function PX(e,t,i,r){if(!ds(e))return e;t=Xd(t,e);for(var a=-1,s=t.length,n=s-1,o=e;o!=null&&++a<s;){var l=Bv(t[a]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(a!=n){var c=o[l];h=r?r(c,l,o):void 0,h===void 0&&(h=ds(c)?c:uw(t[a+1])?[]:{})}fw(o,l,h),o=o[l]}return e}var DX=PX;function IX(e,t,i){for(var r=-1,a=t.length,s={};++r<a;){var n=t[r],o=BP(e,n);i(o,n)&&DX(s,Xd(n,e),o)}return s}var OX=IX;function RX(e,t){return OX(e,t,function(i,r){return aX(e,r)})}var LX=RX,BX=kP(function(e,t){return e==null?{}:LX(e,t)}),Vn=BX,zX="Expected a function";function kX(e,t,i){var r=!0,a=!0;if(typeof e!="function")throw new TypeError(zX);return ds(i)&&(r="leading"in i?!!i.leading:r,a="trailing"in i?!!i.trailing:a),Dp(e,t,{leading:r,maxWait:t,trailing:a})}var FX=kX;function UX(e,t){for(var i=e.length;i--&&Oj(t,e[i],0)>-1;);return i}var NX=UX;function VX(e,t,i){if(e=LP(e),e&&(i||t===void 0))return e.slice(0,SP(e)+1);if(!e||!(t=_P(t)))return e;var r=rM(e),a=NX(r,rM(t))+1;return E7(r,0,a).join("")}var jX=VX;function rD(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function rs(e,t){return Object.setPrototypeOf(e,t),e}var HX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),GX=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),WX=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||kv&&"ontouchend"in document,qX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,XX=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,YX=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},QX=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},KX=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},aD=HX(),Yle=aD?KX():void 0,kv=GX(),Qd=WX(),ZX=qX(),hs=XX(),wM=YX(),JX=Number(QX());function sD(e){return Array.isArray(e)?e:[e]}function nD(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function sm(e){return kv?e.metaKey:e.ctrlKey}function $X(e){return e.wheelDeltaY===0||e.deltaY===0?kv&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var Ot=[],Bg={},Qu={},sg={};function oD(e){Ot.includes(e)||Ot.push(e)}function hd(e){delete Bg[e.pointerId];for(let t=0;t<Ot.length;t++)if(Ot[t].pointerId===e.pointerId){Ot.splice(t,1);break}}function eY(){Ot.splice(0,Ot.length)}function zg(e){if(e.pointerType!=="touch")return;let t=Bg[e.pointerId];t===void 0&&(t={x:0,y:0},Bg[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function m1(e){let t=e.pointerId===Ot[0].pointerId?Ot[1]:Ot[0];return Bg[t.pointerId]}function lD(e){Qu[e.key]=!0,sg[e.key]=sg[e.key]===void 0?1:sg[e.key]+1}function hD(e){if(kv&&Qu.Meta)for(let t in Qu)Qu[t]=!1;else Qu[e.key]=!1;sg={}}function tY(e){e.addEventListener("pointerdown",oD,!0),e.addEventListener("pointerdown",zg,!0),e.addEventListener("pointermove",zg,!0),e.addEventListener("pointerup",hd,!0),e.addEventListener("pointercancel",hd,!0),e.addEventListener("pointerleave",hd,!0),window.addEventListener("keydown",lD,!0),window.addEventListener("keyup",hD,!0)}function iY(e){e.removeEventListener("pointerdown",oD,!0),e.removeEventListener("pointerdown",zg,!0),e.removeEventListener("pointermove",zg,!0),e.removeEventListener("pointerup",hd,!0),e.removeEventListener("pointercancel",hd,!0),e.removeEventListener("pointerleave",hd,!0),window.removeEventListener("keydown",lD,!0),window.removeEventListener("keyup",hD,!0)}var cD,rY=new Promise(e=>{cD=e}),nm;function aY(e){if(nm)return nm;async function t(){let i=e??"https://unpkg.com/@splinetool/navmesh-wasm@1.12.54/build",r=import("./navmesh.js"),[a,s]=await Promise.all([r,fetch(`${i}/navmesh.wasm`).then(l=>l.arrayBuffer())]),n=a.default,o=await n({wasmBinary:s});cD(o)}return nm=t(),nm}var dD,sY=new Promise(e=>{dD=e}),om;function nY(){if(om)return om;async function e(){let t=await import("./physics.js");await t.init(),dD(t)}return om=e(),om}var bt=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,bt.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:a,data:s}=e,n={...t,[a]:s};return Object.setPrototypeOf(n,bt.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let a={...t};return Object.setPrototypeOf(a,bt.prototype),delete a[i],{data:a,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Ew(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&Ew(r)}return Object.freeze(e)}function oY(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var uD=class extends Error{};function g1(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Cl(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],a=1/(i+1);for(let s=0;s<i;s++){let n=e+(t-e)*(s+.75+Math.random()*.5)*a;r.push(n)}return r}function Cw(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function lY(){return typeof process<"u"}function pD(e,t){for(let i of e)t(i.id,i.data)!==!0&&pD(i.children,t)}function fD(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)fD(i,t)}var xa=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,xa.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ew(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&fD(i,t)}}traverse(e){pD(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),a=r.findIndex(n=>n.id===e);if(a<0)throw new Error("not expected");let s=r[a];return r=[...r],r[a]={...s,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let s=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:s}}Object.setPrototypeOf(r,xa.prototype);let a=r;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:a,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:a,children:s};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),a=r.findIndex(n=>n.id===t);e.localIndex=a,r=[...r];let s=r.splice(a,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new uD("cyclic tree");d=this.parent(d)}}let a=this.parent(r);if(a===void 0)return null;let s=a,n=this.childrenArray(a),o=n.findIndex(d=>d.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(a,n);a=t,n=h.childrenArray(a);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((d,u)=>d.fi-u.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(a,n),{data:h,actual:e,reverse:{type:9,parent:s,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>oY(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),a=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...a,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Cl(0,i,i);{let a=r[0].fi;return Cl(a-i,a,i)}}else{let a=this.get(t);if(a===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(n=>n.fi>a.fi);if(s===void 0){let n=r[r.length-1].fi;return Cl(n,n+i,i)}else return Cl(a.fi,s.fi,i)}}},kg;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let a=r.props,s={},n=[...i],o=!1;if(a)for(let l of Object.keys(a)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");s[l]=n[h],n[h]=a[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}else{let a=r.props,s={},n={...i},o=!1;if(a)for(let l of Object.keys(a)){s[l]=n[l];let h=a[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}}e.runOp=t})(kg||(kg={}));var pt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,pt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ew(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let a=i[r];return i=[...i],i[r]={...a,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,pt.prototype);let t=e;return lY()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,a=this,s={fi:t,id:i,data:r};return a=[...a,s],a.sort((n,o)=>n.fi-o.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let a=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let a=r.findIndex(o=>o.id===i);if(a===-1)return null;let s=r[a].fi,n={...r[a],fi:t};return r[a]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Cl(0,t,t);{let r=i[0].fi;return Cl(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let a=i.find(s=>s.fi>r.fi);if(a===void 0){let s=i[i.length-1].fi;return Cl(s,s+t,t)}else return Cl(r.fi,a.fi,t)}}};function Md(e){return e&&typeof e=="object"&&e instanceof dr}var dr=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,a={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!Md(i))return null;r+=1}i=i?g1(i):new dr;for(let[o,l]of Object.entries(e.props)){let h=i[o];a[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=g1(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=g1(o);l[e.path[r-1]]=i,i=l}else{let l=new dr;l[e.path[r-1]]=i,i=l}}r-=1}let s=Object.setPrototypeOf(i,dr.prototype),n={...e,props:a};return{data:s,actual:e,reverse:n}}},kl;(e=>{function t(a,s){return Ip(a,s)??a}e.apply=t;function i(a,s){return Pw(a,s)}e.merge=i;function r(a,s){let n=0,o=s.path,l=a;for(;n<o.length&&l!==void 0;){if(l=Gr.zoomOnce(l,o[n]),l===void 0)return s;if(!Md(l))return;n+=1}if(l===void 0)return s;if(Md(l))if(s.type===0){let h={...s.props};for(let c of Object.keys(l))delete h[c];return{...s,props:h}}else if(s.type===1||s.type===4||s.type===7){let h=Tw([s],l);return h?h[0]:s}else return s}e.filterOp=r})(kl||(kl={}));function Tw(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=Ip(a.data,t[s]);if(i=i||n!==void 0,n===void 0&&(n=a.data),a.children){let o=Tw(a.children,t);return o!==void 0?i=!0:o=a.children,{...a,id:s,data:n,children:o}}else return{...a,id:s,data:n}});if(i)return r}function hY(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=Ip(a.data,t[s]);return i=i||n!==void 0,n===void 0&&(n=a.data),{...a,id:s,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function Ip(e,t){if(!Md(t))return t;if(e instanceof xa){let i=Tw(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof pt)return hY(e,t);if(Array.isArray(e)){let i=!1,r=e.map((a,s)=>{let n=Ip(a,t[s]);return i=i||n!==void 0,n===void 0&&(n=a),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof dr)return Pw(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[a,s]of Object.entries(e)){let n=Ip(s,t[a]);r=r||n!==void 0,n===void 0&&(n=s),i[a]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function Pw(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Md(t))return t;if(!Md(e))return kl.apply(e,t);let i=new Set;for(let a of Object.keys(e))i.add(a);for(let a of Object.keys(t))i.add(a);let r=new dr;for(let a of i){let s=Pw(e===void 0?void 0:e[a],t===void 0?void 0:t[a]);r[a]=s}return r}function cY(e,t){let i={cur:[],result:[],len:0};return e=Op(e,t,i)??e,[e,i.result]}function Fg(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Ug(e){e&&(e.len-=1)}function dY(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function mD(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=Op(s.data,t,Fg(i,n));Ug(i),r=r||l!==void 0,l===void 0&&(l=s.data);let h=mD(s.children,t,i);return h!==void 0?r=!0:h=s.children,{...s,id:n,data:l,children:h}});if(r)return a}function uY(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=Op(s.data,t,Fg(i,n));return Ug(i),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:n,data:l}});if(r)return Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a}function Op(e,t,i){if(e instanceof xa){let r=mD(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof pt)return uY(e,t,i);if(Array.isArray(e)){let r=!1,a=e.map((s,n)=>{let o=Op(s,t,Fg(i,n));return Ug(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a):void 0}else if(e&&typeof e=="object"&&!Cw(e)){let r={},a=!1;for(let[s,n]of Object.entries(e))if(s!=="name"&&s!=="variableId"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");a=!0,s=o}let l=Op(n,t,Fg(i,s));Ug(i),a=a||l!==void 0,l===void 0&&(l=n),r[s]=l}else r[s]=n;return a?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&dY(i),r}else return}}var Ng;(e=>{function t(i,r){let a=Gr.zoom(r,i.path);if(typeof a=="object"){let s={};for(let n of Object.keys(i.props))s[n]=a[n];return{...i,props:s}}else return{...i,props:{}}}e.replaceProps=t})(Ng||(Ng={}));var aa;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let c=h.path;for(var d=[];;){let u;if(l instanceof dr&&h.type===0&&(u=l.runOp({...h,path:c.slice(d.length)}),u===null&&(u=void 0)),u===void 0&&d.length===c.length&&(l instanceof xa||l instanceof pt||l instanceof bt?u=l.runOp(h):u=kg.runOp(l,h)),u!==void 0)if(u!==null){let m=u.data;for(let g=d.length-1;g>=0;g--){let y=c[g],x=d[g];if(x instanceof xa){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof pt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof bt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof dr){let b={...x,[y]:m};m=Object.setPrototypeOf(b,dr.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let b=m;m=[...x],m[y]=b}else m={...x,[y]:m};else return null}return{data:m,actual:{...u.actual,path:c},reverse:{...u.reverse,path:c}}}else return null;let p=c[d.length],f;if(l instanceof xa){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof pt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)d.push(l),l=f;else return null}}e.apply=r;function a(l,h){for(let c=0;c<l.length&&c<h.length;c++)if(l[c]!==h[c])return!0;return!1}e.pathDisjoint=a;function s(l,h){if(l.length!==h.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==h[c])return!1;return!0}e.pathEq=s;function n(l,h){return a(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&s(l.path,h.path)?Object.keys(l.props).every(c=>h.props[c]!==void 0):!1}e.subsumed=o})(aa||(aa={}));var nx;(e=>{function t(){return[]}e.empty=t;function i(h,c){let d=[];for(let u of h){let[p,...f]=u.path;p===c&&d.push({...u,path:f})}return d}e.removePrefix=i;function r(h,c){return h.map(d=>({...d,path:[c,...d.path]}))}e.addPrefix=r;function a(h,c){return[...h,...c]}e.concat=a;function s(h,c){return[...h.filter(d=>!c.some(u=>aa.subsumed(d,u))),...c]}e.compress=s;function n(h,c){return h.every(d=>c.every(u=>aa.commutative(d,u)))}e.commutative=n;function o(h,c){for(let d of c){let u=l(h,d);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,c){var d=h;let u=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,y;if(f.type===3?(m=Gr.zoom(d,[...f.path,f.id]),y=aa.apply(d,{...f,type:2})):(m=Gr.zoom(d,[...f.path,f.id,"value"]),y=aa.apply(d,f)),y!==null){d=y.data;let[x,b]=cY(d,{[f.id]:m});d=x;for(let _=0;_<b.length;_++){let S=b[_],A=S.pop();if(typeof A=="number"){let E=[A];for(let T=_+1;T<b.length;T++){let P=b[T],R=P[P.length-1];if(typeof R=="number"&&Gr.equal(S,P.slice(0,P.length-1)))E.push(R),b.splice(T,1);else break}let M=Gr.zoom(d,S);g=M.map((T,P)=>E.includes(P)?f.id:T),m=M,A=S.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let E=m,M=Gr.zoom(d,S.slice(0,S.length-2)),T=M.layers.map(P=>P.id===S[S.length-1]?{...P,data:{...P.data,[A]:E}}:P);Object.setPrototypeOf(T,Object.getPrototypeOf(M.layers)),M.layers=T}g=f.id}u.push({type:0,path:S,props:{[A]:m}}),p.push({type:0,path:S,props:{[A]:g}})}p.push(y.reverse),u.push(y.actual)}}else{let m=aa.apply(d,f);m!==null&&(u.push(m.actual),d=m.data,p.push(m.reverse))}}catch(m){if(m instanceof uD)return null;throw m}return{data:d,actual:u,reverse:p.reverse()}}e.apply=l})(nx||(nx={}));var gD=Symbol(),pY=Symbol(),Fv=Symbol(),Jp=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let a=i;for(;!(r instanceof yD);){let s=r._path,n=r._current;if(s!==""&&a.splice(0,0,s),r=r._parent,r===null)return;r.update(s,n)}r.push(a,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Fv];i&&i(),delete this._children[e]}}}},fY=class extends Jp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else if(this._current instanceof dr){let i={...this._current,[e]:t};this._current=Object.setPrototypeOf(i,dr.prototype)}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,kg.runOp(this._current,e),e.path)}},mY=class extends Jp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,bt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},vD={get(e,t){if(t===Fv)return()=>{e._parent=null};if(t===gD)return e._current;if(t===pY)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let a=r===void 0?void 0:r[t];if(a!==void 0)return a;let s=i[t],n=Uv(e,t,s);return n!==s?(r===void 0&&(r={},e._children=r),r[t]=n,n):s},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},gY={...vD,set(e,t,i){let r={type:0,props:{[t]:br(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},vY={...vD,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},Dw=class extends Jp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Fv]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=Uv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}add(e,t,i,r,a){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:a})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Iw=class extends Jp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Fv]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,a=this._current[i].fi;e(this.data(this._current[i].id),r,a)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=Uv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function v1(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Gr.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var yD=class extends Jp{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){v1(this.ts,t,e),v1(this.actual,i,e),v1(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Uv(e,t,i){return i instanceof xa?new Dw(e,t,i):i instanceof pt?new Iw(e,t,i):i instanceof bt?new Proxy(new mY(e,t,i),vY):i!==null&&typeof i=="object"?Cw(i)?i:new Proxy(new fY(e,t,i),gY):i}function xD(e){let t=new yD(e);return[Uv(t,"",e),t]}function Rp(e,t){let[i,r]=xD(e);return t(i),r.result()}function br(e){return e instanceof Dw||e instanceof Iw?e._current:e!==null&&typeof e=="object"?e[gD]:e}var Gr;(e=>{function t(s,n){if(n.length===s.length)for(var o=0;o<s.length;){if(s[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(s,n,o){let l=a(o,s);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(c=>{delete h[c]}),h}else return n}e.removeOverridden=i;function r(s,n){if((s instanceof xa||s instanceof Dw)&&typeof n=="string"||(s instanceof pt||s instanceof Iw)&&typeof n=="string")return s.data(n);if(typeof n=="number"&&Array.isArray(s)||typeof n=="string"&&typeof s=="object"&&s!==null)return s[n]}e.zoomOnce=r;function a(s,n,o=0){for(;o<n.length&&s!==void 0;)s=r(s,n[o]),o+=1;return s}e.zoom=a})(Gr||(Gr={}));function yY(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Bi(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var bD=class{},_M=class extends bD{constructor(e){super(),this.id=e}},SM=class extends bD{constructor(e){super(),this.data=e}},ox;try{ox=new TextDecoder}catch{}var ct,Fl,we=0,wD=[],lx=wD,hx=0,Ja={},xi,Tl,Ds=0,Ln=0,ls,ko,Ga=[],Ei,AM={useRecords:!1,mapsAsObjects:!0},_D=class{},SD=new _D;SD.name="MessagePack 0xC1";var Ed=!1,Vg=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ct)return PD(()=>(dx(),this?this.unpack(e,t):Vg.prototype.unpack.call(AM,e,t)));Fl=t>-1?t:e.length,we=0,hx=0,Ln=0,Tl=null,lx=wD,ls=null,ct=e;try{Ei=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw ct=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Vg){if(Ja=this,this.structures)return xi=this.structures,lm();(!xi||xi.length>0)&&(xi=[])}else Ja=AM,(!xi||xi.length>0)&&(xi=[]);return lm()}unpackMultiple(e,t){let i,r=0;try{Ed=!0;let a=e.length,s=this?this.unpack(e,a):Vv.unpack(e,a);if(t){for(t(s);we<a;)if(r=we,t(lm())===!1)return}else{for(i=[s];we<a;)r=we,i.push(lm());return i}}catch(a){throw a.lastPosition=r,a.values=i,a}finally{Ed=!1,dx()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let a=e[i];a&&(a.isShared=!0,i>=32&&(a.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],a=t[i];a&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function lm(){try{if(!Ja.trusted&&!Ed){let t=xi.sharedLength||0;t<xi.length&&(xi.length=t)}let e=lr();if(we==Fl)xi.restoreStructures&&MM(),xi=null,ct=null,ko&&(ko=null);else if(we>Fl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Ed)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw xi.restoreStructures&&MM(),dx(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function MM(){for(let e in xi.restoreStructures)xi[e]=xi.restoreStructures[e];xi.restoreStructures=null}function lr(){let e=ct[we++];if(e<160)if(e<128){if(e<64)return e;{let t=xi[e&63]||Ja.getStructures&&AD()[e&63];return t?(t.read||(t.read=Ow(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Ja.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[ED()]=lr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(lr(),lr());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=lr();return t}else if(e<192){let t=e-160;if(Ln>=we)return Tl.slice(we-Ds,(we+=t)-Ds);if(Ln==0&&Fl<140){let i=t<16?Rw(t):MD(t);if(i!=null)return i}return cx(t)}else{let t;switch(e){case 192:return null;case 193:return ls?(t=lr(),t>0?ls[1].slice(ls.position1,ls.position1+=t):ls[0].slice(ls.position0,ls.position0-=t)):SD;case 194:return!1;case 195:return!0;case 196:return y1(ct[we++]);case 197:return t=Ei.getUint16(we),we+=2,y1(t);case 198:return t=Ei.getUint32(we),we+=4,y1(t);case 199:return lh(ct[we++]);case 200:return t=Ei.getUint16(we),we+=2,lh(t);case 201:return t=Ei.getUint32(we),we+=4,lh(t);case 202:if(t=Ei.getFloat32(we),Ja.useFloat32>2){let i=Lw[(ct[we]&127)<<1|ct[we+1]>>7];return we+=4,(i*t+(t>0?.5:-.5)>>0)/i}return we+=4,t;case 203:return t=Ei.getFloat64(we),we+=8,t;case 204:return ct[we++];case 205:return t=Ei.getUint16(we),we+=2,t;case 206:return t=Ei.getUint32(we),we+=4,t;case 207:return Ja.int64AsNumber?(t=Ei.getUint32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigUint64(we),we+=8,t;case 208:return Ei.getInt8(we++);case 209:return t=Ei.getInt16(we),we+=2,t;case 210:return t=Ei.getInt32(we),we+=4,t;case 211:return Ja.int64AsNumber?(t=Ei.getInt32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigInt64(we),we+=8,t;case 212:if(t=ct[we++],t==114)return DM(ct[we++]&63);{let i=Ga[t];if(i)return i.read?(we++,i.read(lr())):i.noBuffer?(we++,i()):i(ct.subarray(we,++we));throw new Error("Unknown extension "+t)}case 213:return t=ct[we],t==114?(we++,DM(ct[we++]&63,ct[we++])):lh(2);case 214:return lh(4);case 215:return lh(8);case 216:return lh(16);case 217:return t=ct[we++],Ln>=we?Tl.slice(we-Ds,(we+=t)-Ds):bY(t);case 218:return t=Ei.getUint16(we),we+=2,Ln>=we?Tl.slice(we-Ds,(we+=t)-Ds):wY(t);case 219:return t=Ei.getUint32(we),we+=4,Ln>=we?Tl.slice(we-Ds,(we+=t)-Ds):_Y(t);case 220:return t=Ei.getUint16(we),we+=2,CM(t);case 221:return t=Ei.getUint32(we),we+=4,CM(t);case 222:return t=Ei.getUint16(we),we+=2,TM(t);case 223:return t=Ei.getUint32(we),we+=4,TM(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var xY=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ow(e,t){function i(){if(i.count++>2){let a=e.read=new Function("r","return function(){return {"+e.map(s=>xY.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(lr);return e.highByte===0&&(e.read=EM(t,e.read)),a()}let r={};for(let a=0,s=e.length;a<s;a++){let n=e[a];r[n]=lr()}return r}return i.count=0,e.highByte===0?EM(t,i):i}var EM=(e,t)=>function(){let i=ct[we++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),a=xi[r]||AD()[r];if(!a)throw new Error("Record id is not defined for "+r);return a.read||(a.read=Ow(a,e)),a.read()};function AD(){let e=PD(()=>(ct=null,Ja.getStructures()));return xi=Ja._mergeStructures(e,xi)}var cx=Nv,bY=Nv,wY=Nv,_Y=Nv;function Nv(e){let t;if(e<16&&(t=Rw(e)))return t;if(e>64&&ox)return ox.decode(ct.subarray(we,we+=e));let i=we+e,r=[];for(t="";we<i;){let a=ct[we++];if((a&128)===0)r.push(a);else if((a&224)===192){let s=ct[we++]&63;r.push((a&31)<<6|s)}else if((a&240)===224){let s=ct[we++]&63,n=ct[we++]&63;r.push((a&31)<<12|s<<6|n)}else if((a&248)===240){let s=ct[we++]&63,n=ct[we++]&63,o=ct[we++]&63,l=(a&7)<<18|s<<12|n<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(a);r.length>=4096&&(t+=ta.apply(String,r),r.length=0)}return r.length>0&&(t+=ta.apply(String,r)),t}function CM(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=lr();return t}function TM(e){if(Ja.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[ED()]=lr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(lr(),lr());return t}}var ta=String.fromCharCode;function MD(e){let t=we,i=new Array(e);for(let r=0;r<e;r++){let a=ct[we++];if((a&128)>0){we=t;return}i[r]=a}return ta.apply(String,i)}function Rw(e){if(e<4)if(e<2){if(e===0)return"";{let t=ct[we++];if((t&128)>1){we-=1;return}return ta(t)}}else{let t=ct[we++],i=ct[we++];if((t&128)>0||(i&128)>0){we-=2;return}if(e<3)return ta(t,i);let r=ct[we++];if((r&128)>0){we-=3;return}return ta(t,i,r)}else{let t=ct[we++],i=ct[we++],r=ct[we++],a=ct[we++];if((t&128)>0||(i&128)>0||(r&128)>0||(a&128)>0){we-=4;return}if(e<6){if(e===4)return ta(t,i,r,a);{let s=ct[we++];if((s&128)>0){we-=5;return}return ta(t,i,r,a,s)}}else if(e<8){let s=ct[we++],n=ct[we++];if((s&128)>0||(n&128)>0){we-=6;return}if(e<7)return ta(t,i,r,a,s,n);let o=ct[we++];if((o&128)>0){we-=7;return}return ta(t,i,r,a,s,n,o)}else{let s=ct[we++],n=ct[we++],o=ct[we++],l=ct[we++];if((s&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){we-=8;return}if(e<10){if(e===8)return ta(t,i,r,a,s,n,o,l);{let h=ct[we++];if((h&128)>0){we-=9;return}return ta(t,i,r,a,s,n,o,l,h)}}else if(e<12){let h=ct[we++],c=ct[we++];if((h&128)>0||(c&128)>0){we-=10;return}if(e<11)return ta(t,i,r,a,s,n,o,l,h,c);let d=ct[we++];if((d&128)>0){we-=11;return}return ta(t,i,r,a,s,n,o,l,h,c,d)}else{let h=ct[we++],c=ct[we++],d=ct[we++],u=ct[we++];if((h&128)>0||(c&128)>0||(d&128)>0||(u&128)>0){we-=12;return}if(e<14){if(e===12)return ta(t,i,r,a,s,n,o,l,h,c,d,u);{let p=ct[we++];if((p&128)>0){we-=13;return}return ta(t,i,r,a,s,n,o,l,h,c,d,u,p)}}else{let p=ct[we++],f=ct[we++];if((p&128)>0||(f&128)>0){we-=14;return}if(e<15)return ta(t,i,r,a,s,n,o,l,h,c,d,u,p,f);let m=ct[we++];if((m&128)>0){we-=15;return}return ta(t,i,r,a,s,n,o,l,h,c,d,u,p,f,m)}}}}}function y1(e){return Ja.copyBuffers?Uint8Array.prototype.slice.call(ct,we,we+=e):ct.subarray(we,we+=e)}function lh(e){let t=ct[we++];if(Ga[t])return Ga[t](ct.subarray(we,we+=e));throw new Error("Unknown extension type "+t)}var PM=new Array(4096);function ED(){let e=ct[we++];if(e>=160&&e<192){if(e=e-160,Ln>=we)return Tl.slice(we-Ds,(we+=e)-Ds);if(!(Ln==0&&Fl<180))return cx(e)}else return we--,lr();let t=(e<<5^(e>1?Ei.getUint16(we):e>0?ct[we]:0))&4095,i=PM[t],r=we,a=we+e-3,s,n=0;if(i&&i.bytes==e){for(;r<a;){if(s=Ei.getUint32(r),s!=i[n++]){r=1879048192;break}r+=4}for(a+=3;r<a;)if(s=ct[r++],s!=i[n++]){r=1879048192;break}if(r===a)return we=r,i.string;a-=3,r=we}for(i=[],PM[t]=i,i.bytes=e;r<a;)s=Ei.getUint32(r),i.push(s),r+=4;for(a+=3;r<a;)s=ct[r++],i.push(s);let o=e<16?Rw(e):MD(e);return o!=null?i.string=o:i.string=cx(e)}var DM=(e,t)=>{var i=lr();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let a=xi[e];return a&&a.isShared&&((xi.restoreStructures||(xi.restoreStructures=[]))[e]=a),xi[e]=i,i.read=Ow(i,r),i.read()},CD=typeof self=="object"?self:global;Ga[0]=()=>{};Ga[0].noBuffer=!0;Ga[101]=()=>{let e=lr();return(CD[e[0]]||Error)(e[1])};Ga[105]=e=>{let t=Ei.getUint32(we-4);ko||(ko=new Map);let i=ct[we],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let a={target:r};ko.set(t,a);let s=lr();return a.used?Object.assign(r,s):(a.target=s,s)};Ga[112]=e=>{let t=Ei.getUint32(we-4),i=ko.get(t);return i.used=!0,i.target};Ga[115]=()=>new Set(lr());var TD=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ga[116]=e=>{let t=e[0],i=TD[t];if(!i)throw new Error("Could not find typed array for code "+t);return new CD[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ga[120]=()=>{let e=lr();return new RegExp(e[0],e[1])};Ga[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=we;we+=t-4,ls=[lr(),lr()],ls.position0=0,ls.position1=0;let r=we;we=i;try{return lr()}finally{we=r}};Ga[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function PD(e){let t=Fl,i=we,r=hx,a=Ds,s=Ln,n=Tl,o=lx,l=ko,h=ls,c=new Uint8Array(ct.slice(0,Fl)),d=xi,u=xi.slice(0,xi.length),p=Ja,f=Ed,m=e();return Fl=t,we=i,hx=r,Ds=a,Ln=s,Tl=n,lx=o,ko=l,ls=h,ct=c,Ed=f,xi=d,xi.splice(0,xi.length,...u),Ja=p,Ei=new DataView(ct.buffer,ct.byteOffset,ct.byteLength),m}function dx(){ct=null,ko=null,xi=null}function SY(e){e.unpack?Ga[e.type]=e.unpack:Ga[e.type]=e}var Lw=new Array(147);for(let e=0;e<256;e++)Lw[e]=+("1e"+Math.floor(45.15-e*.30103));var Vv=new Vg({useRecords:!1}),Qle=Vv.unpack,Kle=Vv.unpackMultiple,Zle=Vv.unpack,AY={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},MY=new Float32Array(1),Jle=new Uint8Array(MY.buffer,0,4),ng;try{ng=new TextEncoder}catch{}var jg,Bw,jv=typeof Buffer<"u",x1=jv?Buffer.allocUnsafeSlow:Uint8Array,DD=jv?Buffer:Uint8Array,IM=jv?4294967296:2144337920,Ue,gr,Me=0,gn,vn=null,EY=/[\u0080-\uFFFF]/,Mu=Symbol("record-id"),ID=class extends Vg{constructor(e){super(e),this.offset=0;let t,i,r,a,s,n,o=0,l=DD.prototype.utf8Write?function(E,M,T){return Ue.utf8Write(E,M,T)}:ng&&ng.encodeInto?function(E,M){return ng.encodeInto(E,Ue.subarray(M)).written}:!1,h=this;e||(e={});let c=e&&e.sequential,d=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=d?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=d?32:64),c&&!e.saveStructures&&(this.structures=[]);let f=u>32||p+u>64,m=u+64,g=u+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],x=0,b=0;this.pack=this.encode=function(E,M){if(Ue||(Ue=new x1(8192),gr=new DataView(Ue.buffer,0,8192),Me=0),gn=Ue.length-10,gn-Me<2048?(Ue=new x1(Ue.length),gr=new DataView(Ue.buffer,0,Ue.length),gn=Ue.length-10,Me=0):Me=Me+7&2147483640,i=Me,n=h.structuredClone?new Map:null,h.bundleStrings?(vn=["",""],Ue[Me++]=214,Ue[Me++]=98,vn.position=Me-i,Me+=4):vn=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let T=r.sharedLength||0;if(T>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let P=0;P<T;P++){let R=r[P];if(!R)continue;let z,U=r.transitions;for(let L=0,j=R.length;L<j;L++){let q=R[L];z=U[q],z||(z=U[q]=Object.create(null)),U=z}U[Mu]=P+64}o=T}c||(r.nextId=T+64)}a&&(a=!1),s=r||[];try{if(_(E),vn){gr.setUint32(vn.position+i,Me-vn.position-i);let T=vn;vn=null,_(T[0]),_(T[1])}if(h.offset=Me,n&&n.idsToInsert){Me+=n.idsToInsert.length*6,Me>gn&&A(Me),h.offset=Me;let T=TY(Ue.subarray(i,Me),n.idsToInsert);return n=null,T}return M&PY?(Ue.start=i,Ue.end=Me,Ue):Ue.subarray(i,Me)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,y.length>0&&(y=[]);else if(y.length>0&&!c){for(let T=0,P=y.length;T<P;T++)y[T][Mu]=0;y=[]}if(a&&h.saveStructures){let T=r.sharedLength||u;r.length>T&&(r=r.slice(0,T));let P=Ue.subarray(i,Me);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(E)):(o=T,P)}}M&DY&&(Me=i)}};let _=E=>{Me>gn&&(Ue=A(Me));var M=typeof E,T;if(M==="string"){let P=E.length;if(vn&&P>=8&&P<4096){let U=EY.test(E);vn[U?0:1]+=E,Ue[Me++]=193,_(U?-P:P);return}let R;P<32?R=1:P<256?R=2:P<65536?R=3:R=5;let z=P*3;if(Me+z>gn&&(Ue=A(Me+z)),P<64||!l){let U,L,j,q=Me+R;for(U=0;U<P;U++)L=E.charCodeAt(U),L<128?Ue[q++]=L:L<2048?(Ue[q++]=L>>6|192,Ue[q++]=L&63|128):(L&64512)===55296&&((j=E.charCodeAt(U+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),U++,Ue[q++]=L>>18|240,Ue[q++]=L>>12&63|128,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128):(Ue[q++]=L>>12|224,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128);T=q-Me-R}else T=l(E,Me+R,z);T<32?Ue[Me++]=160|T:T<256?(R<2&&Ue.copyWithin(Me+2,Me+1,Me+1+T),Ue[Me++]=217,Ue[Me++]=T):T<65536?(R<3&&Ue.copyWithin(Me+3,Me+2,Me+2+T),Ue[Me++]=218,Ue[Me++]=T>>8,Ue[Me++]=T&255):(R<5&&Ue.copyWithin(Me+5,Me+3,Me+3+T),Ue[Me++]=219,gr.setUint32(Me,T),Me+=4),Me+=T}else if(M==="number")if(E>>>0===E)E<64?Ue[Me++]=E:E<256?(Ue[Me++]=204,Ue[Me++]=E):E<65536?(Ue[Me++]=205,Ue[Me++]=E>>8,Ue[Me++]=E&255):(Ue[Me++]=206,gr.setUint32(Me,E),Me+=4);else if(E>>0===E)E>=-32?Ue[Me++]=256+E:E>=-128?(Ue[Me++]=208,Ue[Me++]=E+256):E>=-32768?(Ue[Me++]=209,gr.setInt16(Me,E),Me+=2):(Ue[Me++]=210,gr.setInt32(Me,E),Me+=4);else{let P;if((P=this.useFloat32)>0&&E<4294967296&&E>=-2147483648){Ue[Me++]=202,gr.setFloat32(Me,E);let R;if(P<4||(R=E*Lw[(Ue[Me]&127)<<1|Ue[Me+1]>>7])>>0===R){Me+=4;return}else Me--}Ue[Me++]=203,gr.setFloat64(Me,E),Me+=8}else if(M==="object")if(!E)Ue[Me++]=192;else{if(n){let R=n.get(E);if(R){if(!R.id){let z=n.idsToInsert||(n.idsToInsert=[]);R.id=z.push(R)}Ue[Me++]=214,Ue[Me++]=112,gr.setUint32(Me,R.id),Me+=4;return}else n.set(E,{offset:Me-i})}let P=E.constructor;if(P===Object)S(E,!0);else if(P===Array){T=E.length,T<16?Ue[Me++]=144|T:T<65536?(Ue[Me++]=220,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=221,gr.setUint32(Me,T),Me+=4);for(let R=0;R<T;R++)_(E[R])}else if(P===Map){T=E.size,T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,gr.setUint32(Me,T),Me+=4);for(let[R,z]of E)_(R),_(z)}else{for(let R=0,z=jg.length;R<z;R++){let U=Bw[R];if(E instanceof U){let L=jg[R];if(L.write){L.type&&(Ue[Me++]=212,Ue[Me++]=L.type,Ue[Me++]=0),_(L.write.call(this,E));return}let j=Ue,q=gr,Q=Me;Ue=null;let X;try{X=L.pack.call(this,E,ie=>(Ue=j,j=null,Me+=ie,Me>gn&&A(Me),{target:Ue,targetView:gr,position:Me-ie}),_)}finally{j&&(Ue=j,gr=q,Me=Q,gn=Ue.length-10)}X&&(X.length+Me>gn&&A(X.length+Me),Me=CY(X,Ue,Me,L.type));return}}S(E,!E.hasOwnProperty)}}else if(M==="boolean")Ue[Me++]=E?195:194;else if(M==="bigint"){if(E<BigInt(1)<<BigInt(63)&&E>=-(BigInt(1)<<BigInt(63)))Ue[Me++]=211,gr.setBigInt64(Me,E);else if(E<BigInt(1)<<BigInt(64)&&E>0)Ue[Me++]=207,gr.setBigUint64(Me,E);else if(this.largeBigIntToFloat)Ue[Me++]=203,gr.setFloat64(Me,Number(E));else throw new RangeError(E+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");Me+=8}else if(M==="undefined")this.encodeUndefinedAsNil?Ue[Me++]=192:(Ue[Me++]=212,Ue[Me++]=0,Ue[Me++]=0);else if(M==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},S=this.useRecords===!1?this.variableMapSize?E=>{let M=Object.keys(E),T=M.length;T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,gr.setUint32(Me,T),Me+=4);let P;for(let R=0;R<T;R++)_(P=M[R]),_(E[P])}:(E,M)=>{Ue[Me++]=222;let T=Me-i;Me+=2;let P=0;for(let R in E)(M||E.hasOwnProperty(R))&&(_(R),_(E[R]),P++);Ue[T+++i]=P>>8,Ue[T+i]=P&255}:E=>{let M=Object.keys(E),T,P=s.transitions||(s.transitions=Object.create(null)),R=0;for(let U=0,L=M.length;U<L;U++){let j=M[U];T=P[j],T||(T=P[j]=Object.create(null),R++),P=T}let z=P[Mu];if(z)z>=96&&f?(Ue[Me++]=((z-=96)&31)+96,Ue[Me++]=z>>5):Ue[Me++]=z;else{z=s.nextId,z||(z=64),z<m&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(z=s.nextOwnId,z<g||(z=m),s.nextOwnId=z+1):(z>=g&&(z=m),s.nextId=z+1);let U=M.highByte=z>=96&&f?z-96>>5:-1;P[Mu]=z,s[z-64]=M,z<m?(M.isShared=!0,s.sharedLength=z-63,a=!0,U>=0?(Ue[Me++]=(z&31)+96,Ue[Me++]=U):Ue[Me++]=z):(U>=0?(Ue[Me++]=213,Ue[Me++]=114,Ue[Me++]=(z&31)+96,Ue[Me++]=U):(Ue[Me++]=212,Ue[Me++]=114,Ue[Me++]=z),R&&(x+=b*R),y.length>=p&&(y.shift()[Mu]=0),y.push(P),_(M))}for(let U=0,L=M.length;U<L;U++)_(E[M[U]])},A=E=>{let M;if(E>16777216){if(E-i>IM)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(IM,Math.round(Math.max((E-i)*(E>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(E-i<<2,Ue.length-1)>>12)+1<<12;let T=new x1(M);return gr=new DataView(T.buffer,0,M),Ue.copy?Ue.copy(T,0,i,E):T.set(Ue.slice(i,E)),Me-=i,i=0,gn=T.length-10,Ue=T}}useBuffer(e){Ue=e,gr=new DataView(Ue.buffer,Ue.byteOffset,Ue.byteLength),Me=0}};Bw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,_D];jg=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:a,targetView:s,position:n}=t(6);a[n++]=214,a[n++]=255,s.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:a,targetView:s,position:n}=t(10);a[n++]=215,a[n++]=255,s.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:a,targetView:s,position:n}=t(3);a[n++]=212,a[n++]=255,a[n++]=255}else{let{target:a,targetView:s,position:n}=t(15);a[n++]=199,a[n++]=12,a[n++]=255,s.setUint32(n,e.getMilliseconds()*1e6),s.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:a,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(a[s++]=212,a[s++]=115,a[s++]=0),i(r)}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=101,r[a++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=120,r[a++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?OM(e,16,t):RM(jv?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==DD&&this.structuredClone?OM(e,TD.indexOf(i.name),t):RM(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function OM(e,t,i,r){let a=e.byteLength;if(a+1<256){var{target:s,position:n}=i(4+a);s[n++]=199,s[n++]=a+1}else if(a+1<65536){var{target:s,position:n}=i(5+a);s[n++]=200,s[n++]=a+1>>8,s[n++]=a+1&255}else{var{target:s,position:n,targetView:o}=i(7+a);s[n++]=201,o.setUint32(n,a+1),n+=4}s[n++]=116,s[n++]=t,s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function RM(e,t){let i=e.byteLength;var r,a;if(i<256){var{target:r,position:a}=t(i+2);r[a++]=196,r[a++]=i}else if(i<65536){var{target:r,position:a}=t(i+3);r[a++]=197,r[a++]=i>>8,r[a++]=i&255}else{var{target:r,position:a,targetView:s}=t(i+5);r[a++]=198,s.setUint32(a,i),a+=4}r.set(e,a)}function CY(e,t,i,r){let a=e.length;switch(a){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:a<256?(t[i++]=199,t[i++]=a):a<65536?(t[i++]=200,t[i++]=a>>8,t[i++]=a&255):(t[i++]=201,t[i++]=a>>24,t[i++]=a>>16&255,t[i++]=a>>8&255,t[i++]=a&255)}return t[i++]=r,t.set(e,i),i+=a,i}function TY(e,t){let i,r=t.length*6,a=e.length-r;for(t.sort((s,n)=>s.offset>n.offset?1:-1);i=t.pop();){let s=i.offset,n=i.id;e.copyWithin(s+r,s,a),r-=6;let o=s+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,a=s}return e}function Kd(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");Bw.unshift(e.Class),jg.unshift(e)}SY(e)}var OD=new ID({useRecords:!1}),$le=OD.pack,ehe=OD.pack,{NEVER:the,ALWAYS:ihe,DECIMAL_ROUND:rhe,DECIMAL_FIT:ahe}=AY,PY=512,DY=1024,LM=new ID({structuredClone:!0});Kd({Class:bt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,bt.prototype),e}});Kd({Class:pt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,pt.prototype),e}});Kd({Class:xa.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,xa.prototype),e}});Kd({Class:_M.prototype.constructor,type:4,write(e){return e.id},read(e){return new _M(e)}});Kd({Class:SM.prototype.constructor,type:5,write(e){return e.data},read(e){return new SM(e)}});Kd({Class:dr.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,dr.prototype),e}});function IY(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function ux(e){if(Cw(e))return e;if(Array.isArray(e))return e.map(ux);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=ux(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Hg;(e=>{function t(a){return LM.pack(a)}e.serialize=t;function i(a){return LM.unpack(a)}e.deserialize=i;function r(a){return IY(t(ux(a))).toString()}e.checksum=r})(Hg||(Hg={}));var BM;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(BM||(BM={}));function px(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var ua={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},zM;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new pt}:{type:r,disabled:!1,name:"",key:void 0,actions:new pt}}e.defaultData=i})(zM||(zM={}));var Gg;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Gg||(Gg={}));var fx;(e=>{function t(a){return{type:"Comparison",operator:"==",lOperand:Gg.propertyDefaultData(a),rOperand:{...Gg.valueDefaultData}}}e.comparisonDefaultData=t;function i(a){return{type:"Distance",toObject:a??null,fromObject:a??null,distance:200}}e.distanceDefaultData=i;function r(a,s){return{type:"State",object:a??null,state:s??null}}e.stateDefaultData=r})(fx||(fx={}));var kM;(e=>{function t(i){return i.find(r=>r==="ifActions"||r==="elseActions")!==void 0}e.isConditionalSubActions=t})(kM||(kM={}));var FM;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,name:"",inActions:new pt,outActions:new pt,condition:fx.distanceDefaultData(r)}}e.defaultData=i})(FM||(FM={}));var UM;(e=>e.defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new pt,drop:new pt}})(UM||(UM={}));var mx;(e=>e.defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new pt})(mx||(mx={}));var gx;(e=>e.defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(gx||(gx={}));var NM;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,name:"",actions:new pt}}e.defaultData=i})(NM||(NM={}));var VM;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new pt}}e.defaultData=i})(VM||(VM={}));var jM;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,name:"",actions:new pt}}e.defaultData=i})(jM||(jM={}));var HM;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new pt}}e.defaultData=i})(HM||(HM={}));var GM;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,a){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new pt,triggerZone:"box",position:a.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(GM||(GM={}));var vx;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function a(){let n={size:"mobile",operator:"<",actions:new pt},o={size:"tablet",operator:"<",actions:new pt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new pt},h=new pt;return h.push({id:tt.generateUUID(),fi:0,data:n},{id:tt.generateUUID(),fi:1,data:o},{id:tt.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:h}}e.defaultData=a;function s(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new pt}}e.defaultBreakpointData=s})(vx||(vx={}));var yx;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",name:"",actions:new pt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(yx||(yx={}));var WM;(e=>{function t(r){return r.type==="API"}e.is=t;function i(){return{disabled:!1,type:"API",name:"",successActions:new pt,errorActions:new pt,userAPIId:""}}e.defaultData=i})(WM||(WM={}));var qM;(e=>{function t(r){return r.type==="WEBHOOK"}e.is=t;function i(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new pt,userWebhookId:""}}e.defaultData=i})(qM||(qM={}));var XM;(e=>{function t(r){return r.type==="AIAssistantListener"}e.is=t;function i(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new pt,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=i})(XM||(XM={}));var YM;(e=>{function t(r){return r.type==="AIAssistantTrigger"}e.is=t;function i(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new pt}}e.defaultData=i})(YM||(YM={}));var Zd="personal camera",lp="a218fcc3-276b-49b9-b485-49037fd14f5f",OY=2960946,us=5526619,RY=(e=>(e.x="x",e.y="y",e.z="z",e))(RY||{}),kn;(e=>{function t(f,m){return f[0]===m[0]&&f[1]===m[1]}e.isEqual=t;function i(f,m,g){return[f[0]+(m[0]-f[0])*g,f[1]+(m[1]-f[1])*g]}e.lerp=i;function r(f,m){return[f[0]+m[0],f[1]+m[1]]}e.add=r;function a(f,m){return[f[0]-m[0],f[1]-m[1]]}e.sub=a;function s(f,m){return[f[0]*m[0],f[1]*m[1]]}e.multiply=s;function n(f,m){return[f[0]/m[0],f[1]/m[1]]}e.divide=n;function o(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}e.distanceSquared=o;function l(f,m){return Math.sqrt(o(f,m))}e.distance=l;function h(f,m){return f[0]*m[0]+f[1]*m[1]}e.dot=h;function c(f,m){return[f[0]*m,f[1]*m]}e.scalarMultiply=c;function d(f,m,g){let y=e.sub(m,f),x=e.sub(g,f),b=e.dot(y,x)/e.dot(y,y),_=e.scalarMultiply(y,b);return e.add(f,_)}e.projectionOnto=d;function u(f,m,g){return l(f,d(f,m,g))}e.projectionOntoDistance=u;function p(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}e.center=p})(kn||(kn={}));var Ul;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function a(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=a;function s(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=s;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(Ul||(Ul={}));var Lp;(e=>{function t(r,a){return r[0]===a[0]&&r[1]===a[1]&&r[2]===a[2]&&r[3]===a[3]}e.isEqual=t;function i(r,a,s){return[r[0]+(a[0]-r[0])*s,r[1]+(a[1]-r[1])*s,r[2]+(a[2]-r[2])*s,r[3]+(a[3]-r[3])*s]}e.lerp=i})(Lp||(Lp={}));var QM;(e=>{let t=180/Math.PI,i=Math.PI/180;function r(o){return typeof o=="number"?o*t:o}function a(o){return typeof o=="number"?o*i:o}function s(o){return[r(o[0]),r(o[1]),r(o[2])]}e.radToDeg=s;function n(o){return[a(o[0]),a(o[1]),a(o[2])]}e.degToRad=n})(QM||(QM={}));var Cd;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(a,s){for(let n=0;n<16;n++)if(a[n]!==s[n])return!1;return!0}e.isEqual=t;function i(a){return a??e.identity}e.simplify=i;function r(a,s){let n=s.slice(0);for(var o=0,l=s.length;o<l;o+=3){let h=a[3]*s[o]+a[7]*s[o+1]+a[11]*s[o+2]+a[15];n[o]=(a[0]*s[o]+a[4]*s[o+1]+a[8]*s[o+2]+a[12])/h,n[o+1]=(a[1]*s[o]+a[5]*s[o+1]+a[9]*s[o+2]+a[13])/h,n[o+2]=(a[2]*s[o]+a[6]*s[o+1]+a[10]*s[o+2]+a[14])/h}return n}e.applyMatrix4=r})(Cd||(Cd={}));var Cr;(e=>{function t(c){return typeof c=="object"&&typeof c.r=="number"&&typeof c.g=="number"&&typeof c.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}e.toRgb255a1=i;function r(c){return{r:c.r,g:c.g,b:c.b}}e.clone=r;function a(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}e.fromHex=a;function s(c){return Math.round(c.r*255)*65536+Math.round(c.g*255)*256+Math.round(c.b*255)}e.toHex=s;function n(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}e.equals=n;function o(c,d){return c.r.toFixed(2)===d.r.toFixed(2)&&c.g.toFixed(2)===d.g.toFixed(2)&&c.b.toFixed(2)===d.b.toFixed(2)}e.equalsFixed=o;function l(c,d,u){return{r:c.r+(d.r-c.r)*u,g:c.g+(d.g-c.g)*u,b:c.b+(d.b-c.b)*u}}e.lerp=l;function h(c){return ds(c)?"r"in c&&"g"in c&&"b"in c&&!("a"in c):!1}e.is=h})(Cr||(Cr={}));var _i;(e=>{e.white={...Cr.white,a:1};function t(h){return ds(h)?"r"in h&&"g"in h&&"b"in h&&"a"in h:!1}e.is=t,e.transparent={...Cr.white,a:0};function i(h){return{r:h[0],g:h[1],b:h[2],a:h[3]}}e.from0to1=i;function r(h,c){return{...Cr.fromHex(h),a:c}}e.fromHexAndA=r;function a(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:h.a}}e.toRgb255a1=a;function s(h,c){return Cr.equals(h,c)&&h.a===c.a}e.equals=s;function n(h,c){return Cr.equalsFixed(h,c)&&h.a.toFixed(2)===c.a.toFixed(2)}e.equalsFixed=n;function o(h,c,d){return{r:h.r+(c.r-h.r)*d,g:h.g+(c.g-h.g)*d,b:h.b+(c.b-h.b)*d,a:h.a+(c.a-h.a)*d}}e.lerp=o;function l({r:h,g:c,b:d,a:u}=e.white){return`rgba(${h*255}, ${c*255}, ${d*255}, ${u})`}e.toStyle=l})(_i||(_i={}));var xx;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(xx||(xx={}));var LY=(e=>(e[e.LINEAR=0]="LINEAR",e[e.EASE=1]="EASE",e[e.EASE_IN=2]="EASE_IN",e[e.EASE_OUT=3]="EASE_OUT",e[e.EASE_IN_OUT=4]="EASE_IN_OUT",e[e.CUBIC=5]="CUBIC",e[e.SPRING=6]="SPRING",e[e.ARC=7]="ARC",e[e.NONE=8]="NONE",e))(LY||{}),Wg;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Wg||(Wg={}));var qg;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(qg||(qg={}));var yl;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(yl||(yl={}));function KM(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var Vh;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Vh||(Vh={}));var Td;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}e.getZoom=t})(Td||(Td={}));var Pl;(e=>{function t(a,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof a[0]=="number"?a[0]:1,typeof a[1]=="number"?a[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof a[0]=="number"?a[0]+a[0]:1)*s,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:a.map(n=>(typeof n=="number"?n:1)*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(a,s){let n={...a};if(RD.forEach(o=>{Object.assign(n,{[o]:s[o]??a[o]})}),n.radial={...a.radial},s.radial){let o=a.radial,l=s.radial;zw.forEach(h=>{Object.assign(n.radial,{[h]:l[h]??o[h]})})}if(n.linear={...a.linear},s.linear){let o=a.linear,l=s.linear;kw.forEach(h=>{Object.assign(n.linear,{[h]:l[h]??o[h]})})}if(n.grid={...a.grid},s.grid){let o=a.grid,l=s.grid;Fw.forEach(h=>{Object.assign(n.grid,{[h]:l[h]??o[h]})})}if(n.toObject={...a.toObject},s.toObject){let o=a.toObject,l=s.toObject;Uw.forEach(h=>{Object.assign(n.toObject,{[h]:l[h]??o[h]})})}if(n.randomnessObject={...a.randomnessObject},s.randomnessObject){let o=a.randomnessObject,l=s.randomnessObject;Nw.forEach(h=>{Object.assign(n.randomnessObject,{[h]:l[h]??o[h]})})}return n}e.merge=i;function r(a){return!!(a.randomnessObject||a.toObject)}e.isPartial=r})(Pl||(Pl={}));var bx;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,a){let s=[];r.count!==void 0&&s.push({type:0,path:a,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&s.push({type:0,path:[...a,n],props:o})}return s}e.toOps=i})(bx||(bx={}));var RD=["count"],zw=["radius","start","end","position","scale","rotation"],kw=["position","scale","rotation"],Fw=["count","size"],Uw=["count","position","scale","rotation"],Nw=["strength","scale","rotation","position","movement","seed","freqScale"],wx;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(wx||(wx={}));var _x;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:_i.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:_i.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:_i.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(_x||(_x={}));var Xg;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.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:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}))(Xg||(Xg={}));var Pd;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Pd||(Pd={}));var BY=(e=>(e[e.Front=0]="Front",e[e.Back=1]="Back",e[e.Double=2]="Double",e))(BY||{}),Sx;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Sx||(Sx={}));var Ax;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Ax||(Ax={}));var Mx;(e=>e.defaultData={...Ax.defaultData,...Sx.defaultData})(Mx||(Mx={}));var ZM;(e=>{function t(i,r){let a=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&a.push(s)}else if("materials"in i)for(let s of i.materials){let n=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;n&&a.push(n)}return a}e.getMaterialData=t})(ZM||(ZM={}));var Yg;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Yg||(Yg={}));var JM;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(JM||(JM={}));function zY(e){return e.type!=="displace"}var $M;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})($M||($M={}));var kY=(e=>(e[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Polar=2]="Polar",e))(kY||{}),FY=(e=>(e[e.RepeatWrapping=1e3]="RepeatWrapping",e[e.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",e[e.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",e))(FY||{}),UY=(e=>(e[e.NearestFilter=1003]="NearestFilter",e[e.LinearFilter=1006]="LinearFilter",e[e.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",e))(UY||{}),NY=(e=>(e[e.UV=0]="UV",e[e.Planar=1]="Planar",e[e.Spherical=2]="Spherical",e[e.Cylindrical=3]="Cylindrical",e[e.Triplanar=4]="Triplanar",e))(NY||{}),VY=(e=>(e[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",e))(VY||{}),jY=(e=>(e[e.F1=0]="F1",e[e.F2=1]="F2",e[e.F2MinusF1=2]="F2MinusF1",e[e.SmoothBlend=3]="SmoothBlend",e[e.Edge=4]="Edge",e[e.Power=5]="Power",e[e.Lines=6]="Lines",e[e.Cells=7]="Cells",e))(jY||{}),HY=(e=>(e[e.Lights=0]="Lights",e[e.Static=1]="Static",e[e.Camera=2]="Camera",e))(HY||{}),GY=(e=>(e[e.Circle=0]="Circle",e[e.Ring=1]="Ring",e[e.Polygon=2]="Polygon",e[e.Cross=3]="Cross",e[e.Diamond=4]="Diamond",e[e.Checkerboard=5]="Checkerboard",e[e.Line=6]="Line",e[e.Wave=7]="Wave",e))(GY||{}),LD=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],WY=["wrapping","image","video","name","minFilter","magFilter"],yr;(e=>{function t(n,o){let{texture:l,...h}=o;if(Object.assign(n,h),l){let c=n.texture;c&&Object.assign(c,l)}}e.patch=t;function i(n){return{...e.defaultData("color"),color:n}}e.defaultColorLayer=i;function r(n,o){return n==="light"&&o?a(o):s(n)}e.defaultData=r;function a(n){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){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 s(n){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){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:Yg.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...o,type:"color",color:Cr.fromHex(us)};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:{...Cr.fromHex(6710886),a:1},colorB:{...Cr.fromHex(6710886),a:1},colorC:{...Cr.fromHex(16777215),a:1},colorD:{...Cr.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:_i.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:_i.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:_i.fromHexAndA(0,1),contourColor:_i.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:{...Cr.fromHex(0),a:1},colorB:{...Cr.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}}}})(yr||(yr={}));var sa;(e=>{function t(d){return!d.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(d){let u="";return d.layers.forEach(p=>{Object.entries(p.data).forEach(([f,m])=>{u+=`${f}${m}`,Array.isArray(m)?m.forEach(g=>u+=`${g}`):typeof m=="object"?Object.values(m).forEach(g=>{typeof g=="number"?u+=`${g.toFixed(4)}`:u+=`${g}`}):u+=`${m}`})}),u}e.getHash=i;function r(){return{layers:new pt}}e.defaultEmptyData=r;function a(d="layer1",u="layer2"){return n("phong",d,u)}e.defaultData=a;function s(d,u){return{...d,name:u}}e.withName=s;function n(d,u="layer1",p="layer2",f=Cr.fromHex(16777215)){let m=new pt;return m.push({fi:0,data:yr.defaultData("light",d),id:u}),m.push({fi:1,data:yr.defaultData("color"),id:p}),{layers:m}}e.defaultTwoLayerData=n;function o(d,u,p="layer1",f="layer2"){let m=new pt;return m.push({fi:0,data:yr.defaultData("light",u),id:p}),m.push({fi:1,data:yr.defaultColorLayer(d),id:f}),{layers:m}}e.defaultColorMaterial=o;function l(d){let u=yr.defaultData("texture");d&&Object.assign(u.texture,{image:d});let p=new pt;return p.push({fi:0,data:u,id:"layer1"}),p.push({fi:1,data:{...yr.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...yr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}e.defaultUIObjectMaterial=l;function h(d,u="phong",p="layer1",f="layer2"){let m=yr.defaultData("texture");Object.assign(m.texture,{image:d});let g=new pt;return g.push({fi:0,data:m,id:p}),g.push({fi:1,data:yr.defaultData("light",u),id:f}),{layers:g}}e.defaultTwoLayerTextureData=h;function c(d,u="phong",p="layer1",f="layer2"){let m=yr.defaultData("video");Object.assign(m.texture,{video:d});let g=new pt;return g.push({fi:0,data:m,id:p}),g.push({fi:1,data:yr.defaultData("light",u),id:f}),{layers:g}}e.defaultTwoLayerVideoTextureData=c})(sa||(sa={}));var Qg;(e=>{function t(){return{points:new pt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Qg||(Qg={}));var Kg;(e=>{function t(){return{points:new pt,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}e.defaultData=t})(Kg||(Kg={}));var Yc={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Ex;(e=>{function t(i,r){let a={...i};return Vw.forEach(s=>{Object.assign(a,{[s]:r[s]??i[s]})}),a}e.merge=t})(Ex||(Ex={}));var BD={shape:Yc,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},Vw=["depth","offset","angle","twist","startScale","endScale"],Zg;(e=>{function t(a){return a==="PolygonGeometry"||a==="RectangleGeometry"||a==="StarGeometry"||a==="TriangleGeometry"||a==="EllipseGeometry"||a==="UIGeometry"}e.is2DParametricMesh=t;function i(a){return a==="PolygonGeometry"||a==="RectangleGeometry"||a==="StarGeometry"||a==="TriangleGeometry"||a==="EllipseGeometry"||a==="PathGeometry"||a==="VectorGeometry"||a==="ConeGeometry"||a==="CubeGeometry"||a==="CylinderGeometry"||a==="DodecahedronGeometry"||a==="HelixGeometry"||a==="IcosahedronGeometry"||a==="LatheGeometry"||a==="PyramidGeometry"||a==="SphereGeometry"||a==="PlaneGeometry"||a==="BackdropGeometry"||a==="TorusGeometry"||a==="TorusKnotGeometry"||a==="BooleanGeometry"||a==="TextGeometry"||a==="InputGeometry"}e.isParametricMesh=i;function r(a){return a==="PolygonGeometry"||a==="RectangleGeometry"||a==="StarGeometry"||a==="TriangleGeometry"||a==="EllipseGeometry"||a==="PathGeometry"||a==="VectorGeometry"||a==="ConeGeometry"||a==="CubeGeometry"||a==="CylinderGeometry"||a==="DodecahedronGeometry"||a==="HelixGeometry"||a==="IcosahedronGeometry"||a==="LatheGeometry"||a==="PyramidGeometry"||a==="SphereGeometry"||a==="PlaneGeometry"||a==="BackdropGeometry"||a==="TorusGeometry"||a==="TorusKnotGeometry"||a==="TextGeometry"||a==="SubdivGeometry"||a==="NonParametricGeometry"}e.isSwappableGeometry=r})(Zg||(Zg={}));var Cx;(e=>{function t(i,r){let a={...i};return Object.assign(a,r),a.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(a.extrusion={...i.extrusion},Object.assign(a.extrusion,Ex.merge(a.extrusion,r.extrusion))),a}e.merge=t})(Cx||(Cx={}));var bl;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Kg.defaultData(),extrusion:BD};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Qg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(bl||(bl={}));var b1=["width","height","depth"],Tx;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Cr.white,near:.1,far:2e3})(Tx||(Tx={}));var Jg;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(Jg||(Jg={}));var Px;(e=>e.defaultData={softShadowQuality:"low"})(Px||(Px={}));var Dx;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Dx||(Dx={}));var Ix;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Ix||(Ix={}));var Dd;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Dd||(Dd={}));var Ox;(e=>e.defaultData={playCamera:Zd,gameControlObject:null})(Ox||(Ox={}));var Rx;(e=>e.defaultData={backgroundColor:_i.fromHexAndA(OY,1),postprocessing:Jg.defaultData,fog:Tx.defaultData,globalPhysics:Dd.defaultData,ambient:Dx.defaultData,ao:Ix.defaultData,shadow:Px.defaultData,publish:Ox.defaultData})(Rx||(Rx={}));var Lx;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Lx||(Lx={}));var eE;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(eE||(eE={}));var Id;(e=>{e.identity={...xx.identity,hiddenMatrix:Cd.identity};function t(a){return{position:a.position,rotation:a.rotation,scale:a.scale,pivot:a.pivot,pivotRotation:a.pivotRotation,hiddenMatrix:a.hiddenMatrix}}e.fromObject=t;function i(a,s){return{position:s?.position||a.position,rotation:s?.rotation||a.rotation,pivot:s?.pivot||a.pivot,pivotRotation:s?.pivotRotation||a.pivotRotation,scale:s?.scale||a.scale,hiddenMatrix:s?.hiddenMatrix||a.hiddenMatrix}}e.merge=i;function r(a,s){return rD({position:Ul.isEqual(a.position,s.position)?void 0:s.position,rotation:Ul.isEqual(a.rotation,s.rotation)?void 0:s.rotation,scale:Ul.isEqual(a.scale,s.scale)?null:s.scale,hiddenMatrix:Cd.isEqual(a.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}e.diff=r})(Id||(Id={}));var qY=["slide","offset"],Wr;(e=>e.defaultData={states:new pt,events:new pt,timelineAnimations:new bt,visible:!0,raycastLock:!1,physics:Pd.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Id.identity,cloner:null})(Wr||(Wr={}));var Bx;(e=>e.defaultData={type:"Empty",...Wr.defaultData})(Bx||(Bx={}));var tE;(e=>e.defaultData={type:"ParticleCollider",...Lx.defaultData,...Wr.defaultData})(tE||(tE={}));var iE;(e=>e.defaultData={type:"Component",...Wr.defaultData})(iE||(iE={}));var rE;(e=>e.defaultData={type:"Particle",...Wr.defaultData,...Xg.defaultData})(rE||(rE={}));var wl;(e=>e.defaultData={type:"Mesh",...Wr.defaultData,...Mx.defaultData})(wl||(wl={}));var Bp;(e=>e.defaultData={...Wr.defaultData,...Id.identity,position:[0,0,Td.DefaultTargetOffset],...Td.defaultData})(Bp||(Bp={}));var zx;(e=>{function t(i){return{...Wr.defaultData,..._x.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(zx||(zx={}));var $g;(e=>{function t(r,a,s=0){for(;s<a.length;){let n=r?r[a[s]]:void 0;if(a.length===s+1)return n;if(n)r=n.descendants,s+=1;else return}}e.resolveWithDes=t;function i(r,a,s=0){let n=t(r,a,s);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})($g||($g={}));var Dl;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,a){return{...Wr.defaultData,...a,component:r,overrides:new dr,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let a=Id.fromObject(r.data);return t(r.id,a)}e.fromComponentData=i})(Dl||(Dl={}));var Od;(e=>{e.defaultData={type:"Page",...Wr.defaultData,physics:{...Pd.defaultData,fusedBody:!1},...Rx.defaultData,camera:Bp.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(Od||(Od={}));var kx;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:Cd.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Pd.defaultData,states:new pt,events:new pt,timelineAnimations:new bt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Td.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("RectangleGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("BooleanGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultShapeBlendObject={name:"Shape Blend",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("ShapeBlendGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("TextGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultInputObject={name:"Input",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("InputGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")}))(kx||(kx={}));var Il;(e=>{function t(s,n){let o={name:n};return s.type==="Mesh"?(o.geometry={},"material"in s&&(o.material={layers:new dr}),"materials"in s&&(o.materials=s.materials.map(l=>({layers:new dr})))):Vh.is(s.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(s,n){if(n===void 0)return s;let o={...s};return"material"in o&&"material"in n&&n.material&&(o.material=Rp(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let d=l.layers.data(h);d&&yr.patch(d,c)}}).data),o.materials&&n.materials&&(o.materials=Rp(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let c=n.materials[h];if(typeof c!="string")for(let[d,u]of Object.entries(c.layers)){let p=l[h]?.layers?.data(d);p&&yr.patch(p,u)}}}).data),o}function r(s,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function c(d,u){for(let[p,f]of Object.entries(u.layers)){let{texture:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...d,"layers",p,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",p],props:g,type:0};l.push(y)}}}for(let[d,u]of Object.entries(n))if(d!=="name")if(d==="cloner")l.push(...bx.toOps(u,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:u.slide,offset:u.offset},type:0});else if(d==="material")c(["material"],u);else if(d==="materials")for(let[p,f]of Object.entries(u))c(["materials",p],f);else if(h[d]===0){if(d==="geometry"&&u.extrusion!==void 0){let p={path:[d,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[d],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[d]=u;return l}e.toOps=r;function a(s,n){if(n===void 0)return s;let o={...s};if(Object.assign(o,Id.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Vh.is(s.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:Cx.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Pl.merge(o.cloner,n.cloner)});else if(s.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Pl.merge(o.cloner,n.cloner)});else if(wx.is(s.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Cr.clone(l.color))}return o}e.patch=a})(Il||(Il={}));var ev;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ev||(ev={}));var Bo;(e=>e.defaultData={orbitControls:ev.defaultData,playPage:lp,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,a=0;return i<5?a=-30:i<10&&(a=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,a],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Bo||(Bo={}));var Fx;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Fx||(Fx={}));var Ux;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Ux||(Ux={}));var Ah;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Fx.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Ux.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ah||(Ah={}));var zp;(e=>{function t(r){return r.find(a=>a.data.type==="Page"&&a.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,a,s){r.scene.objects.traverseFrom(a,(n,o)=>{if(o.type==="Instance"){let l=Lh.getComponentData(r,o.component)?.data;l&&s(n,o,l.events)}else s(n,o,o.events)})}e.traverseModuleInstances=i})(zp||(zp={}));var Mh;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:zx.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function t(a=!0,s=[]){let n=[],o=kx.defaultMeshObject;a&&(n.push({...e.defaultLight}),n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:o,children:[]})),n.push(...s);let l=new xa;return l.push({fi:1,id:lp,data:{...Od.defaultData,name:"Scene 1"},children:n}),l}e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:Bo.defaultData,styles:Ah.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new xa,publish:Bo.defaultData,styles:Ah.defaultData()}},e.emptyDataWithPage=function(a=!0){return{objects:t(a),publish:Bo.defaultData,styles:Ah.defaultData()}},e.emptyData=function(){return{objects:new xa,publish:{...Bo.defaultData},styles:Ah.defaultData()}};function i(a){return{...e.defaultData,objects:rs(a,xa.prototype)}}e.withObjs=i;function r(a,s){return i([{id:a,data:s,children:[],fi:0}])}e.withObj=r})(Mh||(Mh={}));var hp;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(hp||(hp={}));var Nx;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new pt}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(Nx||(Nx={}));var aE;(e=>e.defaultData=(t,i="GET")=>({url:t,method:i,name:"New API",headers:new pt,queries:new pt,autoStart:!0}))(aE||(aE={}));var ba;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function a(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=a;function s(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=s})(ba||(ba={}));var Vx;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Vx||(Vx={}));var sE;(e=>e.all=[...Vx.all,"components"])(sE||(sE={}));var nE;(e=>{function t(){return{images:new bt,videos:new bt,colors:new bt,audios:new bt,particles:new bt,fonts:new bt,materials:new bt,components:new bt,variables:new bt,userAPIs:new bt,userWebhooks:new bt,timelineAnimations:new bt}}e.defaultData=t})(nE||(nE={}));var Ho;(e=>{function t(){return{images:new bt,videos:new bt,colors:new bt,audios:new bt,particles:new bt,fonts:new bt,materials:new bt,components:new bt,variables:new bt,userAPIs:new bt,userWebhooks:new bt,timelineAnimations:new bt}}e.defaultData=t})(Ho||(Ho={}));var Is;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},rs(n,bt.prototype)}e.defaultColors=t;function i(){return rs({},bt.prototype)}e.defaultImages=i;function r(){return{catelogs:new bt,materials:new bt,images:new bt,videos:new bt,colors:new bt,timelineAnimations:new bt,audios:new bt,particles:new bt,fonts:new bt,variables:new pt,userAPIs:new bt,userWebhooks:new bt,lib:Ho.defaultData()}}e.emptyData=r;function a(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=a;function s(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=s})(Is||(Is={}));var tv;(e=>e.list=["idle","move","jump","run"])(tv||(tv={}));var iv;(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 pt,move:new pt,jump:new pt,run:new pt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:_i.fromHexAndA(3728051,1)}}))(iv||(iv={}));function oE(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,a=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)a.push(a[1]),s.push(1);let n={...Vn(br(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:a,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...br(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function _l(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Sl(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((a,s)=>{a===void 0&&(r.materials[s]=sa.defaultData(),a=r.materials[s]),typeof a!="string"&&t(a)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=sa.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=sa.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(a=>{a.material&&typeof a.material!="string"&&Object.getPrototypeOf(a.material)!==dr.prototype&&t(a.material)})})}function XY(e){Object.assign(e.scene.publish,{orbitControls:{...ev.defaultData,...br(e.scene.publish.orbitControls)}})}function YY(e){Object.assign(e.scene.publish.settings,{video:{...Bo.defaultData.settings.video,...br(e.scene.publish.settings.video)}})}function QY(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[a,s]of Object.entries(r))if((LD.includes(a)||typeof s=="boolean")&&delete r[a],a==="texture")for(let[n,o]of Object.entries(s))(WY.includes(n)||typeof o=="boolean")&&delete s[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(a=>{let s=a;s.material?t(s.material):s.materials&&s.materials.forEach(n=>{t(n)})})})}function KY(e){e.scene.publish.withBackground=!0}function ZY(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function JY(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(a=>a+1),r.linear.scale=r.linear.scale.map(a=>a+1))})}function $Y(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function eQ(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let a=br(e.scene.objects.data(r));a&&a.type==="Mesh"&&a.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=br(i).booleanExclude!==!0)}})}function tQ(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function iQ(e){function t(r){Object.setPrototypeOf(r,dr.prototype),r.texture&&Object.setPrototypeOf(r.texture,dr.prototype)}function i(r){Object.setPrototypeOf(r,dr.prototype);for(let a in r)t(r[a])}e.scene.objects.traverse((r,a)=>{a.states.forEach(s=>{let n=s;if(n.material){let o=br(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=br(l).layers;i(h),l.layers=h}})})}function lE(e){e.layers===void 0&&Object.assign(e,sa.defaultTwoLayerData("lambert"))}function w1(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let a={...br(t),colors:i,steps:r};Object.assign(t,a)}})}function rQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function hE(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&w1(r)}):"material"in i&&typeof i.material!="string"&&w1(i.material)}),Object.values(e.shared.materials).forEach(t=>w1(t))}function aQ(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function sQ(e){e.shared.audios=rs({},bt.prototype)}function nQ(e){e.shared.videos=rs({},bt.prototype)}function oQ(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let a={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:a})}})}function lQ(e){Object.entries(br(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(br(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function hQ(e){e.scene.publish.settings.web.preload=!1}function cE(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function dE(e){e.layers&&e.layers.forEach(t=>{zY(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 cQ(e){e.shared.fonts=rs({},bt.prototype)}function dQ(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function uQ(e){let t=[];e.scene.objects.traverse((i,r)=>{let a=r;if(a.type==="TextFrame"){let s=sa.defaultTwoLayerData("phong"),n=typeof a.color=="string"?e.shared.colors[a.color]:a.color;s.layers[1].data.color={r:n.r,g:n.g,b:n.b},s.layers[1].data.alpha=a.alpha;let o=dQ(a.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:a.name,...Wr.defaultData,...wl.defaultData,flatShading:!1,wireframe:!1,geometry:{...bl.defaultData("TextGeometry"),width:a.width,height:a.height,font:o,depth:0,horizontalAlign:a.horizontalAlign,verticalAlign:a.verticalAlign,fontSize:a.fontSize*1.40625,lineHeight:a.lineHeight/1.40625,letterSpacing:a.letterSpacing-1,text:a.text,textTransform:a.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:br(a.states),events:br(a.events),visible:a.visible,raycastLock:a.raycastLock,position:a.position,rotation:a.rotation,scale:a.scale,hiddenMatrix:a.hiddenMatrix},h=br(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function pQ(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(a=>{if(t[Number(a.type)])if(Object.assign(a,{type:t[Number(a.type)]}),a.type==="Audio"&&"audioEvent"in a&&(Object.assign(a,{playAudio:a.audioEvent}),delete a.audioEvent),a.type==="GameControl")Object.assign(a,{gameActions:{idle:new pt,move:new pt,jump:new pt}});else{let s=new pt;Object.assign(a,{actions:s}),(a.type==="MouseDown"||a.type==="MouseUp"||a.type==="KeyDown"||a.type==="KeyUp")&&"url"in a&&s.push({fi:0,id:tt.generateUUID(),data:{type:"Link",url:a.url,delay:0}}),"targets"in a&&(a.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Vn(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let d={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},u={state:n.state,...d,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new pt({fi:0,id:tt.generateUUID(),data:h},{fi:1,id:tt.generateUUID(),data:u})};s.push({fi:l,id:o,data:p})}),delete a.targets)}})})}function fQ(e){e.scene.objects.traverse((t,i)=>{function r(a,s){let n=new pt,o=[];if(i.events.forEach((l,h,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;o.push(h),l.interaction==="play"?d={...Vn(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")&&(d={...Vn(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&n.push({fi:c,id:h,data:d})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===a)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:tt.generateUUID(),data:{type:a,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function uE(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=yr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function pE(e){_l(e,uE),Sl(e,uE)}function mQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function gQ(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function vQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=sa.defaultTwoLayerData("phong"))})}function yQ(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function xQ(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function bQ(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function wQ(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function _Q(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function SQ(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function AQ(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=iv.defaultDataThirdPerson.navmesh)})})}function MQ(e){e.scene.styles||(e.scene.styles=Ah.defaultData())}function fE(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function EQ(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Sl(e,fE),_l(e,fE)}function CQ(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new pt})})})}function TQ(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function mE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function PQ(e,t){if(t<1&&(Sl(e,oE),_l(e,oE),e.schema=1),t<2&&(XY(e),e.schema=2),t<3&&(QY(e),e.schema=3),t<4&&(KY(e),e.schema=4),t<5&&(ZY(e),e.schema=5),t<6&&(JY(e),e.schema=6),t<7&&($Y(e),e.schema=7),t<8&&(e.schema=8),t<9&&(hE(e),e.schema=9),t<10&&(rQ(e),e.schema=10),t<11&&(aQ(e),e.schema=11),t<12&&(hE(e),e.schema=12),t<13&&(sQ(e),e.schema=13),t<14&&(oQ(e),e.schema=14),t<15&&(lQ(e),e.schema=15),t<16&&(hQ(e),e.schema=16),t<17&&(Sl(e,cE),_l(e,cE),e.schema=17),t<18&&(Sl(e,lE),_l(e,lE),e.schema=18),t<19&&(YY(e),e.schema=19),t<20&&(cQ(e),uQ(e),e.schema=20),t<21&&(pQ(e),fQ(e),e.schema=21),t<22&&(pE(e),e.schema=22),t<23&&(mQ(e),e.schema=23),t<24&&(gQ(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(nQ(e),t<25&&(e.schema=25)),t<26&&(eQ(e),e.schema=26),t<27&&(tQ(e),e.schema=27),t<28&&(pE(e),e.schema=28),t<29&&(iQ(e),e.schema=29),t<30&&(vQ(e),e.schema=30),t<31&&(yQ(e),e.schema=31),t<33&&(xQ(e),e.schema=33),t<34&&(bQ(e),e.schema=34),t<35&&(wQ(e),e.schema=35),t<36&&(_Q(e),e.schema=36),t<37&&(SQ(e),e.schema=37),t<38&&(Sl(e,dE),_l(e,dE),e.schema=38),t<39&&(AQ(e),e.schema=39),t<40&&(MQ(e),e.schema=40),t<41&&(EQ(e),e.schema=41),t<42&&(CQ(e),e.schema=42),t<43&&(TQ(e),e.schema=43),t<99){Sl(e,mE),_l(e,mE),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Zd);let i=br(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=lp,r.insertBefore(null,null,[{id:lp,data:{...Od.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Vn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Vn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Dd.defaultData,...Vn(e.scene.environment,"usePhysics","gravity")},camera:br(e.scene.ownerCamera)??Od.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Mh.TRASH_CAN_ID&&r.move(lp,n.fi,n.id);let a=0,s=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(a,2)],a+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(s,1)],s+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,Pd.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function gE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function DQ(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function IQ(e){Array.isArray(br(e.events))&&e.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Qc=180/Math.PI;function vE(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Qc)}function zD(e){vE(e),e.type==="Page"&&vE(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Qc))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Qc),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Qc),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Qc,t.extrusion.twist*=Qc),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(br(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function OQ(e){e.shared.variables=rs({},bt.prototype)}function RQ(e){let t=br(e.shared.variables);e.shared.variables=rs(Object.entries(t??{}).map(([i,r],a)=>({fi:a,id:i,data:r})),pt.prototype)}var Ao=122;function og(e,t){t(e.data);for(let i of e.children)og(i,t)}function LQ(e){let t=e.schema??104;t!==Ao&&(t<105&&(og(e.asset,zD),e.schema=105),t<118&&(og(e.asset,kD),e.schema=118),t<121&&(og(e.asset,jx),e.schema=121))}function BQ(e){e.shared.particles=rs({},bt.prototype),e.shared.lib&&(e.shared.lib.particles=Ho.defaultData().particles)}function zQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function kQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function FQ(e){e.scene.objects.traverse((t,i)=>{Array.isArray(br(i.events))!==!1&&i.events?.forEach(r=>{let a=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=a??"Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode=a==="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(s=>{r.gameActions[s]?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),n.type==="Animation"&&(n.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(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.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 UQ(e){e.shared.userAPIs=rs({},bt.prototype),e.shared.userWebhooks=rs({},bt.prototype),e.shared.lib&&(e.shared.lib.userAPIs=Ho.defaultData().userAPIs,e.shared.lib.userWebhooks=Ho.defaultData().userWebhooks)}function NQ(e){e.scene.publish.settings.videoStatic===void 0&&(e.scene.publish.settings.videoStatic=Bo.defaultData.settings.videoStatic)}function kD(e){e.timelineAnimations=rs({},bt.prototype)}function jx(e){e.pivot=[0,0,0],e.pivotRotation=[0,0,0]}function FD(e){let t=e.schema??0;if(t!==Ao){console.warn("updating from ",t,"to ",Ao),PQ(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Bo.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Sl(e,gE),_l(e,gE),e.schema=101),t<102&&(DQ(e),e.schema=102),t<104&&(e.shared.catelogs=new bt,e.shared.lib=Ho.defaultData(),e.schema=104),t<105&&(OQ(e),e.scene.objects.traverse((i,r)=>{zD(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))LQ(i);t<106&&(RQ(e),e.schema=106),t<107&&(e.shared.lib.variables=Ho.defaultData().variables,e.schema=107),t<109&&(BQ(e),e.schema=109),t<110&&(zQ(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{IQ(r)}),e.schema=111),t<112&&(kQ(e),e.schema=112),t<113&&(FQ(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(UQ(e),e.schema=115),t<116&&(NQ(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117),t<118&&(e.shared.timelineAnimations=rs({},bt.prototype),e.scene.objects.traverse((i,r)=>{kD(r)}),e.schema=118),t<119&&(e.scene.publish.settings.videoStatic.format=Lh.defaultData.scene.publish.settings.videoStatic.format,e.scene.publish.settings.videoStatic.imageFormat=Lh.defaultData.scene.publish.settings.videoStatic.imageFormat,e.schema=119),t<120&&(e.scene.publish.settings.image.colorSpace="display-p3",e.scene.publish.settings.videoStatic.colorSpace="display-p3",e.schema=120),t<121&&(e.scene.objects.traverse((i,r)=>{jx(r),r.type==="Page"&&jx(r.camera)}),e.schema=121),t<122&&(delete e.scene.publish.settings.video,e.scene.publish.orbitControls.rotationSpeed=Lh.defaultData.scene.publish.orbitControls.rotationSpeed,e.schema=122)}}var Lh;(e=>{e.defaultData={schema:Ao,scene:Mh.defaultData,frames:new bt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hp.defaultData),shared:{...Is.emptyData(),colors:Is.defaultColors()}},e.emptyDataForImports=function(){let s=Mh.emptyDataWithPage();return{schema:Ao,scene:s,frames:new bt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hp.defaultData),shared:{...Is.emptyData(),colors:Is.defaultColors(),images:Is.defaultImages()}}},e.emptyData=function(){return{schema:Ao,scene:Mh.emptyDataWithPage(),frames:new bt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hp.defaultData),shared:Is.emptyData()}},e.clipboard2dData=function(){return{schema:Ao,scene:Mh.emptyData(),frames:new bt,shared:Is.emptyData()}},e.collabHelper={...nx,updateSchema(s){return(s.schema??0)<Ao?Rp(s,FD):(s.schema??0)-Ao}};function t(s){let n=e.collabHelper.updateSchema(s);return typeof n=="number"?n===0?s:null:n.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:Ho.defaultData()}}}e.withoutLib=i;function r(s,n){let o=s.scene.objects.get(n);if(o&&o.data.type==="Component")return o;{let l=s.shared.lib.components[n];if(l)return{...l.asset,id:n}}}e.getComponentData=r;function a(s){let n=Object.values(s.shared.userAPIs);for(let o of n){let l=o.headers;for(let h of l)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}e.hasSensitiveData=a})(Lh||(Lh={}));var Hx;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Hx||(Hx={}));var yE;(e=>{function t(i){return!0}e.is=t})(yE||(yE={}));var rv;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,a){return{position:a?.position??r.position,rotation:a?.rotation??r.rotation,scale:a?.scale??r.scale,shear:a?.shear??r.shear}}e.merge=t;function i(r,a){return rD({position:kn.isEqual(r.position,a.position)?void 0:a.position,rotation:r.rotation===a.rotation?void 0:a.rotation,scale:kn.isEqual(r.scale,a.scale)?void 0:a.scale,shear:r.shear&&a.shear&&kn.isEqual(r.shear,a.shear)?void 0:a.shear})}e.diff=i})(rv||(rv={}));var Gx;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(Gx||(Gx={}));var xE;(e=>e.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(xE||(xE={}));var av;(e=>e.defaultData={opacity:1,fill:{color:_i.fromHexAndA(us,1),enabled:!0},stroke:{color:_i.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:_i.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:_i.from0to1([0,0,0,1]),enabled:!1,spread:0}})(av||(av={}));var Eh;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function a(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,rv.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=a;function s(n,o){let l,h=[];for(let[c,d]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=d);return h}e.toOps=s})(Eh||(Eh={}));var kp;(e=>e.defaultData={...rv.defaultData,...Gx.defaultData,states:new pt,events:new pt,visible:!0,raycastLock:!1})(kp||(kp={}));var Rd;(e=>e.defaultData={...kp.defaultData,...av.defaultData})(Rd||(Rd={}));var sv;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(sv||(sv={}));var Wx;(e=>e.defaultData={...Rd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Wx||(Wx={}));var Fp;(e=>e.defaultData={...Rd.defaultData,...sv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Fp||(Fp={}));var qx;(e=>e.defaultData={...Rd.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"})(qx||(qx={}));var Xx;(e=>e.defaultData={...Rd.defaultData,type:"path2d",path:"",name:"Path"})(Xx||(Xx={}));var bE;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(bE||(bE={}));var nv;(e=>e.defaultData={...kp.defaultData,name:"Group",type:"group2d"})(nv||(nv={}));var Yx;(e=>e.defaultData=()=>({...kp.defaultData,...sv.defaultData,...av.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:_i.fromHexAndA(4737101,1),enabled:!0},stroke:{color:_i.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(Yx||(Yx={}));var Bh;(e=>{function t(n){switch(n){case"rectangle2d":return{...Fp.defaultData};case"ellipse2d":return{...Wx.defaultData};case"text2d":return{...qx.defaultData};case"vector2d":return{...Fp.defaultData};case"path2d":return{...Xx.defaultData};case"frame2d":return{...Yx.defaultData()};case"group2d":return{...nv.defaultData}}}e.defaultData=t;function i(n){return"width"in n&&"height"in n?[typeof n.width=="number"?n.width*.5:0,typeof n.height=="number"?n.height*.5:0]:[0,0]}e.getPivot=i;function r(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"}e.isResizeable=r;function a(n){return n.type==="frame2d"&&n.autoLayout!==void 0}e.isAutoLayoutable=a;function s(n){return n.type==="rectangle2d"||n.type==="frame2d"}e.hasCorners=s})(Bh||(Bh={}));var Qx;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new xa},e.emptyData=function(){return{type:"scene2d",objects:new xa}}))(Qx||(Qx={}));function Ch(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),a=new Set(Object.keys(e[0].morphAttributes)),s={},n={},o=e[0].morphTargetsRelative,l=new vt,h=0;for(let c=0;c<e.length;++c){let d=e[c],u=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(d.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in d.morphAttributes){if(!a.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(d.morphAttributes[p])}if(t){let p;if(i)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(i){let c=0,d=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+c);c+=e[u].attributes.position.count}l.setIndex(d)}for(let c in s){let d=wE(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in n){let d=n[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let u=0;u<d;++u){let p=[];for(let m=0;m<n[c].length;++m)p.push(n[c][m][u]);let f=wE(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function wE(e){let t,i,r,a=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;a+=l.array.length}let s=new t(a),n=0;for(let o=0;o<e.length;++o)s.set(e[o].array,n),n+=e[o].array.length;return new Pt(s,i,r)}var UD={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},jw={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},VQ=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Ld={CSS:{},springs:{}};function rn(e,t,i){return Math.min(Math.max(e,t),i)}function cp(e,t){return e.indexOf(t)>-1}function _1(e,t){return e.apply(null,t)}var zt={arr:function(e){return Array.isArray(e)},obj:function(e){return cp(Object.prototype.toString.call(e),"Object")},pth:function(e){return zt.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||zt.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return zt.hex(e)||zt.rgb(e)||zt.hsl(e)},key:function(e){return!UD.hasOwnProperty(e)&&!jw.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function ND(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function VD(e,t){var i=ND(e),r=rn(zt.und(i[0])?1:i[0],.1,100),a=rn(zt.und(i[1])?100:i[1],.1,100),s=rn(zt.und(i[2])?10:i[2],.1,100),n=rn(zt.und(i[3])?0:i[3],.1,100),o=Math.sqrt(a/r),l=s/(2*Math.sqrt(a*r)),h=l<1?o*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*o+-n)/h:-n+o;function u(f){var m=t?t*f/1e3:f;return l<1?m=Math.exp(-m*l*o)*(c*Math.cos(h*m)+d*Math.sin(h*m)):m=(c+d*m)*Math.exp(-m*o),f===0||f===1?f:1-m}function p(){var f=Ld.springs[e];if(f)return f;for(var m=1/6,g=0,y=0;;)if(g+=m,u(g)===1){if(y++,y>=16)break}else y=0;var x=g*m*1e3;return Ld.springs[e]=x,x}return t?u:p}function jQ(e){return e===void 0&&(e=10),function(t){return Math.ceil(rn(t,1e-6,1)*e)*(1/e)}}var HQ=function(){var e=11,t=1/(e-1);function i(c,d){return 1-3*d+3*c}function r(c,d){return 3*d-6*c}function a(c){return 3*c}function s(c,d,u){return((i(d,u)*c+r(d,u))*c+a(d))*c}function n(c,d,u){return 3*i(d,u)*c*c+2*r(d,u)*c+a(d)}function o(c,d,u,p,f){var m,g,y=0;do g=d+(u-d)/2,m=s(g,p,f)-c,m>0?u=g:d=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(c,d,u,p){for(var f=0;f<4;++f){var m=n(d,u,p);if(m===0)return d;var g=s(d,u,p)-c;d-=g/m}return d}function h(c,d,u,p){if(!(0<=c&&c<=1&&0<=u&&u<=1))return;var f=new Float32Array(e);if(c!==d||u!==p)for(var m=0;m<e;++m)f[m]=s(m*t,c,u);function g(y){for(var x=0,b=1,_=e-1;b!==_&&f[b]<=y;++b)x+=t;--b;var S=(y-f[b])/(f[b+1]-f[b]),A=x+S*t,E=n(A,c,u);return E>=.001?l(y,A,c,u):E===0?A:o(y,x,x+t,c,u)}return function(y){return c===d&&u===p||y===0||y===1?y:s(g(y),d,p)}}return h}(),jD=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var a,s=4;r<((a=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((a*3-2)/22-r,2)}},Elastic:function(r,a){r===void 0&&(r=1),a===void 0&&(a=.5);var s=rn(r,1,10),n=rn(a,.1,2);return function(o){return o===0||o===1?o:-s*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,a){t[r]=function(){return function(s){return Math.pow(s,a+2)}}}),Object.keys(t).forEach(function(r){var a=t[r];e["easeIn"+r]=a,e["easeOut"+r]=function(s,n){return function(o){return 1-a(s,n)(1-o)}},e["easeInOut"+r]=function(s,n){return function(o){return o<.5?a(s,n)(o*2)/2:1-a(s,n)(o*-2+2)/2}}}),e}();function Hw(e,t){if(zt.fnc(e))return e;var i=e.split("(")[0],r=jD[i],a=ND(e);switch(i){case"spring":return VD(e,t);case"cubicBezier":return _1(HQ,a);case"steps":return _1(jQ,a);default:return _1(r,a)}}function HD(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Hv(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,a=[],s=0;s<i;s++)if(s in e){var n=e[s];t.call(r,n,s,e)&&a.push(n)}return a}function Gv(e){return e.reduce(function(t,i){return t.concat(zt.arr(i)?Gv(i):i)},[])}function _E(e){return zt.arr(e)?e:(zt.str(e)&&(e=HD(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Gw(e,t){return e.some(function(i){return i===t})}function Ww(e){var t={};for(var i in e)t[i]=e[i];return t}function Kx(e,t){var i=Ww(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Wv(e,t){var i=Ww(e);for(var r in t)i[r]=zt.und(e[r])?t[r]:e[r];return i}function GQ(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function WQ(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,c){return l+l+h+h+c+c}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),a=parseInt(r[1],16),s=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+a+","+s+","+n+",1)"}function qQ(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,a=parseInt(t[3],10)/100,s=t[4]||1;function n(u,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(p-u)*6*f:f<1/2?p:f<2/3?u+(p-u)*(2/3-f)*6:u}var o,l,h;if(r==0)o=l=h=a;else{var c=a<.5?a*(1+r):a+r-a*r,d=2*a-c;o=n(d,c,i+1/3),l=n(d,c,i),h=n(d,c,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+s+")"}function XQ(e){if(zt.rgb(e))return GQ(e);if(zt.hex(e))return WQ(e);if(zt.hsl(e))return qQ(e)}function Fo(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function YQ(e){if(cp(e,"translate")||e==="perspective")return"px";if(cp(e,"rotate")||cp(e,"skew"))return"deg"}function Zx(e,t){return zt.fnc(e)?e(t.target,t.id,t.total):e}function Fn(e,t){return e.getAttribute(t)}function qw(e,t,i){var r=Fo(t);if(Gw([i,"deg","rad","turn"],r))return t;var a=Ld.CSS[t+i];if(!zt.und(a))return a;var s=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=s+i;var l=s/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return Ld.CSS[t+i]=h,h}function GD(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?qw(e,a,i):a}}function Xw(e,t){if(zt.dom(e)&&!zt.inp(e)&&(Fn(e,t)||zt.svg(e)&&e[t]))return"attribute";if(zt.dom(e)&&Gw(VQ,t))return"transform";if(zt.dom(e)&&t!=="transform"&&GD(e,t))return"css";if(e[t]!=null)return"object"}function WD(e){if(zt.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,a;a=i.exec(t);)r.set(a[1],a[2]);return r}}function QQ(e,t,i,r){var a=cp(t,"scale")?1:0+YQ(t),s=WD(e).get(t)||a;return i&&(i.transforms.list.set(t,s),i.transforms.last=t),r?qw(e,s,r):s}function Yw(e,t,i,r){switch(Xw(e,t)){case"transform":return QQ(e,t,r,i);case"css":return GD(e,t,i);case"attribute":return Fn(e,t);default:return e[t]||0}}function Qw(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Fo(e)||0,a=parseFloat(t),s=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return a+s+r;case"-":return a-s+r;case"*":return a*s+r}}function qD(e,t){if(zt.col(e))return XQ(e);if(/\s/g.test(e))return e;var i=Fo(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Kw(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function KQ(e){return Math.PI*2*Fn(e,"r")}function ZQ(e){return Fn(e,"width")*2+Fn(e,"height")*2}function JQ(e){return Kw({x:Fn(e,"x1"),y:Fn(e,"y1")},{x:Fn(e,"x2"),y:Fn(e,"y2")})}function XD(e){for(var t=e.points,i=0,r,a=0;a<t.numberOfItems;a++){var s=t.getItem(a);a>0&&(i+=Kw(r,s)),r=s}return i}function $Q(e){var t=e.points;return XD(e)+Kw(t.getItem(t.numberOfItems-1),t.getItem(0))}function YD(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return KQ(e);case"rect":return ZQ(e);case"line":return JQ(e);case"polyline":return XD(e);case"polygon":return $Q(e)}}function eK(e){var t=YD(e);return e.setAttribute("stroke-dasharray",t),t}function tK(e){for(var t=e.parentNode;zt.svg(t)&&zt.svg(t.parentNode);)t=t.parentNode;return t}function QD(e,t){var i=t||{},r=i.el||tK(e),a=r.getBoundingClientRect(),s=Fn(r,"viewBox"),n=a.width,o=a.height,l=i.viewBox||(s?s.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function iK(e,t){var i=zt.str(e)?HD(e)[0]:e,r=t||100;return function(a){return{property:a,el:i,svg:QD(i),totalLength:YD(i)*(r/100)}}}function rK(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=QD(e.el,e.svg),a=i(),s=i(-1),n=i(1);switch(e.property){case"x":return(a.x-r.x)*r.w;case"y":return(a.y-r.y)*r.h;case"angle":return Math.atan2(n.y-s.y,n.x-s.x)*180/Math.PI}}function SE(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=qD(zt.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:zt.str(e)||t?r.split(i):[]}}function KD(e){var t=e?Gv(zt.arr(e)?e.map(_E):_E(e)):[];return Hv(t,function(i,r,a){return a.indexOf(i)===r})}function ZD(e){var t=KD(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:WD(i)}}})}function aK(e,t){var i=Ww(t);if(/^spring/.test(i.easing)&&(i.duration=VD(i.easing)),zt.arr(e)){var r=e.length,a=r===2&&!zt.obj(e[0]);a?e={value:e}:zt.fnc(t.duration)||(i.duration=t.duration/r)}var s=zt.arr(e)?e:[e];return s.map(function(n,o){var l=zt.obj(n)&&!zt.pth(n)?n:{value:n};return zt.und(l.delay)&&(l.delay=o?0:t.delay),zt.und(l.endDelay)&&(l.endDelay=o===s.length-1?t.endDelay:0),l}).map(function(n){return Wv(n,i)})}function sK(e){for(var t=Hv(Gv(e.map(function(s){return Object.keys(s)})),function(s){return zt.key(s)}).reduce(function(s,n){return s.indexOf(n)<0&&s.push(n),s},[]),i={},r=function(s){var n=t[s];i[n]=e.map(function(o){var l={};for(var h in o)zt.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},a=0;a<t.length;a++)r(a);return i}function nK(e,t){var i=[],r=t.keyframes;r&&(t=Wv(sK(r),t));for(var a in t)zt.key(a)&&i.push({name:a,tweens:aK(t[a],e)});return i}function oK(e,t){var i={};for(var r in e){var a=Zx(e[r],t);zt.arr(a)&&(a=a.map(function(s){return Zx(s,t)}),a.length===1&&(a=a[0])),i[r]=a}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function lK(e,t){var i;return e.tweens.map(function(r){var a=oK(r,t),s=a.value,n=zt.arr(s)?s[1]:s,o=Fo(n),l=Yw(t.target,e.name,o,t),h=i?i.to.original:l,c=zt.arr(s)?s[0]:h,d=Fo(c)||Fo(l),u=o||d;return zt.und(n)&&(n=h),a.from=SE(c,u),a.to=SE(Qw(n,c),u),a.start=i?i.end:0,a.end=a.start+a.delay+a.duration+a.endDelay,a.easing=Hw(a.easing,a.duration),a.isPath=zt.pth(s),a.isColor=zt.col(a.from.original),a.isColor&&(a.round=1),i=a,a})}var JD={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,a){if(r.list.set(t,i),t===r.last||a){var s="";r.list.forEach(function(n,o){s+=o+"("+n+") "}),e.style.transform=s}}};function $D(e,t){var i=ZD(e);i.forEach(function(r){for(var a in t){var s=Zx(t[a],r),n=r.target,o=Fo(s),l=Yw(n,a,o,r),h=o||Fo(l),c=Qw(qD(s,h),l),d=Xw(n,a);JD[d](n,a,c,r.transforms,!0)}})}function hK(e,t){var i=Xw(e.target,t.name);if(i){var r=lK(t,e),a=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:a.end,delay:r[0].delay,endDelay:a.endDelay}}}function cK(e,t){return Hv(Gv(e.map(function(i){return t.map(function(r){return hK(i,r)})})),function(i){return!zt.und(i)})}function eI(e,t){var i=e.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},a={};return a.duration=i?Math.max.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+n+o+l+s.duration*(s.loop??1)})):t.duration,a.delay=i?Math.min.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0;return r(s)+n+o+s.delay})):t.delay,a.endDelay=i?a.duration-Math.max.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+n+o+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,a}var AE=0;function dK(e){var t=Kx(UD,e),i=Kx(jw,e),r=nK(i,e),a=ZD(e.targets),s=cK(a,r),n=eI(s,i),o=AE;return AE++,Wv(t,{id:o,children:[],animatables:a,animations:s,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var _a=[],cd=[],Po,Jx=function(){let e=0,t=!0;function i(s){let n=_a.length;if(n){let o=0;for(;o<n;){let l=_a[o];l.paused?(_a.splice(o,1),n--):(l.tick(s),o++)}t&&(Po=requestAnimationFrame(i))}else Po&&(cancelAnimationFrame(Po),Po=null)}function r(){e=performance.now(),Po=requestAnimationFrame(i)}function a(s){e+=s,i(e)}return{get isUsingInternalRaf(){return t},set isUsingInternalRaf(s){t=s},play:r,update:a}}();function $x(e){!Jx.isUsingInternalRaf||(document.hidden?(_a.forEach(function(t){return t.pause(e.timeStamp)}),cd=_a.slice(0),zi.running=_a=[]):(cd.forEach(function(t){return t.play(e.timeStamp)}),cd=[]))}function zi(e){e===void 0&&(e={});var t=0,i=0,r=0,a,s,n=0,o=null;function l(E){var M=window.Promise&&new Promise(function(T){return o=T});return E.finished=M,M}var h=dK(e),c=l(h);function d(){var E=h.direction;E!=="alternate"&&(h.direction=E!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,s.forEach(function(M){(M.loop===1||M.loop%2===0)&&(M.reversed=h.reversed)})}function u(){h.direction="normal",h.reversed=!1,s.forEach(function(E){return E.reversed=!1})}function p(E){return h.reversed?h.duration-E:E}function f(){t=0,i=p(h.currentTime)*(1/zi.speed)}function m(E,M,T=!1){M&&(h.reversed?M.seek(M.duration*M.loop-(E-M.timelineOffset-M.pingPongDelayCorrection),T):M.seek(E-M.timelineOffset-M.startOnceDelay-M.pingPongDelayCorrection,T))}function g(E,M=!1){if(h.reversed)for(var T=n;T--;)m(E,s[T],M);else for(var P=0;P<n;P++)m(E,s[P],M)}function y(E){var M=0,T=h.animations,P=T.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?E=h.duration-h.delay+h.endDelay-E:E=h.duration+h.delay-h.endDelay-E):S(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?E=h.duration-h.delay+h.endDelay-E:E=h.duration+h.delay-h.endDelay-E);M<P;){var R=T[M],z=R.animatable,U=R.tweens,L=U.length-1,j=U[L];L&&(j=Hv(U,function(ye){return E<ye.end})[0]||j);let Ae;h.parent?.reversed&&h.direction==="alternate"?Ae=rn(E-j.start-j.endDelay,0,j.duration)/j.duration:Ae=rn(E-j.start-j.delay,0,j.duration)/j.duration;for(var q=isNaN(Ae)?1:j.easing(Ae),Q=j.to.strings,X=j.round,ie=[],oe=j.to.numbers.length,te=void 0,re=0;re<oe;re++){var fe=void 0;let ye,Ve;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(ye=j.to.numbers[re],Ve=j.from.numbers[re]||0):(Ve=j.to.numbers[re],ye=j.from.numbers[re]||0):S(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(ye=j.to.numbers[re],Ve=j.from.numbers[re]||0):(Ve=j.to.numbers[re],ye=j.from.numbers[re]||0),j.isPath?fe=rK(j.value,q*Ve):fe=ye+q*(Ve-ye),X&&(j.isColor&&re>2||(fe=Math.round(fe*X)/X)),ie.push(fe)}var ce=Q.length;if(!ce)te=ie[0];else{te=Q[0];for(var de=0;de<ce;de++){var se=Q[de],Pe=Q[de+1],ve=ie[de];isNaN(ve)||(Pe?te+=ve+Pe:te+=ve+" ")}}JD[R.type](z.target,R.property,te,z.transforms),R.currentValue=te,M++}}function x(E){h[E]&&!h.passThrough&&h[E](h)}function b(){h.remaining&&h.remaining!==!0&&h.remaining--}let _={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 S(E,M,T,P,R){return _[E<<4|M<<3|T<<2|P<<1|R]}function A(E,M=!1){var T=h.duration;let P=h.delay,R=T-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(P=h.endDelay,R=T-h.delay);var z=p(E);if(h.progress=rn(z/T*100,0,100),M||(h.reversePlayback=z<h.currentTime),n&&g(z,M),!h.began&&z>=P&&(h.began=!0),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,x("loopBegin")),(h.reversed||z>=0)&&z<=P&&h.currentTime!==0&&(y(0),x("change")),(z>=R&&h.currentTime!==T+h.pingPongDelayCorrection||!T)&&(y(T),x("change")),z>P&&z<R?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,x("changeBegin")),y(z),x("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,x("change"),n&&x("timelineChangeComplete")):h.began&&z>R&&x("changeComplete"),h.currentTime=rn(z,0,T+h.pingPongDelayCorrection),h.began&&x("update"),E>=T)if(b(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,x("loopComplete"),x("complete"),!h.passThrough&&"Promise"in window&&(o(),c=l(h)));else{n?t+=h.duration/zi.speed:t+=h.duration;for(let U of s)U.setStartTime(0),U.remaining=U.loop;x("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?d():n&&u()}}return h.reset=function(){var E=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversed=E==="reverse",h.remaining=h.loop,s=h.children,n=s.length;for(var M=n;M--;)h.children[M].reset();y(h.reversed?h.duration:0)},h.setStartTime=function(E){t=E},h.set=function(E,M){return $D(E,M),h},h.tick=function(E){r=E,t||(t=r),A((r+(i-t))*zi.speed)},h.seek=function(E,M=!1){A(E-t,M)},h.pause=function(E){h.paused=!0,n&&(a=E??performance.now())},h.play=function(E){!h.paused||(h.completed&&h.reset(),h.paused=!1,_a.push(h),n&&a!==void 0&&(t+=(E??performance.now())-a),!Po&&Jx.isUsingInternalRaf&&Jx.play())},h.reverse=function(E=0){d(),h.completed=!h.reversed,t=void 0,i=E},h.restart=function(){h.reset(),t=void 0,i=0,h.play()},h.destroy=function(){h.paused=!0;var E=_a.indexOf(h);E>-1&&_a.splice(E,1),E=cd.indexOf(h),E>-1&&cd.splice(E,1),h.children&&h.children.forEach(function(M){M.destroy&&M.destroy()}),h.animations=[],h.animatables=[],h.children=[],h.update=null,h.begin=null,h.complete=null,h.loopBegin=null,h.loopComplete=null,h.change=null,h.changeBegin=null,h.changeComplete=null,h.timelineChangeComplete=null,h.parent=null,o=null,s=[],n=0},h.reset(),h.autoplay&&h.play(),h}function ME(e,t){for(var i=t.length;i--;)Gw(e,t[i].animatable.target)&&t.splice(i,1)}function uK(e){for(var t=KD(e),i=_a.length;i--;){var r=_a[i],a=r.animations,s=r.children;ME(t,a);for(var n=s.length;n--;){var o=s[n],l=o.animations;ME(t,l),!l.length&&!o.children.length&&s.splice(n,1)}!a.length&&!s.length&&r.pause()}}function pK(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?Hw(t.easing):null,a=t.grid,s=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",c=zt.arr(e),d=parseFloat(c?e[0]:e),u=c?parseFloat(e[1]):0,p=Fo(c?e[1]:e)||0,f=t.start||0+(c?d:0),m=[],g=0;return function(y,x,b){if(o&&(n=0),l&&(n=(b-1)/2),h&&(n=b-1),!m.length){for(var _=0;_<b;_++){if(!a)m.push(Math.abs(n-_));else{var S=l?(a[0]-1)/2:n%a[0],A=l?(a[1]-1)/2:Math.floor(n/a[0]),E=_%a[0],M=Math.floor(_/a[0]),T=S-E,P=A-M,R=Math.sqrt(T*T+P*P);s==="x"&&(R=-T),s==="y"&&(R=-P),m.push(R)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(U){return r(U/g)*g})),i==="reverse"&&(m=m.map(function(U){return s?U<0?U*-1:-U:Math.abs(g-U)}))}var z=c?(u-d)/g:d;return f+z*(Math.round(m[x]*100)/100)+p}}function fK(e){e===void 0&&(e={});var t=zi(e);return t.duration=0,t.add=function(i,r){var a=_a.indexOf(t),s=t.children;a>-1&&_a.splice(a,1);function n(u){u.passThrough=!0}for(var o=0;o<s.length;o++)n(s[o]);var l=Wv(i,Kx(jw,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=zt.und(r)?h:Qw(r,h),n(t);var c=zi(l);n(c),s.push(c),c.parent=t;var d=eI(s,e);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}zi.version="3.2.0";zi.speed=1;zi.running=_a;zi.remove=uK;zi.get=Yw;zi.set=$D;zi.convertPx=qw;zi.path=iK;zi.setDashoffset=eK;zi.stagger=pK;zi.timeline=fK;zi.easing=Hw;zi.penner=jD;zi.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};zi.removeAll=function(){_a.forEach(function(e){e.destroy&&e.destroy()}),_a=[],cd=[],zi.running=_a,Po&&(cancelAnimationFrame(Po),Po=null)};zi.clearCache=function(){Ld.CSS={},Ld.springs={}};zi.init=function(){typeof document<"u"&&(document.removeEventListener("visibilitychange",$x),document.addEventListener("visibilitychange",$x))};zi.dispose=function(e){zi.removeAll(),zi.clearCache(),document.removeEventListener("visibilitychange",$x)};var Uo=zi,qr=class extends Ct{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},{degToRad:she,radToDeg:nhe}=tt,EE=new O,CE=new O,TE=new Rt,mK=1e-4;function gK(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let a=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(a>=1)return i.copy(e);let s=1-a*a;if(s<=Number.EPSILON){let c=1-r;return i.w=c*e.w+r*t.w,i.x=c*e.x+r*t.x,i.y=c*e.y+r*t.y,i.z=c*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(s),o=Math.atan2(n,a),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function va(e,t,i,r,a,s){let n=i[e]!==void 0?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(a.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(a.getVariable(o)??0):o;if(l!==h)return{update:c=>{let d=tt.lerp(l,h,c);s?t[e]=Math.trunc(d):t[e]=d},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function Zw(e,t,i,r,a,s){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(d=>typeof d=="string"?Number(a.getVariable(d)??0):d),c=[...o].map(d=>typeof d=="string"?Number(a.getVariable(d)??0):d);if(!(h.length!==c.length||Mw(h,c)))return{update:d=>{h.forEach((u,p)=>{let f=tt.lerp(u,c[p],d);t[e][p]=s?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],c)}}}function ov(e,t,i){return t.forEach((r,a)=>{e.setComponent(a,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function PE(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=s?ov(new O,s,a):o.clone(),h=ov(new O,n,a);if(!l.equals(h))return{update:c=>{o.lerpVectors(l,h,c)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function DE(e,t,i){return t.forEach((r,a)=>{e.setComponent(a,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function lv(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=!(o instanceof ae),h=o instanceof ae?o:new ae().fromArray(o),c=s?DE(new ae,s,a):h.clone(),d=DE(new ae,n,a);if(!c.equals(d))return{update:u=>{h.lerpVectors(c,d,u),l&&(t[e]=h.toArray())},start:()=>{h.copy(c),l&&(t[e]=h.toArray())},end:()=>{h.copy(d),l&&(t[e]=h.toArray())}}}function vK(e,t,i,r){let a=i[e]?i[e]:void 0,s=r[e];if(!s)return;let n=t[e],o=a?new je().fromArray(a):n.clone(),l=new O,h=new Rt,c=new O;o.decompose(l,h,c);let d=new je().fromArray(s),u=new O,p=new Rt,f=new O;if(d.decompose(u,p,f),!o.equals(d))return{update:m=>{TE.slerpQuaternions(h,p,m),EE.lerpVectors(l,u,m),CE.lerpVectors(c,f,m),n.compose(EE,TE,CE)},start:()=>{n.compose(l,h,c)},end:()=>{n.compose(u,p,f)}}}function yK(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=s?typeof s=="string"?a.getColor(s).clone():new Ct().setRGB(s.r,s.g,s.b):o.clone(),h=typeof n=="string"?a.getColor(n).clone():new Ct().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:d=>{c.lerpColors(l,h,d),t[e]?.copy?.(c)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function hm(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=new qr(o.r,o.g,o.b,o.a),h=s?typeof s=="string"?a.getColor(s).clone():new qr(s.r,s.g,s.b,s.a):l.clone(),c=typeof n=="string"?a.getColor(n).clone():new qr(n.r,n.g,n.b,n.a);if(!h.equals(c))return{update:d=>{l.lerpColors(h,c,d);let u=tt.lerp(h.a,c.a,d);l.a=u,t[e]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(c)}}}function Kl(e,t,i,r,a){if(typeof t[e]=="number")return va(e,t,i??{},r,a);if(Array.isArray(t[e]))return Zw(e,t,i??{},r,a)}var ohe=new xr;function Al(e,t,i,r,a){let s=i[e],n=r[e];if(typeof t[e]=="number")Math.abs(s-n)>mK&&(t[e]=tt.lerp(s,n,a));else if(Array.isArray(t[e]))for(let o=0,l=s.length;o<l;o++)t[e][o]=tt.lerp(s[o],n[o],a)}function xK(e,t,i,r){let a=[];if(!("cloner"in i)||!e.cloner)return a;let s=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;RD.forEach(p=>{let f;p==="count"?f=va("count",s.parameters,n,o,r.shared,!0):f=Kl(p,s.parameters,n??{},o,r.shared),f&&a.push(f)});let l=bK(s,n,o,r.shared);l?.length&&a.push(...l);let h=wK(s,n,o,r.shared);h?.length&&a.push(...h);let c=_K(s,n,o,r.shared);c?.length&&a.push(...c);let d=SK(s,n,o,r.shared);d?.length&&a.push(...d);let u=AK(s,n,o,r.shared);return u?.length&&a.push(...u),a.length&&a.push({update:()=>{s.update(r)}}),a}function bK(e,t,i,r){if(e.parameters.type!=="radial")return;let a=t.radial,s=i.radial;if(!s)return;let n=e.parameters.radial,o=[];return zw.forEach(l=>{let h=Kl(l,n,a??{},s,r);h&&o.push(h)}),o}function wK(e,t,i,r){if(e.parameters.type!=="linear")return;let a=t.linear,s=i.linear;if(!s)return;let n=[],o=e.parameters.linear;return kw.forEach(l=>{let h=Kl(l,o,a??{},s,r);h&&n.push(h)}),n}function _K(e,t,i,r){if(e.parameters.type!=="grid")return;let a=t.grid,s=i.grid;if(!s)return;let n=[],o=e.parameters.grid;return Fw.forEach(l=>{let h;l==="count"?h=Zw(l,o,a??{},s,r,!0):h=Kl(l,o,a??{},s,r),h&&n.push(h)}),n}function SK(e,t,i,r){if(e.parameters.type!=="toObject")return;let a=t.toObject,s=i.toObject;if(!s)return;let n=[],o=e.parameters.toObject;return Uw.forEach(l=>{let h;l==="count"?h=va(l,o,a??{},s,r,!0):h=Kl(l,o,a??{},s,r),h&&n.push(h)}),n}function AK(e,t,i,r){if(!e.parameters.randomness)return;let a=t.randomnessObject,s=i.randomnessObject;if(!s)return;let n=[],o=e.parameters.randomnessObject;return Nw.forEach(l=>{let h=Kl(l,o,a??{},s,r);h&&n.push(h)}),n}function MK(e,t,i,r){let a=r.cloner?.parameters;if(a){Al("count",a,e,t,i),a.count=Math.trunc(a.count);for(let s of zw)Al(s,a.radial,e.radial,t.radial,i);for(let s of kw)Al(s,a.linear,e.linear,t.linear,i);for(let s of Fw)Al(s,a.grid,e.grid,t.grid,i);for(let s of Uw)Al(s,a.toObject,e.toObject,t.toObject,i);return a}}function EK(e,t,i,r){let a=r.cloner?.parameters;if(a){for(let s of Nw)Al(s,a.randomnessObject,e.randomnessObject,t.randomnessObject,i);return a}}function Or(e,t=[0,0]){let i=e&&!isNaN(e[0])?e[0]:t[0],r=e&&!isNaN(e[1])?e[1]:t[1];return[i,r]}function Na(e,t,i){switch(e){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:let{control1:r,control2:a}=t??{...qg.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${a[0]}, ${a[1]} )`;case 6:let{mass:s,stiffness:n,damping:o,velocity:l}=i??{...Wg.defaultData},h=new BK(s,n,o,l),c=h.solve(1);return()=>d=>h.solve(d)/c;case 8:return()=>d=>Math.floor(d)}}var IE;(e=>{function t(i){return i&&typeof i.x=="number"&&typeof i.y=="number"&&typeof i.z=="number"}e.is=t})(IE||(IE={}));var eb;(e=>{function t(o,l){let h=[0,0],c=[1,1];if(o?.cubicControls)h=Or(o.cubicControls.control1,h);else switch(o?.type){case 2:h=[.42,0];break;case 3:h=[0,0];break;case 4:h=[.42,0];break;case 1:h=[.25,.1];break;case 0:h=[0,0];break;case 7:h=[.25,1];break}if(l?.cubicControls)c=Or(l.cubicControls.control2,c);else switch(l?.type){case 2:c=[1,1];break;case 3:c=[.58,1];break;case 4:c=[.58,1];break;case 1:c=[.25,1];break;case 0:c=[1,1];break;case 7:c=[.5,1];break}return{control1:h,control2:c}}e.getControlsWithDefault=t;function i(o,l){return{id:o,name:l,to:5,properties:new pt}}e.defaultData=i;function r(o){let l=new pt;return o.forEach(({data:h,id:c,fi:d})=>{if(h.type==="light"){let u=OE(["material",`${h.category} lighting`],c,d);l.push(u)}else{let u=OE(["material",h.type],c,d);l.push(u)}}),l}e.createMaterialGroup=r;function a(o){return Object.entries(o).reduce((l,[h,c])=>(typeof c!="string"&&l.push({name:c.name}),l),[])}e.createName=a;function s(o,l,h){let c=Uo.timeline({easing:Na(0),begin(){o.resetBBoxNeedsUpdate()},change(){o.resetBBoxNeedsUpdate()},direction:l.direction,autoplay:!1});return n(o,l,h).forEach(d=>c.add(d,0)),c.duration=l.to*1e3,c}e.createTimeline=s;function n(o,l,h,c){let d=[];return l.properties.forEach((u,p)=>{let f=u.data.path?.[0];if(f&&["position","rotation","scale"].includes(f)){let m=CK(u.data,h?.[f]);m&&d.push(...m)}if(f&&f==="shape size"&&"geometry"in o){let m=TK(o,u.data,h?.shapeSize);m&&d.push(...m)}if(f&&f==="path extrusion"&&o instanceof e0){let m=PK(o,u.data,h?.pathExtrusion);m&&d.push(m)}if(f&&f==="path snapping"&&o.data.pathSnapping){let m=DK(o,u.data,h?.pathSnapping);m&&d.push(m)}if(f&&f==="material"&&o.type==="Mesh"&&"material"in o&&o.material instanceof Wo){let m=u.data.id;if(m){let g=o.material.getLayerByUuid(m);if(g){let y=RE(g,u.data,h?.material,c);y&&d.push(y)}else{let y=o.material.getLayersOfType(u.data.type);if(y)for(let x of y){let b=RE(x,u.data,h?.material,c);b&&d.push(b)}}}}if(f&&f==="opacity"&&o.type==="Mesh"&&"material"in o){let m=IK(u.data,h?.opacity);m&&d.push(m)}if(f&&f==="cloner"){let m=OK(o,u.data,h?.cloner);m&&d.push(m)}if(f&&f==="camera"&&o instanceof Xr){let m=RK(o,u.data,h?.camera,"zoom");m&&d.push(m)}if(f&&f==="light"&&(o instanceof Zv||o instanceof C_||o instanceof Jv)){let m=LK(o,u.data,h?.light,u.data.path[1],c);m&&d.push(m)}}),d}e.addKeyframesToTimeline=n,e.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:Na(3),duration:1e3},opacity:{value:[0,1],easing:Na(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:Na(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:Na(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:Na(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(eb||(eb={}));function OE(e,t,i){let r=t;return{id:r,fi:i,data:{id:r,path:e,keyframes:new pt}}}var tI=["x","y","z"];function CK(e,t=()=>{}){let i=[];for(let r of tI){let a=[...e.keyframes??[]].filter(o=>o.data.value[r]!==void 0).sort((o,l)=>o.data.time-l.data.time),s=a[0];s&&t?.(s.data.value);let n={index:[],t:[]};for(let o=0;o<a.length-1;o++){let l=a[o],h=a[o+1]??l,c={duration:(h?.data?.time-l.data.time)*1e3,delay:o===0?a[0].data.time*1e3:0};o<a.length-1&&(n.t.push({...c,value:o%2===0?1:0,easing:Na(l.data.easing.type,{control1:Or(l.data.easing.cubicControls?.control1,[0,0]),control2:Or(h.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),n.index.push({...c,value:o,easing:"linear"}))}if(a.length>1){let o={t:0,index:0};i.push({targets:o,...n,update:l=>{let h=Math.ceil(o.index),c=h%2===0?o.t:1-o.t,d=a?.[h].data.value,u=a?.[h+1]?.data.value;if(d!==void 0&&u!==void 0){let p={[r]:d[r]+(u[r]-d[r])*c};t?.(p)}}})}}return i}function TK(e,t,i){let r=[];for(let a of tI){let s={},n=[...t.keyframes??[]].filter(l=>l.data.value[a]!==void 0).sort((l,h)=>l.data.time-h.data.time),o=n[0];o&&i?.(o.data.value),s={index:[],t:[]};for(let l=0;l<n.length-1;l++){let h=n[l],c=n[l+1]??h,d={duration:(c?.data?.time-h.data.time)*1e3,delay:l===0?n[0].data.time*1e3:0};l<n.length-1&&(s.t.push({...d,value:l%2===0?1:0,easing:Na(h.data.easing.type,{control1:Or(h.data.easing.cubicControls?.control1,[0,0]),control2:Or(c.data.easing.cubicControls?.control2,[1,1])},h.data.easing.springParameters)}),s.index.push({...d,value:l,easing:"linear"}))}if(n.length>1){let l={t:0,index:0};r.push({targets:l,...s,update:h=>{let c=Math.ceil(l.index),d=c%2===0?l.t:1-l.t,u=n?.[c].data.value,p=n?.[c+1]?.data.value;if(u!==void 0&&p!==void 0){let f={[a]:u[a]+(p[a]-u[a])*d};i?.(f)}}})}}return r}function PK(e,t,i){let r={},a=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time),s=a[0];s&&i?.(e,s.data.value),r={index:[],t:[]};for(let n=0;n<a.length-1;n++){let o=a[n],l=a[n+1]??o,h={duration:(l?.data?.time-o.data.time)*1e3,delay:n===0?a[0].data.time*1e3:0};n<a.length-1&&(r.t.push({...h,value:n%2===0?1:0,easing:Na(o.data.easing.type,{control1:Or(o.data.easing.cubicControls?.control1,[0,0]),control2:Or(l.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),r.index.push({...h,value:n,easing:"linear"}))}if(a.length>1){let n={t:0,index:0};return{targets:n,...r,update:o=>{let l=Math.ceil(n.index),h=l%2===0?n.t:1-n.t,c=a?.[Math.min(l,a.length-1)].data.value,d=a?.[Math.min(l,a.length-1)+1]?.data.value;i?.(e,Kse(e,c,d,h))}}}}function DK(e,t,i){let r={},a=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time),s=a[0];s&&i?.(s.data.value),r={index:[],t:[]};for(let n=0;n<a.length-1;n++){let o=a[n],l=a[n+1]??o,h={duration:(l?.data?.time-o.data.time)*1e3,delay:n===0?a[0].data.time*1e3:0};n<a.length-1&&(r.t.push({...h,value:n%2===0?1:0,easing:Na(o.data.easing.type,{control1:Or(o.data.easing.cubicControls?.control1,[0,0]),control2:Or(l.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),r.index.push({...h,value:n,easing:"linear"}))}if(a.length>1){let n={t:0,index:0};return{targets:n,...r,update:o=>{let l=Math.ceil(n.index),h=l%2===0?n.t:1-n.t,c=a?.[Math.min(l,a.length-1)].data.value,d=a?.[Math.min(l,a.length-1)+1]?.data.value;i?.(Zse(e,c,d,h))}}}}function RE(e,t,i,r){if(t){let a={},s=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time);if("data"in e){let n=s[0];n&&i?.(n.data.value,e),a={index:[],t:[]};for(let o=0;o<s.length-1;o++){let l=s[o],h=s[o+1]??l,c={duration:(h?.data?.time-l.data.time)*1e3,delay:o===0?s[0].data.time*1e3:0};o<s.length-1&&(a.t.push({...c,value:o%2===0?1:0,easing:Na(l.data.easing.type,{control1:Or(l.data.easing.cubicControls?.control1,[0,0]),control2:Or(h.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),a.index.push({...c,value:o,easing:"linear"}))}if(s.length>1){let o={t:0,index:0};return{targets:o,...a,update:l=>{let h=Math.ceil(o.index),c=h%2===0?o.t:1-o.t,d=s?.[Math.min(h,s.length-1)].data.value,u=s?.[Math.min(h,s.length-1)+1]?.data.value,p={},f={};if(Object.keys(d).length>0&&Object.keys(u).length>0){for(let m in e.data)if(m in d&&m in u){let g=Jw(d[m],u[m],c,r);g!==void 0&&(p[m]=g,f[m]={start:d,end:u,t:c})}}i?.({...p},e,f)}}}}}}function IK(e,t){if(e){let i={},r=[...e.keyframes??[]].sort((s,n)=>s.data.time-n.data.time),a=r[0];a&&t?.(a.data.value),i={index:[],t:[]};for(let s=0;s<r.length-1;s++){let n=r[s],o=r[s+1]??n,l={duration:(o?.data?.time-n.data.time)*1e3,delay:s===0?r[0].data.time*1e3:0};s<r.length-1&&(i.t.push({...l,value:s%2===0?1:0,easing:Na(n.data.easing.type,{control1:Or(n.data.easing.cubicControls?.control1,[0,0]),control2:Or(o.data.easing.cubicControls?.control2,[1,1])},n.data.easing.springParameters)}),i.index.push({...l,value:s,easing:"linear"}))}if(r.length>1){let s={t:0,index:0};return{targets:s,...i,update:n=>{let o=Math.ceil(s.index),l=o%2===0?s.t:1-s.t,h=r?.[Math.min(o,r.length-1)].data.value,c=r?.[Math.min(o,r.length-1)+1]?.data.value,d=tt.lerp(h,c,l);t?.(d)}}}}}function OK(e,t,i){let r={},a=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time),s=a[0];s&&i?.(e,s.data.value,s.data.value),r={index:[],t:[]};for(let n=0;n<a.length-1;n++){let o=a[n],l=a[n+1]??o,h={duration:(l?.data?.time-o.data.time)*1e3,delay:n===0?a[0].data.time*1e3:0};n<a.length-1&&(r.t.push({...h,value:n%2===0?1:0,easing:Na(o.data.easing.type,{control1:Or(o.data.easing.cubicControls?.control1,[0,0]),control2:Or(l.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),r.index.push({...h,value:n,easing:"linear"}))}if(a.length>1){let n={t:0,index:0};return{targets:n,...r,update:o=>{let l=Math.ceil(n.index),h=l%2===0?n.t:1-n.t,c=a?.[Math.min(l,a.length-1)].data.value,d=a?.[Math.min(l,a.length-1)+1]?.data.value;i?.(e,c.randomnessObject?void 0:MK(c,d,h,e),c.randomnessObject?EK(c,d,h,e):void 0)}}}}function Jw(e,t,i,r){if(typeof e=="string"&&r&&(e=r.color(e)),typeof t=="string"&&r&&(e=r.color(t)),typeof e=="number")return e===t?void 0:tt.lerp(e,t,i);if(_i.is(e))return _i.lerp(e,t,i);if(Cr.is(e))return Cr.lerp(e,t,i);if(Array.isArray(e))return(e.length>t.length?t:e).map((a,s,n)=>{if(Array.isArray(a)){let o=e[s].length>t[s].length?t[s].length:e[s].length;return(o===4?Lp:o===3?Ul:kn).lerp(e[s],t[s],i)}else return tt.lerp(e[s],t[s],i)});if(typeof e=="object"&&e!==null){let a={};for(let s in e){let n=Jw(e[s],t[s],i,r);n!==void 0&&(a[s]=n)}return a}}function RK(e,t,i,r){if(t){let a={[r]:[]},s=[...t.keyframes??[]].sort((o,l)=>o.data.time-l.data.time),n=s[0];n&&(e[r]=n.data.value,n&&i?.(r,n.data.value));for(let o=0;o<s.length-1;o++){let l=s[o];if(!Number.isFinite(l.data.value))continue;let h=s[o+1]??l,c=h.data.value;a[r].push({value:c,easing:Na(l.data.easing.type,{control1:Or(l.data.easing.cubicControls?.control1,[0,0]),control2:Or(h.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters),duration:(h?.data?.time-l.data.time)*1e3,delay:o===0?s[0].data.time*1e3:0})}if(s.length>1)return{targets:e,...a,update:()=>{i?.(r,e[r])}}}}function LK(e,t,i,r,a){if(t){let s={},n=[...t.keyframes??[]].sort((l,h)=>l.data.time-h.data.time),o=n[0];if(o){let l=o.data.value;e[r]=l,i?.(r,l)}s={index:[],t:[]};for(let l=0;l<n.length-1;l++){let h=n[l],c=n[l+1]??h,d={duration:(c?.data?.time-h.data.time)*1e3,delay:l===0?n[0].data.time*1e3:0};l<n.length-1&&(s.t.push({...d,value:l%2===0?1:0,easing:Na(h.data.easing.type,{control1:Or(h.data.easing.cubicControls?.control1,[0,0]),control2:Or(c.data.easing.cubicControls?.control2,[1,1])},h.data.easing.springParameters)}),s.index.push({...d,value:l,easing:"linear"}))}if(n.length>1){let l={t:0,index:0};return{targets:l,...s,update:()=>{let h=Math.ceil(l.index),c=h%2===0?l.t:1-l.t,d=n?.[Math.min(h,n.length-1)].data.value,u=n?.[Math.min(h,n.length-1)+1]?.data.value,p=Jw(d,u,c,a);i?.(r,p)}}}}}var BK=class{constructor(e=1,t=100,i=10,r=0){this.mass=e,this.stiffness=t,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(t/e),this.m_zeta=i/(2*Math.sqrt(t*e)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0+-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+this.m_w0)}solve(e){return this.m_zeta<1?e=Math.exp(-e*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*e)+this.m_B*Math.sin(this.m_wd*e)):e=(this.m_A+this.m_B*e)*Math.exp(-e*this.m_w0),1-e}getDuration(){let e=.16666666666666666,t=0,i=0;for(;;)if(t+=e,this.solve(t)===1){if(i++,i>=16)break}else i=0;return t*e*1e3}},zK=Math.pow(2,-24),cm=class{constructor(){}};function Bn(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function LE(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let a=e[r+3]-e[r];a>i&&(i=a,t=r)}return t}function BE(e,t){t.set(e)}function zE(e,t,i){let r,a;for(let s=0;s<3;s++){let n=s+3;r=e[s],a=t[s],i[s]=r<a?r:a,r=e[n],a=t[n],i[n]=r>a?r:a}}function dm(e,t,i){for(let r=0;r<3;r++){let a=t[e+2*r],s=t[e+2*r+1],n=a-s,o=a+s;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function Eu(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function kK(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,a;i>65535?a=new Uint32Array(new r(4*i)):a=new Uint16Array(new r(2*i)),e.setIndex(new Pt(a,1));for(let s=0;s<i;s++)a[s]=s}}function FK(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let a of e.groups)i.add(a.start),i.add(a.start+a.count);let r=Array.from(i.values()).sort((a,s)=>a-s);for(let a=0;a<r.length-1;a++){let s=r[a],n=r[a+1];t.push({offset:s/3,count:(n-s)/3})}return t}function S1(e,t,i,r,a=null){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,d=1/0,u=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,y=a!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],S=e[x+1],A=_-S,E=_+S;A<s&&(s=A),E>l&&(l=E),y&&_<d&&(d=_),y&&_>f&&(f=_);let M=e[x+2],T=e[x+3],P=M-T,R=M+T;P<n&&(n=P),R>h&&(h=R),y&&M<u&&(u=M),y&&M>m&&(m=M);let z=e[x+4],U=e[x+5],L=z-U,j=z+U;L<o&&(o=L),j>c&&(c=j),y&&z<p&&(p=z),y&&z>g&&(g=z)}r[0]=s,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,y&&(a[0]=d,a[1]=u,a[2]=p,a[3]=f,a[4]=m,a[5]=g)}function UK(e,t,i,r){let a=1/0,s=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,d=(t+i)*6;c<d;c+=6){let u=e[c+0];u<a&&(a=u),u>o&&(o=u);let p=e[c+2];p<s&&(s=p),p>l&&(l=p);let f=e[c+4];f<n&&(n=f),f>h&&(h=f)}r[0]=a,r[1]=s,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function NK(e,t,i,r,a){let s=i,n=i+r-1,o=a.pos,l=a.axis*2;for(;;){for(;s<=n&&t[s*6+l]<o;)s++;for(;s<=n&&t[n*6+l]>=o;)n--;if(s<n){for(let h=0;h<3;h++){let c=e[s*3+h];e[s*3+h]=e[n*3+h],e[n*3+h]=c;let d=t[s*6+h*2+0];t[s*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=d;let u=t[s*6+h*2+1];t[s*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=u}s++,n--}else return s}}var xo=32,VK=(e,t)=>e.candidate-t.candidate,ol=new Array(xo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),um=new Float32Array(6);function jK(e,t,i,r,a,s){let n=-1,o=0;if(s===0)n=LE(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(s===1)n=LE(e),n!==-1&&(o=HK(i,r,a,n));else if(s===2){let l=Eu(e),h=1.25*a,c=r*6,d=(r+a)*6;for(let u=0;u<3;u++){let p=t[u],f=(t[u+3]-p)/xo;if(a<xo/4){let m=[...ol];m.length=a;let g=0;for(let x=c;x<d;x+=6,g++){let b=m[g];b.candidate=i[x+2*u],b.count=0;let{bounds:_,leftCacheBounds:S,rightCacheBounds:A}=b;for(let E=0;E<3;E++)A[E]=1/0,A[E+3]=-1/0,S[E]=1/0,S[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;dm(x,i,_)}m.sort(VK);let y=a;for(let x=0;x<y;x++){let b=m[x];for(;x+1<y&&m[x+1].candidate===b.candidate;)m.splice(x+1,1),y--}for(let x=c;x<d;x+=6){let b=i[x+2*u];for(let _=0;_<y;_++){let S=m[_];b>=S.candidate?dm(x,i,S.rightCacheBounds):(dm(x,i,S.leftCacheBounds),S.count++)}}for(let x=0;x<y;x++){let b=m[x],_=b.count,S=a-b.count,A=b.leftCacheBounds,E=b.rightCacheBounds,M=0;_!==0&&(M=Eu(A)/l);let T=0;S!==0&&(T=Eu(E)/l);let P=1+1.25*(M*_+T*S);P<h&&(n=u,h=P,o=b.candidate)}}else{for(let y=0;y<xo;y++){let x=ol[y];x.count=0,x.candidate=p+f+y*f;let b=x.bounds;for(let _=0;_<3;_++)b[_]=1/0,b[_+3]=-1/0}for(let y=c;y<d;y+=6){let x=~~((i[y+2*u]-p)/f);x>=xo&&(x=xo-1);let b=ol[x];b.count++,dm(y,i,b.bounds)}let m=ol[xo-1];BE(m.bounds,m.rightCacheBounds);for(let y=xo-2;y>=0;y--){let x=ol[y],b=ol[y+1];zE(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let g=0;for(let y=0;y<xo-1;y++){let x=ol[y],b=x.count,_=x.bounds,S=ol[y+1].rightCacheBounds;b!==0&&(g===0?BE(_,um):zE(_,um,um)),g+=b;let A=0,E=0;g!==0&&(A=Eu(um)/l);let M=a-g;M!==0&&(E=Eu(S)/l);let T=1+1.25*(A*g+E*M);T<h&&(n=u,h=T,o=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:n,pos:o}}function HK(e,t,i,r){let a=0;for(let s=t,n=t+i;s<n;s++)a+=e[s*6+r*2];return a/i}function GK(e,t){let i=e.attributes.position,r=e.index.array,a=r.length/3,s=new Float32Array(a*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let d=0;d<a;d++){let u=d*3,p=d*6,f,m,g;n?(f=r[u+0],m=r[u+1],g=r[u+2]):(f=r[u+0]*h+l,m=r[u+1]*h+l,g=r[u+2]*h+l);for(let y=0;y<3;y++){let x,b,_;n?(x=i[c[y]](f),b=i[c[y]](m),_=i[c[y]](g)):(x=o[f+y],b=o[m+y],_=o[g+y]);let S=x;b<S&&(S=b),_<S&&(S=_);let A=x;b>A&&(A=b),_>A&&(A=_);let E=(A-S)/2,M=y*2;s[p+M+0]=S+E,s[p+M+1]=E+(Math.abs(S)+E)*zK,S<t[y]&&(t[y]=S),A>t[y+3]&&(t[y+3]=A)}}return s}function WK(e,t){function i(y){u&&u(y/p)}function r(y,x,b,_=null,S=0){if(!f&&S>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=c||S>=l)return i(x+b),y.offset=x,y.count=b,y;let A=jK(y.boundingData,_,n,x,b,d);if(A.axis===-1)return i(x+b),y.offset=x,y.count=b,y;let E=NK(o,n,x,b,A);if(E===x||E===x+b)i(x+b),y.offset=x,y.count=b;else{y.splitAxis=A.axis;let M=new cm,T=x,P=E-x;y.left=M,M.boundingData=new Float32Array(6),S1(n,T,P,M.boundingData,s),r(M,T,P,s,S+1);let R=new cm,z=E,U=b-P;y.right=R,R.boundingData=new Float32Array(6),S1(n,z,U,R.boundingData,s),r(R,z,U,s,S+1)}return y}kK(e,t);let a=new Float32Array(6),s=new Float32Array(6),n=GK(e,a),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,d=t.strategy,u=t.onProgress,p=e.index.count/3,f=!1,m=[],g=FK(e);if(g.length===1){let y=g[0],x=new cm;x.boundingData=a,UK(n,y.offset,y.count,s),r(x,y.offset,y.count,s),m.push(x)}else for(let y of g){let x=new cm;x.boundingData=new Float32Array(6),S1(n,y.offset,y.count,x.boundingData,s),r(x,y.offset,y.count,s),m.push(x)}return m}function qK(e,t){let i=WK(e,t),r,a,s,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<i.length;c++){let d=i[c],u=l(d),p=new o(32*u);r=new Float32Array(p),a=new Uint32Array(p),s=new Uint16Array(p),h(0,d),n.push(p)}return n;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function h(c,d){let u=c/4,p=c/2,f=!!d.count,m=d.boundingData;for(let g=0;g<6;g++)r[u+g]=m[g];if(f){let g=d.offset,y=d.count;return a[u+6]=g,s[p+14]=y,s[p+15]=65535,c+32}else{let g=d.left,y=d.right,x=d.splitAxis,b;if(b=h(c+32,g),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return a[u+6]=b/4,b=h(b,y),a[u+7]=x,b}}}var qn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let a=0,s=e.length;a<s;a++){let n=e[a][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let a=0,s=t.length;a<s;a++){let n=t[a],o=e.dot(n);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};qn.prototype.setFromBox=function(){let e=new O;return function(t,i){let r=i.min,a=i.max,s=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+a.x*(1-o),e.y=r.y*l+a.y*(1-l),e.z=r.z*h+a.z*(1-h);let c=t.dot(e);s=Math.min(c,s),n=Math.max(c,n)}this.min=s,this.max=n}}();var lhe=function(){let e=new qn;return function(t,i){let r=t.points,a=t.satAxes,s=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let c=s[h],d=a[h];if(e.setFromPoints(d,n),c.isSeparated(e))return!1}for(let h=0;h<3;h++){let c=l[h],d=o[h];if(e.setFromPoints(d,r),c.isSeparated(e))return!1}}}(),XK=function(){let e=new O,t=new O,i=new O;return function(r,a,s){let n=r.start,o=e,l=a.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(a.end,a.start);let c=i.dot(h),d=h.dot(o),u=h.dot(h),p=i.dot(o),f=o.dot(o)*u-d*d,m,g;f!==0?m=(c*d-p*u)/f:m=0,g=(c+m*d)/u,s.x=m,s.y=g}}(),$w=function(){let e=new ae,t=new O,i=new O;return function(r,a,s,n){XK(r,a,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,s),a.at(l,n);return}else if(o>=0&&o<=1){l<0?a.at(0,n):a.at(1,n),r.closestPointToPoint(n,!0,s);return}else if(l>=0&&l<=1){o<0?r.at(0,s):r.at(1,s),a.closestPointToPoint(s,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=a.start:c=a.end;let d=t,u=i;if(r.closestPointToPoint(c,!0,t),a.closestPointToPoint(h,!0,i),d.distanceToSquared(c)<=u.distanceToSquared(h)){s.copy(d),n.copy(c);return}else{s.copy(h),n.copy(u);return}}}}(),YK=function(){let e=new O,t=new O,i=new Ka,r=new zs;return function(a,s){let{radius:n,center:o}=a,{a:l,b:h,c}=s;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let d=s.getPlane(i);if(Math.abs(d.distanceToPoint(o))<=n){let u=d.projectPoint(o,t);if(s.containsPoint(u))return!0}return!1}}(),QK=1e-15;function Tc(e){return Math.abs(e)<QK}var Go=class extends ya{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new O),this.satBounds=new Array(4).fill().map(()=>new qn),this.points=[this.a,this.b,this.c],this.sphere=new cs,this.plane=new Ka,this.needsUpdate=!0}intersectsSphere(e){return YK(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,a=this.satAxes,s=this.satBounds,n=a[0],o=s[0];this.getNormal(n),o.setFromPoints(n,r);let l=a[1],h=s[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=a[2],d=s[2];c.subVectors(t,i),d.setFromPoints(c,r);let u=a[3],p=s[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};Go.prototype.closestPointToSegment=function(){let e=new O,t=new O,i=new zs;return function(r,a=null,s=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let d=0;d<3;d++){let u=(d+1)%3;i.start.copy(l[d]),i.end.copy(l[u]),$w(i,r,e,t),h=e.distanceToSquared(t),h<c&&(c=h,a&&a.copy(e),s&&s.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(o)),Math.sqrt(c)}}();Go.prototype.intersectsTriangle=function(){let e=new Go,t=new Array(3),i=new Array(3),r=new qn,a=new qn,s=new O,n=new O,o=new O,l=new O,h=new zs,c=new zs,d=new zs;return function(u,p=null,f=!1){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let m=this.plane,g=u.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let y=this.satBounds,x=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let S=0;S<4;S++){let A=y[S],E=x[S];if(r.setFromPoints(E,i),A.isSeparated(r))return!1}let b=u.satBounds,_=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){let A=b[S],E=_[S];if(r.setFromPoints(E,t),A.isSeparated(r))return!1}for(let S=0;S<4;S++){let A=x[S];for(let E=0;E<4;E++){let M=_[E];if(s.crossVectors(A,M),r.setFromPoints(s,t),a.setFromPoints(s,i),r.isSeparated(a))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let y=this.points,x=!1,b=0;for(let U=0;U<3;U++){let L=y[U],j=y[(U+1)%3];h.start.copy(L),h.end.copy(j),h.delta(n);let q=x?c.start:c.end,Q=Tc(g.distanceToPoint(L));if(Tc(g.normal.dot(n))&&Q){c.copy(h),b=2;break}if((g.intersectLine(h,q)||Q)&&!Tc(q.distanceTo(j))){if(b++,x)break;x=!0}}if(b===1&&u.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let _=u.points,S=!1,A=0;for(let U=0;U<3;U++){let L=_[U],j=_[(U+1)%3];h.start.copy(L),h.end.copy(j),h.delta(o);let q=S?d.start:d.end,Q=Tc(m.distanceToPoint(L));if(Tc(m.normal.dot(o))&&Q){d.copy(h),A=2;break}if((m.intersectLine(h,q)||Q)&&!Tc(q.distanceTo(j))){if(A++,S)break;S=!0}}if(A===1&&this.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(A!==2)return!1;if(c.delta(n),d.delta(o),n.dot(o)<0){let U=d.start;d.start=d.end,d.end=U}let E=c.start.dot(n),M=c.end.dot(n),T=d.start.dot(n),P=d.end.dot(n),R=M<T,z=E<P;return E!==P&&T!==M&&R===z?!1:(p&&(l.subVectors(c.start,d.start),l.dot(n)>0?p.start.copy(c.start):p.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(d.end)),!0)}}}();Go.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Go.prototype.distanceToTriangle=function(){let e=new O,t=new O,i=["a","b","c"],r=new zs,a=new zs;return function(s,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(s,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let d,u=i[c],p=s[u];this.closestPointToPoint(p,e),d=p.distanceToSquared(e),d<h&&(h=d,n&&n.copy(e),o&&o.copy(p));let f=this[u];s.closestPointToPoint(f,e),d=f.distanceToSquared(e),d<h&&(h=d,n&&n.copy(f),o&&o.copy(e))}for(let c=0;c<3;c++){let d=i[c],u=i[(c+1)%3];r.set(this[d],this[u]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];a.set(s[f],s[m]),$w(r,a,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Xn=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new O,this.max=new O,this.matrix=new je,this.invMatrix=new je,this.points=new Array(8).fill().map(()=>new O),this.satAxes=new Array(3).fill().map(()=>new O),this.satBounds=new Array(3).fill().map(()=>new qn),this.alignedSatBounds=new Array(3).fill().map(()=>new qn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Xn.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let d=1*l|2*h|4*c,u=r[d];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=c?i.z:t.z,u.applyMatrix4(e)}let a=this.satBounds,s=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=s[l],c=a[l],d=1<<l,u=r[d];h.subVectors(n,u),c.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Xn.prototype.intersectsBox=function(){let e=new qn;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,a=this.satBounds,s=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=s[o],h=a[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Xn.prototype.intersectsTriangle=function(){let e=new Go,t=new Array(3),i=new qn,r=new qn,a=new O;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(e.copy(s),e.update(),s=e);let n=this.satBounds,o=this.satAxes;t[0]=s.a,t[1]=s.b,t[2]=s.c;for(let d=0;d<3;d++){let u=n[d],p=o[d];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=s.satBounds,h=s.satAxes,c=this.points;for(let d=0;d<3;d++){let u=l[d],p=h[d];if(i.setFromPoints(p,c),u.isSeparated(i))return!1}for(let d=0;d<3;d++){let u=o[d];for(let p=0;p<4;p++){let f=h[p];if(a.crossVectors(u,f),i.setFromPoints(a,t),r.setFromPoints(a,c),i.isSeparated(r))return!1}}return!0}}();Xn.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Xn.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Xn.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new zs),i=new Array(12).fill().map(()=>new zs),r=new O,a=new O;return function(s,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(a),this.closestPointToPoint(a,r),s.closestPointToPoint(r,a),o&&o.copy(r),l&&l.copy(a)),0;let h=n*n,c=s.min,d=s.max,u=this.points,p=1/0;for(let m=0;m<8;m++){let g=u[m];a.copy(g).clamp(c,d);let y=g.distanceToSquared(a);if(y<p&&(p=y,o&&o.copy(g),l&&l.copy(a),y<h))return Math.sqrt(y)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let y=0;y<=1;y++){let x=(m+1)%3,b=(m+2)%3,_=g<<x|y<<b,S=1<<m|g<<x|y<<b,A=u[_],E=u[S];t[f].set(A,E);let M=e[m],T=e[x],P=e[b],R=i[f],z=R.start,U=R.end;z[M]=c[M],z[T]=g?c[T]:d[T],z[P]=y?c[P]:d[T],U[M]=d[M],U[T]=g?c[T]:d[T],U[P]=y?c[P]:d[T],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let y=0;y<=1;y++){a.x=m?d.x:c.x,a.y=g?d.y:c.y,a.z=y?d.z:c.z,this.closestPointToPoint(a,r);let x=a.distanceToSquared(r);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(a),x<h))return Math.sqrt(x)}for(let m=0;m<12;m++){let g=t[m];for(let y=0;y<12;y++){let x=i[y];$w(g,x,r,a);let b=r.distanceToSquared(a);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(a),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var Pc=new O,Dc=new O,Ic=new O,pm=new ae,fm=new ae,mm=new ae,kE=new O,FE=new O,UE=new O,gm=new O;function KK(e,t,i,r,a,s){let n;return s===na?n=e.intersectTriangle(r,i,t,!0,a):n=e.intersectTriangle(t,i,r,s!==Pa,a),n===null?null:{distance:e.origin.distanceTo(a),point:a.clone()}}function ZK(e,t,i,r,a,s,n,o,l){Pc.fromBufferAttribute(t,s),Dc.fromBufferAttribute(t,n),Ic.fromBufferAttribute(t,o);let h=KK(e,Pc,Dc,Ic,gm,l);if(h){r&&(pm.fromBufferAttribute(r,s),fm.fromBufferAttribute(r,n),mm.fromBufferAttribute(r,o),h.uv=ya.getInterpolation(gm,Pc,Dc,Ic,pm,fm,mm,new ae)),a&&(pm.fromBufferAttribute(a,s),fm.fromBufferAttribute(a,n),mm.fromBufferAttribute(a,o),h.uv1=ya.getInterpolation(gm,Pc,Dc,Ic,pm,fm,mm,new ae)),i&&(kE.fromBufferAttribute(i,s),FE.fromBufferAttribute(i,n),UE.fromBufferAttribute(i,o),h.normal=ya.getInterpolation(gm,Pc,Dc,Ic,kE,FE,UE,new O),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let c={a:s,b:n,c:o,normal:new O,materialIndex:0};ya.getNormal(Pc,Dc,Ic,c.normal),h.face=c,h.faceIndex=s}return h}function iI(e,t,i,r,a){let s=r*3,n=e.index.getX(s),o=e.index.getX(s+1),l=e.index.getX(s+2),{position:h,normal:c,uv:d,uv1:u}=e.attributes,p=ZK(i,h,c,d,u,n,o,l,t);return p?(p.faceIndex=r,a&&a.push(p),p):null}function JK(e,t,i,r,a,s){for(let n=r,o=r+a;n<o;n++)iI(e,t,i,n,s)}function $K(e,t,i,r,a){let s=1/0,n=null;for(let o=r,l=r+a;o<l;o++){let h=iI(e,t,i,o);h&&h.distance<s&&(n=h,s=h.distance)}return n}function On(e,t,i,r){let a=e.a,s=e.b,n=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),a.x=r.getX(o),a.y=r.getY(o),a.z=r.getZ(o),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function NE(e,t,i,r,a,s,n){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(On(n,h*3,o,l),n.needsUpdate=!0,r(n,h,a,s))return!0;return!1}var rI=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function Ml(e,t){return t[e+15]===65535}function dd(e,t){return t[e+6]}function Up(e,t){return t[e+14]}function Np(e){return e+8}function Vp(e,t){return t[e+6]}function eZ(e,t){return t[e+7]}var ad=new wr,hv=new O,tZ=["x","y","z"];function tb(e,t,i,r,a){let s=e*2,n=Jd,o=Nl,l=Vl;if(Ml(s,o)){let h=dd(e,l),c=Up(s,o);JK(t,i,r,h,c,a)}else{let h=Np(e);cv(h,n,r,hv)&&tb(h,t,i,r,a);let c=Vp(e,l);cv(c,n,r,hv)&&tb(c,t,i,r,a)}}function ib(e,t,i,r){let a=e*2,s=Jd,n=Nl,o=Vl;if(Ml(a,n)){let l=dd(e,o),h=Up(a,n);return $K(t,i,r,l,h)}else{let l=eZ(e,o),h=tZ[l],c=r.direction[h]>=0,d,u;c?(d=Np(e),u=Vp(e,o)):(d=Vp(e,o),u=Np(e));let p=cv(d,s,r,hv)?ib(d,t,i,r):null;if(p){let m=p.point[h];if(c?m<=s[u+l]:m>=s[u+l+3])return p}let f=cv(u,s,r,hv)?ib(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var iZ=function(){let e,t,i=[],r=new rI(()=>new wr);return function(...s){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=a(...s);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function a(s,n,o,l,h=null,c=0,d=0){function u(x){let b=x*2,_=Nl,S=Vl;for(;!Ml(b,_);)x=Np(x),b=x*2;return dd(x,S)}function p(x){let b=x*2,_=Nl,S=Vl;for(;!Ml(b,_);)x=Vp(x,S),b=x*2;return dd(x,S)+Up(b,_)}let f=s*2,m=Jd,g=Nl,y=Vl;if(Ml(f,g)){let x=dd(s,y),b=Up(f,g);return Bn(s,m,e),l(x,b,!1,d,c+s,e)}else{let x=Np(s),b=Vp(s,y),_=x,S=b,A,E,M,T;if(h&&(M=e,T=t,Bn(_,m,M),Bn(S,m,T),A=h(M),E=h(T),E<A)){_=b,S=x;let q=A;A=E,E=q,M=T}M||(M=e,Bn(_,m,M));let P=Ml(_*2,g),R=o(M,P,A,d+1,c+_),z;if(R===2){let q=u(_),Q=p(_)-q;z=l(q,Q,!0,d+1,c+_,M)}else z=R&&a(_,n,o,l,h,c,d+1);if(z)return!0;T=t,Bn(S,m,T);let U=Ml(S*2,g),L=o(T,U,E,d+1,c+S),j;if(L===2){let q=u(S),Q=p(S)-q;j=l(q,Q,!0,d+1,c+S,T)}else j=L&&a(S,n,o,l,h,c,d+1);return!!j}}}(),rZ=function(){let e=new Go,t=new Go,i=new je,r=new Xn,a=new Xn;return function s(n,o,l,h,c=null){let d=n*2,u=Jd,p=Nl,f=Vl;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),c=r),Ml(d,p)){let m=o,g=m.index,y=m.attributes.position,x=l.index,b=l.attributes.position,_=dd(n,f),S=Up(d,p);if(i.copy(h).invert(),l.boundsTree)return Bn(n,u,a),a.matrix.copy(i),a.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>a.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let E=_*3,M=(S+_)*3;E<M;E+=3)if(On(t,E,g,y),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=_*3,E=S+_*3;A<E;A+=3){On(e,A,g,y),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let M=0,T=x.count;M<T;M+=3)if(On(t,M,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return Bn(m,u,ad),!!(c.intersectsBox(ad)&&s(m,o,l,h,c)||(Bn(g,u,ad),c.intersectsBox(ad)&&s(g,o,l,h,c)))}}}();function cv(e,t,i,r){return Bn(e,t,ad),i.intersectBox(ad,r)}var rb=[],lg,Jd,Nl,Vl;function Ku(e){lg&&rb.push(lg),lg=e,Jd=new Float32Array(e),Nl=new Uint16Array(e),Vl=new Uint32Array(e)}function vm(){lg=null,Jd=null,Nl=null,Vl=null,rb.length&&Ku(rb.pop())}var A1=Symbol("skip tree generation"),M1=new wr,E1=new wr,Oc=new je,hh=new Xn,Cu=new Xn,Tu=new O,ym=new O,aZ=new O,sZ=new O,nZ=new O,VE=new wr,yn=new rI(()=>new Go),dp=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),dp.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,a=i.getIndex(),s;return t.cloneBuffers?s={roots:r.map(n=>n.slice()),index:a.array.slice()}:s={roots:r,index:a.array},s}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),dp.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:a}=e,s=new dp(t,{...i,[A1]:!0});if(s._roots=a,i.setIndex){let n=t.getIndex();if(n===null){let o=new Pt(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return s}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[A1]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[A1]||(this._roots=qK(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new wr))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,a,s,n,o,l=0,h=this._roots;for(let d=0,u=h.length;d<u;d++)a=h[d],s=new Uint32Array(a),n=new Uint16Array(a),o=new Float32Array(a),c(0,l),l+=a.byteLength;function c(d,u,p=!1){let f=d*2;if(n[f+15]===65535){let m=s[d+6],g=n[f+14],y=1/0,x=1/0,b=1/0,_=-1/0,S=-1/0,A=-1/0;for(let E=3*m,M=3*(m+g);E<M;E++){let T=i[E],P=r.getX(T),R=r.getY(T),z=r.getZ(T);P<y&&(y=P),P>_&&(_=P),R<x&&(x=R),R>S&&(S=R),z<b&&(b=z),z>A&&(A=z)}return o[d+0]!==y||o[d+1]!==x||o[d+2]!==b||o[d+3]!==_||o[d+4]!==S||o[d+5]!==A?(o[d+0]=y,o[d+1]=x,o[d+2]=b,o[d+3]=_,o[d+4]=S,o[d+5]=A,!0):!1}else{let m=d+8,g=s[d+6],y=m+u,x=g+u,b=p,_=!1,S=!1;e?b||(_=e.has(y),S=e.has(x),b=!_&&!S):(_=!0,S=!0);let A=b||_,E=b||S,M=!1;A&&(M=c(m,u,b));let T=!1;E&&(T=c(g,u,b));let P=M||T;if(P)for(let R=0;R<3;R++){let z=m+R,U=g+R,L=o[z],j=o[z+3],q=o[U],Q=o[U+3];o[d+R]=L<q?L:q,o[d+R+3]=j>Q?j:Q}return P}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),a=new Uint16Array(i);s(0);function s(n,o=0){let l=n*2,h=a[l+15]===65535;if(h){let c=r[n+6],d=a[l+14];e(o,h,new Float32Array(i,n*4,6),c,d)}else{let c=n+8,d=r[n+6],u=r[n+7];e(o,h,new Float32Array(i,n*4,6),u)||(s(c,o+1),s(d,o+1))}}}raycast(e,t=nn){let i=this._roots,r=this.geometry,a=[],s=t.isMaterial,n=Array.isArray(t),o=r.groups,l=s?t.side:t;for(let h=0,c=i.length;h<c;h++){let d=n?t[o[h].materialIndex].side:l,u=a.length;if(Ku(i[h]),tb(0,r,d,e,a),vm(),n){let p=o[h].materialIndex;for(let f=u,m=a.length;f<m;f++)a[f].face.materialIndex=p}}return a}raycastFirst(e,t=nn){let i=this._roots,r=this.geometry,a=t.isMaterial,s=Array.isArray(t),n=null,o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let d=s?t[o[h].materialIndex].side:l;Ku(i[h]);let u=ib(0,r,d,e);vm(),u!=null&&(n==null||u.distance<n.distance)&&(n=u,s&&(u.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let a of this._roots)if(Ku(a),r=rZ(0,i,e,t),vm(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let d=t;t=(u,p,f,m)=>{let g=p*3;return d(u,g,g+1,g+2,f,m)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let a=yn.getPrimitive(),{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let d=o;o=(u,p,f,m,g)=>d(u,p,f,m,g)?!0:NE(u,p,r,l,f,m,a)}else o||(l?o=(d,u,p,f)=>NE(d,u,r,l,p,f,a):o=(d,u,p)=>p);let h=!1,c=0;for(let d of this._roots){if(Ku(d),h=iZ(0,r,n,o,s,c),vm(),h)break;c+=d.byteLength}return yn.releasePrimitive(a),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:a}=i,s=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Oc.copy(t).invert();let h=yn.getPrimitive(),c=yn.getPrimitive();if(a){let u=function(p,f,m,g,y,x,b,_){for(let S=m,A=m+g;S<A;S++){On(c,S*3,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let E=p,M=p+f;E<M;E++)if(On(h,E*3,s,n),h.needsUpdate=!0,a(h,c,E,S,y,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,m,g,y,x,b,_,S){return p(f,m,g,y,x,b,_,S)?!0:u(f,m,g,y,x,b,_,S)}}else r=u}e.getBoundingBox(E1),E1.applyMatrix4(t);let d=this.shapecast({intersectsBounds:u=>E1.intersectsBox(u),intersectsRange:(u,p,f,m,g,y)=>(M1.copy(y),M1.applyMatrix4(Oc),e.shapecast({intersectsBounds:x=>M1.intersectsBox(x),intersectsRange:(x,b,_,S,A)=>r(u,p,x,b,m,g,S,A)}))});return yn.releasePrimitive(h),yn.releasePrimitive(c),d}intersectsBox(e,t){return hh.set(e.min,e.max,t),hh.needsUpdate=!0,this.shapecast({intersectsBounds:i=>hh.intersectsBox(i),intersectsTriangle:i=>hh.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},a=0,s=1/0){e.boundingBox||e.computeBoundingBox(),hh.set(e.boundingBox.min,e.boundingBox.max,t),hh.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,d=yn.getPrimitive(),u=yn.getPrimitive(),p=ym,f=aZ,m=null,g=null;r&&(m=sZ,g=nZ);let y=1/0,x=null,b=null;return Oc.copy(t).invert(),Cu.matrix.copy(Oc),this.shapecast({boundsTraverseOrder:_=>hh.distanceToBox(_),intersectsBounds:(_,S,A)=>A<y&&A<s?(S&&(Cu.min.copy(_.min),Cu.max.copy(_.max),Cu.needsUpdate=!0),!0):!1,intersectsRange:(_,S)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Cu.distanceToBox(A),intersectsBounds:(A,E,M)=>M<y&&M<s,intersectsRange:(A,E)=>{for(let M=A*3,T=(A+E)*3;M<T;M+=3){On(u,M,c,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let P=_*3,R=(_+S)*3;P<R;P+=3){On(d,P,l,o),d.needsUpdate=!0;let z=d.distanceToTriangle(u,p,m);if(z<y&&(f.copy(p),g&&g.copy(m),y=z,x=P/3,b=M/3),z<a)return!0}}}});{let A=c?c.count:h.count;for(let E=0,M=A;E<M;E+=3){On(u,E,c,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let T=_*3,P=(_+S)*3;T<P;T+=3){On(d,T,l,o),d.needsUpdate=!0;let R=d.distanceToTriangle(u,p,m);if(R<y&&(f.copy(p),g&&g.copy(m),y=R,x=T/3,b=E/3),R<a)return!0}}}}}),yn.releasePrimitive(d),yn.releasePrimitive(u),y===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=y,i.faceIndex=x,r&&(r.point?r.point.copy(g):r.point=g.clone(),r.point.applyMatrix4(Oc),f.applyMatrix4(Oc),r.distance=f.sub(r.point).length(),r.faceIndex=b),i)}closestPointToPoint(e,t={},i=0,r=1/0){let a=i*i,s=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Tu.copy(e).clamp(h.min,h.max),Tu.distanceToSquared(e)),intersectsBounds:(h,c,d)=>d<n&&d<s,intersectsTriangle:(h,c)=>{h.closestPointToPoint(e,Tu);let d=e.distanceToSquared(Tu);return d<n&&(ym.copy(Tu),n=d,o=c),d<a}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(ym):t.point=ym.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Bn(0,new Float32Array(t),VE),e.union(VE)}),e}},ab=Xl(pz()),oZ=.5*(Math.sqrt(3)-1),Pu=(3-Math.sqrt(3))/6,lZ=1/3,xn=1/6,hhe=(Math.sqrt(5)-1)/4,che=(5-Math.sqrt(5))/20,up=e=>Math.floor(e)|0,jE=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]),C1=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 hZ(e=Math.random){let t=aI(e),i=new Float64Array(t).map(a=>jE[a%12*2]),r=new Float64Array(t).map(a=>jE[a%12*2+1]);return function(a,s){let n=0,o=0,l=0,h=(a+s)*oZ,c=up(a+h),d=up(s+h),u=(c+d)*Pu,p=c-u,f=d-u,m=a-p,g=s-f,y,x;m>g?(y=1,x=0):(y=0,x=1);let b=m-y+Pu,_=g-x+Pu,S=m-1+2*Pu,A=g-1+2*Pu,E=c&255,M=d&255,T=.5-m*m-g*g;if(T>=0){let z=E+t[M],U=i[z],L=r[z];T*=T,n=T*T*(U*m+L*g)}let P=.5-b*b-_*_;if(P>=0){let z=E+y+t[M+x],U=i[z],L=r[z];P*=P,o=P*P*(U*b+L*_)}let R=.5-S*S-A*A;if(R>=0){let z=E+1+t[M+1],U=i[z],L=r[z];R*=R,l=R*R*(U*S+L*A)}return 70*(n+o+l)}}function cZ(e=Math.random){let t=aI(e),i=new Float64Array(t).map(s=>C1[s%12*3]),r=new Float64Array(t).map(s=>C1[s%12*3+1]),a=new Float64Array(t).map(s=>C1[s%12*3+2]);return function(s,n,o){let l,h,c,d,u=(s+n+o)*lZ,p=up(s+u),f=up(n+u),m=up(o+u),g=(p+f+m)*xn,y=p-g,x=f-g,b=m-g,_=s-y,S=n-x,A=o-b,E,M,T,P,R,z;_>=S?S>=A?(E=1,M=0,T=0,P=1,R=1,z=0):_>=A?(E=1,M=0,T=0,P=1,R=0,z=1):(E=0,M=0,T=1,P=1,R=0,z=1):S<A?(E=0,M=0,T=1,P=0,R=1,z=1):_<A?(E=0,M=1,T=0,P=0,R=1,z=1):(E=0,M=1,T=0,P=1,R=1,z=0);let U=_-E+xn,L=S-M+xn,j=A-T+xn,q=_-P+2*xn,Q=S-R+2*xn,X=A-z+2*xn,ie=_-1+3*xn,oe=S-1+3*xn,te=A-1+3*xn,re=p&255,fe=f&255,ce=m&255,de=.6-_*_-S*S-A*A;if(de<0)l=0;else{let Ae=re+t[fe+t[ce]];de*=de,l=de*de*(i[Ae]*_+r[Ae]*S+a[Ae]*A)}let se=.6-U*U-L*L-j*j;if(se<0)h=0;else{let Ae=re+E+t[fe+M+t[ce+T]];se*=se,h=se*se*(i[Ae]*U+r[Ae]*L+a[Ae]*j)}let Pe=.6-q*q-Q*Q-X*X;if(Pe<0)c=0;else{let Ae=re+P+t[fe+R+t[ce+z]];Pe*=Pe,c=Pe*Pe*(i[Ae]*q+r[Ae]*Q+a[Ae]*X)}let ve=.6-ie*ie-oe*oe-te*te;if(ve<0)d=0;else{let Ae=re+1+t[fe+1+t[ce+1]];ve*=ve,d=ve*ve*(i[Ae]*ie+r[Ae]*oe+a[Ae]*te)}return 32*(l+h+c+d)}}function aI(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),a=t[i];t[i]=t[r],t[r]=a}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var qs=new ya,dZ=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let a=1;qs.a.fromBufferAttribute(e,r),qs.b.fromBufferAttribute(e,r+1),qs.c.fromBufferAttribute(e,r+2),a*=qs.getArea(),t[r/3]=a}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,a=-1;for(;i<=r;){let s=Math.ceil((i+r)/2);if(s===0||t[s-1]<=e&&t[s]>e){a=s;break}else e<t[s]?r=s-1:i=s+1}return a}sampleFace(e,t,i){let r=this.randomFunction(),a=this.randomFunction();return r+a>1&&(r=1-r,a=1-a),qs.a.fromBufferAttribute(this.positionAttribute,e*3),qs.b.fromBufferAttribute(this.positionAttribute,e*3+1),qs.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(qs.a,r).addScaledVector(qs.b,a).addScaledVector(qs.c,1-(r+a)),qs.getNormal(i),this}},uZ=Xl(v3()),pZ=new je,fZ=new je,mZ=new je,jh;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(jh||(jh={}));var e_=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new je,this.copyPreviousMatrix=!0,this.hiddenMatrix=new je,this.pivotMatrix=new je,this.matrixWorldRigid=new je,this.shearScale=new je,this.shearScaleInv=new je}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Ci&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)jh.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)jh.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:a,q:s}=(0,uZ.SVD)(i),n=pZ.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=fZ.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),l=mZ.copy(o).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),s.every(h=>Math.abs(s[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new je().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof je?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,a,s,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},gZ=class extends e_(Ci){},vZ=e=>e.type==="Mesh",wa=class extends gZ{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new wa(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix,i.pivotMatrix=t.pivotMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return vZ(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}},yh=new O,xh=new O,ud=new je,sI=[new O(-1,1,1),new O(-1,-1,1),new O(1,-1,1),new O(1,1,1),new O(-1,1,-1),new O(-1,-1,-1),new O(1,-1,-1),new O(1,1,-1)],yZ=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],xZ=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],HE=(e,t,i)=>{e.updateEntityBoxSize(yh,xh),ud.copy(t).multiply(e.matrixWorld),xh.x===0&&xh.y===0&&xh.z===0?i.push(new O(yh.x,yh.y,yh.z).applyMatrix4(ud)):sI.forEach(r=>{i.push(r.clone().multiply(xh).add(yh).applyMatrix4(ud))})},GE=class extends wr{constructor(){super(...arguments),this.matrix=new je,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new je().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){r.push(new O);return}HE(a,t,r)}}):HE(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(ud.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(xh).multiplyScalar(.5),this.getCenter(yh),ud.copy(this.matrix).setPosition(yh),this.vertices=sI.map(e=>e.clone().multiply(xh).applyMatrix4(ud))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=yZ.map(([e,t])=>new zs(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new O))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=xZ.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},Ol={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},bZ=class extends X3{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),a=r[r.length-1]/r.length;for(let s=0,n=this.curves;s<n.length;s++){let o=n[s],l=s===0?r[s]:r[s]-r[s-1],h=Math.ceil(e*l/a),c=o.getPoints(h);for(let d=0;d<c.length;d++){let u=c[d];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},sb=.001;function nb(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=sb}function T1(e,t){let i=new O(...e.position),r=new O(...e.controlNext.position),a=new O(...t.controlPrevious.position),s=new O(...t.position);return nb(i,r,s)&&nb(i,a,s)}function nI(e){let t=e.points.map(c=>new O(...c.data.position)),i=[e.points[0]],r=new O(...i[0].data.position);for(let c=0;c<e.points.length-1;c++)nb(r,t[c],t[c+1])||(i.push(e.points[c]),r=t[c]);i.push(e.points[e.points.length-1]);let a=e.isClosed,s=i.length-(a?0:1),n=i.length,o=[];for(let c=0;c<n;c++){let d=i[c].data,u=new O(...d.position),p=new O(...d.controlPrevious.position),f=new O(...d.controlNext.position),m={position:u,baseRoundness:d.roundness,controlPrevious:p,controlNext:f};if(d.roundness===0||!e.isClosed&&(c===0||c===n-1)){o[c]={...m,removedLength:0};continue}let g=a&&c==0?n-1:c-1,y=a&&c==n-1?0:c+1,x=i[g].data,b=i[y].data,_=new O(...x.position),S=new O(...b.position),A=_.clone().sub(u).normalize(),E=S.clone().sub(u).normalize();Object.assign(m,{prevDir:A,nextDir:E});let M=T1(x,d),T=T1(d,b);if(!M||!T)o[c]={...m,removedLength:0};else{let P=A.clone().add(E).normalize(),R=P.clone().cross(A).length()/A.dot(P);o[c]={...m,tan:R,removedLength:d.roundness/R}}}for(let c=0;c<s;c++){let d=c,u=a&&c===n-1?0:c+1,p=o[d],f=o[u];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let d=c,u=a&&c===n-1?0:c+1,p=o[d],f=o[u],m=null;if(!T1(i[d].data,i[u].data))p.position.distanceTo(f.position)>sb&&(m=new ig(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),y=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&y.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(y)>sb&&(m=new ig(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c<n;c++){let d=o[c];if(d.removedLength===0){l[2*c]=null;continue}let u=d.position,p=d.prevDir.clone().multiplyScalar(d.removedLength).add(u),f=d.nextDir.clone().multiplyScalar(d.removedLength).add(u),m=d.tan*d.removedLength,g=d.prevDir.clone().add(d.nextDir).normalize(),y=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(x,2))).add(y),_=g.clone().multiplyScalar(-m).add(b),S=u.distanceTo(_)/u.distanceTo(y),A=d.prevDir.clone().multiplyScalar(S*u.distanceTo(p)).add(u),E=A.clone().lerp(_,2),M=p.clone().lerp(A,4/3),T=f.clone().lerp(E,4/3);l[2*c]=new ig(p,M,T,f)}let h=new bZ;return l.forEach(c=>{c&&h.add(c)}),h}var oi;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(oi||(oi={}));var Mo=e=>oi.is(e),wZ={type:"completeState",isfromEntity:!0},_Z=["x","y","z"],Du=new O,WE=new O(1,1,1),P1=new Rt,qE=new xr,SZ=new O().set(0,1,0),t_=e=>class extends e_(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new GE,this._recursiveBBox=new GE,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(oi.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(oi.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(oi.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let a of this.data.states)Il.toOps(this.data,a.data).forEach(s=>{let n=Ng.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=Il.patch(this.data,a),Il.toOps(this.data,a).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{Mo(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(oi.is(i[r]))return i[r];if(oi.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&oi.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)Mo(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{oi.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Mo(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Mo(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Mo(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>Mo(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*tt.RAD2DEG,this.rotation.y*tt.RAD2DEG,this.rotation.z*tt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return sx(i,t)}getTransformValues(t,i,r){return i[t].map((a,s)=>r?.shared.getVariable(a,[this.uuid,t,_Z[s]])??a)}updateTransformState(t,i){let r=!1;if(t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Du.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(tt.DEG2RAD),this.rotation.setFromVector3(Du),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Cd.identity)),t.pivot!==void 0||t.pivotRotation!==void 0){if(r=!0,t.pivot!==void 0&&t.pivotRotation!==void 0)this.pivotMatrix.compose(Du.fromArray(t.pivot).negate(),P1.setFromEuler(qE.fromArray(t.pivotRotation.map(a=>a*tt.DEG2RAD))).invert(),WE);else if(t.pivot!==void 0)this.pivotMatrix.setPosition(-t.pivot[0],-t.pivot[1],-t.pivot[2]);else if(t.pivotRotation!==void 0){let a=Du.setFromMatrixPosition(this.pivotMatrix);P1.setFromEuler(qE.fromArray(t.pivotRotation.map(s=>s*tt.DEG2RAD))).invert(),this.pivotMatrix.compose(a,P1,WE)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)oi.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{oi.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return sx(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,a){let s=this.data;this.data=i;let n=t,o=Bi(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let d=Gr.zoom(c,t.path.slice(2));if(d)for(let u in t.props)t.props[u]===void 0&&u in d&&(h[u]=d[u])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:c,...d}=l;l=d}let h=Gr.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Il.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Bi(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[c],d.updateState(kl.apply(d.component.data,d.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let d=Gr.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(u===t.props&&(u={...t.props}),u[p]=d[p]);t={...t,props:u}}c.overrideData=$g.resolve(i.overrides,l),c.updateByOp(t,aa.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of Dl.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of Dl.rootOverrideProps)if(Bi(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=kl.filterOp(h.overrideData,l);c&&h.updateByOp(c,aa.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=kl.filterOp(h.overrideData,t);if(c){let d;s===h.data&&t===c?d=i:d=aa.applySimple(h.data,c),h.updateByOp(c,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Vh.is(t.props.type)&&Ol.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Ol.changeEntityProptotype(this,i,r);for(let a of this.children)oi.is(a)&&a.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let a=i.morphTargetInfluences.get(t.path[1])?.data.name;a&&this.updateMorphInfluences(a,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",a]))}if(Bi(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Bi(t.path,["cloner"])!==null){let a=aa.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=nI(o.geometry.path),h=(r+a)%1;r+a===1&&h===0&&(h=1);let c=null;try{c=l.curves.length?l.getPointAt(h):null}catch{}if(c===null)return;let d=this.parent?this.parent?.matrixWorld:new je;n.updateMatrixWorld();let u=new je().multiplyMatrices(d.clone().invert(),n.matrixWorld);c.applyMatrix4(u);let p={position:c.toArray(),rotation:o.rotation};if(s==="tangential"){let f=new je().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(c),g=new je().lookAt(c,m,SZ),y=Du.setFromEuler(new xr().setFromRotationMatrix(g)).multiplyScalar(tt.RAD2DEG);p={...p,rotation:y.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(wZ)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof Ol.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Ol.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},oI=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,a=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);a.thetaLength=tt.clamp(a.thetaLength,0,360);let s=a.width/2,n=a.radiusTop??s,o=a.radiusBottom??s;if(n===o?(n=s,o=s):n>o?(n=s,o=o*s/n):(n=n*s/o,o=s),a.shapeBlendNode){n=i??s,o=r??s;let l=Math.max(n,o)*2;a.width=l,a.depth=l}return{parameters:Object.assign(a,{width:Math.abs(a.width),height:Math.abs(a.height??a.width),depth:Math.abs(a.depth??a.width),radiusTop:n,radiusBottom:o})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:d,cornerSegments:u,hollow:p}=e.parameters,f;return l===0?(f=new vt,f.setAttribute("position",new nt([],3))):d||p?f=new lI(h,c,r,a,s,n,o,l*Math.PI/180,d,d,u,p):f=new iw(h,c,r,a,s,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function ll(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function XE(e){return new ae(e.y,-e.x)}var lI=class extends vt{constructor(e,t,i,r,a,s,n,o,l,h,c,d,u=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,a=Math.floor(a)||1,s=s!==void 0?s:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,s&&(l=0,h=0);let p=[],f=[],m=[],g=[],y=0,x=i/2,b=new O,_=new O;u&&e==0&&(e=l),u&&t==0&&(t=h);let S=new ae(e,x),A=new ae(t,-x),E=null,M=null,T=null,P=null,R=S.clone().sub(A),z=0,U=0,L=0;d>0&&(z=Math.min(e,t)*(1-d),U=e-z,L=t-z);let j=S.clone();j.x-=z;let q=Math.PI-R.angle(),Q=R.angle(),X=Math.tan(Q/2),ie=Math.tan(q/2),oe=X+ie,te=d?oe:ie,re=d?oe:X;if(l=Math.min(l,(e-U)/te,R.length()/oe),h=Math.min(h,(t-L)/re,R.length()/oe),l>0){let ve=l/X;E=S.clone().sub(new ae(ve,l)),d&&(T=E.clone(),T.x-=z-oe*l),S.sub(R.clone().setLength(ve))}if(h>0){let ve=h/ie;M=A.clone().sub(new ae(ve,-h)),A.add(R.clone().setLength(ve)),d&&(P=M.clone(),P.x-=z-oe*h,j.sub(R.clone().setLength(ve)))}R=S.clone().sub(A);let fe=R.length()<.5,ce=[];for(let ve=0;ve<=r;ve++){let Ae=[],ye=ve/r,Ve=ye*o+n,Ie=new ae(Math.sin(Ve),Math.cos(Ve));P&&M?(de(Ae,ye,Ie,q,h,P,-1,!0),de(Ae,ye,Ie,Q,h,M,-1,!1)):M?(se(Ae,Ie,M.x,0,-1),de(Ae,ye,Ie,Q,h,M,-1,!1)):s||se(Ae,Ie,t,L,-1);let Ce=XE(R).normalize();if(ll(Ce,Ie,b),!fe)for(let rt=0;rt<=a;rt++){let Je=rt/a,st=R.clone().multiplyScalar(Je).add(A);ll(st,Ie,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(ye,.5+_.y/i),Ae.push(y++)}if(T&&E?(de(Ae,ye,Ie,q,l,E,1,!1),de(Ae,ye,Ie,Q,l,T,1,!0)):E?(de(Ae,ye,Ie,q,l,E,1,!1),se(Ae,Ie,E.x,0,1)):s||se(Ae,Ie,e,U,1),d&&!fe){let rt=XE(R).multiplyScalar(-1).normalize();ll(rt,Ie,b);for(let Je=0;Je<=a;Je++){let st=Je/a,ot=R.clone().multiplyScalar(-st).add(j);ll(ot,Ie,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(ye,.5+_.y/i),Ae.push(y++)}}d&&!s&&Ae.push(Ae[0]),ce.push(Ae)}for(let ve=0;ve<ce.length-1;ve++)for(let Ae=0;Ae<ce[0].length-1;Ae++){if(s&&d&&Ae==a)continue;let ye=ce[ve][Ae],Ve=ce[ve+1][Ae],Ie=ce[ve+1][Ae+1],Ce=ce[ve][Ae+1],rt=f[Ie*3+0],Je=f[Ie*3+2];p.push(ye,Ve,Ce),(rt!=0||Je!=0)&&p.push(Ve,Ie,Ce)}o<Math.PI*2&&(Pe(-1,ce[0],n),Pe(1,ce[ce.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new nt(f,3)),this.setAttribute("normal",new nt(m,3)),this.setAttribute("uv",new nt(g,2));function de(ve,Ae,ye,Ve,Ie,Ce,rt,Je){for(let st=0;st<c+1;st++){let ot=st/c,Ke=rt<0?ot:1-ot;Je&&(Ke-=1),Ke*=Ve;let Qe=new ae(Math.sin(Ke),Math.cos(Ke)*rt),ft=Qe.clone().multiplyScalar(Ie).add(Ce);ll(ft,ye,_),f.push(_.x,_.y,_.z),ll(Qe,ye,b),m.push(b.x,b.y,b.z),g.push(Ae,.5+_.y/i),ve.push(y++)}}function se(ve,Ae,ye,Ve,Ie){let Ce=new O,rt=new ae,Je=[ye,Ve];Ie<0&&Je.reverse();for(let st of Je)rt.set(st,x*Ie),ll(rt,Ae,Ce),f.push(Ce.x,Ce.y,Ce.z),m.push(0,Ie,0),g.push(.5,.5),ve.push(y++)}function Pe(ve,Ae,ye){let Ve=new ae(Math.sin(ye),Math.cos(ye)),Ie=new ae(-Math.cos(ye),Math.sin(ye)),Ce=new O,rt=ve<0?(ot,Ke,Qe)=>p.push(ot,Ke,Qe):(ot,Ke,Qe)=>p.push(ot,Qe,Ke),Je=new ae((e+t+U+L)/4,0);ll(Je,Ve,Ce),f.push(Ce.x,Ce.y,Ce.z),m.push(Ie.x,0,Ie.y),g.push(.5,.5);let st=y++;for(let ot of Ae){let Ke=f.slice(ot*3,ot*3+3);f.push(...Ke),m.push(Ie.x,0,Ie.y);let Qe=g.slice(ot*2,ot*2+2);g.push(...Qe),y++}for(let ot=st+1;ot<y-1;ot++)rt(st,ot,ot+1);rt(st,y-1,st+1)}}},AZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=tt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:c,cornerSegments:d}=e.parameters,u;return l===0?(u=new vt,u.setAttribute("position",new nt([],3))):h>0||c>0||l<360?u=new lI(0,t/2,r,a,s,n,o,l*Math.PI/180,h,c,d,0,!0):u=new rw(t/2,r,a,s,n),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},MZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:a,heightSegments:s,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o===0?h=new ln(t,i,r,a,s,n):h=new EZ(t,i,r,a,s,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},D1=Math.PI/2,EZ=class extends vt{constructor(e=1,t=1,i=1,r=1,a=1,s=1,n=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),a=Math.floor(a),s=Math.floor(s),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let l=[],h=[],c=[],d=[],u=0;p("z","y","x",-1,-1,i,t,e,s,a),p("z","y","x",1,-1,i,t,-e,s,a),p("x","z","y",1,1,e,i,t,r,s),p("x","z","y",1,-1,e,i,-t,r,s),p("x","y","z",1,-1,e,t,i,r,a),p("x","y","z",-1,-1,e,t,-i,r,a),n>0&&(f("z","y","x",-1,-1,1,i,t,e,s),f("z","y","x",1,-1,-1,i,t,e,s),f("z","y","x",-1,1,-1,i,t,e,s),f("z","y","x",1,1,1,i,t,e,s),f("x","y","z",-1,-1,-1,e,t,i,r),f("x","y","z",1,-1,1,e,t,i,r),f("x","y","z",-1,1,1,e,t,i,r),f("x","y","z",1,1,-1,e,t,i,r),f("y","x","z",-1,-1,1,t,e,i,a),f("y","x","z",1,-1,-1,t,e,i,a),f("y","x","z",1,1,1,t,e,i,a),f("y","x","z",-1,1,-1,t,e,i,a),m(1,1,1),m(-1,1,1),m(1,-1,1),m(-1,-1,1),m(1,1,-1),m(-1,1,-1),m(1,-1,-1),m(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new nt(h,3)),this.setAttribute("normal",new nt(c,3)),this.setAttribute("uv",new nt(d,2));function p(g,y,x,b,_,S,A,E,M,T){let P=(S-2*n)/M,R=(A-2*n)/T,z=S/2-n,U=A/2-n,L=E/2,j=M+1,q=T+1,Q=0,X=new O;for(let ie=0;ie<q;ie++){let oe=ie*R-U;for(let te=0;te<j;te++){let re=te*P-z;X[g]=re*b,X[y]=oe*_,X[x]=L,h.push(X.x,X.y,X.z),X[g]=0,X[y]=0,X[x]=E>0?1:-1,c.push(X.x,X.y,X.z),d.push(te/M),d.push(1-ie/T),Q+=1}}for(let ie=0;ie<T;ie++)for(let oe=0;oe<M;oe++){let te=u+oe+j*ie,re=u+oe+j*(ie+1),fe=u+(oe+1)+j*(ie+1),ce=u+(oe+1)+j*ie;l.push(te,re,ce),l.push(re,fe,ce)}u+=Q}function f(g,y,x,b,_,S,A,E,M,T){let P=(A-2*n)/T,R=A/2-n,z=E/2-n,U=M/2,L=T+1,j=0,q=new O,Q=new O;for(let X=0;X<o+1;X++){let ie=X/o*D1,oe=Math.sin(ie)*n,te=(1-Math.cos(ie))*n,re=Math.sin(ie),fe=Math.cos(ie);q[y]=(z+oe)*_,q[x]=(U-te)*S,Q[g]=0,Q[y]=re*Math.sign(q[y]),Q[x]=fe*Math.sign(q[x]);for(let ce=0;ce<L;ce++){let de=ce*P-R;q[g]=de*b,h.push(q.x,q.y,q.z),c.push(Q.x,Q.y,Q.z),d.push(ce/T),d.push(0),j+=1}}for(let X=0;X<o;X++)for(let ie=0;ie<T;ie++){let oe=u+ie+L*X,te=u+ie+L*(X+1),re=u+(ie+1)+L*(X+1),fe=u+(ie+1)+L*X;l.push(oe,te,fe),l.push(te,re,fe)}u+=j}function m(g,y,x){let b=new O,_=new O(e/2,t/2,i/2);_.subScalar(n);let S=[],A=g*y*x>0?(M,T,P)=>l.push(M,T,P):(M,T,P)=>l.push(M,P,T);for(let M=0;M<=o;M++){let T=[],P=D1*(1-M/o),R=Math.cos(P),z=Math.sin(P),U=0;for(let L=0;L<=M;L++){let j=Math.cos(U),q=Math.sin(U);b.x=R*j,b.y=z,b.z=R*q;let Q=_.clone().addScaledVector(b,n);h.push(g*Q.x,y*Q.y,x*Q.z),c.push(g*b.x,y*b.y,x*b.z),d.push(0,0),T.push(u++),U+=D1/M}S.push(T)}let E=S.length-1;for(let M=0;M<E;M++){let T=S[M],P=S[M+1],R=T.length-1;A(T[0],P[1],P[0]);for(let z=1;z<=R;z++)A(T[z-1],T[z],P[z]),A(T[z],P[z+1],P[z])}}}},i_=class extends vt{constructor(e=[],t=[],i="",r=1,a=.2,s=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),c(),this.setAttribute("position",new nt(n,3)),this.setAttribute("normal",new nt(l,3)),this.setAttribute("uv",new nt(o,2));return;function h(){a=Math.min(1-1e-5,a),a==0&&(s=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new O,p=u.clone(),f=new ya,m=a*r,g=r-m,y=s+1,x=new O,b=(Q,X)=>x.subVectors(Q,X).normalize(),_=(Q,X)=>Array(Q).fill(void 0).map(X),S=_(e.length/3,(Q,X)=>new O().fromArray(e,X*3).setLength(r)),A=[],E=1e6;for(let Q=0;Q<S.length;Q++){let X=S[Q],ie=[],oe,te,re,fe=1e10,ce=-1;for(;(ce=t.indexOf(Q,ce+1))!=-1;){let ve=ce-ce%3;oe=t[ve+(ce+1)%3],te=t[ve+(ce+2)%3],re=X.distanceToSquared(S[oe]),fe=Math.min(fe,re),ie.push([oe,te,re])}fe+=1e-6;let de=[],se=0,Pe=ie.length;for(let ve=0;ve<Pe;ve++){[oe,te,re]=ie[se];let Ae=A[oe]?.includes(Q)==!0;re<=fe&&de.push(oe+ +Ae*E),se=ie.findIndex(ye=>ye[0]==te)}A.push(de)}let M=[];{let Q=0,X=0,ie,oe,te=d==3;for(let re=0;re<=s;re++){ie=re*(re+1)/2,oe=(re+1)*(re+2)/2;for(let fe=0;fe<s-re;fe++)[Q,X]=[ie+fe+re+2,oe+fe+re+3],M.push(ie,oe,...te?[X,ie]:[Q,oe],X,Q),[ie,oe]=[Q,X];M.push(ie,oe,ie+s+2)}}let T=u.clone(),P=u.clone(),R=u.clone(),z=u.clone(),U=u.clone(),L=[],j=_(S.length,()=>_(d,()=>u.clone()));for(let Q=0;Q<S.length;Q++){u.copy(S[Q]).normalize(),T.copy(u).multiplyScalar(g);let X=A[Q];for(let de=0;de<X.length;de++){let se=X[de],Pe=X[(de+1)%d];f.setFromPointsAndIndices(S,Q,se%E,Pe%E),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(T,j[Q][de])}let ie=[],oe=[],te=[],re=new O;s==0&&[...j[Q]].reduce((de,se)=>de.add(se),re).multiplyScalar(1/d);for(let de=0;de<d;de++){let se=[],Pe=(de-1+d)%d,ve=j[Q][Pe],Ae=j[Q][de];u.copy(ve).sub(T),p.copy(Ae).sub(T);let ye=T.angleTo(u),Ve=u.angleTo(p),Ie=Math.cos(ye)*m;s==0?P.copy(re):P.copy(T).setLength(g+Ie),oe.push(Ie);let Ce=[P,ve,Ae];for(let rt=0;rt<2;rt++){let Je=Ce[rt],st=Ce[rt+1];z.subVectors(Je,T),U.subVectors(st,T),R.crossVectors(z,U).normalize();for(let ot=0;ot<y;ot++){let Ke=[ye,Ve][rt]*ot/y;u.copy(z).applyAxisAngle(R,Ke).add(T),ie.push(u.clone()),rt&&(b(u,T),se.push([ot==0?Je:u.clone(),x.clone()]))}rt&&(b(st,T),se.push([st,x.clone()]))}te.push(se)}L.push(te);let fe=2*y,ce=2;for(let de=0;de<d;de++){let se=fe*de,Pe=fe*((de+1)%d),ve=[ie[se]];for(let ye=1;ye<y;ye++){z=ie[se+ye],U=ie[Pe+ye],ve.push(z);for(let Ve=1,Ie=ye-ce+1;Ve<=Ie;Ve++)u.lerpVectors(z,U,Ve/(Ie+1)),u.sub(T).setLength(oe[de]).add(T),ve.push(u.clone());ve.push(U)}for(let ye=0;ye<y;ye++)ve.push(ie[ye+y+se]);ve.push(ie[Pe+y]);let Ae=M.map(ye=>ve[ye]);n.push(...Ae.map(ye=>[ye.x,ye.y,ye.z]).flat()),l.push(...Ae.map(ye=>(b(ye,T),[x.x,x.y,x.z])).flat())}}let q=[];for(let Q=0;Q<A.length;Q++)for(let X=0;X<d;X++){let ie=A[Q][X];if(ie<E){let oe=A[ie].findIndex(fe=>fe%E==Q),te=L[Q][X],re=L[ie][oe];for(let fe=0;fe<y;fe++){let ce=te[fe],de=re[y-fe],se=te[fe+1],Pe=re[y-(fe+1)];[ce,de,se,se,de,Pe].forEach(ve=>{n.push(ve[0].x,ve[0].y,ve[0].z),l.push(ve[1].x,ve[1].y,ve[1].z)})}q.push(te[0][0],re[y][0],te[y][0],re[0][0])}}for(;q.length;){let Q,X,ie,oe;[Q,X]=q.splice(0,2);let te=[Q];for(;Q!=X;)te.push(X),ie=q.indexOf(X),oe=ie%2,X=q.splice(ie-oe,2)[1-oe];x.subVectors(te[0],te[1]).cross(u.subVectors(te[0],te[2])).normalize();let re=x.dot(te[0])<0;re&&x.negate();for(let fe=1;fe<=te.length-2;fe++)[te[fe+ +re],te[fe+1-+re],te[0]].forEach(ce=>{n.push(ce.x,ce.y,ce.z),l.push(x.x,x.y,x.z)})}}function c(){let d=new O;for(let A=0;A<n.length;A+=3){d.x=n[A+0],d.y=n[A+1],d.z=n[A+2];let E=_(d)/2/Math.PI+.5,M=S(d)/Math.PI+.5;o.push(E,1-M)}let u=new O,p=new O,f=new O,m=new O,g=new ae,y=new ae,x=new ae,b=(A,E,M,T)=>{T<0&&A.x===1&&(o[E]=A.x-1),M.x===0&&M.z===0&&(o[E]=T/2/Math.PI+.5)};for(let A=0,E=0;A<n.length;A+=9,E+=6){u.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[E+0],o[E+1]),y.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),m.copy(u).add(p).add(f).divideScalar(3);let M=_(m);b(g,E+0,u,M),b(y,E+2,p,M),b(x,E+4,f,M)}for(let A=0;A<o.length;A+=6){let E=o[A+0],M=o[A+2],T=o[A+4],P=Math.max(E,M,T),R=Math.min(E,M,T);P>.9&&R<.1&&(E<.2&&(o[A+0]+=1),M<.2&&(o[A+2]+=1),T<.2&&(o[A+4]+=1))}function _(A){return Math.atan2(A.z,-A.x)}function S(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new i_(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},CZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:a,corner:s,cornerSides:n}=e.parameters,o=a===0&&s!==0?new hI(t*.5,s,n):new Q3(t*.5,a);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},hI=class extends i_{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,a=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,-a,-r,0,-a,r,0,a,-r,0,a,r,-a,-r,0,-a,r,0,a,-r,0,a,r,0,-r,0,-a,r,0,-a,-r,0,a,r,0,a],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(s,n,o,e,t,i),this.type=o}static fromJSON(e){return new hI(e.radius,e.corner,e.cornerSides)}},Iu=1e-12,r_=class{constructor(e){this.position=new ae,this.startPosition=new ae,this.uuid=tt.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new r_(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ob=class extends r_{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new ob(this.parent).copy(this)}},pd=class extends r_{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new ob(this),new ob(this))}static create(e,t){let i=new pd(e,new ae(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let a=this.controls[i];this.position.distanceTo(a.position)<=t?a.position.copy(this.position):a.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 pd(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new ae,t=new ae){let[i,r]=this.computeTangents();return i&&r&&(YE(i,e),YE(r,t)),[e,t]}computeTangent(e=new ae){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new ae){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function YE(e,t=new ae){let i=e.length();return t.set(-e.y/i,e.x/i)}var a_=e=>e,$d=new ae,qv=new ae,TZ=new ae,PZ=new ae,DZ=new ae,IZ=new ae,cI=new O,dI=new O;function OZ(e){let t=new ae;t.addVectors(e.v0,$d.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new ae;return i.addVectors(e.v2,qv.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new tn(e.v0,t,i,e.v2)}function Zu(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function RZ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function LZ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function uI(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((a*a+r*r-s*s)/(2*a*r))}function BZ(e,t,i){return KE(e,t)&&KE(t,i)&&lb(e.position,t.position,i.position)}function lb(e,t,i){return $d.copy(t).sub(e).cross(qv.copy(i).sub(e))===0}function zZ(e,t,i,r,a){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,h=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,n+h),a.set(o-l,n-h),[r,a]}function kZ(e,t,i){let r=e.distanceTo(i),a=t.distanceTo(i);return r<a?t:e}function FZ(e,t,i,r,a,s){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,c=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),d;return uI(t,e,i)>Math.PI&&(c*=-1),Zu(h,o)?d=(o+h)*(r/c-.5)*8/3/(n-l):d=(n+l)*(r/c-.5)*8/3/(h-o),a.set(t.x-d*o,t.y+d*n),s.set(i.x+d*h,i.y-d*l),[a,s]}function QE(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function KE(e,t){return lb(e.position,e.controls[1].position,t.position)&&lb(e.position,t.controls[0].position,t.position)}function UZ(e,t,i,r,a=.5){let s=$d.subVectors(t,e).multiplyScalar(a).add(e),n=qv.subVectors(i,t).multiplyScalar(a).add(t),o=TZ.subVectors(r,i).multiplyScalar(a).add(i),l=s,h=PZ.subVectors(n,s).multiplyScalar(a).add(s),c=DZ.subVectors(o,n).multiplyScalar(a).add(n),d=o,u=IZ.subVectors(c,h).multiplyScalar(a).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,c.x,c.y,d.x,d.y,r.x,r.y]}function NZ(e,t,i=12,r=!0){let a=dI.set(0,0,0),s,n=0,o=[];for(let l=0;l<t.length;l++){let h=a_(t[l]),c=$d,d=zh(h,i);o.push(d);for(let u=0;u<=d;u++)if(h instanceof tn||h instanceof Hl||h instanceof sn){if(h.getPoint(u/d,c),a.set(c.x,c.y,0),s!==void 0&&LZ(s,a))continue;s===void 0&&(s=cI),s.copy(a),e.setXYZ(n,a.x,a.y,a.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function VZ(e,t,i,r=12,a=!0){let s=dI.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,c=a_(t[l]),d=$d,u=zh(c,r);o.push(u);for(let p=0;p<=u;p++)if(c instanceof tn||c instanceof Hl||c instanceof sn){if(c.getPoint(p/u,d),s.set(d.x,d.y,0),h?.equals(s))continue;h===void 0?h=cI:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,s.x,s.y,s.z),n++),h.copy(s)}}return a&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function ZE(e,t=12,i=!1){let r=[];for(let a=0,s=e.length;a<s;a++){let n=e[a],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=zh(n.roundedCurveCorner,t)*.5;a>0&&(r[a-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=zh(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=zh(e[0].roundedCurveCorner,t)*.5),r}function zh(e,t=12){return e&&e instanceof Tv?t*2:e&&(e instanceof sn||e instanceof q3)?1:e&&e instanceof tw?t*e.points.length:t}function jZ(e,t,i=12,r=!0){let a,s=0;for(let n=0;n<t.length;n++){let o=a_(t[n]),l=zh(o,i),h=$d;for(let c=0;c<=l;c++)if(o instanceof tn||o instanceof Hl||o instanceof sn){if(o.getPoint(c/l,h),a!==void 0&&RZ(a,h,Iu))continue;a===void 0&&(a=qv),a.copy(h),e.push(h.x,h.y),s++}}return Zu(e[0],e[e.length-2],Iu)&&Zu(e[1],e[e.length-1],Iu)&&(e.pop(),e.pop()),r&&s>1&&!(Zu(e[s-1],e[1],Iu)&&Zu(e[s-2],e[0],Iu))&&(e.push(e[0],e[1]),s++),e}var I1=new ae,HZ=new ae,GZ=new ae,WZ=new ae,qZ=new ae,XZ=new ae,hr=class extends Mg{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ka(new O(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=tt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new hr;return r.isClosed=e.isClosed,r.points=e.points.map(a=>pd.create(a.id,a.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(a=>hr.createFromState(a)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let a=0,s=this.shapeHoles.length;a<s;a++){let n=this.shapeHoles[a],o=n.points.length,l=n.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=e-t;if(s<=a.points.length-1)return a.points[s];t+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=a.points.indexOf(e);if(s>=0)return t+s;t+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=I1.set(e,t);for(let r=0,a=this.points.length;r<a;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,a=this.shapeHoles.length;r<a;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=tt.generateUUID()){let r;e instanceof ae?r=e:r=new ae(e,t);let a=new pd(i,r);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return NZ(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=ZE(this.points,e,!1),this.roundedCurveDivisions=ZE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return VZ(e,this.curves,t,i,this.autoClose).reduce((r,a)=>r+a,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),jZ(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=zh(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(s<i+l)return[n,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,n=s[e];if(QE(r,a)){let l=r.position.distanceTo(a.position);return r.position.distanceTo(I1.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){QE(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(r,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let a=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=a.roundness,l=s&&n&&BZ(s,a,n);if(!a.controlsMoved()&&o>0&&!l){let h=a.curveBefore,c=a.curveAfter;if(h===void 0||c===void 0)continue;let d=a.roundedCurveBefore,u=a.roundedCurveAfter,p=h.getLength(),f=c.getLength(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),y=Math.min(m,g),x=1-y/p,b=y/f,_=h.getPointAt(x,I1),S=c.getPointAt(b,HZ);this._subSplitCurve(h,d,x,_,void 0),this._subSplitCurve(c,u,b,void 0,S);let A;if(this.useCubicForRoundedCorners){let E=uI(_,a.position,S)/2,M=Math.tan(E)*_.distanceTo(a.position),[T,P]=zZ(_,S,M,GZ,WZ),R=kZ(T,P,a.position),[z,U]=FZ(R,_,S,M,qZ,XZ);A=new tn(_.clone(),z.clone(),U.clone(),S.clone())}else A=new Hl(_.clone(),a.position.clone(),S.clone());a.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,a){if(e instanceof sn)r!==void 0&&t.v2.copy(r),a!==void 0&&t.v1.copy(a);else{let s=e,n=t,o=s.getUtoTmapping(i,0),l=UZ(s.v0,s.v1,s.v2,s.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),a!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new hr(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,a=e.points[r+0],s=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],c=e.points[r+6],d=new pd(tt.generateUUID(),new ae(a,s));d.controls[0].position.set(n,o),d.controls[1].position.set(l,h),d.roundness=c,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new hr;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(a,s)=>{s instanceof tn&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},r=a=>{let s=[],n,o;for(n=0,o=a.length;n<o;n++)a[n]instanceof Hl&&(a[n]=OZ(a[n]));for(n=0,o=a.length;n<o;n++){let c=a[n],d=n>0?a[n-1]:null,u;c instanceof tn?(u=this.createPoint(c.v0),u.controls[1].position.copy(c.v1)):c instanceof sn&&(u=this.createPoint(c.v1)),u!==void 0&&(d!==null&&i(u,d),s.push(u))}let l=a[a.length-1],h=!1;return l instanceof tn?l.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(l.v2),h=!0):l instanceof sn&&l.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=r(e.curves),e instanceof Mg&&(this.shapeHoles=e.holes.map(a=>{let s=new hr;return s.fromShape(a),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},hb=Math.PI*2;function O1({x:e,y:t},i,r,a,s){return{x:e*i+a,y:t*r+s}}function YZ(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),a=Math.sin(e),s=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-a*i,y:a+r*i},{x:s+n*i,y:n-s*i},{x:s,y:n}]}function JE(e,t,i,r){let a=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return a*Math.acos(s)}function QZ(e,t,i,r,a,s,n,o,l,h){let c=Math.pow(a,2),d=Math.pow(s,2),u=Math.pow(n,2),p=Math.pow(o,2),f=c*d-c*p-d*u;f<0&&(f=0),f/=c*p+d*u,f=Math.sqrt(f)*(l===h?-1:1);let m=f*a/s*o,g=f*-s/a*n,y=m+(e+i)/2,x=g+(t+r)/2,b=(n-m)/a,_=(o-g)/s,S=(-n-m)/a,A=(-o-g)/s,E=JE(1,0,b,_),M=JE(b,_,S,A);return!h&&M>0&&(M-=hb),h&&M<0&&(M+=hb),{centerx:y,centery:x,ang1:E,ang2:M}}function KZ({px:e,py:t,cx:i,cy:r,rx:a,ry:s,largeArcFlag:n,sweepFlag:o}){let l=[];if(a===0||s===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];a=Math.abs(a),s=Math.abs(s);let d=Math.pow(h,2)/Math.pow(a,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(a*=Math.sqrt(d),s*=Math.sqrt(d));let u=QZ(e,t,i,r,a,s,h,c,n,o),{ang1:p,ang2:f}=u,{centerx:m,centery:g}=u,y=Math.abs(f)/(hb/4);Math.abs(1-y)<1e-7&&(y=1);let x=Math.max(Math.ceil(y),1);f/=x;for(let b=0;b<x;b++)l.push(YZ(p,f)),p+=f;return l.map(b=>{let{x:_,y:S}=O1(b[0],a,s,m,g),{x:A,y:E}=O1(b[1],a,s,m,g),{x:M,y:T}=O1(b[2],a,s,m,g);return{x1:_,y1:S,x2:A,y2:E,x:M,y:T}})}var Ii;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ii||(Ii={}));var Pr;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Pr||(Pr={}));function Bt(e,t){if(!e)throw t||"Assertion Failed!"}var Et=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Bt(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?a<s?i.t-t.t+(t.t-r.t)*(a/(a+s)):i.t-r.t+(r.t-t.t)*(s/(a+s)):0},e.edgeSign=function(t,i,r){Bt(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?(i.t-r.t)*a+(i.t-t.t)*s:0},e.transEval=function(t,i,r){Bt(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?a<s?i.s-t.s+(t.s-r.s)*(a/(a+s)):i.s-r.s+(r.s-t.s)*(s/(a+s)):0},e.transSign=function(t,i,r){Bt(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?(i.s-r.s)*a+(i.s-t.s)*s:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,a){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+a)/2:i+(a-i)*(t/(t+r)):a+(i-a)*(r/(t+r))},e.intersect=function(t,i,r,a,s){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,a)||(l=r,r=a,a=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.vertLeq(r,i)?e.vertLeq(i,a)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,a),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,a,i),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,a.s)):s.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,a)||(l=r,r=a,a=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.transLeq(r,i)?e.transLeq(i,a)?(n=e.transEval(t,r,i),o=e.transEval(r,i,a),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,a,i),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,a.t)):s.t=(r.t+i.t)/2},e}(),Ou=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),xm=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Kc=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),$E=function(){function e(){var t=new Kc,i=new Ou,r=new xm(0),a=new xm(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=a,a.next=a,a.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=a}return e.prototype.makeEdge_=function(t){var i=new xm(0),r=new xm(1);t.Sym.side<t.side&&(t=t.Sym);var a=t.Sym.next;return r.next=a,a.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,a=i.Onext;r.Sym.Lnext=i,a.Sym.Lnext=t,t.Onext=a,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var a=t;Bt(a,"Vertex can't be null!");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i;var n=i;do n.Org=a,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var a=t;Bt(a,"Face can't be null");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i,a.trail=null,a.marked=!1,a.inside=r.inside;var n=i;do n.Lface=a,n=n.Lnext;while(n!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,a=r;do a.Org=i,a=a.Onext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,a=r;do a.Lface=i,a=a.Lnext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.makeEdge=function(){var t=new Kc,i=new Kc,r=new Ou,a=this.makeEdge_(this.eHead);return this.makeVertex_(t,a,this.vHead),this.makeVertex_(i,a.Sym,this.vHead),this.makeFace_(r,a,this.fHead),a},e.prototype.splice=function(t,i){var r=!1,a=!1;if(t!==i){if(i.Org!==t.Org&&(a=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!a){var s=new Kc;this.makeVertex_(s,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Ou;this.makeFace_(n,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var a=new Ou;this.makeFace_(a,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var a=new Kc;return this.makeVertex_(a,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,a=this.makeEdge_(t),s=a.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(a,t.Lnext),this.splice_(s,i),a.Org=t.Dst,s.Org=i.Org,a.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var n=new Ou;this.makeFace_(n,a,t.Lface)}return a},e.prototype.zapFace=function(t){var i=t.anEdge,r,a,s,n,o;a=i.Lnext;do r=a,a=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!=i);n=t.prev,o=t.next,o.prev=n,n.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,a,s,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;a=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(s.Lface),o+l-2<=t&&Et.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Et.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(a=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===n);)r=a;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,a,s,n,o,l,h;for(s=t,s=t;(a=s.next)!==t;s=a){Bt(a.prev===s),l=a.anEdge;do Bt(l.Sym!==l),Bt(l.Sym.Sym===l),Bt(l.Lnext.Onext.Sym===l),Bt(l.Onext.Sym.Lnext===l),Bt(l.Lface===a),l=l.Lnext;while(l!==a.anEdge)}for(Bt(a.prev===s&&a.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Bt(n.prev===o),l=n.anEdge;do Bt(l.Sym!==l),Bt(l.Sym.Sym===l),Bt(l.Lnext.Onext.Sym===l),Bt(l.Onext.Sym.Lnext===l),Bt(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Bt(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Bt(l.Sym.next===h.Sym),Bt(l.Sym!==l),Bt(l.Sym.Sym===l),Bt(l.Org!==null),Bt(l.Dst!==null),Bt(l.Lnext.Onext.Sym===l),Bt(l.Onext.Sym.Lnext===l);Bt(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),eC=function(){function e(){this.handle=null}return e}(),tC=function(){function e(){this.key=null,this.node=0}return e}(),ZZ=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new eC,this.handles[r]=new tC;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Bt(n<=this.max),s=i[n].handle,n>this.size||this.leq(r[a].key,r[s].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t>>1,s=i[n].handle,n===0||this.leq(r[s].key,r[a].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var a,s;for(s=this.nodes.length,this.nodes.length=this.max+1,a=s;a<this.nodes.length;a++)this.nodes[a]=new eC;for(s=this.handles.length,this.handles.length=this.max+1,a=s;a<this.handles.length;a++)this.handles[a]=new tC}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,a=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),a},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,a;Bt(t>=1&&t<=this.max&&r[t].key!==null),a=r[t].node,i[a].handle=i[this.size].handle,r[i[a].handle].node=a,--this.size,a<=this.size&&(a<=1||this.leq(r[i[a>>1].handle].key,r[i[a].handle].key)?this.floatDown_(a):this.floatUp_(a)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),R1=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),iC=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),JZ=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new iC,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new iC;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),$Z=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var a=t.event,s=i.eUp,n=r.eUp;if(s.Dst===a)return n.Dst===a?Et.vertLeq(s.Org,n.Org)?Et.edgeSign(n.Dst,s.Org,n.Org)<=0:Et.edgeSign(s.Dst,n.Org,s.Org)>=0:Et.edgeSign(n.Dst,a,n.Org)<=0;if(n.Dst===a)return Et.edgeSign(s.Dst,a,s.Org)>=0;var o=Et.edgeEval(s.Dst,a,s.Org),l=Et.edgeEval(n.Dst,a,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Bt(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Bt(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,a;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(a=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),a===null)return null;e.fixUpperEdge(t,i,a),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var a=new R1;return a.eUp=r,a.nodeUp=t.dict.insertBefore(i.nodeUp,a),a.fixUpperEdge=!1,a.sentinel=!1,a.dirty=!1,r.activeRegion=a,a},e.isWindingInside=function(t,i){switch(t.windingRule){case Ii.ODD:return(i&1)!==0;case Ii.NONZERO:return i!==0;case Ii.POSITIVE:return i>0;case Ii.NEGATIVE:return i<0;case Ii.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,a=r.Lface;a.inside=i.inside,a.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var a,s=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,s=e.regionBelow(n),a=s.eUp,a.Org!=o.Org){if(!s.fixUpperEdge){e.finishRegion(t,n);break}a=t.mesh.connect(o.Lprev,a.Sym),e.fixUpperEdge(t,s,a)}o.Onext!==a&&(t.mesh.splice(a.Oprev,a),t.mesh.splice(o,a)),e.finishRegion(t,n),o=s.eUp,n=s}return o},e.addRightEdges=function(t,i,r,a,s,n){var o,l,h,c,d=!0;h=r;do Bt(Et.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==a);for(s===null&&(s=e.regionBelow(i).eUp.Rprev),l=i,c=s;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!d&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=o,c=h;l.dirty=!0,Bt(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var a=Et.vertL1dist(i,t),s=Et.vertL1dist(r,t),n=.5*s/(a+s),o=.5*a/(a+s);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,a,s,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,a),e.vertexWeights(i,s,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp;if(Et.vertLeq(a.Org,s.Org)){if(Et.edgeSign(s.Dst,a.Org,s.Org)>0)return!1;Et.vertEq(a.Org,s.Org)?a.Org!==s.Org&&(t.pq.delete(a.Org.pqHandle),e.spliceMergeVertices(t,s.Oprev,a)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(a,s.Oprev),i.dirty=r.dirty=!0)}else{if(Et.edgeSign(a.Dst,s.Org,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Oprev,a)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n;if(Bt(!Et.vertEq(a.Dst,s.Dst)),Et.vertLeq(a.Dst,s.Dst)){if(Et.edgeSign(a.Dst,s.Dst,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Sym,n),n.Lface.inside=i.inside}else{if(Et.edgeSign(s.Dst,a.Dst,s.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Lnext,s.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n=a.Org,o=s.Org,l=a.Dst,h=s.Dst,c,d,u=new Kc,p,f;if(Bt(!Et.vertEq(h,l)),Bt(Et.edgeSign(l,t.event,n)<=0),Bt(Et.edgeSign(h,t.event,o)>=0),Bt(n!==t.event&&o!==t.event),Bt(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),d=Math.max(o.t,h.t),c>d))return!1;if(Et.vertLeq(n,o)){if(Et.edgeSign(h,n,o)>0)return!1}else if(Et.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Et.intersect(l,n,h,o,u),Bt(Math.min(n.t,l.t)<=u.t),Bt(u.t<=Math.max(o.t,h.t)),Bt(Math.min(h.s,l.s)<=u.s),Bt(u.s<=Math.max(o.s,n.s)),Et.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Et.vertLeq(n,o)?n:o,Et.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Et.vertEq(u,n)||Et.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Et.vertEq(l,t.event)&&Et.edgeSign(l,t.event,u)>=0||!Et.vertEq(h,t.event)&&Et.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Sym,a),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,a.Oprev,a,a,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Lnext,s.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=s.Oprev,s=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,s.Onext,a.Rprev,f,!0),!0):(Et.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),Et.edgeSign(h,t.event,u)<=0&&(i.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(a.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,a),a.Org.s=u.s,a.Org.t=u.t,a.Org.pqHandle=t.pq.insert(a.Org),e.getIntersectData(t,a.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),a,s;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,a=i.eUp,s=r.eUp,a.Dst!==s.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(s),r=e.regionBelow(i),s=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r),a=i.eUp)),a.Org!==s.Org)if(a.Dst!==s.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(a.Dst===t.event||s.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);a.Org===s.Org&&a.Dst===s.Dst&&(e.addWinding(s,a),e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var a,s=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Et.vertEq(o.Org,t.event)&&(t.mesh.splice(s.Oprev,o),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Et.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,s,s,!0);return}Et.vertLeq(l.Org,o.Org)?a=l.Oprev:a=o,a=t.mesh.connect(r.Lprev,a),e.addRightEdges(t,i,a,a.Onext,a.Onext,!1),a.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var a,s,n,o,l;if(a=i.eUp,Et.vertEq(a.Org,r)){Bt(!1),e.spliceMergeVertices(t,a,r.anEdge);return}if(!Et.vertEq(a.Dst,r)){t.mesh.splitEdge(a.Sym),i.fixUpperEdge&&(t.mesh.delete(a.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,a),e.sweepEvent(t,r);return}Bt(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,s=o=n.Onext,l.fixUpperEdge&&(Bt(s!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=s.Oprev),t.mesh.splice(r.anEdge,n),Et.edgeGoesLeft(s)||(s=null),e.addRightEdges(t,i,n.Onext,o,s,!0)},e.connectLeftVertex=function(t,i){var r,a,s,n,o,l,h=new R1;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,a=e.regionBelow(r),!!a){if(n=r.eUp,o=a.eUp,Et.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(s=Et.vertLeq(o.Dst,n.Dst)?r:a,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}s.fixUpperEdge?e.fixUpperEdge(t,s,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var a=e.topLeftRegion(t,r.activeRegion);Bt(a!==null);var s=e.regionBelow(a),n=s.eUp,o=e.finishLeftRegions(t,s,null);o.Onext===n?e.connectRightVertex(t,a,o):e.addRightEdges(t,a,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,a){var s=new R1,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=a,n.Dst.s=i,n.Dst.t=a,t.event=n.Dst,s.eUp=n,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},e.initEdgeDict=function(t){t.dict=new JZ(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],a=t.bmin[0]-i,s=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,a,s,n),e.addSentinel(t,a,s,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Bt(i.fixUpperEdge),Bt(++r===1)),Bt(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,a,s=t.mesh.eHead;for(i=s.next;i!==s;i=r)r=i.next,a=i.Lnext,Et.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,a,i),t.mesh.delete(i),i=a,a=i.Lnext),a.Lnext===i&&(a!==i&&((a===r||a===r.Sym)&&(r=r.next),t.mesh.delete(a)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,a,s=0;for(a=t.mesh.vHead,r=a.next;r!==a;r=r.next)s++;for(s+=8,i=t.pq=new ZZ(s,Et.vertLeq),a=t.mesh.vHead,r=a.next;r!==a;r=r.next)r.pqHandle=i.insert(r);return r!==a?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,a,s;for(r=i.fHead.next;r!==i.fHead;r=a)a=r.next,s=r.anEdge,Bt(s.Lnext!==s),s.Lnext.Lnext===s&&(e.addWinding(s.Onext,s),t.mesh.delete(s));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,a;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;a=t.pq.min(),!(a===null||!Et.vertEq(a,r));)a=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,a.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),eJ=function(){function e(){this.mesh=new $E,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=Ii.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,a,s,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)s=i.coords[g],h[g]=s,f[g]=i,l[g]=s,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var y=0;y<3;++y)s=i.coords[y],s<h[y]&&(h[y]=s,f[y]=i),s>l[y]&&(l[y]=s,p[y]=i);var x=0;if(l[1]-h[1]>l[0]-h[0]&&(x=1),l[2]-h[2]>l[x]-h[x]&&(x=2),h[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[x],a=p[x],c[0]=r.coords[0]-a.coords[0],c[1]=r.coords[1]-a.coords[1],c[2]=r.coords[2]-a.coords[2],i=m.next;i!==m;i=i.next)d[0]=i.coords[0]-a.coords[0],d[1]=i.coords[1]-a.coords[1],d[2]=i.coords[2]-a.coords[2],u[0]=c[1]*d[2]-c[2]*d[1],u[1]=c[2]*d[0]-c[0]*d[2],u[2]=c[0]*d[1]-c[1]*d[0],n=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],n>o&&(o=n,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,a,s=0,n=t.next;n!==t;n=n.next)if(a=n.anEdge,!(a.winding<=0))do s+=(a.Org.s-a.Dst.s)*(a.Org.t+a.Dst.t),a=a.Lnext;while(a!==n.anEdge);if(s<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,a,s=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),s=!0),r=this.sUnit,a=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,a[n]=0,a[(n+1)%3]=0,a[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,a);s&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,a;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Et.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Et.vertLeq(r.Org,r.Dst);r=r.Lnext);a=r.Lprev;for(var s=void 0;r.Lnext!==a;)if(Et.vertLeq(r.Dst,a.Org)){for(;a.Lnext!==r&&(Et.edgeGoesLeft(a.Lnext)||Et.edgeSign(a.Org,a.Dst,a.Lnext.Dst)<=0);)s=t.connect(a.Lnext,a),a=s.Sym;a=a.Lprev}else{for(;a.Lnext!==r&&(Et.edgeGoesRight(r.Lprev)||Et.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(a.Lnext===r)throw"Mono region invalid";for(;a.Lnext.Lnext!==r;)s=t.connect(a.Lnext,a),a=s.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var a,s=t.eHead.next;s!==t.eHead;s=a)a=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?i:-i:r?t.delete(s):s.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,a){var s,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var h=s.Org;h.n===-1&&(h.n=o,o++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===Pr.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*a,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var d=h.n*a;this.vertices[d+0]=h.coords[0],this.vertices[d+1]=h.coords[1],a>2&&(this.vertices[d+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var u=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){s=c.anEdge,l=0;do{var h=s.Org;this.elements[u++]=h.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===Pr.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[u++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,a,s=0,n=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==a);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,c=0;s=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=0,a=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==a);this.elements[c++]=s,this.elements[c++]=n,s+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new $E),t<2&&(t=2),t>3&&(t=3);for(var r=null,a=0;a<i.length;a+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[a+0],r.Org.coords[1]=i[a+1],t>2?r.Org.coords[2]=i[a+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,a,s,n){if(t===void 0&&(t=Ii.ODD),i===void 0&&(i=Pr.POLYGONS),n===void 0&&(n=!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,a<2&&(a=2),a>3&&(a=3),!this.mesh)return!1;this.projectPolygon_(),$Z.computeInterior(this,n);var o=this.mesh;return i===Pr.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===Pr.BOUNDARY_CONTOURS?this.outputContours_(o,a):this.outputPolymesh_(o,i,r,a),!0},e}();function Rl(e){var t=e.windingRule,i=t===void 0?Ii.ODD:t,r=e.elementType,a=r===void 0?Pr.POLYGONS:r,s=e.polySize,n=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,d=e.contours,u=d===void 0?[]:d,p=e.strict,f=p===void 0?!0:p,m=e.debug,g=m===void 0?!1:m;if(!u&&f)throw new Error("Contours can't be empty");if(u){var y=new eJ;e.edgeCreateCallback&&(y.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(y.vertexIdCallback=e.vertexIdCallback);for(var x=0;x<u.length;x++)y.addContour(l||2,u[x]);return y.tesselate(i,a,n,l,c,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var dhe=Ii.ODD,uhe=Ii.NONZERO,phe=Ii.POSITIVE,fhe=Ii.NEGATIVE,mhe=Ii.ABS_GEQ_TWO,ghe=Pr.POLYGONS,vhe=Pr.CONNECTED_POLYGONS,yhe=Pr.BOUNDARY_CONTOURS,cb=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*cb.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,a=0;this.positions=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.normals=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.uvs=new Float32Array(this.buffer,a*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*cb.eSize,r=new ArrayBuffer(i),a=Float32Array.BYTES_PER_ELEMENT,s=0,n=new Float32Array(r,s*a,3*e);s+=3*e;let o=new Float32Array(r,s*a,3*e);s+=3*e;let l=new Float32Array(r,s*a,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},pI=cb;pI.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var tJ=class{constructor(e=[],t=(i,r)=>i<r?-1:i>r?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,s=t[a];if(i(r,s)>=0)break;t[e]=s,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let s=(e<<1)+1,n=s+1;if(n<this.length&&i(t[n],t[s])<0&&(s=n),i(t[s],a)>=0)break;t[e]=t[s],e=s}t[e]=a}};function iJ(e,t,i=1,r=!1){let a=1/0,s=1/0,n=-1/0,o=-1/0;for(let[x,b]of e[0])x<a&&(a=x),b<s&&(s=b),x>n&&(n=x),b>o&&(o=b);let l=n-a,h=o-s,c=Math.max(i,Math.min(l,h));if(c===i){let x=[a,s];return x.distance=0,x.distance}let d=new tJ([],(x,b)=>b.max-x.max),u=aJ(e),p=new dv(a+l/2,s+h/2,0,e);p.d>u.d&&(u=p);let f=2;function m(x,b,_){let S=new dv(x,b,_,e);if(f++,S.max>u.d+i&&d.push(S),S.d>u.d&&(u=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${f} probes`),u.d>t))return t}let g=c/2;for(let x=a;x<n;x+=c)for(let b=s;b<o;b+=c)m(x+g,b+g,g);for(;d.length;){let{max:x,x:b,y:_,h:S}=d.pop();if(x-u.d<=i)break;g=S/2,m(b-g,_-g,g),m(b+g,_-g,g),m(b-g,_+g,g),m(b+g,_+g,g)}r&&console.log(`num probes: ${f}
3175
+ }`;function dN(e,t,i){let r=new Zb,a=new ae,s=new ae,n=new Lt,o=new j3({depthPacking:C3}),l=new lN,h={},c=i.maxTextureSize,d={[nn]:na,[na]:nn,[Pa]:Pa},u=new di({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ae},radius:{value:4}},vertexShader:hN,fragmentShader:cN}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new vt;f.setAttribute("position",new Pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Fi(f,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Wb,this.render=function(_,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||_.length===0)return;let E=e.getRenderTarget(),M=e.getActiveCubeFace(),T=e.getActiveMipmapLevel(),P=e.state;P.setBlending(Ir),P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);for(let R=0,z=_.length;R<z;R++){let U=_[R],L=U.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",U,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;a.copy(L.mapSize);let j=L.getFrameExtents();if(a.multiply(j),s.copy(L.mapSize),(a.x>c||a.y>c)&&(a.x>c&&(s.x=Math.floor(c/j.x),a.x=s.x*j.x,L.mapSize.x=s.x),a.y>c&&(s.y=Math.floor(c/j.y),a.y=s.y*j.y,L.mapSize.y=s.y)),L.map===null){let Q=this.type!==Xu?{minFilter:ei,magFilter:ei}:{};L.map=new ci(a.x,a.y,Q),L.map.texture.name=U.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let q=L.getViewportCount();for(let Q=0;Q<q;Q++){let X=L.getViewport(Q);n.set(s.x*X.x,s.y*X.y,s.x*X.z,s.y*X.w),P.viewport(n),L.updateMatrices(U,Q),r=L.getFrustum(),b(S,A,L.camera,U,this.type)}L.isPointLightShadow!==!0&&this.type===Xu&&y(L,A),L.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(E,M,T)};function y(_,S){let A=t.update(m);u.defines.VSM_SAMPLES!==_.blurSamples&&(u.defines.VSM_SAMPLES=_.blurSamples,p.defines.VSM_SAMPLES=_.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new ci(a.x,a.y)),u.uniforms.shadow_pass.value=_.map.texture,u.uniforms.resolution.value=_.mapSize,u.uniforms.radius.value=_.radius,e.setRenderTarget(_.mapPass),e.clear(),e.renderBufferDirect(S,null,A,u,m,null),p.uniforms.shadow_pass.value=_.mapPass.texture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,e.setRenderTarget(_.map),e.clear(),e.renderBufferDirect(S,null,A,p,m,null)}function x(_,S,A,E,M,T){let P=null,R=A.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)P=R;else if(P=A.isPointLight===!0?l:o,e.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let z=P.uuid,U=S.uuid,L=h[z];L===void 0&&(L={},h[z]=L);let j=L[U];j===void 0&&(j=P.clone(),L[U]=j),P=j}return P.visible=S.visible,P.wireframe=S.wireframe,T===Xu?P.side=S.shadowSide!==null?S.shadowSide:S.side:P.side=S.shadowSide!==null?S.shadowSide:d[S.side],P.alphaMap=S.alphaMap,P.alphaTest=S.alphaTest,P.map=S.map,P.clipShadows=S.clipShadows,P.clippingPlanes=S.clippingPlanes,P.clipIntersection=S.clipIntersection,P.displacementMap=S.displacementMap,P.displacementScale=S.displacementScale,P.displacementBias=S.displacementBias,P.wireframeLinewidth=S.wireframeLinewidth,P.linewidth=S.linewidth,A.isPointLight===!0&&P.isMeshDistanceMaterial===!0&&(P.referencePosition.setFromMatrixPosition(A.matrixWorld),P.nearDistance=E,P.farDistance=M),P}function b(_,S,A,E,M){if(_.visible===!1)return;if(_.layers.test(S.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&M===Xu)&&(!_.frustumCulled||r.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,_.matrixWorld);let P=t.update(_),R=_.material;if(Array.isArray(R)){let z=P.groups;for(let U=0,L=z.length;U<L;U++){let j=z[U],q=R[j.materialIndex];if(q&&q.visible){let Q=x(_,q,E,A.near,A.far,M);e.renderBufferDirect(A,null,P,Q,_,j)}}}else if(R.visible){let z=x(_,R,E,A.near,A.far,M);e.renderBufferDirect(A,null,P,z,_,null)}}let T=_.children;for(let P=0,R=T.length;P<R;P++)b(T[P],S,A,E,M)}}function uN(e,t,i){let r=i.isWebGL2;function a(){let me=!1,Ee=new Lt,Xe=null,Ze=new Lt(0,0,0,0);return{setMask:function(yt){Xe!==yt&&!me&&(e.colorMask(yt,yt,yt,yt),Xe=yt)},setLocked:function(yt){me=yt},setClear:function(yt,Tt,Si,Gi,Br){Br===!0&&(yt*=Gi,Tt*=Gi,Si*=Gi),Ee.set(yt,Tt,Si,Gi),Ze.equals(Ee)===!1&&(e.clearColor(yt,Tt,Si,Gi),Ze.copy(Ee))},reset:function(){me=!1,Xe=null,Ze.set(-1,0,0,0)}}}function s(){let me=!1,Ee=null,Xe=null,Ze=null;return{setTest:function(yt){yt?Pe(2929):ve(2929)},setMask:function(yt){Ee!==yt&&!me&&(e.depthMask(yt),Ee=yt)},setFunc:function(yt){if(Xe!==yt){switch(yt){case Rz:e.depthFunc(512);break;case Lz:e.depthFunc(519);break;case Bz:e.depthFunc(513);break;case By:e.depthFunc(515);break;case zz:e.depthFunc(514);break;case kz:e.depthFunc(518);break;case Fz:e.depthFunc(516);break;case Uz:e.depthFunc(517);break;default:e.depthFunc(515)}Xe=yt}},setLocked:function(yt){me=yt},setClear:function(yt){Ze!==yt&&(e.clearDepth(yt),Ze=yt)},reset:function(){me=!1,Ee=null,Xe=null,Ze=null}}}function n(){let me=!1,Ee=null,Xe=null,Ze=null,yt=null,Tt=null,Si=null,Gi=null,Br=null;return{setTest:function(Ti){me||(Ti?Pe(2960):ve(2960))},setMask:function(Ti){Ee!==Ti&&!me&&(e.stencilMask(Ti),Ee=Ti)},setFunc:function(Ti,da,zr){(Xe!==Ti||Ze!==da||yt!==zr)&&(e.stencilFunc(Ti,da,zr),Xe=Ti,Ze=da,yt=zr)},setOp:function(Ti,da,zr){(Tt!==Ti||Si!==da||Gi!==zr)&&(e.stencilOp(Ti,da,zr),Tt=Ti,Si=da,Gi=zr)},setLocked:function(Ti){me=Ti},setClear:function(Ti){Br!==Ti&&(e.clearStencil(Ti),Br=Ti)},reset:function(){me=!1,Ee=null,Xe=null,Ze=null,yt=null,Tt=null,Si=null,Gi=null,Br=null}}}let o=new a,l=new s,h=new n,c=new WeakMap,d=new WeakMap,u={},p={},f=new WeakMap,m=[],g=null,y=!1,x=null,b=null,_=null,S=null,A=null,E=null,M=null,T=!1,P=null,R=null,z=null,U=null,L=null,j=e.getParameter(35661),q=!1,Q=0,X=e.getParameter(7938);X.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(X)[1]),q=Q>=1):X.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),q=Q>=2);let ie=null,oe={},te=e.getParameter(3088),re=e.getParameter(2978),fe=new Lt().fromArray(te),ce=new Lt().fromArray(re);function de(me,Ee,Xe){let Ze=new Uint8Array(4),yt=e.createTexture();e.bindTexture(me,yt),e.texParameteri(me,10241,9728),e.texParameteri(me,10240,9728);for(let Tt=0;Tt<Xe;Tt++)e.texImage2D(Ee+Tt,0,6408,1,1,0,6408,5121,Ze);return yt}let se={};se[3553]=de(3553,3553,1),se[34067]=de(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),Pe(2929),l.setFunc(By),st(!1),ot(sS),Pe(2884),rt(Ir);function Pe(me){u[me]!==!0&&(e.enable(me),u[me]=!0)}function ve(me){u[me]!==!1&&(e.disable(me),u[me]=!1)}function Ae(me,Ee){return p[me]!==Ee?(e.bindFramebuffer(me,Ee),p[me]=Ee,r&&(me===36009&&(p[36160]=Ee),me===36160&&(p[36009]=Ee)),!0):!1}function ye(me,Ee){let Xe=m,Ze=!1;if(me)if(Xe=f.get(Ee),Xe===void 0&&(Xe=[],f.set(Ee,Xe)),me.isWebGLMultipleRenderTargets){let yt=me.texture;if(Xe.length!==yt.length||Xe[0]!==36064){for(let Tt=0,Si=yt.length;Tt<Si;Tt++)Xe[Tt]=36064+Tt;Xe.length=yt.length,Ze=!0}}else Xe[0]!==36064&&(Xe[0]=36064,Ze=!0);else Xe[0]!==1029&&(Xe[0]=1029,Ze=!0);Ze&&(i.isWebGL2?e.drawBuffers(Xe):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Xe))}function Ve(me){return g!==me?(e.useProgram(me),g=me,!0):!1}let Ie={[qc]:32774,[_z]:32778,[Sz]:32779};if(r)Ie[hS]=32775,Ie[cS]=32776;else{let me=t.get("EXT_blend_minmax");me!==null&&(Ie[hS]=me.MIN_EXT,Ie[cS]=me.MAX_EXT)}let Ce={[Az]:0,[Mz]:1,[Ez]:768,[x3]:770,[Oz]:776,[Dz]:774,[Tz]:772,[Cz]:769,[b3]:771,[Iz]:775,[Pz]:773};function rt(me,Ee,Xe,Ze,yt,Tt,Si,Gi){if(me===Ir){y===!0&&(ve(3042),y=!1);return}if(y===!1&&(Pe(3042),y=!0),me!==wz){if(me!==x||Gi!==T){if((b!==qc||A!==qc)&&(e.blendEquation(32774),b=qc,A=qc),Gi)switch(me){case Dh:e.blendFuncSeparate(1,771,1,771);break;case nS:e.blendFunc(1,1);break;case oS:e.blendFuncSeparate(0,769,0,1);break;case lS:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}else switch(me){case Dh:e.blendFuncSeparate(770,771,1,771);break;case nS:e.blendFunc(770,1);break;case oS:e.blendFuncSeparate(0,769,0,1);break;case lS:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}_=null,S=null,E=null,M=null,x=me,T=Gi}return}yt=yt||Ee,Tt=Tt||Xe,Si=Si||Ze,(Ee!==b||yt!==A)&&(e.blendEquationSeparate(Ie[Ee],Ie[yt]),b=Ee,A=yt),(Xe!==_||Ze!==S||Tt!==E||Si!==M)&&(e.blendFuncSeparate(Ce[Xe],Ce[Ze],Ce[Tt],Ce[Si]),_=Xe,S=Ze,E=Tt,M=Si),x=me,T=!1}function Je(me,Ee){me.side===Pa?ve(2884):Pe(2884);let Xe=me.side===na;Ee&&(Xe=!Xe),st(Xe),me.blending===Dh&&me.transparent===!1?rt(Ir):rt(me.blending,me.blendEquation,me.blendSrc,me.blendDst,me.blendEquationAlpha,me.blendSrcAlpha,me.blendDstAlpha,me.premultipliedAlpha),l.setFunc(me.depthFunc),l.setTest(me.depthTest),l.setMask(me.depthWrite),o.setMask(me.colorWrite);let Ze=me.stencilWrite;h.setTest(Ze),Ze&&(h.setMask(me.stencilWriteMask),h.setFunc(me.stencilFunc,me.stencilRef,me.stencilFuncMask),h.setOp(me.stencilFail,me.stencilZFail,me.stencilZPass)),Qe(me.polygonOffset,me.polygonOffsetFactor,me.polygonOffsetUnits),me.alphaToCoverage===!0?Pe(32926):ve(32926)}function st(me){P!==me&&(me?e.frontFace(2304):e.frontFace(2305),P=me)}function ot(me){me!==yz?(Pe(2884),me!==R&&(me===sS?e.cullFace(1029):me===xz?e.cullFace(1028):e.cullFace(1032))):ve(2884),R=me}function Ke(me){me!==z&&(q&&e.lineWidth(me),z=me)}function Qe(me,Ee,Xe){me?(Pe(32823),(U!==Ee||L!==Xe)&&(e.polygonOffset(Ee,Xe),U=Ee,L=Xe)):ve(32823)}function ft(me){me?Pe(3089):ve(3089)}function St(me){me===void 0&&(me=33984+j-1),ie!==me&&(e.activeTexture(me),ie=me)}function ee(me,Ee,Xe){Xe===void 0&&(ie===null?Xe=33984+j-1:Xe=ie);let Ze=oe[Xe];Ze===void 0&&(Ze={type:void 0,texture:void 0},oe[Xe]=Ze),(Ze.type!==me||Ze.texture!==Ee)&&(ie!==Xe&&(e.activeTexture(Xe),ie=Xe),e.bindTexture(me,Ee||se[me]),Ze.type=me,Ze.texture=Ee)}function W(){let me=oe[ie];me!==void 0&&me.type!==void 0&&(e.bindTexture(me.type,null),me.type=void 0,me.texture=void 0)}function _e(){try{e.compressedTexImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function We(){try{e.compressedTexImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function V(){try{e.texSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function Oe(){try{e.texSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function dt(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function He(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ze(){try{e.texStorage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function Fe(){try{e.texStorage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ut(){try{e.texImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function lt(){try{e.texImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function At(me){fe.equals(me)===!1&&(e.scissor(me.x,me.y,me.z,me.w),fe.copy(me))}function _t(me){ce.equals(me)===!1&&(e.viewport(me.x,me.y,me.z,me.w),ce.copy(me))}function ai(me,Ee){let Xe=d.get(Ee);Xe===void 0&&(Xe=new WeakMap,d.set(Ee,Xe));let Ze=Xe.get(me);Ze===void 0&&(Ze=e.getUniformBlockIndex(Ee,me.name),Xe.set(me,Ze))}function yi(me,Ee){let Xe=d.get(Ee).get(me);c.get(Ee)!==Xe&&(e.uniformBlockBinding(Ee,Xe,me.__bindingPointIndex),c.set(Ee,Xe))}function ri(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),u={},ie=null,oe={},p={},f=new WeakMap,m=[],g=null,y=!1,x=null,b=null,_=null,S=null,A=null,E=null,M=null,T=!1,P=null,R=null,z=null,U=null,L=null,fe.set(0,0,e.canvas.width,e.canvas.height),ce.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:Pe,disable:ve,bindFramebuffer:Ae,drawBuffers:ye,useProgram:Ve,setBlending:rt,setMaterial:Je,setFlipSided:st,setCullFace:ot,setLineWidth:Ke,setPolygonOffset:Qe,setScissorTest:ft,activeTexture:St,bindTexture:ee,unbindTexture:W,compressedTexImage2D:_e,compressedTexImage3D:We,texImage2D:ut,texImage3D:lt,updateUBOMapping:ai,uniformBlockBinding:yi,texStorage2D:ze,texStorage3D:Fe,texSubImage2D:V,texSubImage3D:Oe,compressedTexSubImage2D:dt,compressedTexSubImage3D:He,scissor:At,viewport:_t,reset:ri}}function pN(e,t,i,r,a,s,n){let o=a.isWebGL2,l=a.maxTextures,h=a.maxCubemapSize,c=a.maxTextureSize,d=a.maxSamples,u=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(ee,W){return y?new OffscreenCanvas(ee,W):_p("canvas")}function b(ee,W,_e,We){let V=1;if((ee.width>We||ee.height>We)&&(V=We/Math.max(ee.width,ee.height)),V<1||W===!0)if(typeof HTMLImageElement<"u"&&ee instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&ee instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&ee instanceof ImageBitmap){let Oe=W?_g:Math.floor,dt=Oe(V*ee.width),He=Oe(V*ee.height);m===void 0&&(m=x(dt,He));let ze=_e?x(dt,He):m;return ze.width=dt,ze.height=He,ze.getContext("2d").drawImage(ee,0,0,dt,He),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ee.width+"x"+ee.height+") to ("+dt+"x"+He+")."),ze}else return"data"in ee&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ee.width+"x"+ee.height+")."),ee;return ee}function _(ee){return jy(ee.width)&&jy(ee.height)}function S(ee){return o?!1:ee.wrapS!==qi||ee.wrapT!==qi||ee.minFilter!==ei&&ee.minFilter!==Yt}function A(ee,W){return ee.generateMipmaps&&W&&ee.minFilter!==ei&&ee.minFilter!==Yt}function E(ee){e.generateMipmap(ee)}function M(ee,W,_e,We,V=!1){if(o===!1)return W;if(ee!==null){if(e[ee]!==void 0)return e[ee];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+ee+"'")}let Oe=W;return W===6403&&(_e===5126&&(Oe=33326),_e===5131&&(Oe=33325),_e===5121&&(Oe=33321)),W===33319&&(_e===5126&&(Oe=33328),_e===5131&&(Oe=33327),_e===5121&&(Oe=33323)),W===6408&&(_e===5126&&(Oe=34836),_e===5131&&(Oe=34842),_e===5121&&(Oe=We===Wt&&V===!1?35907:32856),_e===32819&&(Oe=32854),_e===32820&&(Oe=32855)),(Oe===33325||Oe===33326||Oe===33327||Oe===33328||Oe===34842||Oe===34836)&&t.get("EXT_color_buffer_float"),Oe}function T(ee,W,_e){return A(ee,_e)===!0||ee.isFramebufferTexture&&ee.minFilter!==ei&&ee.minFilter!==Yt?Math.log2(Math.max(W.width,W.height))+1:ee.mipmaps!==void 0&&ee.mipmaps.length>0?ee.mipmaps.length:ee.isCompressedTexture&&Array.isArray(ee.image)?W.mipmaps.length:1}function P(ee){return ee===ei||ee===dS||ee===C0?9728:9729}function R(ee){let W=ee.target;W.removeEventListener("dispose",R),U(W),W.isVideoTexture&&f.delete(W)}function z(ee){let W=ee.target;W.removeEventListener("dispose",z),j(W)}function U(ee){let W=r.get(ee);if(W.__webglInit===void 0)return;let _e=ee.source,We=g.get(_e);if(We){let V=We[W.__cacheKey];V.usedTimes--,V.usedTimes===0&&L(ee),Object.keys(We).length===0&&g.delete(_e)}r.remove(ee)}function L(ee){let W=r.get(ee);e.deleteTexture(W.__webglTexture);let _e=ee.source,We=g.get(_e);delete We[W.__cacheKey],n.memory.textures--}function j(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);if(We.__webglTexture!==void 0&&(e.deleteTexture(We.__webglTexture),n.memory.textures--),ee.depthTexture&&ee.depthTexture.dispose(),ee.isWebGLCubeRenderTarget)for(let V=0;V<6;V++)e.deleteFramebuffer(_e.__webglFramebuffer[V]),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer[V]);else{if(e.deleteFramebuffer(_e.__webglFramebuffer),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer),_e.__webglMultisampledFramebuffer&&e.deleteFramebuffer(_e.__webglMultisampledFramebuffer),_e.__webglColorRenderbuffer)for(let V=0;V<_e.__webglColorRenderbuffer.length;V++)_e.__webglColorRenderbuffer[V]&&e.deleteRenderbuffer(_e.__webglColorRenderbuffer[V]);_e.__webglDepthRenderbuffer&&e.deleteRenderbuffer(_e.__webglDepthRenderbuffer)}if(ee.isWebGLMultipleRenderTargets)for(let V=0,Oe=W.length;V<Oe;V++){let dt=r.get(W[V]);dt.__webglTexture&&(e.deleteTexture(dt.__webglTexture),n.memory.textures--),r.remove(W[V])}r.remove(W),r.remove(ee)}let q=0;function Q(){q=0}function X(){let ee=q;return ee>=l&&console.warn("THREE.WebGLTextures: Trying to use "+ee+" texture units while this GPU supports only "+l),q+=1,ee}function ie(ee){let W=[];return W.push(ee.wrapS),W.push(ee.wrapT),W.push(ee.wrapR||0),W.push(ee.magFilter),W.push(ee.minFilter),W.push(ee.anisotropy),W.push(ee.internalFormat),W.push(ee.format),W.push(ee.type),W.push(ee.generateMipmaps),W.push(ee.premultiplyAlpha),W.push(ee.flipY),W.push(ee.unpackAlignment),W.push(ee.encoding),W.join()}function oe(ee,W){let _e=r.get(ee);if(ee.isVideoTexture&&ft(ee),ee.isRenderTargetTexture===!1&&ee.version>0&&_e.__version!==ee.version){let We=ee.image;if(We===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(We.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ve(_e,ee,W);return}}i.bindTexture(3553,_e.__webglTexture,33984+W)}function te(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(35866,_e.__webglTexture,33984+W)}function re(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(32879,_e.__webglTexture,33984+W)}function fe(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){Ae(_e,ee,W);return}i.bindTexture(34067,_e.__webglTexture,33984+W)}let ce={[Io]:10497,[qi]:33071,[Fy]:33648},de={[ei]:9728,[dS]:9984,[C0]:9986,[Yt]:9729,[Xz]:9985,[wd]:9987};function se(ee,W,_e){if(_e?(e.texParameteri(ee,10242,ce[W.wrapS]),e.texParameteri(ee,10243,ce[W.wrapT]),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,ce[W.wrapR]),e.texParameteri(ee,10240,de[W.magFilter]),e.texParameteri(ee,10241,de[W.minFilter])):(e.texParameteri(ee,10242,33071),e.texParameteri(ee,10243,33071),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,33071),(W.wrapS!==qi||W.wrapT!==qi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(ee,10240,P(W.magFilter)),e.texParameteri(ee,10241,P(W.minFilter)),W.minFilter!==ei&&W.minFilter!==Yt&&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 We=t.get("EXT_texture_filter_anisotropic");if(W.magFilter===ei||W.minFilter!==C0&&W.minFilter!==wd||W.type===Di&&t.has("OES_texture_float_linear")===!1||o===!1&&W.type===No&&t.has("OES_texture_half_float_linear")===!1)return;(W.anisotropy>1||r.get(W).__currentAnisotropy)&&(e.texParameterf(ee,We.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(W.anisotropy,a.getMaxAnisotropy())),r.get(W).__currentAnisotropy=W.anisotropy)}}function Pe(ee,W){let _e=!1;ee.__webglInit===void 0&&(ee.__webglInit=!0,W.addEventListener("dispose",R));let We=W.source,V=g.get(We);V===void 0&&(V={},g.set(We,V));let Oe=ie(W);if(Oe!==ee.__cacheKey){V[Oe]===void 0&&(V[Oe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,_e=!0),V[Oe].usedTimes++;let dt=V[ee.__cacheKey];dt!==void 0&&(V[ee.__cacheKey].usedTimes--,dt.usedTimes===0&&L(W)),ee.__cacheKey=Oe,ee.__webglTexture=V[Oe].texture}return _e}function ve(ee,W,_e){let We=3553;(W.isDataArrayTexture||W.isCompressedArrayTexture)&&(We=35866),W.isData3DTexture&&(We=32879);let V=Pe(ee,W),Oe=W.source;i.bindTexture(We,ee.__webglTexture,33984+_e);let dt=r.get(Oe);if(Oe.version!==dt.__version||V===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let He=S(W)&&_(W.image)===!1,ze=b(W.image,He,!1,c);ze=St(W,ze);let Fe=_(ze)||o,ut=s.convert(W.format,W.encoding),lt=s.convert(W.type),At=M(W.internalFormat,ut,lt,W.encoding,W.isVideoTexture);se(We,W,Fe);let _t,ai=W.mipmaps,yi=o&&W.isVideoTexture!==!0,ri=dt.__version===void 0||V===!0,me=T(W,ze,Fe);if(W.isDepthTexture)At=6402,o?W.type===Di?At=36012:W.type===Oo?At=33190:W.type===Ih?At=35056:At=33189:W.type===Di&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),W.format===Oh&&At===6402&&W.type!==S3&&W.type!==Oo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),W.type=Oo,lt=s.convert(W.type)),W.format===Uh&&At===6402&&(At=34041,W.type!==Ih&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),W.type=Ih,lt=s.convert(W.type))),ri&&(yi?i.texStorage2D(3553,1,At,ze.width,ze.height):i.texImage2D(3553,0,At,ze.width,ze.height,0,ut,lt,null));else if(W.isDataTexture)if(ai.length>0&&Fe){yi&&ri&&i.texStorage2D(3553,me,At,ai[0].width,ai[0].height);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],yi?i.texSubImage2D(3553,Ee,0,0,_t.width,_t.height,ut,lt,_t.data):i.texImage2D(3553,Ee,At,_t.width,_t.height,0,ut,lt,_t.data);W.generateMipmaps=!1}else yi?(ri&&i.texStorage2D(3553,me,At,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,ze.width,ze.height,ut,lt,ze.data)):i.texImage2D(3553,0,At,ze.width,ze.height,0,ut,lt,ze.data);else if(W.isCompressedTexture)if(W.isCompressedArrayTexture){yi&&ri&&i.texStorage3D(35866,me,At,ai[0].width,ai[0].height,ze.depth);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],W.format!==Ki?ut!==null?yi?i.compressedTexSubImage3D(35866,Ee,0,0,0,_t.width,_t.height,ze.depth,ut,_t.data,0,0):i.compressedTexImage3D(35866,Ee,At,_t.width,_t.height,ze.depth,0,_t.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):yi?i.texSubImage3D(35866,Ee,0,0,0,_t.width,_t.height,ze.depth,ut,lt,_t.data):i.texImage3D(35866,Ee,At,_t.width,_t.height,ze.depth,0,ut,lt,_t.data)}else{yi&&ri&&i.texStorage2D(3553,me,At,ai[0].width,ai[0].height);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],W.format!==Ki?ut!==null?yi?i.compressedTexSubImage2D(3553,Ee,0,0,_t.width,_t.height,ut,_t.data):i.compressedTexImage2D(3553,Ee,At,_t.width,_t.height,0,_t.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):yi?i.texSubImage2D(3553,Ee,0,0,_t.width,_t.height,ut,lt,_t.data):i.texImage2D(3553,Ee,At,_t.width,_t.height,0,ut,lt,_t.data)}else if(W.isDataArrayTexture)yi?(ri&&i.texStorage3D(35866,me,At,ze.width,ze.height,ze.depth),i.texSubImage3D(35866,0,0,0,0,ze.width,ze.height,ze.depth,ut,lt,ze.data)):i.texImage3D(35866,0,At,ze.width,ze.height,ze.depth,0,ut,lt,ze.data);else if(W.isData3DTexture)yi?(ri&&i.texStorage3D(32879,me,At,ze.width,ze.height,ze.depth),i.texSubImage3D(32879,0,0,0,0,ze.width,ze.height,ze.depth,ut,lt,ze.data)):i.texImage3D(32879,0,At,ze.width,ze.height,ze.depth,0,ut,lt,ze.data);else if(W.isFramebufferTexture){if(ri)if(yi)i.texStorage2D(3553,me,At,ze.width,ze.height);else{let Ee=ze.width,Xe=ze.height;for(let Ze=0;Ze<me;Ze++)i.texImage2D(3553,Ze,At,Ee,Xe,0,ut,lt,null),Ee>>=1,Xe>>=1}}else if(ai.length>0&&Fe){yi&&ri&&i.texStorage2D(3553,me,At,ai[0].width,ai[0].height);for(let Ee=0,Xe=ai.length;Ee<Xe;Ee++)_t=ai[Ee],yi?i.texSubImage2D(3553,Ee,0,0,ut,lt,_t):i.texImage2D(3553,Ee,At,ut,lt,_t);W.generateMipmaps=!1}else yi?(ri&&i.texStorage2D(3553,me,At,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,ut,lt,ze)):i.texImage2D(3553,0,At,ut,lt,ze);A(W,Fe)&&E(We),dt.__version=Oe.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function Ae(ee,W,_e){if(W.image.length!==6)return;let We=Pe(ee,W),V=W.source;i.bindTexture(34067,ee.__webglTexture,33984+_e);let Oe=r.get(V);if(V.version!==Oe.__version||We===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let dt=W.isCompressedTexture||W.image[0].isCompressedTexture,He=W.image[0]&&W.image[0].isDataTexture,ze=[];for(let Ee=0;Ee<6;Ee++)!dt&&!He?ze[Ee]=b(W.image[Ee],!1,!0,h):ze[Ee]=He?W.image[Ee].image:W.image[Ee],ze[Ee]=St(W,ze[Ee]);let Fe=ze[0],ut=_(Fe)||o,lt=s.convert(W.format,W.encoding),At=s.convert(W.type),_t=M(W.internalFormat,lt,At,W.encoding),ai=o&&W.isVideoTexture!==!0,yi=Oe.__version===void 0||We===!0,ri=T(W,Fe,ut);se(34067,W,ut);let me;if(dt){ai&&yi&&i.texStorage2D(34067,ri,_t,Fe.width,Fe.height);for(let Ee=0;Ee<6;Ee++){me=ze[Ee].mipmaps;for(let Xe=0;Xe<me.length;Xe++){let Ze=me[Xe];W.format!==Ki?lt!==null?ai?i.compressedTexSubImage2D(34069+Ee,Xe,0,0,Ze.width,Ze.height,lt,Ze.data):i.compressedTexImage2D(34069+Ee,Xe,_t,Ze.width,Ze.height,0,Ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ai?i.texSubImage2D(34069+Ee,Xe,0,0,Ze.width,Ze.height,lt,At,Ze.data):i.texImage2D(34069+Ee,Xe,_t,Ze.width,Ze.height,0,lt,At,Ze.data)}}}else{me=W.mipmaps,ai&&yi&&(me.length>0&&ri++,i.texStorage2D(34067,ri,_t,ze[0].width,ze[0].height));for(let Ee=0;Ee<6;Ee++)if(He){ai?i.texSubImage2D(34069+Ee,0,0,0,ze[Ee].width,ze[Ee].height,lt,At,ze[Ee].data):i.texImage2D(34069+Ee,0,_t,ze[Ee].width,ze[Ee].height,0,lt,At,ze[Ee].data);for(let Xe=0;Xe<me.length;Xe++){let Ze=me[Xe].image[Ee].image;ai?i.texSubImage2D(34069+Ee,Xe+1,0,0,Ze.width,Ze.height,lt,At,Ze.data):i.texImage2D(34069+Ee,Xe+1,_t,Ze.width,Ze.height,0,lt,At,Ze.data)}}else{ai?i.texSubImage2D(34069+Ee,0,0,0,lt,At,ze[Ee]):i.texImage2D(34069+Ee,0,_t,lt,At,ze[Ee]);for(let Xe=0;Xe<me.length;Xe++){let Ze=me[Xe];ai?i.texSubImage2D(34069+Ee,Xe+1,0,0,lt,At,Ze.image[Ee]):i.texImage2D(34069+Ee,Xe+1,_t,lt,At,Ze.image[Ee])}}}A(W,ut)&&E(34067),Oe.__version=V.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function ye(ee,W,_e,We,V){let Oe=s.convert(_e.format,_e.encoding),dt=s.convert(_e.type),He=M(_e.internalFormat,Oe,dt,_e.encoding);r.get(W).__hasExternalTextures||(V===32879||V===35866?i.texImage3D(V,0,He,W.width,W.height,W.depth,0,Oe,dt,null):i.texImage2D(V,0,He,W.width,W.height,0,Oe,dt,null)),i.bindFramebuffer(36160,ee),Qe(W)?u.framebufferTexture2DMultisampleEXT(36160,We,V,r.get(_e).__webglTexture,0,Ke(W)):(V===3553||V>=34069&&V<=34074)&&e.framebufferTexture2D(36160,We,V,r.get(_e).__webglTexture,0),i.bindFramebuffer(36160,null)}function Ve(ee,W,_e){if(e.bindRenderbuffer(36161,ee),W.depthBuffer&&!W.stencilBuffer){let We=33189;if(_e||Qe(W)){let V=W.depthTexture;V&&V.isDepthTexture&&(V.type===Di?We=36012:V.type===Oo&&(We=33190));let Oe=Ke(W);Qe(W)?u.renderbufferStorageMultisampleEXT(36161,Oe,We,W.width,W.height):e.renderbufferStorageMultisample(36161,Oe,We,W.width,W.height)}else e.renderbufferStorage(36161,We,W.width,W.height);e.framebufferRenderbuffer(36160,36096,36161,ee)}else if(W.depthBuffer&&W.stencilBuffer){let We=Ke(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,We,35056,W.width,W.height):Qe(W)?u.renderbufferStorageMultisampleEXT(36161,We,35056,W.width,W.height):e.renderbufferStorage(36161,34041,W.width,W.height),e.framebufferRenderbuffer(36160,33306,36161,ee)}else{let We=W.isWebGLMultipleRenderTargets===!0?W.texture:[W.texture];for(let V=0;V<We.length;V++){let Oe=We[V],dt=s.convert(Oe.format,Oe.encoding),He=s.convert(Oe.type),ze=M(Oe.internalFormat,dt,He,Oe.encoding),Fe=Ke(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,Fe,ze,W.width,W.height):Qe(W)?u.renderbufferStorageMultisampleEXT(36161,Fe,ze,W.width,W.height):e.renderbufferStorage(36161,ze,W.width,W.height)}}e.bindRenderbuffer(36161,null)}function Ie(ee,W){if(W&&W.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,ee),!(W.depthTexture&&W.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(W.depthTexture).__webglTexture||W.depthTexture.image.width!==W.width||W.depthTexture.image.height!==W.height)&&(W.depthTexture.image.width=W.width,W.depthTexture.image.height=W.height,W.depthTexture.needsUpdate=!0),oe(W.depthTexture,0);let _e=r.get(W.depthTexture).__webglTexture,We=Ke(W);if(W.depthTexture.format===Oh)Qe(W)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,_e,0,We):e.framebufferTexture2D(36160,36096,3553,_e,0);else if(W.depthTexture.format===Uh)Qe(W)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,_e,0,We):e.framebufferTexture2D(36160,33306,3553,_e,0);else throw new Error("Unknown depthTexture format")}function Ce(ee){let W=r.get(ee),_e=ee.isWebGLCubeRenderTarget===!0;if(ee.depthTexture&&!W.__autoAllocateDepthBuffer){if(_e)throw new Error("target.depthTexture not supported in Cube render targets");Ie(W.__webglFramebuffer,ee)}else if(_e){W.__webglDepthbuffer=[];for(let We=0;We<6;We++)i.bindFramebuffer(36160,W.__webglFramebuffer[We]),W.__webglDepthbuffer[We]=e.createRenderbuffer(),Ve(W.__webglDepthbuffer[We],ee,!1)}else i.bindFramebuffer(36160,W.__webglFramebuffer),W.__webglDepthbuffer=e.createRenderbuffer(),Ve(W.__webglDepthbuffer,ee,!1);i.bindFramebuffer(36160,null)}function rt(ee,W,_e){let We=r.get(ee);W!==void 0&&ye(We.__webglFramebuffer,ee,ee.texture,36064,3553),_e!==void 0&&Ce(ee)}function Je(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);ee.addEventListener("dispose",z),ee.isWebGLMultipleRenderTargets!==!0&&(We.__webglTexture===void 0&&(We.__webglTexture=e.createTexture()),We.__version=W.version,n.memory.textures++);let V=ee.isWebGLCubeRenderTarget===!0,Oe=ee.isWebGLMultipleRenderTargets===!0,dt=_(ee)||o;if(V){_e.__webglFramebuffer=[];for(let He=0;He<6;He++)_e.__webglFramebuffer[He]=e.createFramebuffer()}else{if(_e.__webglFramebuffer=e.createFramebuffer(),Oe)if(a.drawBuffers){let He=ee.texture;for(let ze=0,Fe=He.length;ze<Fe;ze++){let ut=r.get(He[ze]);ut.__webglTexture===void 0&&(ut.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&ee.samples>0&&Qe(ee)===!1){let He=Oe?W:[W];_e.__webglMultisampledFramebuffer=e.createFramebuffer(),_e.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,_e.__webglMultisampledFramebuffer);for(let ze=0;ze<He.length;ze++){let Fe=He[ze];_e.__webglColorRenderbuffer[ze]=e.createRenderbuffer(),e.bindRenderbuffer(36161,_e.__webglColorRenderbuffer[ze]);let ut=s.convert(Fe.format,Fe.encoding),lt=s.convert(Fe.type),At=M(Fe.internalFormat,ut,lt,Fe.encoding,ee.isXRRenderTarget===!0),_t=Ke(ee);e.renderbufferStorageMultisample(36161,_t,At,ee.width,ee.height),e.framebufferRenderbuffer(36160,36064+ze,36161,_e.__webglColorRenderbuffer[ze])}e.bindRenderbuffer(36161,null),ee.depthBuffer&&(_e.__webglDepthRenderbuffer=e.createRenderbuffer(),Ve(_e.__webglDepthRenderbuffer,ee,!0)),i.bindFramebuffer(36160,null)}}if(V){i.bindTexture(34067,We.__webglTexture),se(34067,W,dt);for(let He=0;He<6;He++)ye(_e.__webglFramebuffer[He],ee,W,36064,34069+He);A(W,dt)&&E(34067),i.unbindTexture()}else if(Oe){let He=ee.texture;for(let ze=0,Fe=He.length;ze<Fe;ze++){let ut=He[ze],lt=r.get(ut);i.bindTexture(3553,lt.__webglTexture),se(3553,ut,dt),ye(_e.__webglFramebuffer,ee,ut,36064+ze,3553),A(ut,dt)&&E(3553)}i.unbindTexture()}else{let He=3553;(ee.isWebGL3DRenderTarget||ee.isWebGLArrayRenderTarget)&&(o?He=ee.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(He,We.__webglTexture),se(He,W,dt),ye(_e.__webglFramebuffer,ee,W,36064,He),A(W,dt)&&E(He),i.unbindTexture()}ee.depthBuffer&&Ce(ee)}function st(ee){let W=_(ee)||o,_e=ee.isWebGLMultipleRenderTargets===!0?ee.texture:[ee.texture];for(let We=0,V=_e.length;We<V;We++){let Oe=_e[We];if(A(Oe,W)){let dt=ee.isWebGLCubeRenderTarget?34067:3553,He=r.get(Oe).__webglTexture;i.bindTexture(dt,He),E(dt),i.unbindTexture()}}}function ot(ee){if(o&&ee.samples>0&&Qe(ee)===!1){let W=ee.isWebGLMultipleRenderTargets?ee.texture:[ee.texture],_e=ee.width,We=ee.height,V=16384,Oe=[],dt=ee.stencilBuffer?33306:36096,He=r.get(ee),ze=ee.isWebGLMultipleRenderTargets===!0;if(ze)for(let Fe=0;Fe<W.length;Fe++)i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,null),i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,null,0);i.bindFramebuffer(36008,He.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,He.__webglFramebuffer);for(let Fe=0;Fe<W.length;Fe++){Oe.push(36064+Fe),ee.depthBuffer&&Oe.push(dt);let ut=He.__ignoreDepthValues!==void 0?He.__ignoreDepthValues:!1;if(ut===!1&&(ee.depthBuffer&&(V|=256),ee.stencilBuffer&&(V|=1024)),ze&&e.framebufferRenderbuffer(36008,36064,36161,He.__webglColorRenderbuffer[Fe]),ut===!0&&(e.invalidateFramebuffer(36008,[dt]),e.invalidateFramebuffer(36009,[dt])),ze){let lt=r.get(W[Fe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,lt,0)}e.blitFramebuffer(0,0,_e,We,0,0,_e,We,V,9728),p&&e.invalidateFramebuffer(36008,Oe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ze)for(let Fe=0;Fe<W.length;Fe++){i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,He.__webglColorRenderbuffer[Fe]);let ut=r.get(W[Fe]).__webglTexture;i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,ut,0)}i.bindFramebuffer(36009,He.__webglMultisampledFramebuffer)}}function Ke(ee){return Math.min(d,ee.samples)}function Qe(ee){let W=r.get(ee);return o&&ee.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&W.__useRenderToTexture!==!1}function ft(ee){let W=n.render.frame;f.get(ee)!==W&&(f.set(ee,W),ee.update())}function St(ee,W){let _e=ee.encoding,We=ee.format,V=ee.type;return ee.isCompressedTexture===!0||ee.isVideoTexture===!0||ee.format===Vy||_e!==on&&(_e===Wt?o===!1?t.has("EXT_sRGB")===!0&&We===Ki?(ee.format=Vy,ee.minFilter=Yt,ee.generateMipmaps=!1):W=I3.sRGBToLinear(W):(We!==Ki||V!==Da)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",_e)),W}this.allocateTextureUnit=X,this.resetTextureUnits=Q,this.setTexture2D=oe,this.setTexture2DArray=te,this.setTexture3D=re,this.setTextureCube=fe,this.rebindTextures=rt,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=st,this.updateMultisampleRenderTarget=ot,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=Qe}function fN(e,t,i){let r=i.isWebGL2;function a(s,n=null){let o;if(s===Da)return 5121;if(s===Zz)return 32819;if(s===Jz)return 32820;if(s===Yz)return 5120;if(s===Qz)return 5122;if(s===S3)return 5123;if(s===Kz)return 5124;if(s===Oo)return 5125;if(s===Di)return 5126;if(s===No)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===$z)return 6406;if(s===Ki)return 6408;if(s===e5)return 6409;if(s===t5)return 6410;if(s===Oh)return 6402;if(s===Uh)return 34041;if(s===Vy)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===$m)return 6403;if(s===i5)return 36244;if(s===vg)return 33319;if(s===r5)return 33320;if(s===A3)return 36249;if(s===T0||s===P0||s===D0||s===I0)if(n===Wt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===T0)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===P0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===D0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===I0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===T0)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===P0)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===D0)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===I0)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===uS||s===pS||s===fS||s===mS)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===uS)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===pS)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===fS)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===mS)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===a5)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===gS||s===vS)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(s===gS)return n===Wt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===vS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===yS||s===xS||s===bS||s===wS||s===_S||s===SS||s===AS||s===MS||s===ES||s===CS||s===TS||s===PS||s===DS||s===IS)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(s===yS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===xS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===bS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===wS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===_S)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===SS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===AS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===MS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===ES)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===CS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===TS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===PS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===DS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===IS)return n===Wt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===O0)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(s===O0)return n===Wt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===s5||s===OS||s===RS||s===LS)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(s===O0)return o.COMPRESSED_RED_RGTC1_EXT;if(s===OS)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===RS)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===LS)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ih?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[s]!==void 0?e[s]:null}return{convert:a}}var mN=class extends Ea{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Lo=class extends Ci{constructor(){super(),this.isGroup=!0,this.type="Group"}},gN={type:"move"},a1=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lo,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 Lo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,s=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){s=!0;for(let f of e.hand.values()){let m=t.getJointPose(f,i),g=this._getHandJoint(l,f);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==null}let h=l.joints["index-finger-tip"],c=l.joints["thumb-tip"],d=h.position.distanceTo(c.position),u=.02,p=.005;l.inputState.pinching&&d>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=u-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(o.matrix.fromArray(a.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),a.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(a.linearVelocity)):o.hasLinearVelocity=!1,a.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(a.angularVelocity)):o.hasAngularVelocity=!1));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(gN)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=a!==null),l!==null&&(l.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Lo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Sd=class extends Zi{constructor(e,t,i,r,a,s,n,o,l,h){if(h=h!==void 0?h:Oh,h!==Oh&&h!==Uh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===Oh&&(i=Oo),i===void 0&&h===Uh&&(i=Ih),super(null,r,a,s,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:ei,this.minFilter=o!==void 0?o:ei,this.flipY=!1,this.generateMipmaps=!1}},vN=class extends ha{constructor(e,t){super();let i=this,r=null,a=1,s=null,n="local-floor",o=1,l=null,h=null,c=null,d=null,u=null,p=null,f=t.getContextAttributes(),m=null,g=null,y=[],x=[],b=new Set,_=new Map,S=new Ea;S.layers.enable(1),S.viewport=new Lt;let A=new Ea;A.layers.enable(2),A.viewport=new Lt;let E=[S,A],M=new mN;M.layers.enable(1),M.layers.enable(2);let T=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let re=y[te];return re===void 0&&(re=new a1,y[te]=re),re.getTargetRaySpace()},this.getControllerGrip=function(te){let re=y[te];return re===void 0&&(re=new a1,y[te]=re),re.getGripSpace()},this.getHand=function(te){let re=y[te];return re===void 0&&(re=new a1,y[te]=re),re.getHandSpace()};function R(te){let re=x.indexOf(te.inputSource);if(re===-1)return;let fe=y[re];fe!==void 0&&fe.dispatchEvent({type:te.type,data:te.inputSource})}function z(){r.removeEventListener("select",R),r.removeEventListener("selectstart",R),r.removeEventListener("selectend",R),r.removeEventListener("squeeze",R),r.removeEventListener("squeezestart",R),r.removeEventListener("squeezeend",R),r.removeEventListener("end",z),r.removeEventListener("inputsourceschange",U);for(let te=0;te<y.length;te++){let re=x[te];re!==null&&(x[te]=null,y[te].disconnect(re))}T=null,P=null,e.setRenderTarget(m),u=null,d=null,c=null,r=null,g=null,oe.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){a=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){n=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(te){l=te},this.getBaseLayer=function(){return d!==null?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(te){if(r=te,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",R),r.addEventListener("selectstart",R),r.addEventListener("selectend",R),r.addEventListener("squeeze",R),r.addEventListener("squeezestart",R),r.addEventListener("squeezeend",R),r.addEventListener("end",z),r.addEventListener("inputsourceschange",U),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let re={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:a};u=new XRWebGLLayer(r,t,re),r.updateRenderState({baseLayer:u}),g=new ci(u.framebufferWidth,u.framebufferHeight,{format:Ki,type:Da,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let re=null,fe=null,ce=null;f.depth&&(ce=f.stencil?35056:33190,re=f.stencil?Uh:Oh,fe=f.stencil?Ih:Oo);let de={colorFormat:32856,depthFormat:ce,scaleFactor:a};c=new XRWebGLBinding(r,t),d=c.createProjectionLayer(de),r.updateRenderState({layers:[d]}),g=new ci(d.textureWidth,d.textureHeight,{format:Ki,type:Da,depthTexture:new Sd(d.textureWidth,d.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let se=e.properties.get(g);se.__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await r.requestReferenceSpace(n),oe.setContext(r),oe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function U(te){for(let re=0;re<te.removed.length;re++){let fe=te.removed[re],ce=x.indexOf(fe);ce>=0&&(x[ce]=null,y[ce].disconnect(fe))}for(let re=0;re<te.added.length;re++){let fe=te.added[re],ce=x.indexOf(fe);if(ce===-1){for(let se=0;se<y.length;se++)if(se>=x.length){x.push(fe),ce=se;break}else if(x[se]===null){x[se]=fe,ce=se;break}if(ce===-1)break}let de=y[ce];de&&de.connect(fe)}}let L=new O,j=new O;function q(te,re,fe){L.setFromMatrixPosition(re.matrixWorld),j.setFromMatrixPosition(fe.matrixWorld);let ce=L.distanceTo(j),de=re.projectionMatrix.elements,se=fe.projectionMatrix.elements,Pe=de[14]/(de[10]-1),ve=de[14]/(de[10]+1),Ae=(de[9]+1)/de[5],ye=(de[9]-1)/de[5],Ve=(de[8]-1)/de[0],Ie=(se[8]+1)/se[0],Ce=Pe*Ve,rt=Pe*Ie,Je=ce/(-Ve+Ie),st=Je*-Ve;re.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(st),te.translateZ(Je),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();let ot=Pe+Je,Ke=ve+Je,Qe=Ce-st,ft=rt+(ce-st),St=Ae*ve/Ke*ot,ee=ye*ve/Ke*ot;te.projectionMatrix.makePerspective(Qe,ft,St,ee,ot,Ke)}function Q(te,re){re===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(re.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(r===null)return;M.near=A.near=S.near=te.near,M.far=A.far=S.far=te.far,(T!==M.near||P!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,P=M.far);let re=te.parent,fe=M.cameras;Q(M,re);for(let de=0;de<fe.length;de++)Q(fe[de],re);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),te.matrix.copy(M.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale);let ce=te.children;for(let de=0,se=ce.length;de<se;de++)ce[de].updateMatrixWorld(!0);fe.length===2?q(M,S,A):M.projectionMatrix.copy(S.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&u===null))return o},this.setFoveation=function(te){o=te,d!==null&&(d.fixedFoveation=te),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=te)},this.getPlanes=function(){return b};let X=null;function ie(te,re){if(h=re.getViewerPose(l||s),p=re,h!==null){let fe=h.views;u!==null&&(e.setRenderTargetFramebuffer(g,u.framebuffer),e.setRenderTarget(g));let ce=!1;fe.length!==M.cameras.length&&(M.cameras.length=0,ce=!0);for(let de=0;de<fe.length;de++){let se=fe[de],Pe=null;if(u!==null)Pe=u.getViewport(se);else{let Ae=c.getViewSubImage(d,se);Pe=Ae.viewport,de===0&&(e.setRenderTargetTextures(g,Ae.colorTexture,d.ignoreDepthValues?void 0:Ae.depthStencilTexture),e.setRenderTarget(g))}let ve=E[de];ve===void 0&&(ve=new Ea,ve.layers.enable(de),ve.viewport=new Lt,E[de]=ve),ve.matrix.fromArray(se.transform.matrix),ve.projectionMatrix.fromArray(se.projectionMatrix),ve.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),de===0&&M.matrix.copy(ve.matrix),ce===!0&&M.cameras.push(ve)}}for(let fe=0;fe<y.length;fe++){let ce=x[fe],de=y[fe];ce!==null&&de!==void 0&&de.update(ce,re,l||s)}if(X&&X(te,re),re.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:re.detectedPlanes});let fe=null;for(let ce of b)re.detectedPlanes.has(ce)||(fe===null&&(fe=[]),fe.push(ce));if(fe!==null)for(let ce of fe)b.delete(ce),_.delete(ce),i.dispatchEvent({type:"planeremoved",data:ce});for(let ce of re.detectedPlanes)if(!b.has(ce))b.add(ce),_.set(ce,re.lastChangedTime),i.dispatchEvent({type:"planeadded",data:ce});else{let de=_.get(ce);ce.lastChangedTime>de&&(_.set(ce,ce.lastChangedTime),i.dispatchEvent({type:"planechanged",data:ce}))}}p=null}let oe=new k3;oe.setAnimationLoop(ie),this.setAnimationLoop=function(te){X=te},this.dispose=function(){}}};function yN(e,t){function i(m,g){g.color.getRGB(m.fogColor.value,z3(e)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,x,b){g.isMeshBasicMaterial||g.isMeshLambertMaterial?a(m,g):g.isMeshToonMaterial?(a(m,g),c(m,g)):g.isMeshPhongMaterial?(a(m,g),h(m,g)):g.isMeshStandardMaterial?(a(m,g),d(m,g),g.isMeshPhysicalMaterial&&u(m,g,b)):g.isMeshMatcapMaterial?(a(m,g),p(m,g)):g.isMeshDepthMaterial?a(m,g):g.isMeshDistanceMaterial?(a(m,g),f(m,g)):g.isMeshNormalMaterial?a(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&n(m,g)):g.isPointsMaterial?o(m,g,y,x):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function a(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===na&&(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===na&&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 _=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*_}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let x;g.map?x=g.map:g.specularMap?x=g.specularMap:g.displacementMap?x=g.displacementMap:g.normalMap?x=g.normalMap:g.bumpMap?x=g.bumpMap:g.roughnessMap?x=g.roughnessMap:g.metalnessMap?x=g.metalnessMap:g.alphaMap?x=g.alphaMap:g.emissiveMap?x=g.emissiveMap:g.clearcoatMap?x=g.clearcoatMap:g.clearcoatNormalMap?x=g.clearcoatNormalMap:g.clearcoatRoughnessMap?x=g.clearcoatRoughnessMap:g.iridescenceMap?x=g.iridescenceMap:g.iridescenceThicknessMap?x=g.iridescenceThicknessMap:g.specularIntensityMap?x=g.specularIntensityMap:g.specularColorMap?x=g.specularColorMap:g.transmissionMap?x=g.transmissionMap:g.thicknessMap?x=g.thicknessMap:g.sheenColorMap?x=g.sheenColorMap:g.sheenRoughnessMap&&(x=g.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function n(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,y,x){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=x*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.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 h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(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 u(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===na&&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 p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function f(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function xN(e,t,i,r){let a={},s={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(x,b){let _=b.program;r.uniformBlockBinding(x,_)}function h(x,b){let _=a[x.id];_===void 0&&(f(x),_=c(x),a[x.id]=_,x.addEventListener("dispose",g));let S=b.program;r.updateUBOMapping(x,S);let A=t.render.frame;s[x.id]!==A&&(u(x),s[x.id]=A)}function c(x){let b=d();x.__bindingPointIndex=b;let _=e.createBuffer(),S=x.__size,A=x.usage;return e.bindBuffer(35345,_),e.bufferData(35345,S,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,_),_}function d(){for(let x=0;x<o;x++)if(n.indexOf(x)===-1)return n.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){let b=a[x.id],_=x.uniforms,S=x.__cache;e.bindBuffer(35345,b);for(let A=0,E=_.length;A<E;A++){let M=_[A];if(p(M,A,S)===!0){let T=M.__offset,P=Array.isArray(M.value)?M.value:[M.value],R=0;for(let z=0;z<P.length;z++){let U=P[z],L=m(U);typeof U=="number"?(M.__data[0]=U,e.bufferSubData(35345,T+R,M.__data)):U.isMatrix3?(M.__data[0]=U.elements[0],M.__data[1]=U.elements[1],M.__data[2]=U.elements[2],M.__data[3]=U.elements[0],M.__data[4]=U.elements[3],M.__data[5]=U.elements[4],M.__data[6]=U.elements[5],M.__data[7]=U.elements[0],M.__data[8]=U.elements[6],M.__data[9]=U.elements[7],M.__data[10]=U.elements[8],M.__data[11]=U.elements[0]):(U.toArray(M.__data,R),R+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,T,M.__data)}}e.bindBuffer(35345,null)}function p(x,b,_){let S=x.value;if(_[b]===void 0){if(typeof S=="number")_[b]=S;else{let A=Array.isArray(S)?S:[S],E=[];for(let M=0;M<A.length;M++)E.push(A[M].clone());_[b]=E}return!0}else if(typeof S=="number"){if(_[b]!==S)return _[b]=S,!0}else{let A=Array.isArray(_[b])?_[b]:[_[b]],E=Array.isArray(S)?S:[S];for(let M=0;M<A.length;M++){let T=A[M];if(T.equals(E[M])===!1)return T.copy(E[M]),!0}}return!1}function f(x){let b=x.uniforms,_=0,S=16,A=0;for(let E=0,M=b.length;E<M;E++){let T=b[E],P={boundary:0,storage:0},R=Array.isArray(T.value)?T.value:[T.value];for(let z=0,U=R.length;z<U;z++){let L=R[z],j=m(L);P.boundary+=j.boundary,P.storage+=j.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=_,E>0){A=_%S;let z=S-A;A!==0&&z-P.boundary<0&&(_+=S-A,T.__offset=_)}_+=P.storage}return A=_%S,A>0&&(_+=S-A),x.__size=_,x.__cache={},this}function m(x){let b={boundary:0,storage:0};return typeof x=="number"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),b}function g(x){let b=x.target;b.removeEventListener("dispose",g);let _=n.indexOf(b.__bindingPointIndex);n.splice(_,1),e.deleteBuffer(a[b.id]),delete a[b.id],delete s[b.id]}function y(){for(let x in a)e.deleteBuffer(a[x]);n=[],a={},s={}}return{bind:l,update:h,dispose:y}}function bN(){let e=_p("canvas");return e.style.display="block",e}function H3(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:bN(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,a=e.stencil!==void 0?e.stencil:!0,s=e.antialias!==void 0?e.antialias:!1,n=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,c;i!==null?c=i.getContextAttributes().alpha:c=e.alpha!==void 0?e.alpha:!1;let d=null,u=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=on,this.physicallyCorrectLights=!1,this.toneMapping=Nn,this.toneMappingExposure=1;let m=this,g=!1,y=0,x=0,b=null,_=-1,S=null,A=new Lt,E=new Lt,M=null,T=t.width,P=t.height,R=1,z=null,U=null,L=new Lt(0,0,T,P),j=new Lt(0,0,T,P),q=!1,Q=new Zb,X=!1,ie=!1,oe=null,te=new je,re=new ae,fe=new O,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function de(){return b===null?R:1}let se=i;function Pe(J,Se){for(let Te=0;Te<J.length;Te++){let be=J[Te],Be=t.getContext(be,Se);if(Be!==null)return Be}return null}try{let J={alpha:!0,depth:r,stencil:a,antialias:s,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Fd}`),t.addEventListener("webglcontextlost",At,!1),t.addEventListener("webglcontextrestored",_t,!1),t.addEventListener("webglcontextcreationerror",ai,!1),se===null){let Se=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&Se.shift(),se=Pe(Se,J),se===null)throw Pe(Se)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}se.getShaderPrecisionFormat===void 0&&(se.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(J){throw console.error("THREE.WebGLRenderer: "+J.message),J}let ve,Ae,ye,Ve,Ie,Ce,rt,Je,st,ot,Ke,Qe,ft,St,ee,W,_e,We,V,Oe,dt,He,ze,Fe;function ut(){ve=new RU(se),Ae=new CU(se,ve,e),ve.init(Ae),He=new fN(se,ve,Ae),ye=new uN(se,ve,Ae),Ve=new zU,Ie=new $6,Ce=new pN(se,ve,ye,Ie,Ae,He,Ve),rt=new PU(m),Je=new OU(m),st=new W5(se,Ae),ze=new MU(se,ve,st,Ae),ot=new LU(se,st,Ve,ze),Ke=new NU(se,ot,st,Ve),V=new UU(se,Ae,Ce),W=new TU(Ie),Qe=new J6(m,rt,Je,ve,Ae,ze,W),ft=new yN(m,Ie),St=new tN,ee=new oN(ve,Ae),We=new AU(m,rt,Je,ye,Ke,c,n),_e=new dN(m,Ke,Ae),Fe=new xN(se,Ve,Ae,ye),Oe=new EU(se,ve,Ve,Ae),dt=new BU(se,ve,Ve,Ae),Ve.programs=Qe.programs,m.capabilities=Ae,m.extensions=ve,m.properties=Ie,m.renderLists=St,m.shadowMap=_e,m.state=ye,m.info=Ve}ut();let lt=new vN(m,se);this.xr=lt,this.getContext=function(){return se},this.getContextAttributes=function(){return se.getContextAttributes()},this.forceContextLoss=function(){let J=ve.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){let J=ve.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return R},this.setPixelRatio=function(J){J!==void 0&&(R=J,this.setSize(T,P,!1))},this.getSize=function(J){return J.set(T,P)},this.setSize=function(J,Se,Te){if(lt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=J,P=Se,t.width=Math.floor(J*R),t.height=Math.floor(Se*R),Te!==!1&&(t.style.width=J+"px",t.style.height=Se+"px"),this.setViewport(0,0,J,Se)},this.getDrawingBufferSize=function(J){return J.set(T*R,P*R).floor()},this.setDrawingBufferSize=function(J,Se,Te){T=J,P=Se,R=Te,t.width=Math.floor(J*Te),t.height=Math.floor(Se*Te),this.setViewport(0,0,J,Se)},this.getCurrentViewport=function(J){return J.copy(A)},this.getViewport=function(J){return J.copy(L)},this.setViewport=function(J,Se,Te,be){J.isVector4?L.set(J.x,J.y,J.z,J.w):L.set(J,Se,Te,be),ye.viewport(A.copy(L).multiplyScalar(R).floor())},this.getScissor=function(J){return J.copy(j)},this.setScissor=function(J,Se,Te,be){J.isVector4?j.set(J.x,J.y,J.z,J.w):j.set(J,Se,Te,be),ye.scissor(E.copy(j).multiplyScalar(R).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(J){ye.setScissorTest(q=J)},this.setOpaqueSort=function(J){z=J},this.setTransparentSort=function(J){U=J},this.getClearColor=function(J){return J.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor.apply(We,arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha.apply(We,arguments)},this.clear=function(J=!0,Se=!0,Te=!0){let be=0;J&&(be|=16384),Se&&(be|=256),Te&&(be|=1024),se.clear(be)},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",At,!1),t.removeEventListener("webglcontextrestored",_t,!1),t.removeEventListener("webglcontextcreationerror",ai,!1),St.dispose(),ee.dispose(),Ie.dispose(),rt.dispose(),Je.dispose(),Ke.dispose(),ze.dispose(),Fe.dispose(),Qe.dispose(),lt.dispose(),lt.removeEventListener("sessionstart",Ze),lt.removeEventListener("sessionend",yt),oe&&(oe.dispose(),oe=null),Tt.stop()};function At(J){J.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function _t(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let J=Ve.autoReset,Se=_e.enabled,Te=_e.autoUpdate,be=_e.needsUpdate,Be=_e.type;ut(),Ve.autoReset=J,_e.enabled=Se,_e.autoUpdate=Te,_e.needsUpdate=be,_e.type=Be}function ai(J){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function yi(J){let Se=J.target;Se.removeEventListener("dispose",yi),ri(Se)}function ri(J){me(J),Ie.remove(J)}function me(J){let Se=Ie.get(J).programs;Se!==void 0&&(Se.forEach(function(Te){Qe.releaseProgram(Te)}),J.isShaderMaterial&&Qe.releaseShaderCache(J))}this.renderBufferDirect=function(J,Se,Te,be,Be,at){Se===null&&(Se=ce);let kt=Be.isMesh&&Be.matrixWorld.determinant()<0,Ut=au(J,Se,Te,be,Be);ye.setMaterial(be,kt);let Ft=Te.index,li=1;be.wireframe===!0&&(Ft=ot.getWireframeAttribute(Te),li=2);let Jt=Te.drawRange,jt=Te.attributes.position,vi=Jt.start*li,rr=(Jt.start+Jt.count)*li;at!==null&&(vi=Math.max(vi,at.start*li),rr=Math.min(rr,(at.start+at.count)*li)),Ft!==null?(vi=Math.max(vi,0),rr=Math.min(rr,Ft.count)):jt!=null&&(vi=Math.max(vi,0),rr=Math.min(rr,jt.count));let Yi=rr-vi;if(Yi<0||Yi===1/0)return;ze.setup(Be,be,Ut,Te,Ft);let ar,Ui=Oe;if(Ft!==null&&(ar=st.get(Ft),Ui=dt,Ui.setIndex(ar)),Be.isMesh)be.wireframe===!0?(ye.setLineWidth(be.wireframeLinewidth*de()),Ui.setMode(1)):Ui.setMode(4);else if(Be.isLine){let Mt=be.linewidth;Mt===void 0&&(Mt=1),ye.setLineWidth(Mt*de()),Be.isLineSegments?Ui.setMode(1):Be.isLineLoop?Ui.setMode(2):Ui.setMode(3)}else Be.isPoints?Ui.setMode(0):Be.isSprite&&Ui.setMode(4);if(Be.isInstancedMesh)Ui.renderInstances(vi,Yi,Be.count);else if(Te.isInstancedBufferGeometry){let Mt=Te._maxInstanceCount!==void 0?Te._maxInstanceCount:1/0,dn=Math.min(Te.instanceCount,Mt);Ui.renderInstances(vi,Yi,dn)}else Ui.render(vi,Yi)},this.compile=function(J,Se){function Te(be,Be,at){be.transparent===!0&&be.side===Pa&&be.forceSinglePass===!1?(be.side=na,be.needsUpdate=!0,zr(be,Be,at),be.side=nn,be.needsUpdate=!0,zr(be,Be,at),be.side=Pa):zr(be,Be,at)}u=ee.get(J),u.init(),f.push(u),J.traverseVisible(function(be){be.isLight&&be.layers.test(Se.layers)&&(u.pushLight(be),be.castShadow&&u.pushShadow(be))}),u.setupLights(m.physicallyCorrectLights),J.traverse(function(be){let Be=be.material;if(Be)if(Array.isArray(Be))for(let at=0;at<Be.length;at++){let kt=Be[at];Te(kt,J,be)}else Te(Be,J,be)}),f.pop(),u=null};let Ee=null;function Xe(J){Ee&&Ee(J)}function Ze(){Tt.stop()}function yt(){Tt.start()}let Tt=new k3;Tt.setAnimationLoop(Xe),typeof self<"u"&&Tt.setContext(self),this.setAnimationLoop=function(J){Ee=J,lt.setAnimationLoop(J),J===null?Tt.stop():Tt.start()},lt.addEventListener("sessionstart",Ze),lt.addEventListener("sessionend",yt),this.render=function(J,Se){if(Se!==void 0&&Se.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),Se.parent===null&&Se.matrixWorldAutoUpdate===!0&&Se.updateMatrixWorld(),lt.enabled===!0&&lt.isPresenting===!0&&(lt.cameraAutoUpdate===!0&&lt.updateCamera(Se),Se=lt.getCamera()),J.isScene===!0&&J.onBeforeRender(m,J,Se,b),u=ee.get(J,f.length),u.init(),f.push(u),te.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),Q.setFromProjectionMatrix(te),ie=this.localClippingEnabled,X=W.init(this.clippingPlanes,ie),d=St.get(J,p.length),d.init(),p.push(d),Si(J,Se,0,m.sortObjects),d.finish(),m.sortObjects===!0&&d.sort(z,U),X===!0&&W.beginShadows();let Te=u.state.shadowsArray;if(_e.render(Te,J,Se),X===!0&&W.endShadows(),this.info.autoReset===!0&&this.info.reset(),We.render(d,J),u.setupLights(m.physicallyCorrectLights),Se.isArrayCamera){let be=Se.cameras;for(let Be=0,at=be.length;Be<at;Be++){let kt=be[Be];Gi(d,J,kt,kt.viewport)}}else Gi(d,J,Se);b!==null&&(Ce.updateMultisampleRenderTarget(b),Ce.updateRenderTargetMipmap(b)),J.isScene===!0&&J.onAfterRender(m,J,Se),ze.resetDefaultState(),_=-1,S=null,f.pop(),f.length>0?u=f[f.length-1]:u=null,p.pop(),p.length>0?d=p[p.length-1]:d=null};function Si(J,Se,Te,be){if(J.visible===!1)return;if(J.layers.test(Se.layers)){if(J.isGroup)Te=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(Se);else if(J.isLight)u.pushLight(J),J.castShadow&&u.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||Q.intersectsSprite(J)){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let at=Ke.update(J),kt=J.material;kt.visible&&d.push(J,at,kt,Te,fe.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(J.isSkinnedMesh&&J.skeleton.frame!==Ve.render.frame&&(J.skeleton.update(),J.skeleton.frame=Ve.render.frame),!J.frustumCulled||Q.intersectsObject(J))){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let at=Ke.update(J),kt=J.material;if(Array.isArray(kt)){let Ut=at.groups;for(let Ft=0,li=Ut.length;Ft<li;Ft++){let Jt=Ut[Ft],jt=kt[Jt.materialIndex];jt&&jt.visible&&d.push(J,at,jt,Te,fe.z,Jt)}}else kt.visible&&d.push(J,at,kt,Te,fe.z,null)}}let Be=J.children;for(let at=0,kt=Be.length;at<kt;at++)Si(Be[at],Se,Te,be)}function Gi(J,Se,Te,be){let Be=J.opaque,at=J.transmissive,kt=J.transparent;u.setupLightsView(Te),X===!0&&W.setGlobalState(m.clippingPlanes,Te),at.length>0&&Br(Be,Se,Te),be&&ye.viewport(A.copy(be)),Be.length>0&&Ti(Be,Se,Te),at.length>0&&Ti(at,Se,Te),kt.length>0&&Ti(kt,Se,Te),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function Br(J,Se,Te){let be=Ae.isWebGL2;oe===null&&(oe=new ci(1,1,{generateMipmaps:!0,type:ve.has("EXT_color_buffer_half_float")?No:Da,minFilter:wd,samples:be&&s===!0?4:0})),m.getDrawingBufferSize(re),be?oe.setSize(re.x,re.y):oe.setSize(_g(re.x),_g(re.y));let Be=m.getRenderTarget();m.setRenderTarget(oe),m.clear();let at=m.toneMapping;m.toneMapping=Nn,Ti(J,Se,Te),m.toneMapping=at,Ce.updateMultisampleRenderTarget(oe),Ce.updateRenderTargetMipmap(oe),m.setRenderTarget(Be)}function Ti(J,Se,Te){let be=Se.isScene===!0?Se.overrideMaterial:null;for(let Be=0,at=J.length;Be<at;Be++){let kt=J[Be],Ut=kt.object,Ft=kt.geometry,li=be===null?kt.material:be,Jt=kt.group;Ut.layers.test(Te.layers)&&da(Ut,Se,Te,Ft,li,Jt)}}function da(J,Se,Te,be,Be,at){J.onBeforeRender(m,Se,Te,be,Be,at),J.modelViewMatrix.multiplyMatrices(Te.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),Be.onBeforeRender(m,Se,Te,be,J,at),Be.transparent===!0&&Be.side===Pa&&Be.forceSinglePass===!1?(Be.side=na,Be.needsUpdate=!0,m.renderBufferDirect(Te,Se,be,Be,J,at),Be.side=nn,Be.needsUpdate=!0,m.renderBufferDirect(Te,Se,be,Be,J,at),Be.side=Pa):m.renderBufferDirect(Te,Se,be,Be,J,at),J.onAfterRender(m,Se,Te,be,Be,at)}function zr(J,Se,Te){Se.isScene!==!0&&(Se=ce);let be=Ie.get(J),Be=u.state.lights,at=u.state.shadowsArray,kt=Be.state.version,Ut=Qe.getParameters(J,Be.state,at,Se,Te),Ft=Qe.getProgramCacheKey(Ut),li=be.programs;be.environment=J.isMeshStandardMaterial?Se.environment:null,be.fog=Se.fog,be.envMap=(J.isMeshStandardMaterial?Je:rt).get(J.envMap||be.environment),li===void 0&&(J.addEventListener("dispose",yi),li=new Map,be.programs=li);let Jt=li.get(Ft);if(Jt!==void 0){if(be.currentProgram===Jt&&be.lightsStateVersion===kt)return Qo(J,Ut),Jt}else Ut.uniforms=Qe.getUniforms(J),J.onBuild(Te,Ut,m),J.onBeforeCompile(Ut,m),Jt=Qe.acquireProgram(Ut,Ft),li.set(Ft,Jt),be.uniforms=Ut.uniforms;let jt=be.uniforms;(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(jt.clippingPlanes=W.uniform),Qo(J,Ut),be.needsLights=ac(J),be.lightsStateVersion=kt,be.needsLights&&(jt.ambientLightColor.value=Be.state.ambient,jt.lightProbe.value=Be.state.probe,jt.directionalLights.value=Be.state.directional,jt.directionalLightShadows.value=Be.state.directionalShadow,jt.spotLights.value=Be.state.spot,jt.spotLightShadows.value=Be.state.spotShadow,jt.rectAreaLights.value=Be.state.rectArea,jt.ltc_1.value=Be.state.rectAreaLTC1,jt.ltc_2.value=Be.state.rectAreaLTC2,jt.pointLights.value=Be.state.point,jt.pointLightShadows.value=Be.state.pointShadow,jt.hemisphereLights.value=Be.state.hemi,jt.directionalShadowMap.value=Be.state.directionalShadowMap,jt.directionalShadowMatrix.value=Be.state.directionalShadowMatrix,jt.spotShadowMap.value=Be.state.spotShadowMap,jt.spotLightMatrix.value=Be.state.spotLightMatrix,jt.spotLightMap.value=Be.state.spotLightMap,jt.pointShadowMap.value=Be.state.pointShadowMap,jt.pointShadowMatrix.value=Be.state.pointShadowMatrix);let vi=Jt.getUniforms(),rr=tg.seqWithValue(vi.seq,jt);return be.currentProgram=Jt,be.uniformsList=rr,Jt}function Qo(J,Se){let Te=Ie.get(J);Te.outputEncoding=Se.outputEncoding,Te.instancing=Se.instancing,Te.skinning=Se.skinning,Te.morphTargets=Se.morphTargets,Te.morphNormals=Se.morphNormals,Te.morphColors=Se.morphColors,Te.morphTargetsCount=Se.morphTargetsCount,Te.numClippingPlanes=Se.numClippingPlanes,Te.numIntersection=Se.numClipIntersection,Te.vertexAlphas=Se.vertexAlphas,Te.vertexTangents=Se.vertexTangents,Te.toneMapping=Se.toneMapping}function au(J,Se,Te,be,Be){Se.isScene!==!0&&(Se=ce),Ce.resetTextureUnits();let at=Se.fog,kt=be.isMeshStandardMaterial?Se.environment:null,Ut=b===null?m.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:on,Ft=(be.isMeshStandardMaterial?Je:rt).get(be.envMap||kt),li=be.vertexColors===!0&&!!Te.attributes.color&&Te.attributes.color.itemSize===4,Jt=!!be.normalMap&&!!Te.attributes.tangent,jt=!!Te.morphAttributes.position,vi=!!Te.morphAttributes.normal,rr=!!Te.morphAttributes.color,Yi=be.toneMapped?m.toneMapping:Nn,ar=Te.morphAttributes.position||Te.morphAttributes.normal||Te.morphAttributes.color,Ui=ar!==void 0?ar.length:0,Mt=Ie.get(be),dn=u.state.lights;if(X===!0&&(ie===!0||J!==S)){let Ji=J===S&&be.id===_;W.setState(be,J,Ji)}let ps=!1;be.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==dn.state.version||Mt.outputEncoding!==Ut||Be.isInstancedMesh&&Mt.instancing===!1||!Be.isInstancedMesh&&Mt.instancing===!0||Be.isSkinnedMesh&&Mt.skinning===!1||!Be.isSkinnedMesh&&Mt.skinning===!0||Mt.envMap!==Ft||be.fog===!0&&Mt.fog!==at||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==W.numPlanes||Mt.numIntersection!==W.numIntersection)||Mt.vertexAlphas!==li||Mt.vertexTangents!==Jt||Mt.morphTargets!==jt||Mt.morphNormals!==vi||Mt.morphColors!==rr||Mt.toneMapping!==Yi||Ae.isWebGL2===!0&&Mt.morphTargetsCount!==Ui)&&(ps=!0):(ps=!0,Mt.__version=be.version);let fs=Mt.currentProgram;ps===!0&&(fs=zr(be,Se,Be));let ti=!1,Sr=!1,Jn=!1,ur=fs.getUniforms(),ms=Mt.uniforms;if(ye.useProgram(fs.program)&&(ti=!0,Sr=!0,Jn=!0),be.id!==_&&(_=be.id,Sr=!0),ti||S!==J){if(ur.setValue(se,"projectionMatrix",J.projectionMatrix),Ae.logarithmicDepthBuffer&&ur.setValue(se,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),S!==J&&(S=J,Sr=!0,Jn=!0),be.isShaderMaterial||be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshStandardMaterial||be.envMap){let Ji=ur.map.cameraPosition;Ji!==void 0&&Ji.setValue(se,fe.setFromMatrixPosition(J.matrixWorld))}(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial)&&ur.setValue(se,"isOrthographic",J.isOrthographicCamera===!0),(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial||be.isShadowMaterial||Be.isSkinnedMesh)&&ur.setValue(se,"viewMatrix",J.matrixWorldInverse)}if(Be.isSkinnedMesh){ur.setOptional(se,Be,"bindMatrix"),ur.setOptional(se,Be,"bindMatrixInverse");let Ji=Be.skeleton;Ji&&(Ae.floatVertexTextures?(Ji.boneTexture===null&&Ji.computeBoneTexture(),ur.setValue(se,"boneTexture",Ji.boneTexture,Ce),ur.setValue(se,"boneTextureSize",Ji.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 $n=Te.morphAttributes;if(($n.position!==void 0||$n.normal!==void 0||$n.color!==void 0&&Ae.isWebGL2===!0)&&V.update(Be,Te,be,fs),(Sr||Mt.receiveShadow!==Be.receiveShadow)&&(Mt.receiveShadow=Be.receiveShadow,ur.setValue(se,"receiveShadow",Be.receiveShadow)),be.isMeshGouraudMaterial&&be.envMap!==null&&(ms.envMap.value=Ft,ms.flipEnvMap.value=Ft.isCubeTexture&&Ft.isRenderTargetTexture===!1?-1:1),Sr&&(ur.setValue(se,"toneMappingExposure",m.toneMappingExposure),Mt.needsLights&&$l(ms,Jn),at&&be.fog===!0&&ft.refreshFogUniforms(ms,at),ft.refreshMaterialUniforms(ms,be,R,P,oe),tg.upload(se,Mt.uniformsList,ms,Ce)),be.isShaderMaterial&&be.uniformsNeedUpdate===!0&&(tg.upload(se,Mt.uniformsList,ms,Ce),be.uniformsNeedUpdate=!1),be.isSpriteMaterial&&ur.setValue(se,"center",Be.center),ur.setValue(se,"modelViewMatrix",Be.modelViewMatrix),ur.setValue(se,"normalMatrix",Be.normalMatrix),ur.setValue(se,"modelMatrix",Be.matrixWorld),Be.previousModelViewMatrix&&ur.setValue(se,"previousModelViewMatrix",Be.previousModelViewMatrix),J.previousProjectionMatrix&&ur.setValue(se,"previousProjectionMatrix",J.previousProjectionMatrix),be.isShaderMaterial||be.isRawShaderMaterial){let Ji=be.uniformsGroups;for(let Qt=0,su=Ji.length;Qt<su;Qt++)if(Ae.isWebGL2){let eo=Ji[Qt];Fe.update(eo,fs),Fe.bind(eo,fs)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fs}function $l(J,Se){J.ambientLightColor.needsUpdate=Se,J.lightProbe.needsUpdate=Se,J.directionalLights.needsUpdate=Se,J.directionalLightShadows.needsUpdate=Se,J.pointLights.needsUpdate=Se,J.pointLightShadows.needsUpdate=Se,J.spotLights.needsUpdate=Se,J.spotLightShadows.needsUpdate=Se,J.rectAreaLights.needsUpdate=Se,J.hemisphereLights.needsUpdate=Se}function ac(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(J,Se,Te){Ie.get(J.texture).__webglTexture=Se,Ie.get(J.depthTexture).__webglTexture=Te;let be=Ie.get(J);be.__hasExternalTextures=!0,be.__hasExternalTextures&&(be.__autoAllocateDepthBuffer=Te===void 0,be.__autoAllocateDepthBuffer||ve.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),be.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(J,Se){let Te=Ie.get(J);Te.__webglFramebuffer=Se,Te.__useDefaultFramebuffer=Se===void 0},this.setRenderTarget=function(J,Se=0,Te=0){b=J,y=Se,x=Te;let be=!0,Be=null,at=!1,kt=!1;if(J){let Ut=Ie.get(J);Ut.__useDefaultFramebuffer!==void 0?(ye.bindFramebuffer(36160,null),be=!1):Ut.__webglFramebuffer===void 0?Ce.setupRenderTarget(J):Ut.__hasExternalTextures&&Ce.rebindTextures(J,Ie.get(J.texture).__webglTexture,Ie.get(J.depthTexture).__webglTexture);let Ft=J.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(kt=!0);let li=Ie.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Be=li[Se],at=!0):Ae.isWebGL2&&J.samples>0&&Ce.useMultisampledRTT(J)===!1?Be=Ie.get(J).__webglMultisampledFramebuffer:Be=li,A.copy(J.viewport),E.copy(J.scissor),M=J.scissorTest}else A.copy(L).multiplyScalar(R).floor(),E.copy(j).multiplyScalar(R).floor(),M=q;if(ye.bindFramebuffer(36160,Be)&&Ae.drawBuffers&&be&&ye.drawBuffers(J,Be),ye.viewport(A),ye.scissor(E),ye.setScissorTest(M),at){let Ut=Ie.get(J.texture);se.framebufferTexture2D(36160,36064,34069+Se,Ut.__webglTexture,Te)}else if(kt){let Ut=Ie.get(J.texture),Ft=Se||0;se.framebufferTextureLayer(36160,36064,Ut.__webglTexture,Te||0,Ft)}_=-1},this.readRenderTargetPixels=function(J,Se,Te,be,Be,at,kt){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ut=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&kt!==void 0&&(Ut=Ut[kt]),Ut){ye.bindFramebuffer(36160,Ut);try{let Ft=J.texture,li=Ft.format,Jt=Ft.type;if(li!==Ki&&He.convert(li)!==se.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let jt=Jt===No&&(ve.has("EXT_color_buffer_half_float")||Ae.isWebGL2&&ve.has("EXT_color_buffer_float"));if(Jt!==Da&&He.convert(Jt)!==se.getParameter(35738)&&!(Jt===Di&&(Ae.isWebGL2||ve.has("OES_texture_float")||ve.has("WEBGL_color_buffer_float")))&&!jt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be&&se.readPixels(Se,Te,be,Be,He.convert(li),He.convert(Jt),at)}finally{let Ft=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(36160,Ft)}}},this.readRenderTargetPixelsAsync=async function(J,Se,Te,be,Be,at,kt){if(!(J&&J.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ut=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&kt!==void 0&&(Ut=Ut[kt]),Ut){let Ft=J.texture,li=Ft.format,Jt=Ft.type;if(Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be){ye.bindFramebuffer(se.FRAMEBUFFER,Ut);let jt=se.createBuffer();se.bindBuffer(se.PIXEL_PACK_BUFFER,jt),se.bufferData(se.PIXEL_PACK_BUFFER,at.byteLength,se.STREAM_READ),se.readPixels(Se,Te,be,Be,He.convert(li),He.convert(Jt),0);let vi=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(se.FRAMEBUFFER,vi);let rr=se.fenceSync(se.SYNC_GPU_COMMANDS_COMPLETE,0);return se.flush(),await M5(se,rr,4),se.bindBuffer(se.PIXEL_PACK_BUFFER,jt),se.getBufferSubData(se.PIXEL_PACK_BUFFER,0,at),se.deleteBuffer(jt),se.deleteSync(rr),at}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(J,Se,Te=0){let be=Math.pow(2,-Te),Be=Math.floor(Se.image.width*be),at=Math.floor(Se.image.height*be);Ce.setTexture2D(Se,0),se.copyTexSubImage2D(3553,Te,0,0,J.x,J.y,Be,at),ye.unbindTexture()},this.copyTextureToTexture=function(J,Se,Te,be=0){let Be=Se.image.width,at=Se.image.height,kt=He.convert(Te.format),Ut=He.convert(Te.type);Ce.setTexture2D(Te,0),se.pixelStorei(37440,Te.flipY),se.pixelStorei(37441,Te.premultiplyAlpha),se.pixelStorei(3317,Te.unpackAlignment),Se.isDataTexture?se.texSubImage2D(3553,be,J.x,J.y,Be,at,kt,Ut,Se.image.data):Se.isCompressedTexture?se.compressedTexSubImage2D(3553,be,J.x,J.y,Se.mipmaps[0].width,Se.mipmaps[0].height,kt,Se.mipmaps[0].data):se.texSubImage2D(3553,be,J.x,J.y,kt,Ut,Se.image),be===0&&Te.generateMipmaps&&se.generateMipmap(3553),ye.unbindTexture()},this.copyTextureToTexture3D=function(J,Se,Te,be,Be=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let at=J.max.x-J.min.x+1,kt=J.max.y-J.min.y+1,Ut=J.max.z-J.min.z+1,Ft=He.convert(be.format),li=He.convert(be.type),Jt;if(be.isData3DTexture)Ce.setTexture3D(be,0),Jt=32879;else if(be.isDataArrayTexture)Ce.setTexture2DArray(be,0),Jt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}se.pixelStorei(37440,be.flipY),se.pixelStorei(37441,be.premultiplyAlpha),se.pixelStorei(3317,be.unpackAlignment);let jt=se.getParameter(3314),vi=se.getParameter(32878),rr=se.getParameter(3316),Yi=se.getParameter(3315),ar=se.getParameter(32877),Ui=Te.isCompressedTexture?Te.mipmaps[0]:Te.image;se.pixelStorei(3314,Ui.width),se.pixelStorei(32878,Ui.height),se.pixelStorei(3316,J.min.x),se.pixelStorei(3315,J.min.y),se.pixelStorei(32877,J.min.z),Te.isDataTexture||Te.isData3DTexture?se.texSubImage3D(Jt,Be,Se.x,Se.y,Se.z,at,kt,Ut,Ft,li,Ui.data):Te.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),se.compressedTexSubImage3D(Jt,Be,Se.x,Se.y,Se.z,at,kt,Ut,Ft,Ui.data)):se.texSubImage3D(Jt,Be,Se.x,Se.y,Se.z,at,kt,Ut,Ft,li,Ui),se.pixelStorei(3314,jt),se.pixelStorei(32878,vi),se.pixelStorei(3316,rr),se.pixelStorei(3315,Yi),se.pixelStorei(32877,ar),Be===0&&be.generateMipmaps&&se.generateMipmap(Jt),ye.unbindTexture()},this.initRenderTarget=function(J){Ie.get(J).__webglFramebuffer===void 0&&Ce.setupRenderTarget(J)},this.initTexture=function(J){J.isCubeTexture?Ce.setTextureCube(J,0):J.isData3DTexture?Ce.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?Ce.setTexture2DArray(J,0):Ce.setTexture2D(J,0),ye.unbindTexture()},this.resetState=function(){y=0,x=0,b=null,ye.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var wN=class extends H3{};wN.prototype.isWebGL1Renderer=!0;var G3=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ct(e),this.near=t,this.far=i}clone(){return new G3(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},is=class extends Ci{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},_N=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Uy,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Bs()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;r<a;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bs()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bs()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ba=new O,Gy=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ba.fromBufferAttribute(this,t),Ba.applyMatrix4(e),this.setXYZ(t,Ba.x,Ba.y,Ba.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ba.fromBufferAttribute(this,t),Ba.applyNormalMatrix(e),this.setXYZ(t,Ba.x,Ba.y,Ba.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ba.fromBufferAttribute(this,t),Ba.transformDirection(e),this.setXYZ(t,Ba.x,Ba.y,Ba.z);return this}setX(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ki(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ro(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ro(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ro(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ro(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ki(t,this.array),i=ki(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ki(t,this.array),i=ki(i,this.array),r=ki(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=ki(t,this.array),i=ki(i,this.array),r=ki(r,this.array),a=ki(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return new Pt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Gy(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},W3=class extends Ci{constructor(){super(),this.isBone=!0,this.type="Bone"}},ja=class extends Zi{constructor(e=null,t=1,i=1,r,a,s,n,o,l=ei,h=ei,c,d){super(null,s,n,o,l,h,r,a,c,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},fA=new je,SN=new je,$b=class{constructor(e=[],t=[]){this.uuid=Bs(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new je;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){let n=e[a]?e[a].matrixWorld:SN;fA.multiplyMatrices(n,t[a]),fA.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new $b(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=T3(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new ja(t,e,e,Ki,Di);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let a=e.bones[i],s=t[a];s===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",a),s=new W3),this.bones.push(s),this.boneInverses.push(new je().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){let s=t[r];e.bones.push(s.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},Sp=class extends Pt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},mA=new je,gA=new je,qf=[],AN=new je,wu=new Fi,MN=class extends Fi{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Sp(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1;for(let r=0;r<i;r++)this.setMatrixAt(r,AN)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){let i=this.matrixWorld,r=this.count;if(wu.geometry=this.geometry,wu.material=this.material,wu.material!==void 0)for(let a=0;a<r;a++){this.getMatrixAt(a,mA),gA.multiplyMatrices(i,mA),wu.matrixWorld=gA,wu.raycast(e,qf);for(let s=0,n=qf.length;s<n;s++){let o=qf[s];o.instanceId=a,o.object=this,t.push(o)}qf.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Sp(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},Ql=class extends Wp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ct(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},vA=new O,yA=new O,xA=new je,s1=new Ud,Xf=new cs,Sg=class extends Ci{constructor(e=new vt,t=new Ql){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,a=t.count;r<a;r++)vA.fromBufferAttribute(t,r-1),yA.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=vA.distanceTo(yA);e.setAttribute("lineDistance",new nt(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Xf.copy(i.boundingSphere),Xf.applyMatrix4(r),Xf.radius+=a,e.ray.intersectsSphere(Xf)===!1)return;xA.copy(r).invert(),s1.copy(e.ray).applyMatrix4(xA);let n=a/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new O,h=new O,c=new O,d=new O,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,s.start),g=Math.min(p.count,s.start+s.count);for(let y=m,x=g-1;y<x;y+=u){let b=p.getX(y),_=p.getX(y+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),s1.distanceSqToSegment(l,h,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);let S=e.ray.origin.distanceTo(d);S<e.near||S>e.far||t.push({distance:S,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,s.start),g=Math.min(f.count,s.start+s.count);for(let y=m,x=g-1;y<x;y+=u){if(l.fromBufferAttribute(f,y),h.fromBufferAttribute(f,y+1),s1.distanceSqToSegment(l,h,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(d);b<e.near||b>e.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){let s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}},bA=new O,wA=new O,qp=class extends Sg{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,a=t.count;r<a;r+=2)bA.fromBufferAttribute(t,r),wA.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+bA.distanceTo(wA);e.setAttribute("lineDistance",new nt(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},EN=class extends Zi{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isVideoTexture=!0,this.minFilter=s!==void 0?s:Yt,this.magFilter=a!==void 0?a:Yt,this.generateMipmaps=!1;let h=this;function c(){h.needsUpdate=!0,e.requestVideoFrameCallback(c)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(c)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},CN=class extends Zi{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Qn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let n=0,o=a-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-s,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===s)return r/(a-1);let h=i[r],c=i[r+1]-h,d=(s-h)/c;return(r+d)/(a-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),s=this.getPoint(r),n=t||(a.isVector2?new ae:new O);return n.copy(s).sub(a).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new O,r=[],a=[],s=[],n=new O,o=new je;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new O)}a[0]=new O,s[0]=new O;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),d<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],n),s[0].crossVectors(r[0],a[0]);for(let u=1;u<=e;u++){if(a[u]=a[u-1].clone(),s[u]=s[u-1].clone(),n.crossVectors(r[u-1],r[u]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(Tr(r[u-1].dot(r[u]),-1,1));a[u].applyMatrix4(o.makeRotationAxis(n,p))}s[u].crossVectors(r[u],a[u])}if(t===!0){let u=Math.acos(Tr(a[0].dot(a[e]),-1,1));u/=e,r[0].dot(n.crossVectors(a[0],a[e]))>0&&(u=-u);for(let p=1;p<=e;p++)a[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),s[p].crossVectors(r[p],a[p])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Tv=class extends Qn{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new ae,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let n=this.aStartAngle+e*a,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),d=o-this.aX,u=l-this.aY;o=d*h-u*c+this.aX,l=d*c+u*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},TN=class extends Tv{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function ew(){let e=0,t=0,i=0,r=0;function a(s,n,o,l){e=s,t=o,i=-3*s+3*n-2*o-l,r=2*s-2*n+o+l}return{initCatmullRom:function(s,n,o,l,h){a(n,o,h*(o-s),h*(l-n))},initNonuniformCatmullRom:function(s,n,o,l,h,c,d){let u=(n-s)/h-(o-s)/(h+c)+(o-n)/c,p=(o-n)/c-(l-n)/(c+d)+(l-o)/d;u*=c,p*=c,a(n,o,u,p)},calc:function(s){let n=s*s,o=n*s;return e+t*s+i*n+r*o}}}var Yf=new O,n1=new ew,o1=new ew,l1=new ew,PN=class extends Qn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new O){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,n=Math.floor(s),o=s-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/a)+1)*a:o===0&&n===a-1&&(n=a-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%a]:(Yf.subVectors(r[0],r[1]).add(r[0]),l=Yf);let c=r[n%a],d=r[(n+1)%a];if(this.closed||n+2<a?h=r[(n+2)%a]:(Yf.subVectors(r[a-1],r[a-2]).add(r[a-1]),h=Yf),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(c),u),f=Math.pow(c.distanceToSquared(d),u),m=Math.pow(d.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),n1.initNonuniformCatmullRom(l.x,c.x,d.x,h.x,p,f,m),o1.initNonuniformCatmullRom(l.y,c.y,d.y,h.y,p,f,m),l1.initNonuniformCatmullRom(l.z,c.z,d.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(n1.initCatmullRom(l.x,c.x,d.x,h.x,this.tension),o1.initCatmullRom(l.y,c.y,d.y,h.y,this.tension),l1.initCatmullRom(l.z,c.z,d.z,h.z,this.tension));return i.set(n1.calc(o),o1.calc(o),l1.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new O().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function _A(e,t,i,r,a){let s=(r-t)*.5,n=(a-i)*.5,o=e*e,l=e*o;return(2*i-2*r+s+n)*l+(-3*i+3*r-2*s-n)*o+s*e+i}function DN(e,t){let i=1-e;return i*i*t}function IN(e,t){return 2*(1-e)*e*t}function ON(e,t){return e*e*t}function sp(e,t,i,r){return DN(e,t)+IN(e,i)+ON(e,r)}function RN(e,t){let i=1-e;return i*i*i*t}function LN(e,t){let i=1-e;return 3*i*i*e*t}function BN(e,t){return 3*(1-e)*e*e*t}function zN(e,t){return e*e*e*t}function np(e,t,i,r,a){return RN(e,t)+LN(e,i)+BN(e,r)+zN(e,a)}var tn=class extends Qn{constructor(e=new ae,t=new ae,i=new ae,r=new ae){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(np(e,r.x,a.x,s.x,n.x),np(e,r.y,a.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ig=class extends Qn{constructor(e=new O,t=new O,i=new O,r=new O){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(np(e,r.x,a.x,s.x,n.x),np(e,r.y,a.y,s.y,n.y),np(e,r.z,a.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},sn=class extends Qn{constructor(e=new ae,t=new ae){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ae){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new ae;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},q3=class extends Qn{constructor(e=new O,t=new O){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new O){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Hl=class extends Qn{constructor(e=new ae,t=new ae,i=new ae){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(sp(e,r.x,a.x,s.x),sp(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},kN=class extends Qn{constructor(e=new O,t=new O,i=new O){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(sp(e,r.x,a.x,s.x),sp(e,r.y,a.y,s.y),sp(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},tw=class extends Qn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ae){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),n=a-s,o=r[s===0?s:s-1],l=r[s],h=r[s>r.length-2?r.length-1:s+1],c=r[s>r.length-3?r.length-1:s+2];return i.set(_A(n,o.x,l.x,h.x,c.x),_A(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ae().fromArray(r))}return this}},FN=Object.freeze({__proto__:null,ArcCurve:TN,CatmullRomCurve3:PN,CubicBezierCurve:tn,CubicBezierCurve3:ig,EllipseCurve:Tv,LineCurve:sn,LineCurve3:q3,QuadraticBezierCurve:Hl,QuadraticBezierCurve3:kN,SplineCurve:tw}),X3=class extends Qn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new sn(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,n=this.curves[a],o=n.getLength(),l=o===0?0:1-s/o;return n.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],n=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,o=s.getPoints(n);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new FN[r.type]().fromJSON(r))}return this}},Ag=class extends X3{constructor(e){super(),this.type="Path",this.currentPoint=new ae,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new sn(this.currentPoint.clone(),new ae(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new Hl(this.currentPoint.clone(),new ae(e,t),new ae(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let n=new tn(this.currentPoint.clone(),new ae(e,t),new ae(i,r),new ae(a,s));return this.curves.push(n),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new tw(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,a,s,n,o),this}absellipse(e,t,i,r,a,s,n,o){let l=new Tv(e,t,i,r,a,s,n,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Y3=class extends vt{constructor(e=[new ae(0,-.5),new ae(.5,0),new ae(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Tr(r,0,Math.PI*2);let a=[],s=[],n=[],o=[],l=[],h=1/t,c=new O,d=new ae,u=new O,p=new O,f=new O,m=0,g=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,u.x=g*1,u.y=-m,u.z=g*0,f.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,u.x=g*1,u.y=-m,u.z=g*0,p.copy(u),u.x+=f.x,u.y+=f.y,u.z+=f.z,u.normalize(),o.push(u.x,u.y,u.z),f.copy(p)}for(let y=0;y<=t;y++){let x=i+y*h*r,b=Math.sin(x),_=Math.cos(x);for(let S=0;S<=e.length-1;S++){c.x=e[S].x*b,c.y=e[S].y,c.z=e[S].x*_,s.push(c.x,c.y,c.z),d.x=y/t,d.y=S/(e.length-1),n.push(d.x,d.y);let A=o[3*S+0]*b,E=o[3*S+1],M=o[3*S+0]*_;l.push(A,E,M)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){let b=x+y*e.length,_=b,S=b+e.length,A=b+e.length+1,E=b+1;a.push(_,S,E),a.push(A,E,S)}this.setIndex(a),this.setAttribute("position",new nt(s,3)),this.setAttribute("uv",new nt(n,2)),this.setAttribute("normal",new nt(l,3))}static fromJSON(e){return new Y3(e.points,e.segments,e.phiStart,e.phiLength)}},iw=class extends vt{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),a=Math.floor(a);let h=[],c=[],d=[],u=[],p=0,f=[],m=i/2,g=0;y(),s===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new nt(c,3)),this.setAttribute("normal",new nt(d,3)),this.setAttribute("uv",new nt(u,2));function y(){let b=new O,_=new O,S=0,A=(t-e)/i;for(let E=0;E<=a;E++){let M=[],T=E/a,P=T*(t-e)+e;for(let R=0;R<=r;R++){let z=R/r,U=z*o+n,L=Math.sin(U),j=Math.cos(U);_.x=P*L,_.y=-T*i+m,_.z=P*j,c.push(_.x,_.y,_.z),b.set(L,A,j).normalize(),d.push(b.x,b.y,b.z),u.push(z,1-T),M.push(p++)}f.push(M)}for(let E=0;E<r;E++)for(let M=0;M<a;M++){let T=f[M][E],P=f[M+1][E],R=f[M+1][E+1],z=f[M][E+1];h.push(T,P,z),h.push(P,R,z),S+=6}l.addGroup(g,S,0),g+=S}function x(b){let _=p,S=new ae,A=new O,E=0,M=b===!0?e:t,T=b===!0?1:-1;for(let R=1;R<=r;R++)c.push(0,m*T,0),d.push(0,T,0),u.push(.5,.5),p++;let P=p;for(let R=0;R<=r;R++){let z=R/r*o+n,U=Math.cos(z),L=Math.sin(z);A.x=M*L,A.y=m*T,A.z=M*U,c.push(A.x,A.y,A.z),d.push(0,T,0),S.x=U*.5+.5,S.y=L*.5*T+.5,u.push(S.x,S.y),p++}for(let R=0;R<r;R++){let z=_+R,U=P+R;b===!0?h.push(U,U+1,z):h.push(U+1,U,z),E+=3}l.addGroup(g,E,b===!0?1:2),g+=E}}static fromJSON(e){return new iw(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},rw=class extends iw{constructor(e=1,t=1,i=32,r=1,a=!1,s=0,n=Math.PI*2){super(0,e,t,i,r,a,s,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:n}}static fromJSON(e){return new rw(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},aw=class extends vt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let a=[],s=[];n(r),l(i),h(),this.setAttribute("position",new nt(a,3)),this.setAttribute("normal",new nt(a.slice(),3)),this.setAttribute("uv",new nt(s,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(y){let x=new O,b=new O,_=new O;for(let S=0;S<t.length;S+=3)u(t[S+0],x),u(t[S+1],b),u(t[S+2],_),o(x,b,_,y)}function o(y,x,b,_){let S=_+1,A=[];for(let E=0;E<=S;E++){A[E]=[];let M=y.clone().lerp(b,E/S),T=x.clone().lerp(b,E/S),P=S-E;for(let R=0;R<=P;R++)R===0&&E===S?A[E][R]=M:A[E][R]=M.clone().lerp(T,R/P)}for(let E=0;E<S;E++)for(let M=0;M<2*(S-E)-1;M++){let T=Math.floor(M/2);M%2===0?(d(A[E][T+1]),d(A[E+1][T]),d(A[E][T])):(d(A[E][T+1]),d(A[E+1][T+1]),d(A[E+1][T]))}}function l(y){let x=new O;for(let b=0;b<a.length;b+=3)x.x=a[b+0],x.y=a[b+1],x.z=a[b+2],x.normalize().multiplyScalar(y),a[b+0]=x.x,a[b+1]=x.y,a[b+2]=x.z}function h(){let y=new O;for(let x=0;x<a.length;x+=3){y.x=a[x+0],y.y=a[x+1],y.z=a[x+2];let b=m(y)/2/Math.PI+.5,_=g(y)/Math.PI+.5;s.push(b,1-_)}p(),c()}function c(){for(let y=0;y<s.length;y+=6){let x=s[y+0],b=s[y+2],_=s[y+4],S=Math.max(x,b,_),A=Math.min(x,b,_);S>.9&&A<.1&&(x<.2&&(s[y+0]+=1),b<.2&&(s[y+2]+=1),_<.2&&(s[y+4]+=1))}}function d(y){a.push(y.x,y.y,y.z)}function u(y,x){let b=y*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function p(){let y=new O,x=new O,b=new O,_=new O,S=new ae,A=new ae,E=new ae;for(let M=0,T=0;M<a.length;M+=9,T+=6){y.set(a[M+0],a[M+1],a[M+2]),x.set(a[M+3],a[M+4],a[M+5]),b.set(a[M+6],a[M+7],a[M+8]),S.set(s[T+0],s[T+1]),A.set(s[T+2],s[T+3]),E.set(s[T+4],s[T+5]),_.copy(y).add(x).add(b).divideScalar(3);let P=m(_);f(S,T+0,y,P),f(A,T+2,x,P),f(E,T+4,b,P)}}function f(y,x,b,_){_<0&&y.x===1&&(s[x]=y.x-1),b.x===0&&b.z===0&&(s[x]=_/2/Math.PI+.5)}function m(y){return Math.atan2(y.z,-y.x)}function g(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new aw(e.vertices,e.indices,e.radius,e.details)}},Q3=class extends aw{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],s=[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(a,s,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Q3(e.radius,e.detail)}},Mg=class extends Ag{constructor(e){super(e),this.uuid=Bs(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Ag().fromJSON(r))}return this}},UN={triangulate:function(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length,s=K3(e,0,a,i,!0),n=[];if(!s||s.next===s.prev)return n;let o,l,h,c,d,u,p;if(r&&(s=GN(e,t,s,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let f=i;f<a;f+=i)d=e[f],u=e[f+1],d<o&&(o=d),u<l&&(l=u),d>h&&(h=d),u>c&&(c=u);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return Ap(s,n,i,o,l,p,0),n}};function K3(e,t,i,r,a){let s,n;if(a===t8(e,t,i,r)>0)for(s=t;s<i;s+=r)n=SA(s,e[s],e[s+1],n);else for(s=i-r;s>=t;s-=r)n=SA(s,e[s],e[s+1],n);return n&&Pv(n,n.next)&&(Ep(n),n=n.next),n}function Nh(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Pv(i,i.next)||ir(i.prev,i,i.next)===0)){if(Ep(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function Ap(e,t,i,r,a,s,n){if(!e)return;!n&&s&&QN(e,r,a,s);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,s?VN(e,r,a,s):NN(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Ep(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=jN(Nh(e),t,i),Ap(e,t,i,r,a,s,2)):n===2&&HN(e,t,i,r,a,s):Ap(Nh(e),t,i,r,a,s,1);break}}}function NN(e){let t=e.prev,i=e,r=e.next;if(ir(t,i,r)>=0)return!1;let a=t.x,s=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=a<s?a<n?a:n:s<n?s:n,d=o<l?o<h?o:h:l<h?l:h,u=a>s?a>n?a:n:s>n?s:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&rd(a,o,s,l,n,h,f.x,f.y)&&ir(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function VN(e,t,i,r){let a=e.prev,s=e,n=e.next;if(ir(a,s,n)>=0)return!1;let o=a.x,l=s.x,h=n.x,c=a.y,d=s.y,u=n.y,p=o<l?o<h?o:h:l<h?l:h,f=c<d?c<u?c:u:d<u?d:u,m=o>l?o>h?o:h:l>h?l:h,g=c>d?c>u?c:u:d>u?d:u,y=Wy(p,f,t,i,r),x=Wy(m,g,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&rd(o,c,l,d,h,u,b.x,b.y)&&ir(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&rd(o,c,l,d,h,u,_.x,_.y)&&ir(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&rd(o,c,l,d,h,u,b.x,b.y)&&ir(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&rd(o,c,l,d,h,u,_.x,_.y)&&ir(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function jN(e,t,i){let r=e;do{let a=r.prev,s=r.next.next;!Pv(a,s)&&Z3(a,r,r.next,s)&&Mp(a,s)&&Mp(s,a)&&(t.push(a.i/i|0),t.push(r.i/i|0),t.push(s.i/i|0),Ep(r),Ep(r.next),r=e=s),r=r.next}while(r!==e);return Nh(r)}function HN(e,t,i,r,a,s){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&JN(n,o)){let l=J3(n,o);n=Nh(n,n.next),l=Nh(l,l.next),Ap(n,t,i,r,a,s,0),Ap(l,t,i,r,a,s,0);return}o=o.next}n=n.next}while(n!==e)}function GN(e,t,i,r){let a=[],s,n,o,l,h;for(s=0,n=t.length;s<n;s++)o=t[s]*r,l=s<n-1?t[s+1]*r:e.length,h=K3(e,o,l,r,!1),h===h.next&&(h.steiner=!0),a.push(ZN(h));for(a.sort(WN),s=0;s<a.length;s++)i=qN(a[s],i);return i}function WN(e,t){return e.x-t.x}function qN(e,t){let i=XN(e,t);if(!i)return t;let r=J3(i,e);return Nh(r,r.next),Nh(i,i.next)}function XN(e,t){let i=t,r=-1/0,a,s=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let u=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=s&&u>r&&(r=u,a=i.x<i.next.x?i:i.next,u===s))return a}i=i.next}while(i!==t);if(!a)return null;let o=a,l=a.x,h=a.y,c=1/0,d;i=a;do s>=i.x&&i.x>=l&&s!==i.x&&rd(n<h?s:r,n,l,h,n<h?r:s,n,i.x,i.y)&&(d=Math.abs(n-i.y)/(s-i.x),Mp(i,e)&&(d<c||d===c&&(i.x>a.x||i.x===a.x&&YN(a,i)))&&(a=i,c=d)),i=i.next;while(i!==o);return a}function YN(e,t){return ir(e.prev,e,t.prev)<0&&ir(t.next,e,e.next)<0}function QN(e,t,i,r){let a=e;do a.z===0&&(a.z=Wy(a.x,a.y,t,i,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,KN(a)}function KN(e){let t,i,r,a,s,n,o,l,h=1;do{for(i=e,e=null,s=null,n=0;i;){for(n++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(a=i,i=i.nextZ,o--):(a=r,r=r.nextZ,l--),s?s.nextZ=a:e=a,a.prevZ=s,s=a;i=r}s.nextZ=null,h*=2}while(n>1);return e}function Wy(e,t,i,r,a){return e=(e-i)*a|0,t=(t-r)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function ZN(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function rd(e,t,i,r,a,s,n,o){return(a-n)*(t-o)>=(e-n)*(s-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(s-o)>=(a-n)*(r-o)}function JN(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!$N(e,t)&&(Mp(e,t)&&Mp(t,e)&&e8(e,t)&&(ir(e.prev,e,t.prev)||ir(e,t.prev,t))||Pv(e,t)&&ir(e.prev,e,e.next)>0&&ir(t.prev,t,t.next)>0)}function ir(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Pv(e,t){return e.x===t.x&&e.y===t.y}function Z3(e,t,i,r){let a=Kf(ir(e,t,i)),s=Kf(ir(e,t,r)),n=Kf(ir(i,r,e)),o=Kf(ir(i,r,t));return!!(a!==s&&n!==o||a===0&&Qf(e,i,t)||s===0&&Qf(e,r,t)||n===0&&Qf(i,e,r)||o===0&&Qf(i,t,r))}function Qf(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Kf(e){return e>0?1:e<0?-1:0}function $N(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Z3(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Mp(e,t){return ir(e.prev,e,e.next)<0?ir(e,t,e.next)>=0&&ir(e,e.prev,t)>=0:ir(e,t,e.prev)<0||ir(e,e.next,t)<0}function e8(e,t){let i=e,r=!1,a=(e.x+t.x)/2,s=(e.y+t.y)/2;do i.y>s!=i.next.y>s&&i.next.y!==i.y&&a<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function J3(e,t){let i=new qy(e.i,e.x,e.y),r=new qy(t.i,t.x,t.y),a=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function SA(e,t,i,r){let a=new qy(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function Ep(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function qy(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function t8(e,t,i,r){let a=0;for(let s=t,n=i-r;s<i;s+=r)a+=(e[n]-e[s])*(e[s+1]+e[n+1]),n=s;return a}var $3=class{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return $3.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];AA(e),MA(i,e);let s=e.length;t.forEach(AA);for(let o=0;o<t.length;o++)r.push(s),s+=t[o].length,MA(i,t[o]);let n=UN.triangulate(i,r);for(let o=0;o<n.length;o+=3)a.push(n.slice(o,o+3));return a}};function AA(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function MA(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var eP=class extends aw{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,a,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new eP(e.radius,e.detail)}},ld=class extends vt{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(s+n,Math.PI),l=0,h=[],c=new O,d=new O,u=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let y=[],x=g/i,b=0;g==0&&s==0?b=.5/t:g==i&&o==Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let S=_/t;c.x=-e*Math.cos(r+S*a)*Math.sin(s+x*n),c.y=e*Math.cos(s+x*n),c.z=e*Math.sin(r+S*a)*Math.sin(s+x*n),p.push(c.x,c.y,c.z),d.copy(c).normalize(),f.push(d.x,d.y,d.z),m.push(S+b,1-x),y.push(l++)}h.push(y)}for(let g=0;g<i;g++)for(let y=0;y<t;y++){let x=h[g][y+1],b=h[g][y],_=h[g+1][y],S=h[g+1][y+1];(g!==0||s>0)&&u.push(x,b,S),(g!==i-1||o<Math.PI)&&u.push(b,_,S)}this.setIndex(u),this.setAttribute("position",new nt(p,3)),this.setAttribute("normal",new nt(f,3)),this.setAttribute("uv",new nt(m,2))}static fromJSON(e){return new ld(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},tP=class extends vt{constructor(e=1,t=.4,i=12,r=48,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:a},i=Math.floor(i),r=Math.floor(r);let s=[],n=[],o=[],l=[],h=new O,c=new O,d=new O;for(let u=0;u<=i;u++)for(let p=0;p<=r;p++){let f=p/r*a,m=u/i*Math.PI*2;c.x=(e+t*Math.cos(m))*Math.cos(f),c.y=(e+t*Math.cos(m))*Math.sin(f),c.z=t*Math.sin(m),n.push(c.x,c.y,c.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),d.subVectors(c,h).normalize(),o.push(d.x,d.y,d.z),l.push(p/r),l.push(u/i)}for(let u=1;u<=i;u++)for(let p=1;p<=r;p++){let f=(r+1)*u+p-1,m=(r+1)*(u-1)+p-1,g=(r+1)*(u-1)+p,y=(r+1)*u+p;s.push(f,m,y),s.push(m,g,y)}this.setIndex(s),this.setAttribute("position",new nt(n,3)),this.setAttribute("normal",new nt(o,3)),this.setAttribute("uv",new nt(l,2))}static fromJSON(e){return new tP(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},iP=class extends vt{constructor(e=1,t=.4,i=64,r=8,a=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:a,q:s},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],c=new O,d=new O,u=new O,p=new O,f=new O,m=new O,g=new O;for(let x=0;x<=i;++x){let b=x/i*a*Math.PI*2;y(b,a,s,e,u),y(b+.01,a,s,e,p),m.subVectors(p,u),g.addVectors(p,u),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let _=0;_<=r;++_){let S=_/r*Math.PI*2,A=-t*Math.cos(S),E=t*Math.sin(S);c.x=u.x+(A*g.x+E*f.x),c.y=u.y+(A*g.y+E*f.y),c.z=u.z+(A*g.z+E*f.z),o.push(c.x,c.y,c.z),d.subVectors(c,u).normalize(),l.push(d.x,d.y,d.z),h.push(x/i),h.push(_/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let _=(r+1)*(x-1)+(b-1),S=(r+1)*x+(b-1),A=(r+1)*x+b,E=(r+1)*(x-1)+b;n.push(_,S,E),n.push(S,A,E)}this.setIndex(n),this.setAttribute("position",new nt(o,3)),this.setAttribute("normal",new nt(l,3)),this.setAttribute("uv",new nt(h,2));function y(x,b,_,S,A){let E=Math.cos(x),M=Math.sin(x),T=_/b*x,P=Math.cos(T);A.x=S*(2+P)*.5*E,A.y=S*(2+P)*M*.5,A.z=S*Math.sin(T)*.5}}static fromJSON(e){return new iP(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},i8=class extends di{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};function nl(e,t,i){return rP(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Zf(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function rP(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function r8(e){function t(a,s){return e[a]-e[s]}let i=e.length,r=new Array(i);for(let a=0;a!==i;++a)r[a]=a;return r.sort(t),r}function EA(e,t,i){let r=e.length,a=new e.constructor(r);for(let s=0,n=0;n!==r;++s){let o=i[s]*t;for(let l=0;l!==t;++l)a[n++]=e[o+l]}return a}function aP(e,t,i,r){let a=1,s=e[0];for(;s!==void 0&&s[r]===void 0;)s=e[a++];if(s===void 0)return;let n=s[r];if(n!==void 0)if(Array.isArray(n))do n=s[r],n!==void 0&&(t.push(s.time),i.push.apply(i,n)),s=e[a++];while(s!==void 0);else if(n.toArray!==void 0)do n=s[r],n!==void 0&&(t.push(s.time),n.toArray(i,i.length)),s=e[a++];while(s!==void 0);else do n=s[r],n!==void 0&&(t.push(s.time),i.push(n)),s=e[a++];while(s!==void 0)}var Dv=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<a)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break i}if(!(e>=a)){let n=t[1];e<n&&(i=2,a=n);for(let o=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break i}break e}for(;i<s;){let n=i+s>>>1;e<t[n]?s=n:i=n+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},a8=class extends Dv{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ed,endingEnd:ed}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,n=r[a],o=r[s];if(n===void 0)switch(this.getSettings_().endingStart){case td:a=e,n=2*t-i;break;case bg:a=r.length-2,n=t+r[a]-r[a+1];break;default:a=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case td:s=e,o=2*i-t;break;case bg:s=1,o=i+r[1]-r[0];break;default:s=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=a*h,this._offsetNext=s*h}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,c=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-d*m+2*d*f-d*p,y=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,x=(-1-u)*m+(1.5+u)*f+.5*p,b=u*m-u*f;for(let _=0;_!==n;++_)a[_]=g*s[h+_]+y*s[l+_]+x*s[o+_]+b*s[c+_];return a}},sP=class extends Dv{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),c=1-h;for(let d=0;d!==n;++d)a[d]=s[l+d]*c+s[o+d]*h;return a}},s8=class extends Dv{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Kn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Zf(t,this.TimeBufferType),this.values=Zf(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Zf(e.times,Array),values:Zf(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new s8(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new sP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new a8(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case yg:t=this.InterpolantFactoryMethodDiscrete;break;case xg:t=this.InterpolantFactoryMethodLinear;break;case R0:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yg;case this.InterpolantFactoryMethodLinear:return xg;case this.InterpolantFactoryMethodSmooth:return R0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let n=this.getValueSize();this.times=nl(i,a,s),this.values=nl(this.values,a*n,s*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let n=0;n!==a;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(s!==null&&s>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,s),e=!1;break}s=o}if(r!==void 0&&rP(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=nl(this.times),t=nl(this.values),i=this.getValueSize(),r=this.getInterpolation()===R0,a=e.length-1,s=1;for(let n=1;n<a;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let c=n*i,d=c-i,u=c+i;for(let p=0;p!==i;++p){let f=t[c+p];if(f!==t[d+p]||f!==t[u+p]){o=!0;break}}}if(o){if(n!==s){e[s]=e[n];let c=n*i,d=s*i;for(let u=0;u!==i;++u)t[d+u]=t[c+u]}++s}}if(a>0){e[s]=e[a];for(let n=a*i,o=s*i,l=0;l!==i;++l)t[o+l]=t[n+l];++s}return s!==e.length?(this.times=nl(e,0,s),this.values=nl(t,0,s*i)):(this.times=e,this.values=t),this}clone(){let e=nl(this.times,0),t=nl(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Kn.prototype.TimeBufferType=Float32Array;Kn.prototype.ValueBufferType=Float32Array;Kn.prototype.DefaultInterpolation=xg;var jd=class extends Kn{};jd.prototype.ValueTypeName="bool";jd.prototype.ValueBufferType=Array;jd.prototype.DefaultInterpolation=yg;jd.prototype.InterpolantFactoryMethodLinear=void 0;jd.prototype.InterpolantFactoryMethodSmooth=void 0;var nP=class extends Kn{};nP.prototype.ValueTypeName="color";var Eg=class extends Kn{};Eg.prototype.ValueTypeName="number";var n8=class extends Dv{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)Rt.slerpFlat(a,0,s,l-n,s,l,o);return a}},Xp=class extends Kn{InterpolantFactoryMethodLinear(e){return new n8(this.times,this.values,this.getValueSize(),e)}};Xp.prototype.ValueTypeName="quaternion";Xp.prototype.DefaultInterpolation=xg;Xp.prototype.InterpolantFactoryMethodSmooth=void 0;var Hd=class extends Kn{};Hd.prototype.ValueTypeName="string";Hd.prototype.ValueBufferType=Array;Hd.prototype.DefaultInterpolation=yg;Hd.prototype.InterpolantFactoryMethodLinear=void 0;Hd.prototype.InterpolantFactoryMethodSmooth=void 0;var Cg=class extends Kn{};Cg.prototype.ValueTypeName="vector";var Xy=class{constructor(e,t=-1,i,r=Xb){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Bs(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let s=0,n=i.length;s!==n;++s)t.push(l8(i[s]).scale(r));let a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let a=0,s=i.length;a!==s;++a)t.push(Kn.toJSON(i[a]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let a=t.length,s=[];for(let n=0;n<a;n++){let o=[],l=[];o.push((n+a-1)%a,n,(n+1)%a),l.push(0,1,0);let h=r8(o);o=EA(o,1,h),l=EA(l,1,h),!r&&o[0]===0&&(o.push(a),l.push(l[0])),s.push(new Eg(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},a=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(a);if(h&&h.length>1){let c=h[1],d=r[c];d||(r[c]=d=[]),d.push(l)}}let s=[];for(let n in r)s.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,d,u,p){if(d.length!==0){let f=[],m=[];aP(d,f,m,u),f.length!==0&&p.push(new h(c,f,m))}},r=[],a=e.name||"default",s=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let c=l[h].keys;if(!(!c||c.length===0))if(c[0].morphTargets){let d={},u;for(u=0;u<c.length;u++)if(c[u].morphTargets)for(let p=0;p<c[u].morphTargets.length;p++)d[c[u].morphTargets[p]]=-1;for(let p in d){let f=[],m=[];for(let g=0;g!==c[u].morphTargets.length;++g){let y=c[u];f.push(y.time),m.push(y.morphTarget===p?1:0)}r.push(new Eg(".morphTargetInfluence["+p+"]",f,m))}o=d.length*s}else{let d=".bones["+t[h].name+"]";i(Cg,d+".position",c,"pos",r),i(Xp,d+".quaternion",c,"rot",r),i(Cg,d+".scale",c,"scl",r)}}return r.length===0?null:new this(a,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let a=this.tracks[i];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function o8(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Eg;case"vector":case"vector2":case"vector3":case"vector4":return Cg;case"color":return nP;case"quaternion":return Xp;case"bool":case"boolean":return jd;case"string":return Hd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function l8(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=o8(e.type);if(e.times===void 0){let i=[],r=[];aP(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var Tg={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},oP=class{constructor(e,t,i){let r=this,a=!1,s=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,a===!1&&r.onStart!==void 0&&r.onStart(h,s,n),a=!0},this.itemEnd=function(h){s++,r.onProgress!==void 0&&r.onProgress(h,s,n),s===n&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,d=l.length;c<d;c+=2){let u=l[c],p=l[c+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},h8=new oP,Yp=class{constructor(e){this.manager=e!==void 0?e:h8,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},uo={},c8=class extends Error{constructor(e,t){super(e),this.response=t}},Yy=class extends Yp{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=Tg.get(e);if(a!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0),a;if(uo[e]!==void 0){uo[e].push({onLoad:t,onProgress:i,onError:r});return}uo[e]=[],uo[e].push({onLoad:t,onProgress:i,onError:r});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(s).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=uo[e],c=l.body.getReader(),d=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=d?parseInt(d):0,p=u!==0,f=0,m=new ReadableStream({start(g){y();function y(){c.read().then(({done:x,value:b})=>{if(x)g.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let S=0,A=h.length;S<A;S++){let E=h[S];E.onProgress&&E.onProgress(_)}g.enqueue(b),y()}})}}});return new Response(m)}else throw new c8(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(c);return l.arrayBuffer().then(u=>d.decode(u))}}}).then(l=>{Tg.add(e,l);let h=uo[e];delete uo[e];for(let c=0,d=h.length;c<d;c++){let u=h[c];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=uo[e];if(h===void 0)throw this.manager.itemError(e),l;delete uo[e];for(let c=0,d=h.length;c<d;c++){let u=h[c];u.onError&&u.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},d8=class extends Yp{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,s=Tg.get(e);if(s!==void 0)return a.manager.itemStart(e),setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0),s;let n=_p("img");function o(){h(),Tg.add(e,this),t&&t(this),a.manager.itemEnd(e)}function l(c){h(),r&&r(c),a.manager.itemError(e),a.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),a.manager.itemStart(e),n.src=e,n}},u8=class extends Yp{constructor(e){super(e)}load(e,t,i,r){let a=new Zi,s=new d8(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(n){a.image=n,a.needsUpdate=!0,t!==void 0&&t(a)},i,r),a}},Qp=class extends Ci{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ct(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},p8=class extends Qp{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ct(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},h1=new je,CA=new O,TA=new O,sw=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ae(512,512),this.map=null,this.mapPass=null,this.matrix=new je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zb,this._frameExtents=new ae(1,1),this._viewportCount=1,this._viewports=[new Lt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;CA.setFromMatrixPosition(e.matrixWorld),t.position.copy(CA),TA.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(TA),t.updateMatrixWorld(),h1.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(h1),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(h1)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},f8=class extends sw{constructor(){super(new Ea(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=wp*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||t.far;(i!==t.fov||r!==t.aspect||a!==t.far)&&(t.fov=i,t.aspect=r,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},m8=class extends Qp{constructor(e,t,i=0,r=Math.PI/3,a=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.target=new Ci,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new f8}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},PA=new je,_u=new O,c1=new O,g8=class extends sw{constructor(){super(new Ea(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ae(4,2),this._viewportCount=6,this._viewports=[new Lt(2,1,1,1),new Lt(0,1,1,1),new Lt(3,1,1,1),new Lt(1,1,1,1),new Lt(3,0,1,1),new Lt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),_u.setFromMatrixPosition(e.matrixWorld),i.position.copy(_u),c1.copy(i.position),c1.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(c1),i.updateMatrixWorld(),r.makeTranslation(-_u.x,-_u.y,-_u.z),PA.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(PA)}},v8=class extends Qp{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new g8}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},y8=class extends sw{constructor(){super(new Ev(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},x8=class extends Qp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ci.DEFAULT_UP),this.updateMatrix(),this.target=new Ci,this.shadow=new y8}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},lP=class extends vt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},hP=class extends Yp{constructor(e){super(e)}load(e,t,i,r){let a=this,s=new Yy(a.manager);s.setPath(a.path),s.setRequestHeader(a.requestHeader),s.setWithCredentials(a.withCredentials),s.load(e,function(n){try{t(a.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),a.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(d,u){if(t[u]!==void 0)return t[u];let p=d.interleavedBuffers[u],f=a(d,p.buffer),m=Cf(p.type,f),g=new _N(m,p.stride);return g.uuid=p.uuid,t[u]=g,g}function a(d,u){if(i[u]!==void 0)return i[u];let p=d.arrayBuffers[u],f=new Uint32Array(p).buffer;return i[u]=f,f}let s=e.isInstancedBufferGeometry?new lP:new vt,n=e.data.index;if(n!==void 0){let d=Cf(n.type,n.array);s.setIndex(new Pt(d,1))}let o=e.data.attributes;for(let d in o){let u=o[d],p;if(u.isInterleavedBufferAttribute){let f=r(e.data,u.data);p=new Gy(f,u.itemSize,u.offset,u.normalized)}else{let f=Cf(u.type,u.array),m=u.isInstancedBufferAttribute?Sp:Pt;p=new m(f,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),s.setAttribute(d,p)}let l=e.data.morphAttributes;if(l)for(let d in l){let u=l[d],p=[];for(let f=0,m=u.length;f<m;f++){let g=u[f],y;if(g.isInterleavedBufferAttribute){let x=r(e.data,g.data);y=new Gy(x,g.itemSize,g.offset,g.normalized)}else{let x=Cf(g.type,g.array);y=new Pt(x,g.itemSize,g.normalized)}g.name!==void 0&&(y.name=g.name),p.push(y)}s.morphAttributes[d]=p}e.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let d=0,u=h.length;d!==u;++d){let p=h[d];s.addGroup(p.start,p.count,p.materialIndex)}let c=e.data.boundingSphere;if(c!==void 0){let d=new O;c.center!==void 0&&d.fromArray(c.center),s.boundingSphere=new cs(d,c.radius)}return e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}},b8=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=DA(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=DA();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function DA(){return(typeof performance>"u"?Date:performance).now()}var w8=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,a,s;switch(t){case"quaternion":r=this._slerp,a=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,a=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,a=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=a,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,a=e*r+r,s=this.cumulativeWeight;if(s===0){for(let n=0;n!==r;++n)i[a+n]=i[n];s=t}else{s+=t;let n=t/s;this._mixBufferRegion(i,a,0,n,r)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,a=this.cumulativeWeight,s=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,a<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-a,t)}s>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let a=i,s=r;a!==s;++a)t[a]=t[r+a%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,a){if(r>=.5)for(let s=0;s!==a;++s)e[t+s]=e[i+s]}_slerp(e,t,i,r){Rt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,a){let s=this._workIndex*a;Rt.multiplyQuaternionsFlat(e,s,e,t,e,i),Rt.slerpFlat(e,t,e,t,e,s,r)}_lerp(e,t,i,r,a){let s=1-r;for(let n=0;n!==a;++n){let o=t+n;e[o]=e[o]*s+e[i+n]*r}}_lerpAdditive(e,t,i,r,a){for(let s=0;s!==a;++s){let n=t+s;e[n]=e[n]+e[i+s]*r}}},nw="\\[\\]\\.:\\/",_8=new RegExp("["+nw+"]","g"),ow="[^"+nw+"]",S8="[^"+nw.replace("\\.","")+"]",A8=/((?:WC+[\/:])*)/.source.replace("WC",ow),M8=/(WCOD+)?/.source.replace("WCOD",S8),E8=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ow),C8=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ow),T8=new RegExp("^"+A8+M8+E8+C8+"$"),P8=["material","materials","bones","map"],D8=class{constructor(e,t,i){let r=i||Ri.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Ri=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Ri.parseTrackName(t),this.node=Ri.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Ri.Composite(e,t,i):new Ri(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_8,"")}static parseTrackName(e){let t=T8.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);P8.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let n=a[s];if(n.name===t||n.uuid===t)return n;let o=i(n.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=Ri.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ri.Composite=D8;Ri.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ri.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ri.prototype.GetterByBindingType=[Ri.prototype._getValue_direct,Ri.prototype._getValue_array,Ri.prototype._getValue_arrayElement,Ri.prototype._getValue_toArray];Ri.prototype.SetterByBindingTypeAndVersioning=[[Ri.prototype._setValue_direct,Ri.prototype._setValue_direct_setNeedsUpdate,Ri.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_array,Ri.prototype._setValue_array_setNeedsUpdate,Ri.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_arrayElement,Ri.prototype._setValue_arrayElement_setNeedsUpdate,Ri.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ri.prototype._setValue_fromArray,Ri.prototype._setValue_fromArray_setNeedsUpdate,Ri.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var I8=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let a=t.tracks,s=a.length,n=new Array(s),o={endingStart:ed,endingEnd:ed};for(let l=0;l!==s;++l){let h=a[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=E3,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,a=e._clip.duration,s=a/r,n=r/a;e.warp(1,s,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,a=r.time,s=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=a,o[1]=a+i,l[0]=e/s,l[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let a=this._startTime;if(a!==null){let o=(e-a)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let s=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case n5:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulateAdditive(n);break;case Xb:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,a=this._loopCount,s=i===qb;if(e===0)return a===-1?r:s&&(a&1)===1?t-r:r;if(i===M3){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,a+=Math.abs(n);let o=this.repetitions-a;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,s)}else this._setEndings(!1,!1,s);this._loopCount=a,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(s&&(a&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=td,r.endingEnd=td):(e?r.endingStart=this.zeroSlopeAtStart?td:ed:r.endingStart=bg,t?r.endingEnd=this.zeroSlopeAtEnd?td:ed:r.endingEnd=bg)}_scheduleFading(e,t,i){let r=this._mixer,a=r.time,s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);let n=s.parameterPositions,o=s.sampleValues;return n[0]=a,o[0]=t,n[1]=a+e,o[1]=i,this}},O8=new Float32Array(1),R8=class extends ha{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,a=r.length,s=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==a;++c){let d=r[c],u=d.name,p=h[u];if(p!==void 0)++p.referenceCount,s[c]=p;else{if(p=s[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new w8(Ri.create(i,u,f),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),s[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,a=this._actionsByClip[r];this._bindAction(e,a&&a.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];a.useCount++===0&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.useCount===0&&(a.restoreOriginalState(),this._takeBackBinding(a))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,a=this._actionsByClip,s=a[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,a[t]=s;else{let n=s.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let a=e._clip.uuid,s=this._actionsByClip,n=s[a],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let c=n.actionByRoot,d=(e._localRoot||this._root).uuid;delete c[d],o.length===0&&delete s[a],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.referenceCount===0&&this._removeInactiveBinding(a)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,a=this._bindings,s=r[t];s===void 0&&(s={},r[t]=s),s[i]=e,e._cacheIndex=a.length,a.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,a=i.path,s=this._bindingsByRootAndName,n=s[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[a],Object.keys(n).length===0&&delete s[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new sP(new Float32Array(2),new Float32Array(2),1,O8),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,a=t[r];e.__cacheIndex=r,t[r]=e,a.__cacheIndex=i,t[i]=a}clipAction(e,t,i){let r=t||this._root,a=r.uuid,s=typeof e=="string"?Xy.findByName(r,e):e,n=s!==null?s.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(s!==null?i=s.blendMode:i=Xb),o!==void 0){let c=o.actionByRoot[a];if(c!==void 0&&c.blendMode===i)return c;l=o.knownActions[0],s===null&&(s=l._clip)}if(s===null)return null;let h=new I8(this,s,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,a),h}existingAction(e,t){let i=t||this._root,r=i.uuid,a=typeof e=="string"?Xy.findByName(i,e):e,s=a?a.uuid:e,n=this._actionsByClip[s];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,a=Math.sign(e),s=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,a,s);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,a=r[i];if(a!==void 0){let s=a.knownActions;for(let n=0,o=s.length;n!==o;++n){let l=s[n];this._deactivateAction(l);let h=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=h,t[h]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let s in i){let n=i[s].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,a=r[t];if(a!==void 0)for(let s in a){let n=a[s];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},ke=class{constructor(e){this.value=e}clone(){return new ke(this.value.clone===void 0?this.value:this.value.clone())}},cP=class{constructor(e,t,i=0,r=1/0){this.ray=new Ud(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Qb,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return Qy(e,this,i,t),i.sort(IA),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)Qy(e[r],this,i,t);return i.sort(IA),i}};function IA(e,t){return e.distance-t.distance}function Qy(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let a=e.children;for(let s=0,n=a.length;s<n;s++)Qy(a[s],t,i,!0)}}var OA=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Tr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},RA=new ae,lw=class{constructor(e=new ae(1/0,1/0),t=new ae(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=RA.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return RA.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},LA=new O,Jf=new O,zs=class{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){LA.subVectors(e,this.start),Jf.subVectors(this.end,this.start);let i=Jf.dot(Jf),r=Jf.dot(LA)/i;return t&&(r=Tr(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},BA=new O,L8=class extends Ci{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new vt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,n=1,o=32;s<o;s++,n++){let l=s/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new nt(r,3));let a=new Ql({fog:!1,toneMapped:!1});this.cone=new qp(i,a),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),BA.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(BA),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},B8=class extends Fi{constructor(e,t,i){let r=new ld(t,4,2),a=new Vo({wireframe:!0,fog:!1,toneMapped:!1});super(r,a),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},zA=new O,$f=new O,kA=new O,z8=class extends Ci{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new vt;r.setAttribute("position",new nt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let a=new Ql({fog:!1,toneMapped:!1});this.lightPlane=new Sg(r,a),this.add(this.lightPlane),r=new vt,r.setAttribute("position",new nt([0,0,0,0,0,1],3)),this.targetLine=new Sg(r,a),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),zA.setFromMatrixPosition(this.light.matrixWorld),$f.setFromMatrixPosition(this.light.target.matrixWorld),kA.subVectors($f,zA),this.lightPlane.lookAt($f),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($f),this.targetLine.scale.z=kA.length()}},em=new O,nr=new Yl,Pg=class extends qp{constructor(e){let t=new vt,i=new Ql({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],a=[],s={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),a.push(0,0,0),s[p]===void 0&&(s[p]=[]),s[p].push(r.length/3-1)}t.setAttribute("position",new nt(r,3)),t.setAttribute("color",new nt(a,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();let l=new Ct(16755200),h=new Ct(16711680),c=new Ct(43775),d=new Ct(16777215),u=new Ct(3355443);this.setColors(l,h,c,d,u)}setColors(e,t,i,r,a){let s=this.geometry.getAttribute("color");s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,r.r,r.g,r.b),s.setXYZ(39,r.r,r.g,r.b),s.setXYZ(40,a.r,a.g,a.b),s.setXYZ(41,a.r,a.g,a.b),s.setXYZ(42,a.r,a.g,a.b),s.setXYZ(43,a.r,a.g,a.b),s.setXYZ(44,a.r,a.g,a.b),s.setXYZ(45,a.r,a.g,a.b),s.setXYZ(46,a.r,a.g,a.b),s.setXYZ(47,a.r,a.g,a.b),s.setXYZ(48,a.r,a.g,a.b),s.setXYZ(49,a.r,a.g,a.b),s.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;nr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mr("c",t,e,nr,0,0,-1),mr("t",t,e,nr,0,0,1),mr("n1",t,e,nr,-i,-r,-1),mr("n2",t,e,nr,i,-r,-1),mr("n3",t,e,nr,-i,r,-1),mr("n4",t,e,nr,i,r,-1),mr("f1",t,e,nr,-i,-r,1),mr("f2",t,e,nr,i,-r,1),mr("f3",t,e,nr,-i,r,1),mr("f4",t,e,nr,i,r,1),mr("u1",t,e,nr,i*.7,r*1.1,-1),mr("u2",t,e,nr,-i*.7,r*1.1,-1),mr("u3",t,e,nr,0,r*2,-1),mr("cf1",t,e,nr,-i,0,1),mr("cf2",t,e,nr,i,0,1),mr("cf3",t,e,nr,0,-r,1),mr("cf4",t,e,nr,0,r,1),mr("cn1",t,e,nr,-i,0,-1),mr("cn2",t,e,nr,i,0,-1),mr("cn3",t,e,nr,0,-r,-1),mr("cn4",t,e,nr,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mr(e,t,i,r,a,s,n){em.set(a,s,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],em.x,em.y,em.z)}}var Dg=class extends qp{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],a=new vt;a.setIndex(new Pt(i,1)),a.setAttribute("position",new nt(r,3)),super(a,new Ql({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},k8=class extends qp{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new vt;r.setAttribute("position",new nt(t,3)),r.setAttribute("color",new nt(i,3));let a=new Ql({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,t,i){let r=new Ct,a=this.geometry.attributes.color.array;return r.set(e),r.toArray(a,0),r.toArray(a,3),r.set(t),r.toArray(a,6),r.toArray(a,9),r.set(i),r.toArray(a,12),r.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},To=F8();function F8(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),a=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,a[l]=24,a[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,a[l]=-h-1,a[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,a[l]=13,a[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,a[l]=24,a[l|256]=24):(r[l]=31744,r[l|256]=64512,a[l]=13,a[l|256]=13)}let s=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,s[l]=h|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:a,mantissaTable:s,exponentTable:n,offsetTable:o}}function U8(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Tr(e,-65504,65504),To.floatView[0]=e;let t=To.uint32View[0],i=t>>23&511;return To.baseTable[i]+((t&8388607)>>To.shiftTable[i])}function N8(e){let t=e>>10;return To.uint32View[0]=To.mantissaTable[To.offsetTable[t]+(e&1023)]+To.exponentTable[t],To.floatView[0]}var V8=Object.freeze({__proto__:null,fromHalfFloat:N8,toHalfFloat:U8});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Fd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Fd);var Su=".",hw=Symbol("target"),dP=Symbol("unsubscribe");function Ky(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function j8(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Rn=Array.isArray;function cw(e){return typeof e=="symbol"}var H8={after:(e,t)=>Rn(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Rn(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Su),cw(t)?e+t.toString():e+t):e,initial:e=>{if(Rn(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Su);return t===-1?"":e.slice(0,t)},last:e=>{if(Rn(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Su);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Rn(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Su);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(Su,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Ps=H8;function G8(e){return typeof e=="object"&&typeof e.next=="function"}function W8(e,t,i,r,a){let s=e.next;if(t.name==="entries")e.next=function(){let n=s.call(this);return n.done===!1&&(n.value[0]=a(n.value[0],t,n.value[0],r),n.value[1]=a(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[hw].keys();e.next=function(){let o=s.call(this);return o.done===!1&&(o.value=a(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=s.call(this);return n.done===!1&&(n.value=a(n.value,t,n.value,r)),n};return e}function FA(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&cw(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var q8=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let a=e[r],s=a||e;this._pathCache.set(s,t);let n=this._proxyCache.get(s);return n===void 0&&(n=a===void 0?new Proxy(e,i):e,this._proxyCache.set(s,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Ps.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,a){if(!this._equals(a,i)||!(t in e)){let s=this._getOwnPropertyDescriptor(e,t);return s!==void 0&&"set"in s?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Zy(e){return toString.call(e)==="[object Object]"}function tm(){return!0}function Cc(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var uP=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),X8=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),pP={push:tm,pop:tm,shift:tm,unshift:tm,copyWithin:Cc,reverse:Cc,sort:Cc,splice:Cc,flat:Cc,fill:Cc},Y8=new Set([...uP,...X8,...Object.keys(pP)]);function im(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var fP=["keys","values","entries"],mP=new Set(["has","toString"]),gP={add:im,clear:im,delete:im,forEach:im},Q8=new Set([...mP,...Object.keys(gP),...fP]);function rm(e,t){if(e.size!==t.size)return!0;let i;for(let[r,a]of e)if(i=t.get(r),i!==a||i===void 0&&!t.has(r))return!0;return!1}var K8=new Set([...mP,"get"]),vP={set:rm,clear:rm,delete:rm,forEach:rm},Z8=new Set([...K8,...Object.keys(vP),...fP]),Gl=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return uP.has(e)}_shallowClone(e){let t=e;if(Zy(e))t={...e};else if(Rn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(Rn(r)?this._onIsChanged=pP[t]:r instanceof Set?this._onIsChanged=gP[t]:r instanceof Map&&(this._onIsChanged=vP[t]),r):i}update(e,t,i){let r=Ps.after(e,this._path);if(t!=="length"){let a=this.clone;Ps.walk(r,s=>{a&&a[s]&&(this._clonedCache.has(a[s])||(a[s]=this._shallowClone(a[s])),a=a[s])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),a&&a[t]&&(a[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],Ps.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},UA=class extends Gl{static isHandledMethod(e){return Y8.has(e)}},J8=class extends Gl{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},NA=class extends Gl{static isHandledMethod(e){return Q8.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},VA=class extends Gl{static isHandledMethod(e){return Z8.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},$8=class extends Gl{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},eV=class extends Gl{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Xc=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Zy(e)||Rn(e)||Ky(e)}static isHandledMethod(e,t){return Zy(e)?Gl.isHandledMethod(t):Rn(e)?UA.isHandledMethod(t):e instanceof Set?NA.isHandledMethod(t):e instanceof Map?VA.isHandledMethod(t):Ky(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Gl;Rn(e)?r=UA:e instanceof Date?r=J8:e instanceof Set?r=NA:e instanceof Map?r=VA:e instanceof WeakSet?r=$8:e instanceof WeakMap&&(r=eV),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,a=Xc.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(a,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},tV={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},dw=(e,t,i={})=>{i={...tV,...i};let r=Symbol("ProxyTarget"),{equals:a,isShallow:s,ignoreDetached:n,details:o}=i,l=new q8(a),h=typeof i.onValidate=="function",c=new Xc(h),d=(x,b,_,S,A)=>!h||c.isCloning||i.onValidate(Ps.concat(l.getPath(x),b),_,S,A)===!0,u=(x,b,_,S)=>{!FA(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,S)},p=(x,b,_,S,A)=>{c.isCloning?c.update(x,b,S):t(Ps.concat(x,b),_,S,A)},f=x=>x&&(x[r]||x),m=(x,b,_,S)=>j8(x)||_==="constructor"||s&&!Xc.isHandledMethod(b,_)||FA(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(S===void 0&&(S=l.getPath(b)),l.getProxy(x,Ps.concat(S,_),g,r)),g={get(x,b,_){if(cw(b)){if(b===r||b===hw)return x;if(b===dP&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let S=Ky(x)?Reflect.get(x,b):Reflect.get(x,b,_);return m(S,x,b)},set(x,b,_,S){_=f(_);let A=x[r]||x,E=A[b];if(a(E,_)&&b in x)return!0;let M=d(x,b,_,E);return M&&l.setProperty(A,b,_,S,E)?(u(x,b,x[b],E),!0):!M},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let S=x[b];d(x,b,_.value,S)&&l.defineProperty(x,b,_,S)&&u(x,b,_.value,S)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),S=d(x,b,void 0,_);return S&&l.deleteProperty(x,b,_)?(u(x,b,void 0,_),!0):!S},apply(x,b,_){let S=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,S,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Xc.isHandledType(S)){let A=Ps.initial(l.getPath(x)),E=Xc.isHandledMethod(S,x.name);c.start(S,A,_);let M=Reflect.apply(x,c.preferredThisArg(x,b,S),E?_.map(R=>f(R)):_),T=c.isChanged(S,a),P=c.stop();if(Xc.isHandledType(M)&&E&&(b instanceof Map&&x.name==="get"&&(A=Ps.concat(A,_[0])),M=l.getProxy(M,A,g)),T){let R={name:x.name,args:_,result:M},z=c.isCloning?Ps.initial(A):A,U=c.isCloning?Ps.last(A):"";d(Ps.get(e,z),U,S,P,R)?p(z,U,S,P,R):c.undo(S)}return(b instanceof Map||b instanceof Set)&&G8(M)?W8(M,x,b,A,m):M}return Reflect.apply(x,b,_)}},y=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};dw.target=e=>e&&e[hw]||e;dw.unsubscribe=e=>e[dP]||e;var jA=dw,iV=typeof global=="object"&&global&&global.Object===Object&&global,yP=iV,rV=typeof self=="object"&&self&&self.Object===Object&&self,aV=yP||rV||Function("return this")(),hn=aV,sV=hn.Symbol,ks=sV,xP=Object.prototype,nV=xP.hasOwnProperty,oV=xP.toString,Au=ks?ks.toStringTag:void 0;function lV(e){var t=nV.call(e,Au),i=e[Au];try{e[Au]=void 0;var r=!0}catch{}var a=oV.call(e);return r&&(t?e[Au]=i:delete e[Au]),a}var hV=lV,cV=Object.prototype,dV=cV.toString;function uV(e){return dV.call(e)}var pV=uV,fV="[object Null]",mV="[object Undefined]",HA=ks?ks.toStringTag:void 0;function gV(e){return e==null?e===void 0?mV:fV:HA&&HA in Object(e)?hV(e):pV(e)}var Xh=gV;function vV(e){return e!=null&&typeof e=="object"}var jo=vV,yV="[object Symbol]";function xV(e){return typeof e=="symbol"||jo(e)&&Xh(e)==yV}var Kp=xV;function bV(e,t){for(var i=-1,r=e==null?0:e.length,a=Array(r);++i<r;)a[i]=t(e[i],i,e);return a}var bP=bV,wV=Array.isArray,Wn=wV,_V=1/0,GA=ks?ks.prototype:void 0,WA=GA?GA.toString:void 0;function wP(e){if(typeof e=="string")return e;if(Wn(e))return bP(e,wP)+"";if(Kp(e))return WA?WA.call(e):"";var t=e+"";return t=="0"&&1/e==-_V?"-0":t}var _P=wP,SV=/\s/;function AV(e){for(var t=e.length;t--&&SV.test(e.charAt(t)););return t}var SP=AV,MV=/^\s+/;function EV(e){return e&&e.slice(0,SP(e)+1).replace(MV,"")}var CV=EV;function TV(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ds=TV,qA=0/0,PV=/^[-+]0x[0-9a-f]+$/i,DV=/^0b[01]+$/i,IV=/^0o[0-7]+$/i,OV=parseInt;function RV(e){if(typeof e=="number")return e;if(Kp(e))return qA;if(ds(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ds(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=CV(e);var i=DV.test(e);return i||IV.test(e)?OV(e.slice(2),i?2:8):PV.test(e)?qA:+e}var XA=RV;function LV(e){return e}var AP=LV,BV="[object AsyncFunction]",zV="[object Function]",kV="[object GeneratorFunction]",FV="[object Proxy]";function UV(e){if(!ds(e))return!1;var t=Xh(e);return t==zV||t==kV||t==BV||t==FV}var MP=UV,NV=hn["__core-js_shared__"],d1=NV,YA=function(){var e=/[^.]+$/.exec(d1&&d1.keys&&d1.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function VV(e){return!!YA&&YA in e}var jV=VV,HV=Function.prototype,GV=HV.toString;function WV(e){if(e!=null){try{return GV.call(e)}catch{}try{return e+""}catch{}}return""}var Yh=WV,qV=/[\\^$.*+?()[\]{}|]/g,XV=/^\[object .+?Constructor\]$/,YV=Function.prototype,QV=Object.prototype,KV=YV.toString,ZV=QV.hasOwnProperty,JV=RegExp("^"+KV.call(ZV).replace(qV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $V(e){if(!ds(e)||jV(e))return!1;var t=MP(e)?JV:XV;return t.test(Yh(e))}var ej=$V;function tj(e,t){return e?.[t]}var ij=tj;function rj(e,t){var i=ij(e,t);return ej(i)?i:void 0}var Qh=rj,aj=Qh(hn,"WeakMap"),Jy=aj,QA=Object.create,sj=function(){function e(){}return function(t){if(!ds(t))return{};if(QA)return QA(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),nj=sj;function oj(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var lj=oj;function hj(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var cj=hj,dj=800,uj=16,pj=Date.now;function fj(e){var t=0,i=0;return function(){var r=pj(),a=uj-(r-i);if(i=r,a>0){if(++t>=dj)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var mj=fj;function gj(e){return function(){return e}}var vj=gj,yj=function(){try{var e=Qh(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Ig=yj,xj=Ig?function(e,t){return Ig(e,"toString",{configurable:!0,enumerable:!1,value:vj(t),writable:!0})}:AP,bj=xj,wj=mj(bj),_j=wj;function Sj(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var Aj=Sj;function Mj(e,t,i,r){for(var a=e.length,s=i+(r?1:-1);r?s--:++s<a;)if(t(e[s],s,e))return s;return-1}var Ej=Mj;function Cj(e){return e!==e}var Tj=Cj;function Pj(e,t,i){for(var r=i-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}var Dj=Pj;function Ij(e,t,i){return t===t?Dj(e,t,i):Ej(e,Tj,i)}var Oj=Ij,Rj=9007199254740991,Lj=/^(?:0|[1-9]\d*)$/;function Bj(e,t){var i=typeof e;return t=t??Rj,!!t&&(i=="number"||i!="symbol"&&Lj.test(e))&&e>-1&&e%1==0&&e<t}var uw=Bj;function zj(e,t,i){t=="__proto__"&&Ig?Ig(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var EP=zj;function kj(e,t){return e===t||e!==e&&t!==t}var pw=kj,Fj=Object.prototype,Uj=Fj.hasOwnProperty;function Nj(e,t,i){var r=e[t];(!(Uj.call(e,t)&&pw(r,i))||i===void 0&&!(t in e))&&EP(e,t,i)}var fw=Nj;function Vj(e,t,i,r){var a=!i;i||(i={});for(var s=-1,n=t.length;++s<n;){var o=t[s],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),a?EP(i,o,l):fw(i,o,l)}return i}var Zp=Vj,KA=Math.max;function jj(e,t,i){return t=KA(t===void 0?e.length-1:t,0),function(){for(var r=arguments,a=-1,s=KA(r.length-t,0),n=Array(s);++a<s;)n[a]=r[t+a];a=-1;for(var o=Array(t+1);++a<t;)o[a]=r[a];return o[t]=i(n),lj(e,this,o)}}var Hj=jj,Gj=9007199254740991;function Wj(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Gj}var mw=Wj;function qj(e){return e!=null&&mw(e.length)&&!MP(e)}var CP=qj,Xj=Object.prototype;function Yj(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||Xj;return e===i}var gw=Yj;function Qj(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var Kj=Qj,Zj="[object Arguments]";function Jj(e){return jo(e)&&Xh(e)==Zj}var ZA=Jj,TP=Object.prototype,$j=TP.hasOwnProperty,eH=TP.propertyIsEnumerable,tH=ZA(function(){return arguments}())?ZA:function(e){return jo(e)&&$j.call(e,"callee")&&!eH.call(e,"callee")},vw=tH;function iH(){return!1}var rH=iH,PP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,JA=PP&&typeof module=="object"&&module&&!module.nodeType&&module,aH=JA&&JA.exports===PP,$A=aH?hn.Buffer:void 0,sH=$A?$A.isBuffer:void 0,nH=sH||rH,Og=nH,oH="[object Arguments]",lH="[object Array]",hH="[object Boolean]",cH="[object Date]",dH="[object Error]",uH="[object Function]",pH="[object Map]",fH="[object Number]",mH="[object Object]",gH="[object RegExp]",vH="[object Set]",yH="[object String]",xH="[object WeakMap]",bH="[object ArrayBuffer]",wH="[object DataView]",_H="[object Float32Array]",SH="[object Float64Array]",AH="[object Int8Array]",MH="[object Int16Array]",EH="[object Int32Array]",CH="[object Uint8Array]",TH="[object Uint8ClampedArray]",PH="[object Uint16Array]",DH="[object Uint32Array]",Wi={};Wi[_H]=Wi[SH]=Wi[AH]=Wi[MH]=Wi[EH]=Wi[CH]=Wi[TH]=Wi[PH]=Wi[DH]=!0;Wi[oH]=Wi[lH]=Wi[bH]=Wi[hH]=Wi[wH]=Wi[cH]=Wi[dH]=Wi[uH]=Wi[pH]=Wi[fH]=Wi[mH]=Wi[gH]=Wi[vH]=Wi[yH]=Wi[xH]=!1;function IH(e){return jo(e)&&mw(e.length)&&!!Wi[Xh(e)]}var OH=IH;function RH(e){return function(t){return e(t)}}var yw=RH,DP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,op=DP&&typeof module=="object"&&module&&!module.nodeType&&module,LH=op&&op.exports===DP,u1=LH&&yP.process,BH=function(){try{var e=op&&op.require&&op.require("util").types;return e||u1&&u1.binding&&u1.binding("util")}catch{}}(),Ad=BH,eM=Ad&&Ad.isTypedArray,zH=eM?yw(eM):OH,IP=zH,kH=Object.prototype,FH=kH.hasOwnProperty;function UH(e,t){var i=Wn(e),r=!i&&vw(e),a=!i&&!r&&Og(e),s=!i&&!r&&!a&&IP(e),n=i||r||a||s,o=n?Kj(e.length,String):[],l=o.length;for(var h in e)(t||FH.call(e,h))&&!(n&&(h=="length"||a&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||uw(h,l)))&&o.push(h);return o}var OP=UH;function NH(e,t){return function(i){return e(t(i))}}var RP=NH,VH=RP(Object.keys,Object),jH=VH,HH=Object.prototype,GH=HH.hasOwnProperty;function WH(e){if(!gw(e))return jH(e);var t=[];for(var i in Object(e))GH.call(e,i)&&i!="constructor"&&t.push(i);return t}var qH=WH;function XH(e){return CP(e)?OP(e):qH(e)}var xw=XH;function YH(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var QH=YH,KH=Object.prototype,ZH=KH.hasOwnProperty;function JH(e){if(!ds(e))return QH(e);var t=gw(e),i=[];for(var r in e)r=="constructor"&&(t||!ZH.call(e,r))||i.push(r);return i}var $H=JH;function e9(e){return CP(e)?OP(e,!0):$H(e)}var Sh=e9,t9=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i9=/^\w*$/;function r9(e,t){if(Wn(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Kp(e)?!0:i9.test(e)||!t9.test(e)||t!=null&&e in Object(t)}var a9=r9,s9=Qh(Object,"create"),Cp=s9;function n9(){this.__data__=Cp?Cp(null):{},this.size=0}var o9=n9;function l9(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var h9=l9,c9="__lodash_hash_undefined__",d9=Object.prototype,u9=d9.hasOwnProperty;function p9(e){var t=this.__data__;if(Cp){var i=t[e];return i===c9?void 0:i}return u9.call(t,e)?t[e]:void 0}var f9=p9,m9=Object.prototype,g9=m9.hasOwnProperty;function v9(e){var t=this.__data__;return Cp?t[e]!==void 0:g9.call(t,e)}var y9=v9,x9="__lodash_hash_undefined__";function b9(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Cp&&t===void 0?x9:t,this}var w9=b9;function Gd(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Gd.prototype.clear=o9;Gd.prototype.delete=h9;Gd.prototype.get=f9;Gd.prototype.has=y9;Gd.prototype.set=w9;var tM=Gd;function _9(){this.__data__=[],this.size=0}var S9=_9;function A9(e,t){for(var i=e.length;i--;)if(pw(e[i][0],t))return i;return-1}var Iv=A9,M9=Array.prototype,E9=M9.splice;function C9(e){var t=this.__data__,i=Iv(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():E9.call(t,i,1),--this.size,!0}var T9=C9;function P9(e){var t=this.__data__,i=Iv(t,e);return i<0?void 0:t[i][1]}var D9=P9;function I9(e){return Iv(this.__data__,e)>-1}var O9=I9;function R9(e,t){var i=this.__data__,r=Iv(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var L9=R9;function Wd(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Wd.prototype.clear=S9;Wd.prototype.delete=T9;Wd.prototype.get=D9;Wd.prototype.has=O9;Wd.prototype.set=L9;var Ov=Wd,B9=Qh(hn,"Map"),Tp=B9;function z9(){this.size=0,this.__data__={hash:new tM,map:new(Tp||Ov),string:new tM}}var k9=z9;function F9(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var U9=F9;function N9(e,t){var i=e.__data__;return U9(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Rv=N9;function V9(e){var t=Rv(this,e).delete(e);return this.size-=t?1:0,t}var j9=V9;function H9(e){return Rv(this,e).get(e)}var G9=H9;function W9(e){return Rv(this,e).has(e)}var q9=W9;function X9(e,t){var i=Rv(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var Y9=X9;function qd(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}qd.prototype.clear=k9;qd.prototype.delete=j9;qd.prototype.get=G9;qd.prototype.has=q9;qd.prototype.set=Y9;var Lv=qd,Q9="Expected a function";function bw(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Q9);var i=function(){var r=arguments,a=t?t.apply(this,r):r[0],s=i.cache;if(s.has(a))return s.get(a);var n=e.apply(this,r);return i.cache=s.set(a,n)||s,n};return i.cache=new(bw.Cache||Lv),i}bw.Cache=Lv;var K9=bw,Z9=500;function J9(e){var t=K9(e,function(r){return i.size===Z9&&i.clear(),r}),i=t.cache;return t}var $9=J9,e7=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t7=/\\(\\)?/g,i7=$9(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(e7,function(i,r,a,s){t.push(a?s.replace(t7,"$1"):r||i)}),t}),r7=i7;function a7(e){return e==null?"":_P(e)}var LP=a7;function s7(e,t){return Wn(e)?e:a9(e,t)?[e]:r7(LP(e))}var Xd=s7,n7=1/0;function o7(e){if(typeof e=="string"||Kp(e))return e;var t=e+"";return t=="0"&&1/e==-n7?"-0":t}var Bv=o7;function l7(e,t){t=Xd(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Bv(t[i++])];return i&&i==r?e:void 0}var BP=l7;function h7(e,t){for(var i=-1,r=t.length,a=e.length;++i<r;)e[a+i]=t[i];return e}var ww=h7,iM=ks?ks.isConcatSpreadable:void 0;function c7(e){return Wn(e)||vw(e)||!!(iM&&e&&e[iM])}var d7=c7;function zP(e,t,i,r,a){var s=-1,n=e.length;for(i||(i=d7),a||(a=[]);++s<n;){var o=e[s];t>0&&i(o)?t>1?zP(o,t-1,i,r,a):ww(a,o):r||(a[a.length]=o)}return a}var u7=zP;function p7(e){var t=e==null?0:e.length;return t?u7(e,1):[]}var f7=p7;function m7(e){return _j(Hj(e,void 0,f7),e+"")}var kP=m7,g7=RP(Object.getPrototypeOf,Object),_w=g7,v7="[object Object]",y7=Function.prototype,x7=Object.prototype,FP=y7.toString,b7=x7.hasOwnProperty,w7=FP.call(Object);function _7(e){if(!jo(e)||Xh(e)!=v7)return!1;var t=_w(e);if(t===null)return!0;var i=b7.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&FP.call(i)==w7}var S7=_7;function A7(e,t,i){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),i=i>a?a:i,i<0&&(i+=a),a=t>i?0:i-t>>>0,t>>>=0;for(var s=Array(a);++r<a;)s[r]=e[r+t];return s}var UP=A7;function M7(e,t,i){var r=e.length;return i=i===void 0?r:i,!t&&i>=r?e:UP(e,t,i)}var E7=M7,C7="\\ud800-\\udfff",T7="\\u0300-\\u036f",P7="\\ufe20-\\ufe2f",D7="\\u20d0-\\u20ff",I7=T7+P7+D7,O7="\\ufe0e\\ufe0f",R7="\\u200d",L7=RegExp("["+R7+C7+I7+O7+"]");function B7(e){return L7.test(e)}var z7=B7;function k7(e){return e.split("")}var F7=k7,NP="\\ud800-\\udfff",U7="\\u0300-\\u036f",N7="\\ufe20-\\ufe2f",V7="\\u20d0-\\u20ff",j7=U7+N7+V7,H7="\\ufe0e\\ufe0f",G7="["+NP+"]",$y="["+j7+"]",ex="\\ud83c[\\udffb-\\udfff]",W7="(?:"+$y+"|"+ex+")",VP="[^"+NP+"]",jP="(?:\\ud83c[\\udde6-\\uddff]){2}",HP="[\\ud800-\\udbff][\\udc00-\\udfff]",q7="\\u200d",GP=W7+"?",WP="["+H7+"]?",X7="(?:"+q7+"(?:"+[VP,jP,HP].join("|")+")"+WP+GP+")*",Y7=WP+GP+X7,Q7="(?:"+[VP+$y+"?",$y,jP,HP,G7].join("|")+")",K7=RegExp(ex+"(?="+ex+")|"+Q7+Y7,"g");function Z7(e){return e.match(K7)||[]}var J7=Z7;function $7(e){return z7(e)?J7(e):F7(e)}var rM=$7;function eG(){this.__data__=new Ov,this.size=0}var tG=eG;function iG(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var rG=iG;function aG(e){return this.__data__.get(e)}var sG=aG;function nG(e){return this.__data__.has(e)}var oG=nG,lG=200;function hG(e,t){var i=this.__data__;if(i instanceof Ov){var r=i.__data__;if(!Tp||r.length<lG-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Lv(r)}return i.set(e,t),this.size=i.size,this}var cG=hG;function Yd(e){var t=this.__data__=new Ov(e);this.size=t.size}Yd.prototype.clear=tG;Yd.prototype.delete=rG;Yd.prototype.get=sG;Yd.prototype.has=oG;Yd.prototype.set=cG;var rg=Yd;function dG(e,t){return e&&Zp(t,xw(t),e)}var uG=dG;function pG(e,t){return e&&Zp(t,Sh(t),e)}var fG=pG,qP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,aM=qP&&typeof module=="object"&&module&&!module.nodeType&&module,mG=aM&&aM.exports===qP,sM=mG?hn.Buffer:void 0,nM=sM?sM.allocUnsafe:void 0;function gG(e,t){if(t)return e.slice();var i=e.length,r=nM?nM(i):new e.constructor(i);return e.copy(r),r}var vG=gG;function yG(e,t){for(var i=-1,r=e==null?0:e.length,a=0,s=[];++i<r;){var n=e[i];t(n,i,e)&&(s[a++]=n)}return s}var xG=yG;function bG(){return[]}var XP=bG,wG=Object.prototype,_G=wG.propertyIsEnumerable,oM=Object.getOwnPropertySymbols,SG=oM?function(e){return e==null?[]:(e=Object(e),xG(oM(e),function(t){return _G.call(e,t)}))}:XP,Sw=SG;function AG(e,t){return Zp(e,Sw(e),t)}var MG=AG,EG=Object.getOwnPropertySymbols,CG=EG?function(e){for(var t=[];e;)ww(t,Sw(e)),e=_w(e);return t}:XP,YP=CG;function TG(e,t){return Zp(e,YP(e),t)}var PG=TG;function DG(e,t,i){var r=t(e);return Wn(e)?r:ww(r,i(e))}var QP=DG;function IG(e){return QP(e,xw,Sw)}var tx=IG;function OG(e){return QP(e,Sh,YP)}var KP=OG,RG=Qh(hn,"DataView"),ix=RG,LG=Qh(hn,"Promise"),rx=LG,BG=Qh(hn,"Set"),ax=BG,lM="[object Map]",zG="[object Object]",hM="[object Promise]",cM="[object Set]",dM="[object WeakMap]",uM="[object DataView]",kG=Yh(ix),FG=Yh(Tp),UG=Yh(rx),NG=Yh(ax),VG=Yh(Jy),fh=Xh;(ix&&fh(new ix(new ArrayBuffer(1)))!=uM||Tp&&fh(new Tp)!=lM||rx&&fh(rx.resolve())!=hM||ax&&fh(new ax)!=cM||Jy&&fh(new Jy)!=dM)&&(fh=function(e){var t=Xh(e),i=t==zG?e.constructor:void 0,r=i?Yh(i):"";if(r)switch(r){case kG:return uM;case FG:return lM;case UG:return hM;case NG:return cM;case VG:return dM}return t});var Pp=fh,jG=Object.prototype,HG=jG.hasOwnProperty;function GG(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&HG.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var WG=GG,qG=hn.Uint8Array,Rg=qG;function XG(e){var t=new e.constructor(e.byteLength);return new Rg(t).set(new Rg(e)),t}var Aw=XG;function YG(e,t){var i=t?Aw(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var QG=YG,KG=/\w*$/;function ZG(e){var t=new e.constructor(e.source,KG.exec(e));return t.lastIndex=e.lastIndex,t}var JG=ZG,pM=ks?ks.prototype:void 0,fM=pM?pM.valueOf:void 0;function $G(e){return fM?Object(fM.call(e)):{}}var eW=$G;function tW(e,t){var i=t?Aw(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var iW=tW,rW="[object Boolean]",aW="[object Date]",sW="[object Map]",nW="[object Number]",oW="[object RegExp]",lW="[object Set]",hW="[object String]",cW="[object Symbol]",dW="[object ArrayBuffer]",uW="[object DataView]",pW="[object Float32Array]",fW="[object Float64Array]",mW="[object Int8Array]",gW="[object Int16Array]",vW="[object Int32Array]",yW="[object Uint8Array]",xW="[object Uint8ClampedArray]",bW="[object Uint16Array]",wW="[object Uint32Array]";function _W(e,t,i){var r=e.constructor;switch(t){case dW:return Aw(e);case rW:case aW:return new r(+e);case uW:return QG(e,i);case pW:case fW:case mW:case gW:case vW:case yW:case xW:case bW:case wW:return iW(e,i);case sW:return new r;case nW:case hW:return new r(e);case oW:return JG(e);case lW:return new r;case cW:return eW(e)}}var SW=_W;function AW(e){return typeof e.constructor=="function"&&!gw(e)?nj(_w(e)):{}}var MW=AW,EW="[object Map]";function CW(e){return jo(e)&&Pp(e)==EW}var TW=CW,mM=Ad&&Ad.isMap,PW=mM?yw(mM):TW,DW=PW,IW="[object Set]";function OW(e){return jo(e)&&Pp(e)==IW}var RW=OW,gM=Ad&&Ad.isSet,LW=gM?yw(gM):RW,BW=LW,zW=1,kW=2,FW=4,ZP="[object Arguments]",UW="[object Array]",NW="[object Boolean]",VW="[object Date]",jW="[object Error]",JP="[object Function]",HW="[object GeneratorFunction]",GW="[object Map]",WW="[object Number]",$P="[object Object]",qW="[object RegExp]",XW="[object Set]",YW="[object String]",QW="[object Symbol]",KW="[object WeakMap]",ZW="[object ArrayBuffer]",JW="[object DataView]",$W="[object Float32Array]",eq="[object Float64Array]",tq="[object Int8Array]",iq="[object Int16Array]",rq="[object Int32Array]",aq="[object Uint8Array]",sq="[object Uint8ClampedArray]",nq="[object Uint16Array]",oq="[object Uint32Array]",Vi={};Vi[ZP]=Vi[UW]=Vi[ZW]=Vi[JW]=Vi[NW]=Vi[VW]=Vi[$W]=Vi[eq]=Vi[tq]=Vi[iq]=Vi[rq]=Vi[GW]=Vi[WW]=Vi[$P]=Vi[qW]=Vi[XW]=Vi[YW]=Vi[QW]=Vi[aq]=Vi[sq]=Vi[nq]=Vi[oq]=!0;Vi[jW]=Vi[JP]=Vi[KW]=!1;function ag(e,t,i,r,a,s){var n,o=t&zW,l=t&kW,h=t&FW;if(i&&(n=a?i(e,r,a,s):i(e)),n!==void 0)return n;if(!ds(e))return e;var c=Wn(e);if(c){if(n=WG(e),!o)return cj(e,n)}else{var d=Pp(e),u=d==JP||d==HW;if(Og(e))return vG(e,o);if(d==$P||d==ZP||u&&!a){if(n=l||u?{}:MW(e),!o)return l?PG(e,fG(n,e)):MG(e,uG(n,e))}else{if(!Vi[d])return a?e:{};n=SW(e,d,o)}}s||(s=new rg);var p=s.get(e);if(p)return p;s.set(e,n),BW(e)?e.forEach(function(g){n.add(ag(g,t,i,g,e,s))}):DW(e)&&e.forEach(function(g,y){n.set(y,ag(g,t,i,y,e,s))});var f=h?l?KP:tx:l?Sh:xw,m=c?void 0:f(e);return Aj(m||e,function(g,y){m&&(y=g,g=e[y]),fw(n,y,ag(g,t,i,y,e,s))}),n}var eD=ag,lq=1,hq=4;function cq(e){return eD(e,lq|hq)}var zv=cq,dq="__lodash_hash_undefined__";function uq(e){return this.__data__.set(e,dq),this}var pq=uq;function fq(e){return this.__data__.has(e)}var mq=fq;function Lg(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Lv;++t<i;)this.add(e[t])}Lg.prototype.add=Lg.prototype.push=pq;Lg.prototype.has=mq;var gq=Lg;function vq(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var yq=vq;function xq(e,t){return e.has(t)}var bq=xq,wq=1,_q=2;function Sq(e,t,i,r,a,s){var n=i&wq,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=s.get(e),c=s.get(t);if(h&&c)return h==t&&c==e;var d=-1,u=!0,p=i&_q?new gq:void 0;for(s.set(e,t),s.set(t,e);++d<o;){var f=e[d],m=t[d];if(r)var g=n?r(m,f,d,t,e,s):r(f,m,d,e,t,s);if(g!==void 0){if(g)continue;u=!1;break}if(p){if(!yq(t,function(y,x){if(!bq(p,x)&&(f===y||a(f,y,i,r,s)))return p.push(x)})){u=!1;break}}else if(!(f===m||a(f,m,i,r,s))){u=!1;break}}return s.delete(e),s.delete(t),u}var tD=Sq;function Aq(e){var t=-1,i=Array(e.size);return e.forEach(function(r,a){i[++t]=[a,r]}),i}var Mq=Aq;function Eq(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var Cq=Eq,Tq=1,Pq=2,Dq="[object Boolean]",Iq="[object Date]",Oq="[object Error]",Rq="[object Map]",Lq="[object Number]",Bq="[object RegExp]",zq="[object Set]",kq="[object String]",Fq="[object Symbol]",Uq="[object ArrayBuffer]",Nq="[object DataView]",vM=ks?ks.prototype:void 0,p1=vM?vM.valueOf:void 0;function Vq(e,t,i,r,a,s,n){switch(i){case Nq:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Uq:return!(e.byteLength!=t.byteLength||!s(new Rg(e),new Rg(t)));case Dq:case Iq:case Lq:return pw(+e,+t);case Oq:return e.name==t.name&&e.message==t.message;case Bq:case kq:return e==t+"";case Rq:var o=Mq;case zq:var l=r&Tq;if(o||(o=Cq),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=Pq,n.set(e,t);var c=tD(o(e),o(t),r,a,s,n);return n.delete(e),c;case Fq:if(p1)return p1.call(e)==p1.call(t)}return!1}var jq=Vq,Hq=1,Gq=Object.prototype,Wq=Gq.hasOwnProperty;function qq(e,t,i,r,a,s){var n=i&Hq,o=tx(e),l=o.length,h=tx(t),c=h.length;if(l!=c&&!n)return!1;for(var d=l;d--;){var u=o[d];if(!(n?u in t:Wq.call(t,u)))return!1}var p=s.get(e),f=s.get(t);if(p&&f)return p==t&&f==e;var m=!0;s.set(e,t),s.set(t,e);for(var g=n;++d<l;){u=o[d];var y=e[u],x=t[u];if(r)var b=n?r(x,y,u,t,e,s):r(y,x,u,e,t,s);if(!(b===void 0?y===x||a(y,x,i,r,s):b)){m=!1;break}g||(g=u=="constructor")}if(m&&!g){var _=e.constructor,S=t.constructor;_!=S&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof S=="function"&&S instanceof S)&&(m=!1)}return s.delete(e),s.delete(t),m}var Xq=qq,Yq=1,yM="[object Arguments]",xM="[object Array]",am="[object Object]",Qq=Object.prototype,bM=Qq.hasOwnProperty;function Kq(e,t,i,r,a,s){var n=Wn(e),o=Wn(t),l=n?xM:Pp(e),h=o?xM:Pp(t);l=l==yM?am:l,h=h==yM?am:h;var c=l==am,d=h==am,u=l==h;if(u&&Og(e)){if(!Og(t))return!1;n=!0,c=!1}if(u&&!c)return s||(s=new rg),n||IP(e)?tD(e,t,i,r,a,s):jq(e,t,l,i,r,a,s);if(!(i&Yq)){var p=c&&bM.call(e,"__wrapped__"),f=d&&bM.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return s||(s=new rg),a(m,g,i,r,s)}}return u?(s||(s=new rg),Xq(e,t,i,r,a,s)):!1}var Zq=Kq;function iD(e,t,i,r,a){return e===t?!0:e==null||t==null||!jo(e)&&!jo(t)?e!==e&&t!==t:Zq(e,t,i,r,iD,a)}var Jq=iD;function $q(e,t){return e!=null&&t in Object(e)}var eX=$q;function tX(e,t,i){t=Xd(t,e);for(var r=-1,a=t.length,s=!1;++r<a;){var n=Bv(t[r]);if(!(s=e!=null&&i(e,n)))break;e=e[n]}return s||++r!=a?s:(a=e==null?0:e.length,!!a&&mw(a)&&uw(n,a)&&(Wn(e)||vw(e)))}var iX=tX;function rX(e,t){return e!=null&&iX(e,t,eX)}var aX=rX,sX=function(){return hn.Date.now()},f1=sX,nX="Expected a function",oX=Math.max,lX=Math.min;function hX(e,t,i){var r,a,s,n,o,l,h=0,c=!1,d=!1,u=!0;if(typeof e!="function")throw new TypeError(nX);t=XA(t)||0,ds(i)&&(c=!!i.leading,d="maxWait"in i,s=d?oX(XA(i.maxWait)||0,t):s,u="trailing"in i?!!i.trailing:u);function p(A){var E=r,M=a;return r=a=void 0,h=A,n=e.apply(M,E),n}function f(A){return h=A,o=setTimeout(y,t),c?p(A):n}function m(A){var E=A-l,M=A-h,T=t-E;return d?lX(T,s-M):T}function g(A){var E=A-l,M=A-h;return l===void 0||E>=t||E<0||d&&M>=s}function y(){var A=f1();if(g(A))return x(A);o=setTimeout(y,m(A))}function x(A){return o=void 0,u&&r?p(A):(r=a=void 0,n)}function b(){o!==void 0&&clearTimeout(o),h=0,r=l=a=o=void 0}function _(){return o===void 0?n:x(f1())}function S(){var A=f1(),E=g(A);if(r=arguments,a=this,l=A,E){if(o===void 0)return f(l);if(d)return clearTimeout(o),o=setTimeout(y,t),p(l)}return o===void 0&&(o=setTimeout(y,t)),n}return S.cancel=b,S.flush=_,S}var Dp=hX;function cX(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var dX=cX;function uX(e,t){return e>t}var pX=uX;function fX(e,t){return t.length<2?e:BP(e,UP(t,0,-1))}var mX=fX;function gX(e,t){return Jq(e,t)}var Mw=gX;function vX(e,t,i){for(var r=-1,a=e.length;++r<a;){var s=e[r],n=t(s);if(n!=null&&(o===void 0?n===n&&!Kp(n):i(n,o)))var o=n,l=s}return l}var yX=vX;function xX(e){return e&&e.length?yX(e,AP,pX):void 0}var bX=xX;function wX(e,t){return t=Xd(t,e),e=mX(e,t),e==null||delete e[Bv(dX(t))]}var _X=wX;function SX(e){return S7(e)?void 0:e}var AX=SX,MX=1,EX=2,CX=4,TX=kP(function(e,t){var i={};if(e==null)return i;var r=!1;t=bP(t,function(s){return s=Xd(s,e),r||(r=s.length>1),s}),Zp(e,KP(e),i),r&&(i=eD(i,MX|EX|CX,AX));for(var a=t.length;a--;)_X(i,t[a]);return i}),sx=TX;function PX(e,t,i,r){if(!ds(e))return e;t=Xd(t,e);for(var a=-1,s=t.length,n=s-1,o=e;o!=null&&++a<s;){var l=Bv(t[a]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(a!=n){var c=o[l];h=r?r(c,l,o):void 0,h===void 0&&(h=ds(c)?c:uw(t[a+1])?[]:{})}fw(o,l,h),o=o[l]}return e}var DX=PX;function IX(e,t,i){for(var r=-1,a=t.length,s={};++r<a;){var n=t[r],o=BP(e,n);i(o,n)&&DX(s,Xd(n,e),o)}return s}var OX=IX;function RX(e,t){return OX(e,t,function(i,r){return aX(e,r)})}var LX=RX,BX=kP(function(e,t){return e==null?{}:LX(e,t)}),Vn=BX,zX="Expected a function";function kX(e,t,i){var r=!0,a=!0;if(typeof e!="function")throw new TypeError(zX);return ds(i)&&(r="leading"in i?!!i.leading:r,a="trailing"in i?!!i.trailing:a),Dp(e,t,{leading:r,maxWait:t,trailing:a})}var FX=kX;function UX(e,t){for(var i=e.length;i--&&Oj(t,e[i],0)>-1;);return i}var NX=UX;function VX(e,t,i){if(e=LP(e),e&&(i||t===void 0))return e.slice(0,SP(e)+1);if(!e||!(t=_P(t)))return e;var r=rM(e),a=NX(r,rM(t))+1;return E7(r,0,a).join("")}var jX=VX;function rD(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function rs(e,t){return Object.setPrototypeOf(e,t),e}var HX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),GX=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),WX=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||kv&&"ontouchend"in document,qX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,XX=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,YX=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},QX=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},KX=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},aD=HX(),Yle=aD?KX():void 0,kv=GX(),Qd=WX(),ZX=qX(),hs=XX(),wM=YX(),JX=Number(QX());function sD(e){return Array.isArray(e)?e:[e]}function nD(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function sm(e){return kv?e.metaKey:e.ctrlKey}function $X(e){return e.wheelDeltaY===0||e.deltaY===0?kv&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var Ot=[],Bg={},Qu={},sg={};function oD(e){Ot.includes(e)||Ot.push(e)}function hd(e){delete Bg[e.pointerId];for(let t=0;t<Ot.length;t++)if(Ot[t].pointerId===e.pointerId){Ot.splice(t,1);break}}function eY(){Ot.splice(0,Ot.length)}function zg(e){if(e.pointerType!=="touch")return;let t=Bg[e.pointerId];t===void 0&&(t={x:0,y:0},Bg[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function m1(e){let t=e.pointerId===Ot[0].pointerId?Ot[1]:Ot[0];return Bg[t.pointerId]}function lD(e){Qu[e.key]=!0,sg[e.key]=sg[e.key]===void 0?1:sg[e.key]+1}function hD(e){if(kv&&Qu.Meta)for(let t in Qu)Qu[t]=!1;else Qu[e.key]=!1;sg={}}function tY(e){e.addEventListener("pointerdown",oD,!0),e.addEventListener("pointerdown",zg,!0),e.addEventListener("pointermove",zg,!0),e.addEventListener("pointerup",hd,!0),e.addEventListener("pointercancel",hd,!0),e.addEventListener("pointerleave",hd,!0),window.addEventListener("keydown",lD,!0),window.addEventListener("keyup",hD,!0)}function iY(e){e.removeEventListener("pointerdown",oD,!0),e.removeEventListener("pointerdown",zg,!0),e.removeEventListener("pointermove",zg,!0),e.removeEventListener("pointerup",hd,!0),e.removeEventListener("pointercancel",hd,!0),e.removeEventListener("pointerleave",hd,!0),window.removeEventListener("keydown",lD,!0),window.removeEventListener("keyup",hD,!0)}var cD,rY=new Promise(e=>{cD=e}),nm;function aY(e){if(nm)return nm;async function t(){let i=e??"https://unpkg.com/@splinetool/navmesh-wasm@1.12.56/build",r=import("./navmesh.js"),[a,s]=await Promise.all([r,fetch(`${i}/navmesh.wasm`).then(l=>l.arrayBuffer())]),n=a.default,o=await n({wasmBinary:s});cD(o)}return nm=t(),nm}var dD,sY=new Promise(e=>{dD=e}),om;function nY(){if(om)return om;async function e(){let t=await import("./physics.js");await t.init(),dD(t)}return om=e(),om}var bt=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,bt.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:a,data:s}=e,n={...t,[a]:s};return Object.setPrototypeOf(n,bt.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let a={...t};return Object.setPrototypeOf(a,bt.prototype),delete a[i],{data:a,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Ew(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&Ew(r)}return Object.freeze(e)}function oY(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var uD=class extends Error{};function g1(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Cl(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],a=1/(i+1);for(let s=0;s<i;s++){let n=e+(t-e)*(s+.75+Math.random()*.5)*a;r.push(n)}return r}function Cw(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function lY(){return typeof process<"u"}function pD(e,t){for(let i of e)t(i.id,i.data)!==!0&&pD(i.children,t)}function fD(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)fD(i,t)}var xa=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,xa.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ew(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&fD(i,t)}}traverse(e){pD(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),a=r.findIndex(n=>n.id===e);if(a<0)throw new Error("not expected");let s=r[a];return r=[...r],r[a]={...s,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let s=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:s}}Object.setPrototypeOf(r,xa.prototype);let a=r;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:a,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:a,children:s};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),a=r.findIndex(n=>n.id===t);e.localIndex=a,r=[...r];let s=r.splice(a,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new uD("cyclic tree");d=this.parent(d)}}let a=this.parent(r);if(a===void 0)return null;let s=a,n=this.childrenArray(a),o=n.findIndex(d=>d.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(a,n);a=t,n=h.childrenArray(a);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((d,u)=>d.fi-u.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(a,n),{data:h,actual:e,reverse:{type:9,parent:s,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>oY(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),a=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...a,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Cl(0,i,i);{let a=r[0].fi;return Cl(a-i,a,i)}}else{let a=this.get(t);if(a===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(n=>n.fi>a.fi);if(s===void 0){let n=r[r.length-1].fi;return Cl(n,n+i,i)}else return Cl(a.fi,s.fi,i)}}},kg;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let a=r.props,s={},n=[...i],o=!1;if(a)for(let l of Object.keys(a)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");s[l]=n[h],n[h]=a[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}else{let a=r.props,s={},n={...i},o=!1;if(a)for(let l of Object.keys(a)){s[l]=n[l];let h=a[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}}e.runOp=t})(kg||(kg={}));var pt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,pt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ew(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let a=i[r];return i=[...i],i[r]={...a,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,pt.prototype);let t=e;return lY()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,a=this,s={fi:t,id:i,data:r};return a=[...a,s],a.sort((n,o)=>n.fi-o.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let a=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let a=r.findIndex(o=>o.id===i);if(a===-1)return null;let s=r[a].fi,n={...r[a],fi:t};return r[a]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Cl(0,t,t);{let r=i[0].fi;return Cl(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let a=i.find(s=>s.fi>r.fi);if(a===void 0){let s=i[i.length-1].fi;return Cl(s,s+t,t)}else return Cl(r.fi,a.fi,t)}}};function Md(e){return e&&typeof e=="object"&&e instanceof dr}var dr=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,a={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!Md(i))return null;r+=1}i=i?g1(i):new dr;for(let[o,l]of Object.entries(e.props)){let h=i[o];a[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=g1(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=g1(o);l[e.path[r-1]]=i,i=l}else{let l=new dr;l[e.path[r-1]]=i,i=l}}r-=1}let s=Object.setPrototypeOf(i,dr.prototype),n={...e,props:a};return{data:s,actual:e,reverse:n}}},kl;(e=>{function t(a,s){return Ip(a,s)??a}e.apply=t;function i(a,s){return Pw(a,s)}e.merge=i;function r(a,s){let n=0,o=s.path,l=a;for(;n<o.length&&l!==void 0;){if(l=Gr.zoomOnce(l,o[n]),l===void 0)return s;if(!Md(l))return;n+=1}if(l===void 0)return s;if(Md(l))if(s.type===0){let h={...s.props};for(let c of Object.keys(l))delete h[c];return{...s,props:h}}else if(s.type===1||s.type===4||s.type===7){let h=Tw([s],l);return h?h[0]:s}else return s}e.filterOp=r})(kl||(kl={}));function Tw(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=Ip(a.data,t[s]);if(i=i||n!==void 0,n===void 0&&(n=a.data),a.children){let o=Tw(a.children,t);return o!==void 0?i=!0:o=a.children,{...a,id:s,data:n,children:o}}else return{...a,id:s,data:n}});if(i)return r}function hY(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=Ip(a.data,t[s]);return i=i||n!==void 0,n===void 0&&(n=a.data),{...a,id:s,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function Ip(e,t){if(!Md(t))return t;if(e instanceof xa){let i=Tw(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof pt)return hY(e,t);if(Array.isArray(e)){let i=!1,r=e.map((a,s)=>{let n=Ip(a,t[s]);return i=i||n!==void 0,n===void 0&&(n=a),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof dr)return Pw(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[a,s]of Object.entries(e)){let n=Ip(s,t[a]);r=r||n!==void 0,n===void 0&&(n=s),i[a]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function Pw(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Md(t))return t;if(!Md(e))return kl.apply(e,t);let i=new Set;for(let a of Object.keys(e))i.add(a);for(let a of Object.keys(t))i.add(a);let r=new dr;for(let a of i){let s=Pw(e===void 0?void 0:e[a],t===void 0?void 0:t[a]);r[a]=s}return r}function cY(e,t){let i={cur:[],result:[],len:0};return e=Op(e,t,i)??e,[e,i.result]}function Fg(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Ug(e){e&&(e.len-=1)}function dY(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function mD(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=Op(s.data,t,Fg(i,n));Ug(i),r=r||l!==void 0,l===void 0&&(l=s.data);let h=mD(s.children,t,i);return h!==void 0?r=!0:h=s.children,{...s,id:n,data:l,children:h}});if(r)return a}function uY(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=Op(s.data,t,Fg(i,n));return Ug(i),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:n,data:l}});if(r)return Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a}function Op(e,t,i){if(e instanceof xa){let r=mD(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof pt)return uY(e,t,i);if(Array.isArray(e)){let r=!1,a=e.map((s,n)=>{let o=Op(s,t,Fg(i,n));return Ug(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a):void 0}else if(e&&typeof e=="object"&&!Cw(e)){let r={},a=!1;for(let[s,n]of Object.entries(e))if(s!=="name"&&s!=="variableId"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");a=!0,s=o}let l=Op(n,t,Fg(i,s));Ug(i),a=a||l!==void 0,l===void 0&&(l=n),r[s]=l}else r[s]=n;return a?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&dY(i),r}else return}}var Ng;(e=>{function t(i,r){let a=Gr.zoom(r,i.path);if(typeof a=="object"){let s={};for(let n of Object.keys(i.props))s[n]=a[n];return{...i,props:s}}else return{...i,props:{}}}e.replaceProps=t})(Ng||(Ng={}));var aa;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let c=h.path;for(var d=[];;){let u;if(l instanceof dr&&h.type===0&&(u=l.runOp({...h,path:c.slice(d.length)}),u===null&&(u=void 0)),u===void 0&&d.length===c.length&&(l instanceof xa||l instanceof pt||l instanceof bt?u=l.runOp(h):u=kg.runOp(l,h)),u!==void 0)if(u!==null){let m=u.data;for(let g=d.length-1;g>=0;g--){let y=c[g],x=d[g];if(x instanceof xa){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof pt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof bt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof dr){let b={...x,[y]:m};m=Object.setPrototypeOf(b,dr.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let b=m;m=[...x],m[y]=b}else m={...x,[y]:m};else return null}return{data:m,actual:{...u.actual,path:c},reverse:{...u.reverse,path:c}}}else return null;let p=c[d.length],f;if(l instanceof xa){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof pt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)d.push(l),l=f;else return null}}e.apply=r;function a(l,h){for(let c=0;c<l.length&&c<h.length;c++)if(l[c]!==h[c])return!0;return!1}e.pathDisjoint=a;function s(l,h){if(l.length!==h.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==h[c])return!1;return!0}e.pathEq=s;function n(l,h){return a(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&s(l.path,h.path)?Object.keys(l.props).every(c=>h.props[c]!==void 0):!1}e.subsumed=o})(aa||(aa={}));var nx;(e=>{function t(){return[]}e.empty=t;function i(h,c){let d=[];for(let u of h){let[p,...f]=u.path;p===c&&d.push({...u,path:f})}return d}e.removePrefix=i;function r(h,c){return h.map(d=>({...d,path:[c,...d.path]}))}e.addPrefix=r;function a(h,c){return[...h,...c]}e.concat=a;function s(h,c){return[...h.filter(d=>!c.some(u=>aa.subsumed(d,u))),...c]}e.compress=s;function n(h,c){return h.every(d=>c.every(u=>aa.commutative(d,u)))}e.commutative=n;function o(h,c){for(let d of c){let u=l(h,d);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,c){var d=h;let u=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,y;if(f.type===3?(m=Gr.zoom(d,[...f.path,f.id]),y=aa.apply(d,{...f,type:2})):(m=Gr.zoom(d,[...f.path,f.id,"value"]),y=aa.apply(d,f)),y!==null){d=y.data;let[x,b]=cY(d,{[f.id]:m});d=x;for(let _=0;_<b.length;_++){let S=b[_],A=S.pop();if(typeof A=="number"){let E=[A];for(let T=_+1;T<b.length;T++){let P=b[T],R=P[P.length-1];if(typeof R=="number"&&Gr.equal(S,P.slice(0,P.length-1)))E.push(R),b.splice(T,1);else break}let M=Gr.zoom(d,S);g=M.map((T,P)=>E.includes(P)?f.id:T),m=M,A=S.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let E=m,M=Gr.zoom(d,S.slice(0,S.length-2)),T=M.layers.map(P=>P.id===S[S.length-1]?{...P,data:{...P.data,[A]:E}}:P);Object.setPrototypeOf(T,Object.getPrototypeOf(M.layers)),M.layers=T}g=f.id}u.push({type:0,path:S,props:{[A]:m}}),p.push({type:0,path:S,props:{[A]:g}})}p.push(y.reverse),u.push(y.actual)}}else{let m=aa.apply(d,f);m!==null&&(u.push(m.actual),d=m.data,p.push(m.reverse))}}catch(m){if(m instanceof uD)return null;throw m}return{data:d,actual:u,reverse:p.reverse()}}e.apply=l})(nx||(nx={}));var gD=Symbol(),pY=Symbol(),Fv=Symbol(),Jp=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let a=i;for(;!(r instanceof yD);){let s=r._path,n=r._current;if(s!==""&&a.splice(0,0,s),r=r._parent,r===null)return;r.update(s,n)}r.push(a,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Fv];i&&i(),delete this._children[e]}}}},fY=class extends Jp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else if(this._current instanceof dr){let i={...this._current,[e]:t};this._current=Object.setPrototypeOf(i,dr.prototype)}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,kg.runOp(this._current,e),e.path)}},mY=class extends Jp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,bt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},vD={get(e,t){if(t===Fv)return()=>{e._parent=null};if(t===gD)return e._current;if(t===pY)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let a=r===void 0?void 0:r[t];if(a!==void 0)return a;let s=i[t],n=Uv(e,t,s);return n!==s?(r===void 0&&(r={},e._children=r),r[t]=n,n):s},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},gY={...vD,set(e,t,i){let r={type:0,props:{[t]:br(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},vY={...vD,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},Dw=class extends Jp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Fv]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=Uv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}add(e,t,i,r,a){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:a})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Iw=class extends Jp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Fv]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,a=this._current[i].fi;e(this.data(this._current[i].id),r,a)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=Uv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function v1(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Gr.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var yD=class extends Jp{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){v1(this.ts,t,e),v1(this.actual,i,e),v1(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Uv(e,t,i){return i instanceof xa?new Dw(e,t,i):i instanceof pt?new Iw(e,t,i):i instanceof bt?new Proxy(new mY(e,t,i),vY):i!==null&&typeof i=="object"?Cw(i)?i:new Proxy(new fY(e,t,i),gY):i}function xD(e){let t=new yD(e);return[Uv(t,"",e),t]}function Rp(e,t){let[i,r]=xD(e);return t(i),r.result()}function br(e){return e instanceof Dw||e instanceof Iw?e._current:e!==null&&typeof e=="object"?e[gD]:e}var Gr;(e=>{function t(s,n){if(n.length===s.length)for(var o=0;o<s.length;){if(s[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(s,n,o){let l=a(o,s);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(c=>{delete h[c]}),h}else return n}e.removeOverridden=i;function r(s,n){if((s instanceof xa||s instanceof Dw)&&typeof n=="string"||(s instanceof pt||s instanceof Iw)&&typeof n=="string")return s.data(n);if(typeof n=="number"&&Array.isArray(s)||typeof n=="string"&&typeof s=="object"&&s!==null)return s[n]}e.zoomOnce=r;function a(s,n,o=0){for(;o<n.length&&s!==void 0;)s=r(s,n[o]),o+=1;return s}e.zoom=a})(Gr||(Gr={}));function yY(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Bi(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var bD=class{},_M=class extends bD{constructor(e){super(),this.id=e}},SM=class extends bD{constructor(e){super(),this.data=e}},ox;try{ox=new TextDecoder}catch{}var ct,Fl,we=0,wD=[],lx=wD,hx=0,Ja={},xi,Tl,Ds=0,Ln=0,ls,ko,Ga=[],Ei,AM={useRecords:!1,mapsAsObjects:!0},_D=class{},SD=new _D;SD.name="MessagePack 0xC1";var Ed=!1,Vg=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ct)return PD(()=>(dx(),this?this.unpack(e,t):Vg.prototype.unpack.call(AM,e,t)));Fl=t>-1?t:e.length,we=0,hx=0,Ln=0,Tl=null,lx=wD,ls=null,ct=e;try{Ei=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw ct=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Vg){if(Ja=this,this.structures)return xi=this.structures,lm();(!xi||xi.length>0)&&(xi=[])}else Ja=AM,(!xi||xi.length>0)&&(xi=[]);return lm()}unpackMultiple(e,t){let i,r=0;try{Ed=!0;let a=e.length,s=this?this.unpack(e,a):Vv.unpack(e,a);if(t){for(t(s);we<a;)if(r=we,t(lm())===!1)return}else{for(i=[s];we<a;)r=we,i.push(lm());return i}}catch(a){throw a.lastPosition=r,a.values=i,a}finally{Ed=!1,dx()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let a=e[i];a&&(a.isShared=!0,i>=32&&(a.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],a=t[i];a&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function lm(){try{if(!Ja.trusted&&!Ed){let t=xi.sharedLength||0;t<xi.length&&(xi.length=t)}let e=lr();if(we==Fl)xi.restoreStructures&&MM(),xi=null,ct=null,ko&&(ko=null);else if(we>Fl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Ed)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw xi.restoreStructures&&MM(),dx(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function MM(){for(let e in xi.restoreStructures)xi[e]=xi.restoreStructures[e];xi.restoreStructures=null}function lr(){let e=ct[we++];if(e<160)if(e<128){if(e<64)return e;{let t=xi[e&63]||Ja.getStructures&&AD()[e&63];return t?(t.read||(t.read=Ow(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Ja.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[ED()]=lr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(lr(),lr());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=lr();return t}else if(e<192){let t=e-160;if(Ln>=we)return Tl.slice(we-Ds,(we+=t)-Ds);if(Ln==0&&Fl<140){let i=t<16?Rw(t):MD(t);if(i!=null)return i}return cx(t)}else{let t;switch(e){case 192:return null;case 193:return ls?(t=lr(),t>0?ls[1].slice(ls.position1,ls.position1+=t):ls[0].slice(ls.position0,ls.position0-=t)):SD;case 194:return!1;case 195:return!0;case 196:return y1(ct[we++]);case 197:return t=Ei.getUint16(we),we+=2,y1(t);case 198:return t=Ei.getUint32(we),we+=4,y1(t);case 199:return lh(ct[we++]);case 200:return t=Ei.getUint16(we),we+=2,lh(t);case 201:return t=Ei.getUint32(we),we+=4,lh(t);case 202:if(t=Ei.getFloat32(we),Ja.useFloat32>2){let i=Lw[(ct[we]&127)<<1|ct[we+1]>>7];return we+=4,(i*t+(t>0?.5:-.5)>>0)/i}return we+=4,t;case 203:return t=Ei.getFloat64(we),we+=8,t;case 204:return ct[we++];case 205:return t=Ei.getUint16(we),we+=2,t;case 206:return t=Ei.getUint32(we),we+=4,t;case 207:return Ja.int64AsNumber?(t=Ei.getUint32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigUint64(we),we+=8,t;case 208:return Ei.getInt8(we++);case 209:return t=Ei.getInt16(we),we+=2,t;case 210:return t=Ei.getInt32(we),we+=4,t;case 211:return Ja.int64AsNumber?(t=Ei.getInt32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigInt64(we),we+=8,t;case 212:if(t=ct[we++],t==114)return DM(ct[we++]&63);{let i=Ga[t];if(i)return i.read?(we++,i.read(lr())):i.noBuffer?(we++,i()):i(ct.subarray(we,++we));throw new Error("Unknown extension "+t)}case 213:return t=ct[we],t==114?(we++,DM(ct[we++]&63,ct[we++])):lh(2);case 214:return lh(4);case 215:return lh(8);case 216:return lh(16);case 217:return t=ct[we++],Ln>=we?Tl.slice(we-Ds,(we+=t)-Ds):bY(t);case 218:return t=Ei.getUint16(we),we+=2,Ln>=we?Tl.slice(we-Ds,(we+=t)-Ds):wY(t);case 219:return t=Ei.getUint32(we),we+=4,Ln>=we?Tl.slice(we-Ds,(we+=t)-Ds):_Y(t);case 220:return t=Ei.getUint16(we),we+=2,CM(t);case 221:return t=Ei.getUint32(we),we+=4,CM(t);case 222:return t=Ei.getUint16(we),we+=2,TM(t);case 223:return t=Ei.getUint32(we),we+=4,TM(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var xY=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ow(e,t){function i(){if(i.count++>2){let a=e.read=new Function("r","return function(){return {"+e.map(s=>xY.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(lr);return e.highByte===0&&(e.read=EM(t,e.read)),a()}let r={};for(let a=0,s=e.length;a<s;a++){let n=e[a];r[n]=lr()}return r}return i.count=0,e.highByte===0?EM(t,i):i}var EM=(e,t)=>function(){let i=ct[we++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),a=xi[r]||AD()[r];if(!a)throw new Error("Record id is not defined for "+r);return a.read||(a.read=Ow(a,e)),a.read()};function AD(){let e=PD(()=>(ct=null,Ja.getStructures()));return xi=Ja._mergeStructures(e,xi)}var cx=Nv,bY=Nv,wY=Nv,_Y=Nv;function Nv(e){let t;if(e<16&&(t=Rw(e)))return t;if(e>64&&ox)return ox.decode(ct.subarray(we,we+=e));let i=we+e,r=[];for(t="";we<i;){let a=ct[we++];if((a&128)===0)r.push(a);else if((a&224)===192){let s=ct[we++]&63;r.push((a&31)<<6|s)}else if((a&240)===224){let s=ct[we++]&63,n=ct[we++]&63;r.push((a&31)<<12|s<<6|n)}else if((a&248)===240){let s=ct[we++]&63,n=ct[we++]&63,o=ct[we++]&63,l=(a&7)<<18|s<<12|n<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(a);r.length>=4096&&(t+=ta.apply(String,r),r.length=0)}return r.length>0&&(t+=ta.apply(String,r)),t}function CM(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=lr();return t}function TM(e){if(Ja.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[ED()]=lr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(lr(),lr());return t}}var ta=String.fromCharCode;function MD(e){let t=we,i=new Array(e);for(let r=0;r<e;r++){let a=ct[we++];if((a&128)>0){we=t;return}i[r]=a}return ta.apply(String,i)}function Rw(e){if(e<4)if(e<2){if(e===0)return"";{let t=ct[we++];if((t&128)>1){we-=1;return}return ta(t)}}else{let t=ct[we++],i=ct[we++];if((t&128)>0||(i&128)>0){we-=2;return}if(e<3)return ta(t,i);let r=ct[we++];if((r&128)>0){we-=3;return}return ta(t,i,r)}else{let t=ct[we++],i=ct[we++],r=ct[we++],a=ct[we++];if((t&128)>0||(i&128)>0||(r&128)>0||(a&128)>0){we-=4;return}if(e<6){if(e===4)return ta(t,i,r,a);{let s=ct[we++];if((s&128)>0){we-=5;return}return ta(t,i,r,a,s)}}else if(e<8){let s=ct[we++],n=ct[we++];if((s&128)>0||(n&128)>0){we-=6;return}if(e<7)return ta(t,i,r,a,s,n);let o=ct[we++];if((o&128)>0){we-=7;return}return ta(t,i,r,a,s,n,o)}else{let s=ct[we++],n=ct[we++],o=ct[we++],l=ct[we++];if((s&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){we-=8;return}if(e<10){if(e===8)return ta(t,i,r,a,s,n,o,l);{let h=ct[we++];if((h&128)>0){we-=9;return}return ta(t,i,r,a,s,n,o,l,h)}}else if(e<12){let h=ct[we++],c=ct[we++];if((h&128)>0||(c&128)>0){we-=10;return}if(e<11)return ta(t,i,r,a,s,n,o,l,h,c);let d=ct[we++];if((d&128)>0){we-=11;return}return ta(t,i,r,a,s,n,o,l,h,c,d)}else{let h=ct[we++],c=ct[we++],d=ct[we++],u=ct[we++];if((h&128)>0||(c&128)>0||(d&128)>0||(u&128)>0){we-=12;return}if(e<14){if(e===12)return ta(t,i,r,a,s,n,o,l,h,c,d,u);{let p=ct[we++];if((p&128)>0){we-=13;return}return ta(t,i,r,a,s,n,o,l,h,c,d,u,p)}}else{let p=ct[we++],f=ct[we++];if((p&128)>0||(f&128)>0){we-=14;return}if(e<15)return ta(t,i,r,a,s,n,o,l,h,c,d,u,p,f);let m=ct[we++];if((m&128)>0){we-=15;return}return ta(t,i,r,a,s,n,o,l,h,c,d,u,p,f,m)}}}}}function y1(e){return Ja.copyBuffers?Uint8Array.prototype.slice.call(ct,we,we+=e):ct.subarray(we,we+=e)}function lh(e){let t=ct[we++];if(Ga[t])return Ga[t](ct.subarray(we,we+=e));throw new Error("Unknown extension type "+t)}var PM=new Array(4096);function ED(){let e=ct[we++];if(e>=160&&e<192){if(e=e-160,Ln>=we)return Tl.slice(we-Ds,(we+=e)-Ds);if(!(Ln==0&&Fl<180))return cx(e)}else return we--,lr();let t=(e<<5^(e>1?Ei.getUint16(we):e>0?ct[we]:0))&4095,i=PM[t],r=we,a=we+e-3,s,n=0;if(i&&i.bytes==e){for(;r<a;){if(s=Ei.getUint32(r),s!=i[n++]){r=1879048192;break}r+=4}for(a+=3;r<a;)if(s=ct[r++],s!=i[n++]){r=1879048192;break}if(r===a)return we=r,i.string;a-=3,r=we}for(i=[],PM[t]=i,i.bytes=e;r<a;)s=Ei.getUint32(r),i.push(s),r+=4;for(a+=3;r<a;)s=ct[r++],i.push(s);let o=e<16?Rw(e):MD(e);return o!=null?i.string=o:i.string=cx(e)}var DM=(e,t)=>{var i=lr();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let a=xi[e];return a&&a.isShared&&((xi.restoreStructures||(xi.restoreStructures=[]))[e]=a),xi[e]=i,i.read=Ow(i,r),i.read()},CD=typeof self=="object"?self:global;Ga[0]=()=>{};Ga[0].noBuffer=!0;Ga[101]=()=>{let e=lr();return(CD[e[0]]||Error)(e[1])};Ga[105]=e=>{let t=Ei.getUint32(we-4);ko||(ko=new Map);let i=ct[we],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let a={target:r};ko.set(t,a);let s=lr();return a.used?Object.assign(r,s):(a.target=s,s)};Ga[112]=e=>{let t=Ei.getUint32(we-4),i=ko.get(t);return i.used=!0,i.target};Ga[115]=()=>new Set(lr());var TD=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ga[116]=e=>{let t=e[0],i=TD[t];if(!i)throw new Error("Could not find typed array for code "+t);return new CD[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ga[120]=()=>{let e=lr();return new RegExp(e[0],e[1])};Ga[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=we;we+=t-4,ls=[lr(),lr()],ls.position0=0,ls.position1=0;let r=we;we=i;try{return lr()}finally{we=r}};Ga[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function PD(e){let t=Fl,i=we,r=hx,a=Ds,s=Ln,n=Tl,o=lx,l=ko,h=ls,c=new Uint8Array(ct.slice(0,Fl)),d=xi,u=xi.slice(0,xi.length),p=Ja,f=Ed,m=e();return Fl=t,we=i,hx=r,Ds=a,Ln=s,Tl=n,lx=o,ko=l,ls=h,ct=c,Ed=f,xi=d,xi.splice(0,xi.length,...u),Ja=p,Ei=new DataView(ct.buffer,ct.byteOffset,ct.byteLength),m}function dx(){ct=null,ko=null,xi=null}function SY(e){e.unpack?Ga[e.type]=e.unpack:Ga[e.type]=e}var Lw=new Array(147);for(let e=0;e<256;e++)Lw[e]=+("1e"+Math.floor(45.15-e*.30103));var Vv=new Vg({useRecords:!1}),Qle=Vv.unpack,Kle=Vv.unpackMultiple,Zle=Vv.unpack,AY={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},MY=new Float32Array(1),Jle=new Uint8Array(MY.buffer,0,4),ng;try{ng=new TextEncoder}catch{}var jg,Bw,jv=typeof Buffer<"u",x1=jv?Buffer.allocUnsafeSlow:Uint8Array,DD=jv?Buffer:Uint8Array,IM=jv?4294967296:2144337920,Ue,gr,Me=0,gn,vn=null,EY=/[\u0080-\uFFFF]/,Mu=Symbol("record-id"),ID=class extends Vg{constructor(e){super(e),this.offset=0;let t,i,r,a,s,n,o=0,l=DD.prototype.utf8Write?function(E,M,T){return Ue.utf8Write(E,M,T)}:ng&&ng.encodeInto?function(E,M){return ng.encodeInto(E,Ue.subarray(M)).written}:!1,h=this;e||(e={});let c=e&&e.sequential,d=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=d?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=d?32:64),c&&!e.saveStructures&&(this.structures=[]);let f=u>32||p+u>64,m=u+64,g=u+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],x=0,b=0;this.pack=this.encode=function(E,M){if(Ue||(Ue=new x1(8192),gr=new DataView(Ue.buffer,0,8192),Me=0),gn=Ue.length-10,gn-Me<2048?(Ue=new x1(Ue.length),gr=new DataView(Ue.buffer,0,Ue.length),gn=Ue.length-10,Me=0):Me=Me+7&2147483640,i=Me,n=h.structuredClone?new Map:null,h.bundleStrings?(vn=["",""],Ue[Me++]=214,Ue[Me++]=98,vn.position=Me-i,Me+=4):vn=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let T=r.sharedLength||0;if(T>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let P=0;P<T;P++){let R=r[P];if(!R)continue;let z,U=r.transitions;for(let L=0,j=R.length;L<j;L++){let q=R[L];z=U[q],z||(z=U[q]=Object.create(null)),U=z}U[Mu]=P+64}o=T}c||(r.nextId=T+64)}a&&(a=!1),s=r||[];try{if(_(E),vn){gr.setUint32(vn.position+i,Me-vn.position-i);let T=vn;vn=null,_(T[0]),_(T[1])}if(h.offset=Me,n&&n.idsToInsert){Me+=n.idsToInsert.length*6,Me>gn&&A(Me),h.offset=Me;let T=TY(Ue.subarray(i,Me),n.idsToInsert);return n=null,T}return M&PY?(Ue.start=i,Ue.end=Me,Ue):Ue.subarray(i,Me)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,y.length>0&&(y=[]);else if(y.length>0&&!c){for(let T=0,P=y.length;T<P;T++)y[T][Mu]=0;y=[]}if(a&&h.saveStructures){let T=r.sharedLength||u;r.length>T&&(r=r.slice(0,T));let P=Ue.subarray(i,Me);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(E)):(o=T,P)}}M&DY&&(Me=i)}};let _=E=>{Me>gn&&(Ue=A(Me));var M=typeof E,T;if(M==="string"){let P=E.length;if(vn&&P>=8&&P<4096){let U=EY.test(E);vn[U?0:1]+=E,Ue[Me++]=193,_(U?-P:P);return}let R;P<32?R=1:P<256?R=2:P<65536?R=3:R=5;let z=P*3;if(Me+z>gn&&(Ue=A(Me+z)),P<64||!l){let U,L,j,q=Me+R;for(U=0;U<P;U++)L=E.charCodeAt(U),L<128?Ue[q++]=L:L<2048?(Ue[q++]=L>>6|192,Ue[q++]=L&63|128):(L&64512)===55296&&((j=E.charCodeAt(U+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),U++,Ue[q++]=L>>18|240,Ue[q++]=L>>12&63|128,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128):(Ue[q++]=L>>12|224,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128);T=q-Me-R}else T=l(E,Me+R,z);T<32?Ue[Me++]=160|T:T<256?(R<2&&Ue.copyWithin(Me+2,Me+1,Me+1+T),Ue[Me++]=217,Ue[Me++]=T):T<65536?(R<3&&Ue.copyWithin(Me+3,Me+2,Me+2+T),Ue[Me++]=218,Ue[Me++]=T>>8,Ue[Me++]=T&255):(R<5&&Ue.copyWithin(Me+5,Me+3,Me+3+T),Ue[Me++]=219,gr.setUint32(Me,T),Me+=4),Me+=T}else if(M==="number")if(E>>>0===E)E<64?Ue[Me++]=E:E<256?(Ue[Me++]=204,Ue[Me++]=E):E<65536?(Ue[Me++]=205,Ue[Me++]=E>>8,Ue[Me++]=E&255):(Ue[Me++]=206,gr.setUint32(Me,E),Me+=4);else if(E>>0===E)E>=-32?Ue[Me++]=256+E:E>=-128?(Ue[Me++]=208,Ue[Me++]=E+256):E>=-32768?(Ue[Me++]=209,gr.setInt16(Me,E),Me+=2):(Ue[Me++]=210,gr.setInt32(Me,E),Me+=4);else{let P;if((P=this.useFloat32)>0&&E<4294967296&&E>=-2147483648){Ue[Me++]=202,gr.setFloat32(Me,E);let R;if(P<4||(R=E*Lw[(Ue[Me]&127)<<1|Ue[Me+1]>>7])>>0===R){Me+=4;return}else Me--}Ue[Me++]=203,gr.setFloat64(Me,E),Me+=8}else if(M==="object")if(!E)Ue[Me++]=192;else{if(n){let R=n.get(E);if(R){if(!R.id){let z=n.idsToInsert||(n.idsToInsert=[]);R.id=z.push(R)}Ue[Me++]=214,Ue[Me++]=112,gr.setUint32(Me,R.id),Me+=4;return}else n.set(E,{offset:Me-i})}let P=E.constructor;if(P===Object)S(E,!0);else if(P===Array){T=E.length,T<16?Ue[Me++]=144|T:T<65536?(Ue[Me++]=220,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=221,gr.setUint32(Me,T),Me+=4);for(let R=0;R<T;R++)_(E[R])}else if(P===Map){T=E.size,T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,gr.setUint32(Me,T),Me+=4);for(let[R,z]of E)_(R),_(z)}else{for(let R=0,z=jg.length;R<z;R++){let U=Bw[R];if(E instanceof U){let L=jg[R];if(L.write){L.type&&(Ue[Me++]=212,Ue[Me++]=L.type,Ue[Me++]=0),_(L.write.call(this,E));return}let j=Ue,q=gr,Q=Me;Ue=null;let X;try{X=L.pack.call(this,E,ie=>(Ue=j,j=null,Me+=ie,Me>gn&&A(Me),{target:Ue,targetView:gr,position:Me-ie}),_)}finally{j&&(Ue=j,gr=q,Me=Q,gn=Ue.length-10)}X&&(X.length+Me>gn&&A(X.length+Me),Me=CY(X,Ue,Me,L.type));return}}S(E,!E.hasOwnProperty)}}else if(M==="boolean")Ue[Me++]=E?195:194;else if(M==="bigint"){if(E<BigInt(1)<<BigInt(63)&&E>=-(BigInt(1)<<BigInt(63)))Ue[Me++]=211,gr.setBigInt64(Me,E);else if(E<BigInt(1)<<BigInt(64)&&E>0)Ue[Me++]=207,gr.setBigUint64(Me,E);else if(this.largeBigIntToFloat)Ue[Me++]=203,gr.setFloat64(Me,Number(E));else throw new RangeError(E+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");Me+=8}else if(M==="undefined")this.encodeUndefinedAsNil?Ue[Me++]=192:(Ue[Me++]=212,Ue[Me++]=0,Ue[Me++]=0);else if(M==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},S=this.useRecords===!1?this.variableMapSize?E=>{let M=Object.keys(E),T=M.length;T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,gr.setUint32(Me,T),Me+=4);let P;for(let R=0;R<T;R++)_(P=M[R]),_(E[P])}:(E,M)=>{Ue[Me++]=222;let T=Me-i;Me+=2;let P=0;for(let R in E)(M||E.hasOwnProperty(R))&&(_(R),_(E[R]),P++);Ue[T+++i]=P>>8,Ue[T+i]=P&255}:E=>{let M=Object.keys(E),T,P=s.transitions||(s.transitions=Object.create(null)),R=0;for(let U=0,L=M.length;U<L;U++){let j=M[U];T=P[j],T||(T=P[j]=Object.create(null),R++),P=T}let z=P[Mu];if(z)z>=96&&f?(Ue[Me++]=((z-=96)&31)+96,Ue[Me++]=z>>5):Ue[Me++]=z;else{z=s.nextId,z||(z=64),z<m&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(z=s.nextOwnId,z<g||(z=m),s.nextOwnId=z+1):(z>=g&&(z=m),s.nextId=z+1);let U=M.highByte=z>=96&&f?z-96>>5:-1;P[Mu]=z,s[z-64]=M,z<m?(M.isShared=!0,s.sharedLength=z-63,a=!0,U>=0?(Ue[Me++]=(z&31)+96,Ue[Me++]=U):Ue[Me++]=z):(U>=0?(Ue[Me++]=213,Ue[Me++]=114,Ue[Me++]=(z&31)+96,Ue[Me++]=U):(Ue[Me++]=212,Ue[Me++]=114,Ue[Me++]=z),R&&(x+=b*R),y.length>=p&&(y.shift()[Mu]=0),y.push(P),_(M))}for(let U=0,L=M.length;U<L;U++)_(E[M[U]])},A=E=>{let M;if(E>16777216){if(E-i>IM)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(IM,Math.round(Math.max((E-i)*(E>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(E-i<<2,Ue.length-1)>>12)+1<<12;let T=new x1(M);return gr=new DataView(T.buffer,0,M),Ue.copy?Ue.copy(T,0,i,E):T.set(Ue.slice(i,E)),Me-=i,i=0,gn=T.length-10,Ue=T}}useBuffer(e){Ue=e,gr=new DataView(Ue.buffer,Ue.byteOffset,Ue.byteLength),Me=0}};Bw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,_D];jg=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:a,targetView:s,position:n}=t(6);a[n++]=214,a[n++]=255,s.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:a,targetView:s,position:n}=t(10);a[n++]=215,a[n++]=255,s.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:a,targetView:s,position:n}=t(3);a[n++]=212,a[n++]=255,a[n++]=255}else{let{target:a,targetView:s,position:n}=t(15);a[n++]=199,a[n++]=12,a[n++]=255,s.setUint32(n,e.getMilliseconds()*1e6),s.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:a,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(a[s++]=212,a[s++]=115,a[s++]=0),i(r)}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=101,r[a++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=120,r[a++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?OM(e,16,t):RM(jv?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==DD&&this.structuredClone?OM(e,TD.indexOf(i.name),t):RM(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function OM(e,t,i,r){let a=e.byteLength;if(a+1<256){var{target:s,position:n}=i(4+a);s[n++]=199,s[n++]=a+1}else if(a+1<65536){var{target:s,position:n}=i(5+a);s[n++]=200,s[n++]=a+1>>8,s[n++]=a+1&255}else{var{target:s,position:n,targetView:o}=i(7+a);s[n++]=201,o.setUint32(n,a+1),n+=4}s[n++]=116,s[n++]=t,s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function RM(e,t){let i=e.byteLength;var r,a;if(i<256){var{target:r,position:a}=t(i+2);r[a++]=196,r[a++]=i}else if(i<65536){var{target:r,position:a}=t(i+3);r[a++]=197,r[a++]=i>>8,r[a++]=i&255}else{var{target:r,position:a,targetView:s}=t(i+5);r[a++]=198,s.setUint32(a,i),a+=4}r.set(e,a)}function CY(e,t,i,r){let a=e.length;switch(a){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:a<256?(t[i++]=199,t[i++]=a):a<65536?(t[i++]=200,t[i++]=a>>8,t[i++]=a&255):(t[i++]=201,t[i++]=a>>24,t[i++]=a>>16&255,t[i++]=a>>8&255,t[i++]=a&255)}return t[i++]=r,t.set(e,i),i+=a,i}function TY(e,t){let i,r=t.length*6,a=e.length-r;for(t.sort((s,n)=>s.offset>n.offset?1:-1);i=t.pop();){let s=i.offset,n=i.id;e.copyWithin(s+r,s,a),r-=6;let o=s+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,a=s}return e}function Kd(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");Bw.unshift(e.Class),jg.unshift(e)}SY(e)}var OD=new ID({useRecords:!1}),$le=OD.pack,ehe=OD.pack,{NEVER:the,ALWAYS:ihe,DECIMAL_ROUND:rhe,DECIMAL_FIT:ahe}=AY,PY=512,DY=1024,LM=new ID({structuredClone:!0});Kd({Class:bt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,bt.prototype),e}});Kd({Class:pt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,pt.prototype),e}});Kd({Class:xa.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,xa.prototype),e}});Kd({Class:_M.prototype.constructor,type:4,write(e){return e.id},read(e){return new _M(e)}});Kd({Class:SM.prototype.constructor,type:5,write(e){return e.data},read(e){return new SM(e)}});Kd({Class:dr.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,dr.prototype),e}});function IY(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function ux(e){if(Cw(e))return e;if(Array.isArray(e))return e.map(ux);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=ux(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Hg;(e=>{function t(a){return LM.pack(a)}e.serialize=t;function i(a){return LM.unpack(a)}e.deserialize=i;function r(a){return IY(t(ux(a))).toString()}e.checksum=r})(Hg||(Hg={}));var BM;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(BM||(BM={}));function px(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var ua={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},zM;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,name:"",actions:new pt}:{type:r,disabled:!1,name:"",key:void 0,actions:new pt}}e.defaultData=i})(zM||(zM={}));var Gg;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Gg||(Gg={}));var fx;(e=>{function t(a){return{type:"Comparison",operator:"==",lOperand:Gg.propertyDefaultData(a),rOperand:{...Gg.valueDefaultData}}}e.comparisonDefaultData=t;function i(a){return{type:"Distance",toObject:a??null,fromObject:a??null,distance:200}}e.distanceDefaultData=i;function r(a,s){return{type:"State",object:a??null,state:s??null}}e.stateDefaultData=r})(fx||(fx={}));var kM;(e=>{function t(i){return i.find(r=>r==="ifActions"||r==="elseActions")!==void 0}e.isConditionalSubActions=t})(kM||(kM={}));var FM;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,name:"",inActions:new pt,outActions:new pt,condition:fx.distanceDefaultData(r)}}e.defaultData=i})(FM||(FM={}));var UM;(e=>e.defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new pt,drop:new pt}})(UM||(UM={}));var mx;(e=>e.defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new pt})(mx||(mx={}));var gx;(e=>e.defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(gx||(gx={}));var NM;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,name:"",actions:new pt}}e.defaultData=i})(NM||(NM={}));var VM;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new pt}}e.defaultData=i})(VM||(VM={}));var jM;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,name:"",actions:new pt}}e.defaultData=i})(jM||(jM={}));var HM;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new pt}}e.defaultData=i})(HM||(HM={}));var GM;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,a){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new pt,triggerZone:"box",position:a.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(GM||(GM={}));var vx;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function a(){let n={size:"mobile",operator:"<",actions:new pt},o={size:"tablet",operator:"<",actions:new pt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new pt},h=new pt;return h.push({id:tt.generateUUID(),fi:0,data:n},{id:tt.generateUUID(),fi:1,data:o},{id:tt.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:h}}e.defaultData=a;function s(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new pt}}e.defaultBreakpointData=s})(vx||(vx={}));var yx;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",name:"",actions:new pt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(yx||(yx={}));var WM;(e=>{function t(r){return r.type==="API"}e.is=t;function i(){return{disabled:!1,type:"API",name:"",successActions:new pt,errorActions:new pt,userAPIId:""}}e.defaultData=i})(WM||(WM={}));var qM;(e=>{function t(r){return r.type==="WEBHOOK"}e.is=t;function i(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new pt,userWebhookId:""}}e.defaultData=i})(qM||(qM={}));var XM;(e=>{function t(r){return r.type==="AIAssistantListener"}e.is=t;function i(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new pt,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=i})(XM||(XM={}));var YM;(e=>{function t(r){return r.type==="AIAssistantTrigger"}e.is=t;function i(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new pt}}e.defaultData=i})(YM||(YM={}));var Zd="personal camera",lp="a218fcc3-276b-49b9-b485-49037fd14f5f",OY=2960946,us=5526619,RY=(e=>(e.x="x",e.y="y",e.z="z",e))(RY||{}),kn;(e=>{function t(f,m){return f[0]===m[0]&&f[1]===m[1]}e.isEqual=t;function i(f,m,g){return[f[0]+(m[0]-f[0])*g,f[1]+(m[1]-f[1])*g]}e.lerp=i;function r(f,m){return[f[0]+m[0],f[1]+m[1]]}e.add=r;function a(f,m){return[f[0]-m[0],f[1]-m[1]]}e.sub=a;function s(f,m){return[f[0]*m[0],f[1]*m[1]]}e.multiply=s;function n(f,m){return[f[0]/m[0],f[1]/m[1]]}e.divide=n;function o(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}e.distanceSquared=o;function l(f,m){return Math.sqrt(o(f,m))}e.distance=l;function h(f,m){return f[0]*m[0]+f[1]*m[1]}e.dot=h;function c(f,m){return[f[0]*m,f[1]*m]}e.scalarMultiply=c;function d(f,m,g){let y=e.sub(m,f),x=e.sub(g,f),b=e.dot(y,x)/e.dot(y,y),_=e.scalarMultiply(y,b);return e.add(f,_)}e.projectionOnto=d;function u(f,m,g){return l(f,d(f,m,g))}e.projectionOntoDistance=u;function p(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}e.center=p})(kn||(kn={}));var Ul;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function a(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=a;function s(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=s;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(Ul||(Ul={}));var Lp;(e=>{function t(r,a){return r[0]===a[0]&&r[1]===a[1]&&r[2]===a[2]&&r[3]===a[3]}e.isEqual=t;function i(r,a,s){return[r[0]+(a[0]-r[0])*s,r[1]+(a[1]-r[1])*s,r[2]+(a[2]-r[2])*s,r[3]+(a[3]-r[3])*s]}e.lerp=i})(Lp||(Lp={}));var QM;(e=>{let t=180/Math.PI,i=Math.PI/180;function r(o){return typeof o=="number"?o*t:o}function a(o){return typeof o=="number"?o*i:o}function s(o){return[r(o[0]),r(o[1]),r(o[2])]}e.radToDeg=s;function n(o){return[a(o[0]),a(o[1]),a(o[2])]}e.degToRad=n})(QM||(QM={}));var Cd;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(a,s){for(let n=0;n<16;n++)if(a[n]!==s[n])return!1;return!0}e.isEqual=t;function i(a){return a??e.identity}e.simplify=i;function r(a,s){let n=s.slice(0);for(var o=0,l=s.length;o<l;o+=3){let h=a[3]*s[o]+a[7]*s[o+1]+a[11]*s[o+2]+a[15];n[o]=(a[0]*s[o]+a[4]*s[o+1]+a[8]*s[o+2]+a[12])/h,n[o+1]=(a[1]*s[o]+a[5]*s[o+1]+a[9]*s[o+2]+a[13])/h,n[o+2]=(a[2]*s[o]+a[6]*s[o+1]+a[10]*s[o+2]+a[14])/h}return n}e.applyMatrix4=r})(Cd||(Cd={}));var Cr;(e=>{function t(c){return typeof c=="object"&&typeof c.r=="number"&&typeof c.g=="number"&&typeof c.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}e.toRgb255a1=i;function r(c){return{r:c.r,g:c.g,b:c.b}}e.clone=r;function a(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}e.fromHex=a;function s(c){return Math.round(c.r*255)*65536+Math.round(c.g*255)*256+Math.round(c.b*255)}e.toHex=s;function n(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}e.equals=n;function o(c,d){return c.r.toFixed(2)===d.r.toFixed(2)&&c.g.toFixed(2)===d.g.toFixed(2)&&c.b.toFixed(2)===d.b.toFixed(2)}e.equalsFixed=o;function l(c,d,u){return{r:c.r+(d.r-c.r)*u,g:c.g+(d.g-c.g)*u,b:c.b+(d.b-c.b)*u}}e.lerp=l;function h(c){return ds(c)?"r"in c&&"g"in c&&"b"in c&&!("a"in c):!1}e.is=h})(Cr||(Cr={}));var _i;(e=>{e.white={...Cr.white,a:1};function t(h){return ds(h)?"r"in h&&"g"in h&&"b"in h&&"a"in h:!1}e.is=t,e.transparent={...Cr.white,a:0};function i(h){return{r:h[0],g:h[1],b:h[2],a:h[3]}}e.from0to1=i;function r(h,c){return{...Cr.fromHex(h),a:c}}e.fromHexAndA=r;function a(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:h.a}}e.toRgb255a1=a;function s(h,c){return Cr.equals(h,c)&&h.a===c.a}e.equals=s;function n(h,c){return Cr.equalsFixed(h,c)&&h.a.toFixed(2)===c.a.toFixed(2)}e.equalsFixed=n;function o(h,c,d){return{r:h.r+(c.r-h.r)*d,g:h.g+(c.g-h.g)*d,b:h.b+(c.b-h.b)*d,a:h.a+(c.a-h.a)*d}}e.lerp=o;function l({r:h,g:c,b:d,a:u}=e.white){return`rgba(${h*255}, ${c*255}, ${d*255}, ${u})`}e.toStyle=l})(_i||(_i={}));var xx;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(xx||(xx={}));var LY=(e=>(e[e.LINEAR=0]="LINEAR",e[e.EASE=1]="EASE",e[e.EASE_IN=2]="EASE_IN",e[e.EASE_OUT=3]="EASE_OUT",e[e.EASE_IN_OUT=4]="EASE_IN_OUT",e[e.CUBIC=5]="CUBIC",e[e.SPRING=6]="SPRING",e[e.ARC=7]="ARC",e[e.NONE=8]="NONE",e))(LY||{}),Wg;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Wg||(Wg={}));var qg;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(qg||(qg={}));var yl;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(yl||(yl={}));function KM(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var Vh;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Vh||(Vh={}));var Td;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}e.getZoom=t})(Td||(Td={}));var Pl;(e=>{function t(a,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof a[0]=="number"?a[0]:1,typeof a[1]=="number"?a[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof a[0]=="number"?a[0]+a[0]:1)*s,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:a.map(n=>(typeof n=="number"?n:1)*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(a,s){let n={...a};if(RD.forEach(o=>{Object.assign(n,{[o]:s[o]??a[o]})}),n.radial={...a.radial},s.radial){let o=a.radial,l=s.radial;zw.forEach(h=>{Object.assign(n.radial,{[h]:l[h]??o[h]})})}if(n.linear={...a.linear},s.linear){let o=a.linear,l=s.linear;kw.forEach(h=>{Object.assign(n.linear,{[h]:l[h]??o[h]})})}if(n.grid={...a.grid},s.grid){let o=a.grid,l=s.grid;Fw.forEach(h=>{Object.assign(n.grid,{[h]:l[h]??o[h]})})}if(n.toObject={...a.toObject},s.toObject){let o=a.toObject,l=s.toObject;Uw.forEach(h=>{Object.assign(n.toObject,{[h]:l[h]??o[h]})})}if(n.randomnessObject={...a.randomnessObject},s.randomnessObject){let o=a.randomnessObject,l=s.randomnessObject;Nw.forEach(h=>{Object.assign(n.randomnessObject,{[h]:l[h]??o[h]})})}return n}e.merge=i;function r(a){return!!(a.randomnessObject||a.toObject)}e.isPartial=r})(Pl||(Pl={}));var bx;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,a){let s=[];r.count!==void 0&&s.push({type:0,path:a,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&s.push({type:0,path:[...a,n],props:o})}return s}e.toOps=i})(bx||(bx={}));var RD=["count"],zw=["radius","start","end","position","scale","rotation"],kw=["position","scale","rotation"],Fw=["count","size"],Uw=["count","position","scale","rotation"],Nw=["strength","scale","rotation","position","movement","seed","freqScale"],wx;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(wx||(wx={}));var _x;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:_i.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:_i.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:_i.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(_x||(_x={}));var Xg;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.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:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}))(Xg||(Xg={}));var Pd;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Pd||(Pd={}));var BY=(e=>(e[e.Front=0]="Front",e[e.Back=1]="Back",e[e.Double=2]="Double",e))(BY||{}),Sx;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Sx||(Sx={}));var Ax;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Ax||(Ax={}));var Mx;(e=>e.defaultData={...Ax.defaultData,...Sx.defaultData})(Mx||(Mx={}));var ZM;(e=>{function t(i,r){let a=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&a.push(s)}else if("materials"in i)for(let s of i.materials){let n=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;n&&a.push(n)}return a}e.getMaterialData=t})(ZM||(ZM={}));var Yg;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Yg||(Yg={}));var JM;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(JM||(JM={}));function zY(e){return e.type!=="displace"}var $M;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})($M||($M={}));var kY=(e=>(e[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Polar=2]="Polar",e))(kY||{}),FY=(e=>(e[e.RepeatWrapping=1e3]="RepeatWrapping",e[e.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",e[e.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",e))(FY||{}),UY=(e=>(e[e.NearestFilter=1003]="NearestFilter",e[e.LinearFilter=1006]="LinearFilter",e[e.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",e))(UY||{}),NY=(e=>(e[e.UV=0]="UV",e[e.Planar=1]="Planar",e[e.Spherical=2]="Spherical",e[e.Cylindrical=3]="Cylindrical",e[e.Triplanar=4]="Triplanar",e))(NY||{}),VY=(e=>(e[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",e))(VY||{}),jY=(e=>(e[e.F1=0]="F1",e[e.F2=1]="F2",e[e.F2MinusF1=2]="F2MinusF1",e[e.SmoothBlend=3]="SmoothBlend",e[e.Edge=4]="Edge",e[e.Power=5]="Power",e[e.Lines=6]="Lines",e[e.Cells=7]="Cells",e))(jY||{}),HY=(e=>(e[e.Lights=0]="Lights",e[e.Static=1]="Static",e[e.Camera=2]="Camera",e))(HY||{}),GY=(e=>(e[e.Circle=0]="Circle",e[e.Ring=1]="Ring",e[e.Polygon=2]="Polygon",e[e.Cross=3]="Cross",e[e.Diamond=4]="Diamond",e[e.Checkerboard=5]="Checkerboard",e[e.Line=6]="Line",e[e.Wave=7]="Wave",e))(GY||{}),LD=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],WY=["wrapping","image","video","name","minFilter","magFilter"],yr;(e=>{function t(n,o){let{texture:l,...h}=o;if(Object.assign(n,h),l){let c=n.texture;c&&Object.assign(c,l)}}e.patch=t;function i(n){return{...e.defaultData("color"),color:n}}e.defaultColorLayer=i;function r(n,o){return n==="light"&&o?a(o):s(n)}e.defaultData=r;function a(n){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){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 s(n){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){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:Yg.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...o,type:"color",color:Cr.fromHex(us)};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:{...Cr.fromHex(6710886),a:1},colorB:{...Cr.fromHex(6710886),a:1},colorC:{...Cr.fromHex(16777215),a:1},colorD:{...Cr.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:_i.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:_i.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:_i.fromHexAndA(0,1),contourColor:_i.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:{...Cr.fromHex(0),a:1},colorB:{...Cr.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}}}})(yr||(yr={}));var sa;(e=>{function t(d){return!d.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(d){let u="";return d.layers.forEach(p=>{Object.entries(p.data).forEach(([f,m])=>{u+=`${f}${m}`,Array.isArray(m)?m.forEach(g=>u+=`${g}`):typeof m=="object"?Object.values(m).forEach(g=>{typeof g=="number"?u+=`${g.toFixed(4)}`:u+=`${g}`}):u+=`${m}`})}),u}e.getHash=i;function r(){return{layers:new pt}}e.defaultEmptyData=r;function a(d="layer1",u="layer2"){return n("phong",d,u)}e.defaultData=a;function s(d,u){return{...d,name:u}}e.withName=s;function n(d,u="layer1",p="layer2",f=Cr.fromHex(16777215)){let m=new pt;return m.push({fi:0,data:yr.defaultData("light",d),id:u}),m.push({fi:1,data:yr.defaultData("color"),id:p}),{layers:m}}e.defaultTwoLayerData=n;function o(d,u,p="layer1",f="layer2"){let m=new pt;return m.push({fi:0,data:yr.defaultData("light",u),id:p}),m.push({fi:1,data:yr.defaultColorLayer(d),id:f}),{layers:m}}e.defaultColorMaterial=o;function l(d){let u=yr.defaultData("texture");d&&Object.assign(u.texture,{image:d});let p=new pt;return p.push({fi:0,data:u,id:"layer1"}),p.push({fi:1,data:{...yr.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...yr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}e.defaultUIObjectMaterial=l;function h(d,u="phong",p="layer1",f="layer2"){let m=yr.defaultData("texture");Object.assign(m.texture,{image:d});let g=new pt;return g.push({fi:0,data:m,id:p}),g.push({fi:1,data:yr.defaultData("light",u),id:f}),{layers:g}}e.defaultTwoLayerTextureData=h;function c(d,u="phong",p="layer1",f="layer2"){let m=yr.defaultData("video");Object.assign(m.texture,{video:d});let g=new pt;return g.push({fi:0,data:m,id:p}),g.push({fi:1,data:yr.defaultData("light",u),id:f}),{layers:g}}e.defaultTwoLayerVideoTextureData=c})(sa||(sa={}));var Qg;(e=>{function t(){return{points:new pt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Qg||(Qg={}));var Kg;(e=>{function t(){return{points:new pt,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}e.defaultData=t})(Kg||(Kg={}));var Yc={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Ex;(e=>{function t(i,r){let a={...i};return Vw.forEach(s=>{Object.assign(a,{[s]:r[s]??i[s]})}),a}e.merge=t})(Ex||(Ex={}));var BD={shape:Yc,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},Vw=["depth","offset","angle","twist","startScale","endScale"],Zg;(e=>{function t(a){return a==="PolygonGeometry"||a==="RectangleGeometry"||a==="StarGeometry"||a==="TriangleGeometry"||a==="EllipseGeometry"||a==="UIGeometry"}e.is2DParametricMesh=t;function i(a){return a==="PolygonGeometry"||a==="RectangleGeometry"||a==="StarGeometry"||a==="TriangleGeometry"||a==="EllipseGeometry"||a==="PathGeometry"||a==="VectorGeometry"||a==="ConeGeometry"||a==="CubeGeometry"||a==="CylinderGeometry"||a==="DodecahedronGeometry"||a==="HelixGeometry"||a==="IcosahedronGeometry"||a==="LatheGeometry"||a==="PyramidGeometry"||a==="SphereGeometry"||a==="PlaneGeometry"||a==="BackdropGeometry"||a==="TorusGeometry"||a==="TorusKnotGeometry"||a==="BooleanGeometry"||a==="TextGeometry"||a==="InputGeometry"}e.isParametricMesh=i;function r(a){return a==="PolygonGeometry"||a==="RectangleGeometry"||a==="StarGeometry"||a==="TriangleGeometry"||a==="EllipseGeometry"||a==="PathGeometry"||a==="VectorGeometry"||a==="ConeGeometry"||a==="CubeGeometry"||a==="CylinderGeometry"||a==="DodecahedronGeometry"||a==="HelixGeometry"||a==="IcosahedronGeometry"||a==="LatheGeometry"||a==="PyramidGeometry"||a==="SphereGeometry"||a==="PlaneGeometry"||a==="BackdropGeometry"||a==="TorusGeometry"||a==="TorusKnotGeometry"||a==="TextGeometry"||a==="SubdivGeometry"||a==="NonParametricGeometry"}e.isSwappableGeometry=r})(Zg||(Zg={}));var Cx;(e=>{function t(i,r){let a={...i};return Object.assign(a,r),a.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(a.extrusion={...i.extrusion},Object.assign(a.extrusion,Ex.merge(a.extrusion,r.extrusion))),a}e.merge=t})(Cx||(Cx={}));var bl;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Kg.defaultData(),extrusion:BD};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Qg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(bl||(bl={}));var b1=["width","height","depth"],Tx;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Cr.white,near:.1,far:2e3})(Tx||(Tx={}));var Jg;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(Jg||(Jg={}));var Px;(e=>e.defaultData={softShadowQuality:"low"})(Px||(Px={}));var Dx;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Dx||(Dx={}));var Ix;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Ix||(Ix={}));var Dd;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Dd||(Dd={}));var Ox;(e=>e.defaultData={playCamera:Zd,gameControlObject:null})(Ox||(Ox={}));var Rx;(e=>e.defaultData={backgroundColor:_i.fromHexAndA(OY,1),postprocessing:Jg.defaultData,fog:Tx.defaultData,globalPhysics:Dd.defaultData,ambient:Dx.defaultData,ao:Ix.defaultData,shadow:Px.defaultData,publish:Ox.defaultData})(Rx||(Rx={}));var Lx;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Lx||(Lx={}));var eE;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(eE||(eE={}));var Id;(e=>{e.identity={...xx.identity,hiddenMatrix:Cd.identity};function t(a){return{position:a.position,rotation:a.rotation,scale:a.scale,pivot:a.pivot,pivotRotation:a.pivotRotation,hiddenMatrix:a.hiddenMatrix}}e.fromObject=t;function i(a,s){return{position:s?.position||a.position,rotation:s?.rotation||a.rotation,pivot:s?.pivot||a.pivot,pivotRotation:s?.pivotRotation||a.pivotRotation,scale:s?.scale||a.scale,hiddenMatrix:s?.hiddenMatrix||a.hiddenMatrix}}e.merge=i;function r(a,s){return rD({position:Ul.isEqual(a.position,s.position)?void 0:s.position,rotation:Ul.isEqual(a.rotation,s.rotation)?void 0:s.rotation,scale:Ul.isEqual(a.scale,s.scale)?null:s.scale,hiddenMatrix:Cd.isEqual(a.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}e.diff=r})(Id||(Id={}));var qY=["slide","offset"],Wr;(e=>e.defaultData={states:new pt,events:new pt,timelineAnimations:new bt,visible:!0,raycastLock:!1,physics:Pd.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Id.identity,cloner:null})(Wr||(Wr={}));var Bx;(e=>e.defaultData={type:"Empty",...Wr.defaultData})(Bx||(Bx={}));var tE;(e=>e.defaultData={type:"ParticleCollider",...Lx.defaultData,...Wr.defaultData})(tE||(tE={}));var iE;(e=>e.defaultData={type:"Component",...Wr.defaultData})(iE||(iE={}));var rE;(e=>e.defaultData={type:"Particle",...Wr.defaultData,...Xg.defaultData})(rE||(rE={}));var wl;(e=>e.defaultData={type:"Mesh",...Wr.defaultData,...Mx.defaultData})(wl||(wl={}));var Bp;(e=>e.defaultData={...Wr.defaultData,...Id.identity,position:[0,0,Td.DefaultTargetOffset],...Td.defaultData})(Bp||(Bp={}));var zx;(e=>{function t(i){return{...Wr.defaultData,..._x.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(zx||(zx={}));var $g;(e=>{function t(r,a,s=0){for(;s<a.length;){let n=r?r[a[s]]:void 0;if(a.length===s+1)return n;if(n)r=n.descendants,s+=1;else return}}e.resolveWithDes=t;function i(r,a,s=0){let n=t(r,a,s);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})($g||($g={}));var Dl;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,a){return{...Wr.defaultData,...a,component:r,overrides:new dr,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let a=Id.fromObject(r.data);return t(r.id,a)}e.fromComponentData=i})(Dl||(Dl={}));var Od;(e=>{e.defaultData={type:"Page",...Wr.defaultData,physics:{...Pd.defaultData,fusedBody:!1},...Rx.defaultData,camera:Bp.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(Od||(Od={}));var kx;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:Cd.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Pd.defaultData,states:new pt,events:new pt,timelineAnimations:new bt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Td.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("RectangleGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("BooleanGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultShapeBlendObject={name:"Shape Blend",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("ShapeBlendGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("TextGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultInputObject={name:"Input",...Wr.defaultData,...wl.defaultData,geometry:bl.defaultData("InputGeometry"),material:sa.defaultTwoLayerData("phong","layer1","layer2")}))(kx||(kx={}));var Il;(e=>{function t(s,n){let o={name:n};return s.type==="Mesh"?(o.geometry={},"material"in s&&(o.material={layers:new dr}),"materials"in s&&(o.materials=s.materials.map(l=>({layers:new dr})))):Vh.is(s.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(s,n){if(n===void 0)return s;let o={...s};return"material"in o&&"material"in n&&n.material&&(o.material=Rp(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let d=l.layers.data(h);d&&yr.patch(d,c)}}).data),o.materials&&n.materials&&(o.materials=Rp(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let c=n.materials[h];if(typeof c!="string")for(let[d,u]of Object.entries(c.layers)){let p=l[h]?.layers?.data(d);p&&yr.patch(p,u)}}}).data),o}function r(s,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function c(d,u){for(let[p,f]of Object.entries(u.layers)){let{texture:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...d,"layers",p,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",p],props:g,type:0};l.push(y)}}}for(let[d,u]of Object.entries(n))if(d!=="name")if(d==="cloner")l.push(...bx.toOps(u,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:u.slide,offset:u.offset},type:0});else if(d==="material")c(["material"],u);else if(d==="materials")for(let[p,f]of Object.entries(u))c(["materials",p],f);else if(h[d]===0){if(d==="geometry"&&u.extrusion!==void 0){let p={path:[d,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[d],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[d]=u;return l}e.toOps=r;function a(s,n){if(n===void 0)return s;let o={...s};if(Object.assign(o,Id.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Vh.is(s.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:Cx.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Pl.merge(o.cloner,n.cloner)});else if(s.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Pl.merge(o.cloner,n.cloner)});else if(wx.is(s.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Cr.clone(l.color))}return o}e.patch=a})(Il||(Il={}));var ev;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ev||(ev={}));var Bo;(e=>e.defaultData={orbitControls:ev.defaultData,playPage:lp,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,a=0;return i<5?a=-30:i<10&&(a=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,a],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Bo||(Bo={}));var Fx;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Fx||(Fx={}));var Ux;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Ux||(Ux={}));var Ah;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Fx.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Ux.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ah||(Ah={}));var zp;(e=>{function t(r){return r.find(a=>a.data.type==="Page"&&a.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,a,s){r.scene.objects.traverseFrom(a,(n,o)=>{if(o.type==="Instance"){let l=Lh.getComponentData(r,o.component)?.data;l&&s(n,o,l.events)}else s(n,o,o.events)})}e.traverseModuleInstances=i})(zp||(zp={}));var Mh;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:zx.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function t(a=!0,s=[]){let n=[],o=kx.defaultMeshObject;a&&(n.push({...e.defaultLight}),n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:o,children:[]})),n.push(...s);let l=new xa;return l.push({fi:1,id:lp,data:{...Od.defaultData,name:"Scene 1"},children:n}),l}e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:Bo.defaultData,styles:Ah.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new xa,publish:Bo.defaultData,styles:Ah.defaultData()}},e.emptyDataWithPage=function(a=!0){return{objects:t(a),publish:Bo.defaultData,styles:Ah.defaultData()}},e.emptyData=function(){return{objects:new xa,publish:{...Bo.defaultData},styles:Ah.defaultData()}};function i(a){return{...e.defaultData,objects:rs(a,xa.prototype)}}e.withObjs=i;function r(a,s){return i([{id:a,data:s,children:[],fi:0}])}e.withObj=r})(Mh||(Mh={}));var hp;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(hp||(hp={}));var Nx;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new pt}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(Nx||(Nx={}));var aE;(e=>e.defaultData=(t,i="GET")=>({url:t,method:i,name:"New API",headers:new pt,queries:new pt,autoStart:!0}))(aE||(aE={}));var ba;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function a(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=a;function s(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=s})(ba||(ba={}));var Vx;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Vx||(Vx={}));var sE;(e=>e.all=[...Vx.all,"components"])(sE||(sE={}));var nE;(e=>{function t(){return{images:new bt,videos:new bt,colors:new bt,audios:new bt,particles:new bt,fonts:new bt,materials:new bt,components:new bt,variables:new bt,userAPIs:new bt,userWebhooks:new bt,timelineAnimations:new bt}}e.defaultData=t})(nE||(nE={}));var Ho;(e=>{function t(){return{images:new bt,videos:new bt,colors:new bt,audios:new bt,particles:new bt,fonts:new bt,materials:new bt,components:new bt,variables:new bt,userAPIs:new bt,userWebhooks:new bt,timelineAnimations:new bt}}e.defaultData=t})(Ho||(Ho={}));var Is;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},rs(n,bt.prototype)}e.defaultColors=t;function i(){return rs({},bt.prototype)}e.defaultImages=i;function r(){return{catelogs:new bt,materials:new bt,images:new bt,videos:new bt,colors:new bt,timelineAnimations:new bt,audios:new bt,particles:new bt,fonts:new bt,variables:new pt,userAPIs:new bt,userWebhooks:new bt,lib:Ho.defaultData()}}e.emptyData=r;function a(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=a;function s(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=s})(Is||(Is={}));var tv;(e=>e.list=["idle","move","jump","run"])(tv||(tv={}));var iv;(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 pt,move:new pt,jump:new pt,run:new pt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:_i.fromHexAndA(3728051,1)}}))(iv||(iv={}));function oE(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,a=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)a.push(a[1]),s.push(1);let n={...Vn(br(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:a,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...br(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function _l(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Sl(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((a,s)=>{a===void 0&&(r.materials[s]=sa.defaultData(),a=r.materials[s]),typeof a!="string"&&t(a)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=sa.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=sa.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(a=>{a.material&&typeof a.material!="string"&&Object.getPrototypeOf(a.material)!==dr.prototype&&t(a.material)})})}function XY(e){Object.assign(e.scene.publish,{orbitControls:{...ev.defaultData,...br(e.scene.publish.orbitControls)}})}function YY(e){Object.assign(e.scene.publish.settings,{video:{...Bo.defaultData.settings.video,...br(e.scene.publish.settings.video)}})}function QY(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[a,s]of Object.entries(r))if((LD.includes(a)||typeof s=="boolean")&&delete r[a],a==="texture")for(let[n,o]of Object.entries(s))(WY.includes(n)||typeof o=="boolean")&&delete s[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(a=>{let s=a;s.material?t(s.material):s.materials&&s.materials.forEach(n=>{t(n)})})})}function KY(e){e.scene.publish.withBackground=!0}function ZY(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function JY(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(a=>a+1),r.linear.scale=r.linear.scale.map(a=>a+1))})}function $Y(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function eQ(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let a=br(e.scene.objects.data(r));a&&a.type==="Mesh"&&a.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=br(i).booleanExclude!==!0)}})}function tQ(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function iQ(e){function t(r){Object.setPrototypeOf(r,dr.prototype),r.texture&&Object.setPrototypeOf(r.texture,dr.prototype)}function i(r){Object.setPrototypeOf(r,dr.prototype);for(let a in r)t(r[a])}e.scene.objects.traverse((r,a)=>{a.states.forEach(s=>{let n=s;if(n.material){let o=br(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=br(l).layers;i(h),l.layers=h}})})}function lE(e){e.layers===void 0&&Object.assign(e,sa.defaultTwoLayerData("lambert"))}function w1(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let a={...br(t),colors:i,steps:r};Object.assign(t,a)}})}function rQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function hE(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&w1(r)}):"material"in i&&typeof i.material!="string"&&w1(i.material)}),Object.values(e.shared.materials).forEach(t=>w1(t))}function aQ(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function sQ(e){e.shared.audios=rs({},bt.prototype)}function nQ(e){e.shared.videos=rs({},bt.prototype)}function oQ(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let a={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:a})}})}function lQ(e){Object.entries(br(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(br(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function hQ(e){e.scene.publish.settings.web.preload=!1}function cE(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function dE(e){e.layers&&e.layers.forEach(t=>{zY(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 cQ(e){e.shared.fonts=rs({},bt.prototype)}function dQ(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function uQ(e){let t=[];e.scene.objects.traverse((i,r)=>{let a=r;if(a.type==="TextFrame"){let s=sa.defaultTwoLayerData("phong"),n=typeof a.color=="string"?e.shared.colors[a.color]:a.color;s.layers[1].data.color={r:n.r,g:n.g,b:n.b},s.layers[1].data.alpha=a.alpha;let o=dQ(a.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:a.name,...Wr.defaultData,...wl.defaultData,flatShading:!1,wireframe:!1,geometry:{...bl.defaultData("TextGeometry"),width:a.width,height:a.height,font:o,depth:0,horizontalAlign:a.horizontalAlign,verticalAlign:a.verticalAlign,fontSize:a.fontSize*1.40625,lineHeight:a.lineHeight/1.40625,letterSpacing:a.letterSpacing-1,text:a.text,textTransform:a.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:br(a.states),events:br(a.events),visible:a.visible,raycastLock:a.raycastLock,position:a.position,rotation:a.rotation,scale:a.scale,hiddenMatrix:a.hiddenMatrix},h=br(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function pQ(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(a=>{if(t[Number(a.type)])if(Object.assign(a,{type:t[Number(a.type)]}),a.type==="Audio"&&"audioEvent"in a&&(Object.assign(a,{playAudio:a.audioEvent}),delete a.audioEvent),a.type==="GameControl")Object.assign(a,{gameActions:{idle:new pt,move:new pt,jump:new pt}});else{let s=new pt;Object.assign(a,{actions:s}),(a.type==="MouseDown"||a.type==="MouseUp"||a.type==="KeyDown"||a.type==="KeyUp")&&"url"in a&&s.push({fi:0,id:tt.generateUUID(),data:{type:"Link",url:a.url,delay:0}}),"targets"in a&&(a.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Vn(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let d={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},u={state:n.state,...d,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new pt({fi:0,id:tt.generateUUID(),data:h},{fi:1,id:tt.generateUUID(),data:u})};s.push({fi:l,id:o,data:p})}),delete a.targets)}})})}function fQ(e){e.scene.objects.traverse((t,i)=>{function r(a,s){let n=new pt,o=[];if(i.events.forEach((l,h,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;o.push(h),l.interaction==="play"?d={...Vn(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")&&(d={...Vn(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&n.push({fi:c,id:h,data:d})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===a)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:tt.generateUUID(),data:{type:a,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function uE(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=yr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function pE(e){_l(e,uE),Sl(e,uE)}function mQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function gQ(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function vQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=sa.defaultTwoLayerData("phong"))})}function yQ(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function xQ(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function bQ(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function wQ(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function _Q(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function SQ(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function AQ(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=iv.defaultDataThirdPerson.navmesh)})})}function MQ(e){e.scene.styles||(e.scene.styles=Ah.defaultData())}function fE(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function EQ(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Sl(e,fE),_l(e,fE)}function CQ(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new pt})})})}function TQ(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function mE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function PQ(e,t){if(t<1&&(Sl(e,oE),_l(e,oE),e.schema=1),t<2&&(XY(e),e.schema=2),t<3&&(QY(e),e.schema=3),t<4&&(KY(e),e.schema=4),t<5&&(ZY(e),e.schema=5),t<6&&(JY(e),e.schema=6),t<7&&($Y(e),e.schema=7),t<8&&(e.schema=8),t<9&&(hE(e),e.schema=9),t<10&&(rQ(e),e.schema=10),t<11&&(aQ(e),e.schema=11),t<12&&(hE(e),e.schema=12),t<13&&(sQ(e),e.schema=13),t<14&&(oQ(e),e.schema=14),t<15&&(lQ(e),e.schema=15),t<16&&(hQ(e),e.schema=16),t<17&&(Sl(e,cE),_l(e,cE),e.schema=17),t<18&&(Sl(e,lE),_l(e,lE),e.schema=18),t<19&&(YY(e),e.schema=19),t<20&&(cQ(e),uQ(e),e.schema=20),t<21&&(pQ(e),fQ(e),e.schema=21),t<22&&(pE(e),e.schema=22),t<23&&(mQ(e),e.schema=23),t<24&&(gQ(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(nQ(e),t<25&&(e.schema=25)),t<26&&(eQ(e),e.schema=26),t<27&&(tQ(e),e.schema=27),t<28&&(pE(e),e.schema=28),t<29&&(iQ(e),e.schema=29),t<30&&(vQ(e),e.schema=30),t<31&&(yQ(e),e.schema=31),t<33&&(xQ(e),e.schema=33),t<34&&(bQ(e),e.schema=34),t<35&&(wQ(e),e.schema=35),t<36&&(_Q(e),e.schema=36),t<37&&(SQ(e),e.schema=37),t<38&&(Sl(e,dE),_l(e,dE),e.schema=38),t<39&&(AQ(e),e.schema=39),t<40&&(MQ(e),e.schema=40),t<41&&(EQ(e),e.schema=41),t<42&&(CQ(e),e.schema=42),t<43&&(TQ(e),e.schema=43),t<99){Sl(e,mE),_l(e,mE),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Zd);let i=br(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=lp,r.insertBefore(null,null,[{id:lp,data:{...Od.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Vn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Vn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Dd.defaultData,...Vn(e.scene.environment,"usePhysics","gravity")},camera:br(e.scene.ownerCamera)??Od.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Mh.TRASH_CAN_ID&&r.move(lp,n.fi,n.id);let a=0,s=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(a,2)],a+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(s,1)],s+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,Pd.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function gE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function DQ(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function IQ(e){Array.isArray(br(e.events))&&e.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Qc=180/Math.PI;function vE(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Qc)}function zD(e){vE(e),e.type==="Page"&&vE(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Qc))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Qc),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Qc),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Qc,t.extrusion.twist*=Qc),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(br(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function OQ(e){e.shared.variables=rs({},bt.prototype)}function RQ(e){let t=br(e.shared.variables);e.shared.variables=rs(Object.entries(t??{}).map(([i,r],a)=>({fi:a,id:i,data:r})),pt.prototype)}var Ao=122;function og(e,t){t(e.data);for(let i of e.children)og(i,t)}function LQ(e){let t=e.schema??104;t!==Ao&&(t<105&&(og(e.asset,zD),e.schema=105),t<118&&(og(e.asset,kD),e.schema=118),t<121&&(og(e.asset,jx),e.schema=121))}function BQ(e){e.shared.particles=rs({},bt.prototype),e.shared.lib&&(e.shared.lib.particles=Ho.defaultData().particles)}function zQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function kQ(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function FQ(e){e.scene.objects.traverse((t,i)=>{Array.isArray(br(i.events))!==!1&&i.events?.forEach(r=>{let a=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=a??"Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode=a==="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(s=>{r.gameActions[s]?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),n.type==="Animation"&&(n.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(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.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 UQ(e){e.shared.userAPIs=rs({},bt.prototype),e.shared.userWebhooks=rs({},bt.prototype),e.shared.lib&&(e.shared.lib.userAPIs=Ho.defaultData().userAPIs,e.shared.lib.userWebhooks=Ho.defaultData().userWebhooks)}function NQ(e){e.scene.publish.settings.videoStatic===void 0&&(e.scene.publish.settings.videoStatic=Bo.defaultData.settings.videoStatic)}function kD(e){e.timelineAnimations=rs({},bt.prototype)}function jx(e){e.pivot=[0,0,0],e.pivotRotation=[0,0,0]}function FD(e){let t=e.schema??0;if(t!==Ao){console.warn("updating from ",t,"to ",Ao),PQ(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Bo.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Sl(e,gE),_l(e,gE),e.schema=101),t<102&&(DQ(e),e.schema=102),t<104&&(e.shared.catelogs=new bt,e.shared.lib=Ho.defaultData(),e.schema=104),t<105&&(OQ(e),e.scene.objects.traverse((i,r)=>{zD(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))LQ(i);t<106&&(RQ(e),e.schema=106),t<107&&(e.shared.lib.variables=Ho.defaultData().variables,e.schema=107),t<109&&(BQ(e),e.schema=109),t<110&&(zQ(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{IQ(r)}),e.schema=111),t<112&&(kQ(e),e.schema=112),t<113&&(FQ(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(UQ(e),e.schema=115),t<116&&(NQ(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117),t<118&&(e.shared.timelineAnimations=rs({},bt.prototype),e.scene.objects.traverse((i,r)=>{kD(r)}),e.schema=118),t<119&&(e.scene.publish.settings.videoStatic.format=Lh.defaultData.scene.publish.settings.videoStatic.format,e.scene.publish.settings.videoStatic.imageFormat=Lh.defaultData.scene.publish.settings.videoStatic.imageFormat,e.schema=119),t<120&&(e.scene.publish.settings.image.colorSpace="display-p3",e.scene.publish.settings.videoStatic.colorSpace="display-p3",e.schema=120),t<121&&(e.scene.objects.traverse((i,r)=>{jx(r),r.type==="Page"&&jx(r.camera)}),e.schema=121),t<122&&(delete e.scene.publish.settings.video,e.scene.publish.orbitControls.rotationSpeed=Lh.defaultData.scene.publish.orbitControls.rotationSpeed,e.schema=122)}}var Lh;(e=>{e.defaultData={schema:Ao,scene:Mh.defaultData,frames:new bt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hp.defaultData),shared:{...Is.emptyData(),colors:Is.defaultColors()}},e.emptyDataForImports=function(){let s=Mh.emptyDataWithPage();return{schema:Ao,scene:s,frames:new bt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hp.defaultData),shared:{...Is.emptyData(),colors:Is.defaultColors(),images:Is.defaultImages()}}},e.emptyData=function(){return{schema:Ao,scene:Mh.emptyDataWithPage(),frames:new bt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hp.defaultData),shared:Is.emptyData()}},e.clipboard2dData=function(){return{schema:Ao,scene:Mh.emptyData(),frames:new bt,shared:Is.emptyData()}},e.collabHelper={...nx,updateSchema(s){return(s.schema??0)<Ao?Rp(s,FD):(s.schema??0)-Ao}};function t(s){let n=e.collabHelper.updateSchema(s);return typeof n=="number"?n===0?s:null:n.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:Ho.defaultData()}}}e.withoutLib=i;function r(s,n){let o=s.scene.objects.get(n);if(o&&o.data.type==="Component")return o;{let l=s.shared.lib.components[n];if(l)return{...l.asset,id:n}}}e.getComponentData=r;function a(s){let n=Object.values(s.shared.userAPIs);for(let o of n){let l=o.headers;for(let h of l)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}e.hasSensitiveData=a})(Lh||(Lh={}));var Hx;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Hx||(Hx={}));var yE;(e=>{function t(i){return!0}e.is=t})(yE||(yE={}));var rv;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,a){return{position:a?.position??r.position,rotation:a?.rotation??r.rotation,scale:a?.scale??r.scale,shear:a?.shear??r.shear}}e.merge=t;function i(r,a){return rD({position:kn.isEqual(r.position,a.position)?void 0:a.position,rotation:r.rotation===a.rotation?void 0:a.rotation,scale:kn.isEqual(r.scale,a.scale)?void 0:a.scale,shear:r.shear&&a.shear&&kn.isEqual(r.shear,a.shear)?void 0:a.shear})}e.diff=i})(rv||(rv={}));var Gx;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(Gx||(Gx={}));var xE;(e=>e.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(xE||(xE={}));var av;(e=>e.defaultData={opacity:1,fill:{color:_i.fromHexAndA(us,1),enabled:!0},stroke:{color:_i.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:_i.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:_i.from0to1([0,0,0,1]),enabled:!1,spread:0}})(av||(av={}));var Eh;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function a(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,rv.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=a;function s(n,o){let l,h=[];for(let[c,d]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=d);return h}e.toOps=s})(Eh||(Eh={}));var kp;(e=>e.defaultData={...rv.defaultData,...Gx.defaultData,states:new pt,events:new pt,visible:!0,raycastLock:!1})(kp||(kp={}));var Rd;(e=>e.defaultData={...kp.defaultData,...av.defaultData})(Rd||(Rd={}));var sv;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(sv||(sv={}));var Wx;(e=>e.defaultData={...Rd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Wx||(Wx={}));var Fp;(e=>e.defaultData={...Rd.defaultData,...sv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Fp||(Fp={}));var qx;(e=>e.defaultData={...Rd.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"})(qx||(qx={}));var Xx;(e=>e.defaultData={...Rd.defaultData,type:"path2d",path:"",name:"Path"})(Xx||(Xx={}));var bE;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(bE||(bE={}));var nv;(e=>e.defaultData={...kp.defaultData,name:"Group",type:"group2d"})(nv||(nv={}));var Yx;(e=>e.defaultData=()=>({...kp.defaultData,...sv.defaultData,...av.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:_i.fromHexAndA(4737101,1),enabled:!0},stroke:{color:_i.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(Yx||(Yx={}));var Bh;(e=>{function t(n){switch(n){case"rectangle2d":return{...Fp.defaultData};case"ellipse2d":return{...Wx.defaultData};case"text2d":return{...qx.defaultData};case"vector2d":return{...Fp.defaultData};case"path2d":return{...Xx.defaultData};case"frame2d":return{...Yx.defaultData()};case"group2d":return{...nv.defaultData}}}e.defaultData=t;function i(n){return"width"in n&&"height"in n?[typeof n.width=="number"?n.width*.5:0,typeof n.height=="number"?n.height*.5:0]:[0,0]}e.getPivot=i;function r(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"}e.isResizeable=r;function a(n){return n.type==="frame2d"&&n.autoLayout!==void 0}e.isAutoLayoutable=a;function s(n){return n.type==="rectangle2d"||n.type==="frame2d"}e.hasCorners=s})(Bh||(Bh={}));var Qx;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new xa},e.emptyData=function(){return{type:"scene2d",objects:new xa}}))(Qx||(Qx={}));function Ch(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),a=new Set(Object.keys(e[0].morphAttributes)),s={},n={},o=e[0].morphTargetsRelative,l=new vt,h=0;for(let c=0;c<e.length;++c){let d=e[c],u=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(d.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in d.morphAttributes){if(!a.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(d.morphAttributes[p])}if(t){let p;if(i)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(i){let c=0,d=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+c);c+=e[u].attributes.position.count}l.setIndex(d)}for(let c in s){let d=wE(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in n){let d=n[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let u=0;u<d;++u){let p=[];for(let m=0;m<n[c].length;++m)p.push(n[c][m][u]);let f=wE(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function wE(e){let t,i,r,a=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;a+=l.array.length}let s=new t(a),n=0;for(let o=0;o<e.length;++o)s.set(e[o].array,n),n+=e[o].array.length;return new Pt(s,i,r)}var UD={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},jw={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},VQ=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Ld={CSS:{},springs:{}};function rn(e,t,i){return Math.min(Math.max(e,t),i)}function cp(e,t){return e.indexOf(t)>-1}function _1(e,t){return e.apply(null,t)}var zt={arr:function(e){return Array.isArray(e)},obj:function(e){return cp(Object.prototype.toString.call(e),"Object")},pth:function(e){return zt.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||zt.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return zt.hex(e)||zt.rgb(e)||zt.hsl(e)},key:function(e){return!UD.hasOwnProperty(e)&&!jw.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function ND(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function VD(e,t){var i=ND(e),r=rn(zt.und(i[0])?1:i[0],.1,100),a=rn(zt.und(i[1])?100:i[1],.1,100),s=rn(zt.und(i[2])?10:i[2],.1,100),n=rn(zt.und(i[3])?0:i[3],.1,100),o=Math.sqrt(a/r),l=s/(2*Math.sqrt(a*r)),h=l<1?o*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*o+-n)/h:-n+o;function u(f){var m=t?t*f/1e3:f;return l<1?m=Math.exp(-m*l*o)*(c*Math.cos(h*m)+d*Math.sin(h*m)):m=(c+d*m)*Math.exp(-m*o),f===0||f===1?f:1-m}function p(){var f=Ld.springs[e];if(f)return f;for(var m=1/6,g=0,y=0;;)if(g+=m,u(g)===1){if(y++,y>=16)break}else y=0;var x=g*m*1e3;return Ld.springs[e]=x,x}return t?u:p}function jQ(e){return e===void 0&&(e=10),function(t){return Math.ceil(rn(t,1e-6,1)*e)*(1/e)}}var HQ=function(){var e=11,t=1/(e-1);function i(c,d){return 1-3*d+3*c}function r(c,d){return 3*d-6*c}function a(c){return 3*c}function s(c,d,u){return((i(d,u)*c+r(d,u))*c+a(d))*c}function n(c,d,u){return 3*i(d,u)*c*c+2*r(d,u)*c+a(d)}function o(c,d,u,p,f){var m,g,y=0;do g=d+(u-d)/2,m=s(g,p,f)-c,m>0?u=g:d=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(c,d,u,p){for(var f=0;f<4;++f){var m=n(d,u,p);if(m===0)return d;var g=s(d,u,p)-c;d-=g/m}return d}function h(c,d,u,p){if(!(0<=c&&c<=1&&0<=u&&u<=1))return;var f=new Float32Array(e);if(c!==d||u!==p)for(var m=0;m<e;++m)f[m]=s(m*t,c,u);function g(y){for(var x=0,b=1,_=e-1;b!==_&&f[b]<=y;++b)x+=t;--b;var S=(y-f[b])/(f[b+1]-f[b]),A=x+S*t,E=n(A,c,u);return E>=.001?l(y,A,c,u):E===0?A:o(y,x,x+t,c,u)}return function(y){return c===d&&u===p||y===0||y===1?y:s(g(y),d,p)}}return h}(),jD=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var a,s=4;r<((a=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((a*3-2)/22-r,2)}},Elastic:function(r,a){r===void 0&&(r=1),a===void 0&&(a=.5);var s=rn(r,1,10),n=rn(a,.1,2);return function(o){return o===0||o===1?o:-s*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,a){t[r]=function(){return function(s){return Math.pow(s,a+2)}}}),Object.keys(t).forEach(function(r){var a=t[r];e["easeIn"+r]=a,e["easeOut"+r]=function(s,n){return function(o){return 1-a(s,n)(1-o)}},e["easeInOut"+r]=function(s,n){return function(o){return o<.5?a(s,n)(o*2)/2:1-a(s,n)(o*-2+2)/2}}}),e}();function Hw(e,t){if(zt.fnc(e))return e;var i=e.split("(")[0],r=jD[i],a=ND(e);switch(i){case"spring":return VD(e,t);case"cubicBezier":return _1(HQ,a);case"steps":return _1(jQ,a);default:return _1(r,a)}}function HD(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Hv(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,a=[],s=0;s<i;s++)if(s in e){var n=e[s];t.call(r,n,s,e)&&a.push(n)}return a}function Gv(e){return e.reduce(function(t,i){return t.concat(zt.arr(i)?Gv(i):i)},[])}function _E(e){return zt.arr(e)?e:(zt.str(e)&&(e=HD(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Gw(e,t){return e.some(function(i){return i===t})}function Ww(e){var t={};for(var i in e)t[i]=e[i];return t}function Kx(e,t){var i=Ww(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Wv(e,t){var i=Ww(e);for(var r in t)i[r]=zt.und(e[r])?t[r]:e[r];return i}function GQ(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function WQ(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,c){return l+l+h+h+c+c}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),a=parseInt(r[1],16),s=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+a+","+s+","+n+",1)"}function qQ(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,a=parseInt(t[3],10)/100,s=t[4]||1;function n(u,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(p-u)*6*f:f<1/2?p:f<2/3?u+(p-u)*(2/3-f)*6:u}var o,l,h;if(r==0)o=l=h=a;else{var c=a<.5?a*(1+r):a+r-a*r,d=2*a-c;o=n(d,c,i+1/3),l=n(d,c,i),h=n(d,c,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+s+")"}function XQ(e){if(zt.rgb(e))return GQ(e);if(zt.hex(e))return WQ(e);if(zt.hsl(e))return qQ(e)}function Fo(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function YQ(e){if(cp(e,"translate")||e==="perspective")return"px";if(cp(e,"rotate")||cp(e,"skew"))return"deg"}function Zx(e,t){return zt.fnc(e)?e(t.target,t.id,t.total):e}function Fn(e,t){return e.getAttribute(t)}function qw(e,t,i){var r=Fo(t);if(Gw([i,"deg","rad","turn"],r))return t;var a=Ld.CSS[t+i];if(!zt.und(a))return a;var s=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=s+i;var l=s/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return Ld.CSS[t+i]=h,h}function GD(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?qw(e,a,i):a}}function Xw(e,t){if(zt.dom(e)&&!zt.inp(e)&&(Fn(e,t)||zt.svg(e)&&e[t]))return"attribute";if(zt.dom(e)&&Gw(VQ,t))return"transform";if(zt.dom(e)&&t!=="transform"&&GD(e,t))return"css";if(e[t]!=null)return"object"}function WD(e){if(zt.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,a;a=i.exec(t);)r.set(a[1],a[2]);return r}}function QQ(e,t,i,r){var a=cp(t,"scale")?1:0+YQ(t),s=WD(e).get(t)||a;return i&&(i.transforms.list.set(t,s),i.transforms.last=t),r?qw(e,s,r):s}function Yw(e,t,i,r){switch(Xw(e,t)){case"transform":return QQ(e,t,r,i);case"css":return GD(e,t,i);case"attribute":return Fn(e,t);default:return e[t]||0}}function Qw(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Fo(e)||0,a=parseFloat(t),s=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return a+s+r;case"-":return a-s+r;case"*":return a*s+r}}function qD(e,t){if(zt.col(e))return XQ(e);if(/\s/g.test(e))return e;var i=Fo(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Kw(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function KQ(e){return Math.PI*2*Fn(e,"r")}function ZQ(e){return Fn(e,"width")*2+Fn(e,"height")*2}function JQ(e){return Kw({x:Fn(e,"x1"),y:Fn(e,"y1")},{x:Fn(e,"x2"),y:Fn(e,"y2")})}function XD(e){for(var t=e.points,i=0,r,a=0;a<t.numberOfItems;a++){var s=t.getItem(a);a>0&&(i+=Kw(r,s)),r=s}return i}function $Q(e){var t=e.points;return XD(e)+Kw(t.getItem(t.numberOfItems-1),t.getItem(0))}function YD(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return KQ(e);case"rect":return ZQ(e);case"line":return JQ(e);case"polyline":return XD(e);case"polygon":return $Q(e)}}function eK(e){var t=YD(e);return e.setAttribute("stroke-dasharray",t),t}function tK(e){for(var t=e.parentNode;zt.svg(t)&&zt.svg(t.parentNode);)t=t.parentNode;return t}function QD(e,t){var i=t||{},r=i.el||tK(e),a=r.getBoundingClientRect(),s=Fn(r,"viewBox"),n=a.width,o=a.height,l=i.viewBox||(s?s.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function iK(e,t){var i=zt.str(e)?HD(e)[0]:e,r=t||100;return function(a){return{property:a,el:i,svg:QD(i),totalLength:YD(i)*(r/100)}}}function rK(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=QD(e.el,e.svg),a=i(),s=i(-1),n=i(1);switch(e.property){case"x":return(a.x-r.x)*r.w;case"y":return(a.y-r.y)*r.h;case"angle":return Math.atan2(n.y-s.y,n.x-s.x)*180/Math.PI}}function SE(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=qD(zt.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:zt.str(e)||t?r.split(i):[]}}function KD(e){var t=e?Gv(zt.arr(e)?e.map(_E):_E(e)):[];return Hv(t,function(i,r,a){return a.indexOf(i)===r})}function ZD(e){var t=KD(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:WD(i)}}})}function aK(e,t){var i=Ww(t);if(/^spring/.test(i.easing)&&(i.duration=VD(i.easing)),zt.arr(e)){var r=e.length,a=r===2&&!zt.obj(e[0]);a?e={value:e}:zt.fnc(t.duration)||(i.duration=t.duration/r)}var s=zt.arr(e)?e:[e];return s.map(function(n,o){var l=zt.obj(n)&&!zt.pth(n)?n:{value:n};return zt.und(l.delay)&&(l.delay=o?0:t.delay),zt.und(l.endDelay)&&(l.endDelay=o===s.length-1?t.endDelay:0),l}).map(function(n){return Wv(n,i)})}function sK(e){for(var t=Hv(Gv(e.map(function(s){return Object.keys(s)})),function(s){return zt.key(s)}).reduce(function(s,n){return s.indexOf(n)<0&&s.push(n),s},[]),i={},r=function(s){var n=t[s];i[n]=e.map(function(o){var l={};for(var h in o)zt.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},a=0;a<t.length;a++)r(a);return i}function nK(e,t){var i=[],r=t.keyframes;r&&(t=Wv(sK(r),t));for(var a in t)zt.key(a)&&i.push({name:a,tweens:aK(t[a],e)});return i}function oK(e,t){var i={};for(var r in e){var a=Zx(e[r],t);zt.arr(a)&&(a=a.map(function(s){return Zx(s,t)}),a.length===1&&(a=a[0])),i[r]=a}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function lK(e,t){var i;return e.tweens.map(function(r){var a=oK(r,t),s=a.value,n=zt.arr(s)?s[1]:s,o=Fo(n),l=Yw(t.target,e.name,o,t),h=i?i.to.original:l,c=zt.arr(s)?s[0]:h,d=Fo(c)||Fo(l),u=o||d;return zt.und(n)&&(n=h),a.from=SE(c,u),a.to=SE(Qw(n,c),u),a.start=i?i.end:0,a.end=a.start+a.delay+a.duration+a.endDelay,a.easing=Hw(a.easing,a.duration),a.isPath=zt.pth(s),a.isColor=zt.col(a.from.original),a.isColor&&(a.round=1),i=a,a})}var JD={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,a){if(r.list.set(t,i),t===r.last||a){var s="";r.list.forEach(function(n,o){s+=o+"("+n+") "}),e.style.transform=s}}};function $D(e,t){var i=ZD(e);i.forEach(function(r){for(var a in t){var s=Zx(t[a],r),n=r.target,o=Fo(s),l=Yw(n,a,o,r),h=o||Fo(l),c=Qw(qD(s,h),l),d=Xw(n,a);JD[d](n,a,c,r.transforms,!0)}})}function hK(e,t){var i=Xw(e.target,t.name);if(i){var r=lK(t,e),a=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:a.end,delay:r[0].delay,endDelay:a.endDelay}}}function cK(e,t){return Hv(Gv(e.map(function(i){return t.map(function(r){return hK(i,r)})})),function(i){return!zt.und(i)})}function eI(e,t){var i=e.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},a={};return a.duration=i?Math.max.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+n+o+l+s.duration*(s.loop??1)})):t.duration,a.delay=i?Math.min.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0;return r(s)+n+o+s.delay})):t.delay,a.endDelay=i?a.duration-Math.max.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+n+o+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,a}var AE=0;function dK(e){var t=Kx(UD,e),i=Kx(jw,e),r=nK(i,e),a=ZD(e.targets),s=cK(a,r),n=eI(s,i),o=AE;return AE++,Wv(t,{id:o,children:[],animatables:a,animations:s,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var _a=[],cd=[],Po,Jx=function(){let e=0,t=!0;function i(s){let n=_a.length;if(n){let o=0;for(;o<n;){let l=_a[o];l.paused?(_a.splice(o,1),n--):(l.tick(s),o++)}t&&(Po=requestAnimationFrame(i))}else Po&&(cancelAnimationFrame(Po),Po=null)}function r(){e=performance.now(),Po=requestAnimationFrame(i)}function a(s){e+=s,i(e)}return{get isUsingInternalRaf(){return t},set isUsingInternalRaf(s){t=s},play:r,update:a}}();function $x(e){!Jx.isUsingInternalRaf||(document.hidden?(_a.forEach(function(t){return t.pause(e.timeStamp)}),cd=_a.slice(0),zi.running=_a=[]):(cd.forEach(function(t){return t.play(e.timeStamp)}),cd=[]))}function zi(e){e===void 0&&(e={});var t=0,i=0,r=0,a,s,n=0,o=null;function l(E){var M=window.Promise&&new Promise(function(T){return o=T});return E.finished=M,M}var h=dK(e),c=l(h);function d(){var E=h.direction;E!=="alternate"&&(h.direction=E!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,s.forEach(function(M){(M.loop===1||M.loop%2===0)&&(M.reversed=h.reversed)})}function u(){h.direction="normal",h.reversed=!1,s.forEach(function(E){return E.reversed=!1})}function p(E){return h.reversed?h.duration-E:E}function f(){t=0,i=p(h.currentTime)*(1/zi.speed)}function m(E,M,T=!1){M&&(h.reversed?M.seek(M.duration*M.loop-(E-M.timelineOffset-M.pingPongDelayCorrection),T):M.seek(E-M.timelineOffset-M.startOnceDelay-M.pingPongDelayCorrection,T))}function g(E,M=!1){if(h.reversed)for(var T=n;T--;)m(E,s[T],M);else for(var P=0;P<n;P++)m(E,s[P],M)}function y(E){var M=0,T=h.animations,P=T.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?E=h.duration-h.delay+h.endDelay-E:E=h.duration+h.delay-h.endDelay-E):S(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?E=h.duration-h.delay+h.endDelay-E:E=h.duration+h.delay-h.endDelay-E);M<P;){var R=T[M],z=R.animatable,U=R.tweens,L=U.length-1,j=U[L];L&&(j=Hv(U,function(ye){return E<ye.end})[0]||j);let Ae;h.parent?.reversed&&h.direction==="alternate"?Ae=rn(E-j.start-j.endDelay,0,j.duration)/j.duration:Ae=rn(E-j.start-j.delay,0,j.duration)/j.duration;for(var q=isNaN(Ae)?1:j.easing(Ae),Q=j.to.strings,X=j.round,ie=[],oe=j.to.numbers.length,te=void 0,re=0;re<oe;re++){var fe=void 0;let ye,Ve;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(ye=j.to.numbers[re],Ve=j.from.numbers[re]||0):(Ve=j.to.numbers[re],ye=j.from.numbers[re]||0):S(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(ye=j.to.numbers[re],Ve=j.from.numbers[re]||0):(Ve=j.to.numbers[re],ye=j.from.numbers[re]||0),j.isPath?fe=rK(j.value,q*Ve):fe=ye+q*(Ve-ye),X&&(j.isColor&&re>2||(fe=Math.round(fe*X)/X)),ie.push(fe)}var ce=Q.length;if(!ce)te=ie[0];else{te=Q[0];for(var de=0;de<ce;de++){var se=Q[de],Pe=Q[de+1],ve=ie[de];isNaN(ve)||(Pe?te+=ve+Pe:te+=ve+" ")}}JD[R.type](z.target,R.property,te,z.transforms),R.currentValue=te,M++}}function x(E){h[E]&&!h.passThrough&&h[E](h)}function b(){h.remaining&&h.remaining!==!0&&h.remaining--}let _={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 S(E,M,T,P,R){return _[E<<4|M<<3|T<<2|P<<1|R]}function A(E,M=!1){var T=h.duration;let P=h.delay,R=T-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(P=h.endDelay,R=T-h.delay);var z=p(E);if(h.progress=rn(z/T*100,0,100),M||(h.reversePlayback=z<h.currentTime),n&&g(z,M),!h.began&&z>=P&&(h.began=!0),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,x("loopBegin")),(h.reversed||z>=0)&&z<=P&&h.currentTime!==0&&(y(0),x("change")),(z>=R&&h.currentTime!==T+h.pingPongDelayCorrection||!T)&&(y(T),x("change")),z>P&&z<R?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,x("changeBegin")),y(z),x("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,x("change"),n&&x("timelineChangeComplete")):h.began&&z>R&&x("changeComplete"),h.currentTime=rn(z,0,T+h.pingPongDelayCorrection),h.began&&x("update"),E>=T)if(b(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,x("loopComplete"),x("complete"),!h.passThrough&&"Promise"in window&&(o(),c=l(h)));else{n?t+=h.duration/zi.speed:t+=h.duration;for(let U of s)U.setStartTime(0),U.remaining=U.loop;x("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?d():n&&u()}}return h.reset=function(){var E=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversed=E==="reverse",h.remaining=h.loop,s=h.children,n=s.length;for(var M=n;M--;)h.children[M].reset();y(h.reversed?h.duration:0)},h.setStartTime=function(E){t=E},h.set=function(E,M){return $D(E,M),h},h.tick=function(E){r=E,t||(t=r),A((r+(i-t))*zi.speed)},h.seek=function(E,M=!1){A(E-t,M)},h.pause=function(E){h.paused=!0,n&&(a=E??performance.now())},h.play=function(E){!h.paused||(h.completed&&h.reset(),h.paused=!1,_a.push(h),n&&a!==void 0&&(t+=(E??performance.now())-a),!Po&&Jx.isUsingInternalRaf&&Jx.play())},h.reverse=function(E=0){d(),h.completed=!h.reversed,t=void 0,i=E},h.restart=function(){h.reset(),t=void 0,i=0,h.play()},h.destroy=function(){h.paused=!0;var E=_a.indexOf(h);E>-1&&_a.splice(E,1),E=cd.indexOf(h),E>-1&&cd.splice(E,1),h.children&&h.children.forEach(function(M){M.destroy&&M.destroy()}),h.animations=[],h.animatables=[],h.children=[],h.update=null,h.begin=null,h.complete=null,h.loopBegin=null,h.loopComplete=null,h.change=null,h.changeBegin=null,h.changeComplete=null,h.timelineChangeComplete=null,h.parent=null,o=null,s=[],n=0},h.reset(),h.autoplay&&h.play(),h}function ME(e,t){for(var i=t.length;i--;)Gw(e,t[i].animatable.target)&&t.splice(i,1)}function uK(e){for(var t=KD(e),i=_a.length;i--;){var r=_a[i],a=r.animations,s=r.children;ME(t,a);for(var n=s.length;n--;){var o=s[n],l=o.animations;ME(t,l),!l.length&&!o.children.length&&s.splice(n,1)}!a.length&&!s.length&&r.pause()}}function pK(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?Hw(t.easing):null,a=t.grid,s=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",c=zt.arr(e),d=parseFloat(c?e[0]:e),u=c?parseFloat(e[1]):0,p=Fo(c?e[1]:e)||0,f=t.start||0+(c?d:0),m=[],g=0;return function(y,x,b){if(o&&(n=0),l&&(n=(b-1)/2),h&&(n=b-1),!m.length){for(var _=0;_<b;_++){if(!a)m.push(Math.abs(n-_));else{var S=l?(a[0]-1)/2:n%a[0],A=l?(a[1]-1)/2:Math.floor(n/a[0]),E=_%a[0],M=Math.floor(_/a[0]),T=S-E,P=A-M,R=Math.sqrt(T*T+P*P);s==="x"&&(R=-T),s==="y"&&(R=-P),m.push(R)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(U){return r(U/g)*g})),i==="reverse"&&(m=m.map(function(U){return s?U<0?U*-1:-U:Math.abs(g-U)}))}var z=c?(u-d)/g:d;return f+z*(Math.round(m[x]*100)/100)+p}}function fK(e){e===void 0&&(e={});var t=zi(e);return t.duration=0,t.add=function(i,r){var a=_a.indexOf(t),s=t.children;a>-1&&_a.splice(a,1);function n(u){u.passThrough=!0}for(var o=0;o<s.length;o++)n(s[o]);var l=Wv(i,Kx(jw,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=zt.und(r)?h:Qw(r,h),n(t);var c=zi(l);n(c),s.push(c),c.parent=t;var d=eI(s,e);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}zi.version="3.2.0";zi.speed=1;zi.running=_a;zi.remove=uK;zi.get=Yw;zi.set=$D;zi.convertPx=qw;zi.path=iK;zi.setDashoffset=eK;zi.stagger=pK;zi.timeline=fK;zi.easing=Hw;zi.penner=jD;zi.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};zi.removeAll=function(){_a.forEach(function(e){e.destroy&&e.destroy()}),_a=[],cd=[],zi.running=_a,Po&&(cancelAnimationFrame(Po),Po=null)};zi.clearCache=function(){Ld.CSS={},Ld.springs={}};zi.init=function(){typeof document<"u"&&(document.removeEventListener("visibilitychange",$x),document.addEventListener("visibilitychange",$x))};zi.dispose=function(e){zi.removeAll(),zi.clearCache(),document.removeEventListener("visibilitychange",$x)};var Uo=zi,qr=class extends Ct{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},{degToRad:she,radToDeg:nhe}=tt,EE=new O,CE=new O,TE=new Rt,mK=1e-4;function gK(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let a=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(a>=1)return i.copy(e);let s=1-a*a;if(s<=Number.EPSILON){let c=1-r;return i.w=c*e.w+r*t.w,i.x=c*e.x+r*t.x,i.y=c*e.y+r*t.y,i.z=c*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(s),o=Math.atan2(n,a),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function va(e,t,i,r,a,s){let n=i[e]!==void 0?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(a.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(a.getVariable(o)??0):o;if(l!==h)return{update:c=>{let d=tt.lerp(l,h,c);s?t[e]=Math.trunc(d):t[e]=d},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function Zw(e,t,i,r,a,s){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(d=>typeof d=="string"?Number(a.getVariable(d)??0):d),c=[...o].map(d=>typeof d=="string"?Number(a.getVariable(d)??0):d);if(!(h.length!==c.length||Mw(h,c)))return{update:d=>{h.forEach((u,p)=>{let f=tt.lerp(u,c[p],d);t[e][p]=s?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],c)}}}function ov(e,t,i){return t.forEach((r,a)=>{e.setComponent(a,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function PE(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=s?ov(new O,s,a):o.clone(),h=ov(new O,n,a);if(!l.equals(h))return{update:c=>{o.lerpVectors(l,h,c)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function DE(e,t,i){return t.forEach((r,a)=>{e.setComponent(a,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function lv(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=!(o instanceof ae),h=o instanceof ae?o:new ae().fromArray(o),c=s?DE(new ae,s,a):h.clone(),d=DE(new ae,n,a);if(!c.equals(d))return{update:u=>{h.lerpVectors(c,d,u),l&&(t[e]=h.toArray())},start:()=>{h.copy(c),l&&(t[e]=h.toArray())},end:()=>{h.copy(d),l&&(t[e]=h.toArray())}}}function vK(e,t,i,r){let a=i[e]?i[e]:void 0,s=r[e];if(!s)return;let n=t[e],o=a?new je().fromArray(a):n.clone(),l=new O,h=new Rt,c=new O;o.decompose(l,h,c);let d=new je().fromArray(s),u=new O,p=new Rt,f=new O;if(d.decompose(u,p,f),!o.equals(d))return{update:m=>{TE.slerpQuaternions(h,p,m),EE.lerpVectors(l,u,m),CE.lerpVectors(c,f,m),n.compose(EE,TE,CE)},start:()=>{n.compose(l,h,c)},end:()=>{n.compose(u,p,f)}}}function yK(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=s?typeof s=="string"?a.getColor(s).clone():new Ct().setRGB(s.r,s.g,s.b):o.clone(),h=typeof n=="string"?a.getColor(n).clone():new Ct().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:d=>{c.lerpColors(l,h,d),t[e]?.copy?.(c)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function hm(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=new qr(o.r,o.g,o.b,o.a),h=s?typeof s=="string"?a.getColor(s).clone():new qr(s.r,s.g,s.b,s.a):l.clone(),c=typeof n=="string"?a.getColor(n).clone():new qr(n.r,n.g,n.b,n.a);if(!h.equals(c))return{update:d=>{l.lerpColors(h,c,d);let u=tt.lerp(h.a,c.a,d);l.a=u,t[e]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(c)}}}function Kl(e,t,i,r,a){if(typeof t[e]=="number")return va(e,t,i??{},r,a);if(Array.isArray(t[e]))return Zw(e,t,i??{},r,a)}var ohe=new xr;function Al(e,t,i,r,a){let s=i[e],n=r[e];if(typeof t[e]=="number")Math.abs(s-n)>mK&&(t[e]=tt.lerp(s,n,a));else if(Array.isArray(t[e]))for(let o=0,l=s.length;o<l;o++)t[e][o]=tt.lerp(s[o],n[o],a)}function xK(e,t,i,r){let a=[];if(!("cloner"in i)||!e.cloner)return a;let s=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;RD.forEach(p=>{let f;p==="count"?f=va("count",s.parameters,n,o,r.shared,!0):f=Kl(p,s.parameters,n??{},o,r.shared),f&&a.push(f)});let l=bK(s,n,o,r.shared);l?.length&&a.push(...l);let h=wK(s,n,o,r.shared);h?.length&&a.push(...h);let c=_K(s,n,o,r.shared);c?.length&&a.push(...c);let d=SK(s,n,o,r.shared);d?.length&&a.push(...d);let u=AK(s,n,o,r.shared);return u?.length&&a.push(...u),a.length&&a.push({update:()=>{s.update(r)}}),a}function bK(e,t,i,r){if(e.parameters.type!=="radial")return;let a=t.radial,s=i.radial;if(!s)return;let n=e.parameters.radial,o=[];return zw.forEach(l=>{let h=Kl(l,n,a??{},s,r);h&&o.push(h)}),o}function wK(e,t,i,r){if(e.parameters.type!=="linear")return;let a=t.linear,s=i.linear;if(!s)return;let n=[],o=e.parameters.linear;return kw.forEach(l=>{let h=Kl(l,o,a??{},s,r);h&&n.push(h)}),n}function _K(e,t,i,r){if(e.parameters.type!=="grid")return;let a=t.grid,s=i.grid;if(!s)return;let n=[],o=e.parameters.grid;return Fw.forEach(l=>{let h;l==="count"?h=Zw(l,o,a??{},s,r,!0):h=Kl(l,o,a??{},s,r),h&&n.push(h)}),n}function SK(e,t,i,r){if(e.parameters.type!=="toObject")return;let a=t.toObject,s=i.toObject;if(!s)return;let n=[],o=e.parameters.toObject;return Uw.forEach(l=>{let h;l==="count"?h=va(l,o,a??{},s,r,!0):h=Kl(l,o,a??{},s,r),h&&n.push(h)}),n}function AK(e,t,i,r){if(!e.parameters.randomness)return;let a=t.randomnessObject,s=i.randomnessObject;if(!s)return;let n=[],o=e.parameters.randomnessObject;return Nw.forEach(l=>{let h=Kl(l,o,a??{},s,r);h&&n.push(h)}),n}function MK(e,t,i,r){let a=r.cloner?.parameters;if(a){Al("count",a,e,t,i),a.count=Math.trunc(a.count);for(let s of zw)Al(s,a.radial,e.radial,t.radial,i);for(let s of kw)Al(s,a.linear,e.linear,t.linear,i);for(let s of Fw)Al(s,a.grid,e.grid,t.grid,i);for(let s of Uw)Al(s,a.toObject,e.toObject,t.toObject,i);return a}}function EK(e,t,i,r){let a=r.cloner?.parameters;if(a){for(let s of Nw)Al(s,a.randomnessObject,e.randomnessObject,t.randomnessObject,i);return a}}function Or(e,t=[0,0]){let i=e&&!isNaN(e[0])?e[0]:t[0],r=e&&!isNaN(e[1])?e[1]:t[1];return[i,r]}function Na(e,t,i){switch(e){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:let{control1:r,control2:a}=t??{...qg.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${a[0]}, ${a[1]} )`;case 6:let{mass:s,stiffness:n,damping:o,velocity:l}=i??{...Wg.defaultData},h=new BK(s,n,o,l),c=h.solve(1);return()=>d=>h.solve(d)/c;case 8:return()=>d=>Math.floor(d)}}var IE;(e=>{function t(i){return i&&typeof i.x=="number"&&typeof i.y=="number"&&typeof i.z=="number"}e.is=t})(IE||(IE={}));var eb;(e=>{function t(o,l){let h=[0,0],c=[1,1];if(o?.cubicControls)h=Or(o.cubicControls.control1,h);else switch(o?.type){case 2:h=[.42,0];break;case 3:h=[0,0];break;case 4:h=[.42,0];break;case 1:h=[.25,.1];break;case 0:h=[0,0];break;case 7:h=[.25,1];break}if(l?.cubicControls)c=Or(l.cubicControls.control2,c);else switch(l?.type){case 2:c=[1,1];break;case 3:c=[.58,1];break;case 4:c=[.58,1];break;case 1:c=[.25,1];break;case 0:c=[1,1];break;case 7:c=[.5,1];break}return{control1:h,control2:c}}e.getControlsWithDefault=t;function i(o,l){return{id:o,name:l,to:5,properties:new pt}}e.defaultData=i;function r(o){let l=new pt;return o.forEach(({data:h,id:c,fi:d})=>{if(h.type==="light"){let u=OE(["material",`${h.category} lighting`],c,d);l.push(u)}else{let u=OE(["material",h.type],c,d);l.push(u)}}),l}e.createMaterialGroup=r;function a(o){return Object.entries(o).reduce((l,[h,c])=>(typeof c!="string"&&l.push({name:c.name}),l),[])}e.createName=a;function s(o,l,h){let c=Uo.timeline({easing:Na(0),begin(){o.resetBBoxNeedsUpdate()},change(){o.resetBBoxNeedsUpdate()},direction:l.direction,autoplay:!1});return n(o,l,h).forEach(d=>c.add(d,0)),c.duration=l.to*1e3,c}e.createTimeline=s;function n(o,l,h,c){let d=[];return l.properties.forEach((u,p)=>{let f=u.data.path?.[0];if(f&&["position","rotation","scale"].includes(f)){let m=CK(u.data,h?.[f]);m&&d.push(...m)}if(f&&f==="shape size"&&"geometry"in o){let m=TK(o,u.data,h?.shapeSize);m&&d.push(...m)}if(f&&f==="path extrusion"&&o instanceof e0){let m=PK(o,u.data,h?.pathExtrusion);m&&d.push(m)}if(f&&f==="path snapping"&&o.data.pathSnapping){let m=DK(o,u.data,h?.pathSnapping);m&&d.push(m)}if(f&&f==="material"&&o.type==="Mesh"&&"material"in o&&o.material instanceof Wo){let m=u.data.id;if(m){let g=o.material.getLayerByUuid(m);if(g){let y=RE(g,u.data,h?.material,c);y&&d.push(y)}else{let y=o.material.getLayersOfType(u.data.type);if(y)for(let x of y){let b=RE(x,u.data,h?.material,c);b&&d.push(b)}}}}if(f&&f==="opacity"&&o.type==="Mesh"&&"material"in o){let m=IK(u.data,h?.opacity);m&&d.push(m)}if(f&&f==="cloner"){let m=OK(o,u.data,h?.cloner);m&&d.push(m)}if(f&&f==="camera"&&o instanceof Xr){let m=RK(o,u.data,h?.camera,"zoom");m&&d.push(m)}if(f&&f==="light"&&(o instanceof Zv||o instanceof C_||o instanceof Jv)){let m=LK(o,u.data,h?.light,u.data.path[1],c);m&&d.push(m)}}),d}e.addKeyframesToTimeline=n,e.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:Na(3),duration:1e3},opacity:{value:[0,1],easing:Na(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:Na(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:Na(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:Na(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(eb||(eb={}));function OE(e,t,i){let r=t;return{id:r,fi:i,data:{id:r,path:e,keyframes:new pt}}}var tI=["x","y","z"];function CK(e,t=()=>{}){let i=[];for(let r of tI){let a=[...e.keyframes??[]].filter(o=>o.data.value[r]!==void 0).sort((o,l)=>o.data.time-l.data.time),s=a[0];s&&t?.(s.data.value);let n={index:[],t:[]};for(let o=0;o<a.length-1;o++){let l=a[o],h=a[o+1]??l,c={duration:(h?.data?.time-l.data.time)*1e3,delay:o===0?a[0].data.time*1e3:0};o<a.length-1&&(n.t.push({...c,value:o%2===0?1:0,easing:Na(l.data.easing.type,{control1:Or(l.data.easing.cubicControls?.control1,[0,0]),control2:Or(h.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),n.index.push({...c,value:o,easing:"linear"}))}if(a.length>1){let o={t:0,index:0};i.push({targets:o,...n,update:l=>{let h=Math.ceil(o.index),c=h%2===0?o.t:1-o.t,d=a?.[h].data.value,u=a?.[h+1]?.data.value;if(d!==void 0&&u!==void 0){let p={[r]:d[r]+(u[r]-d[r])*c};t?.(p)}}})}}return i}function TK(e,t,i){let r=[];for(let a of tI){let s={},n=[...t.keyframes??[]].filter(l=>l.data.value[a]!==void 0).sort((l,h)=>l.data.time-h.data.time),o=n[0];o&&i?.(o.data.value),s={index:[],t:[]};for(let l=0;l<n.length-1;l++){let h=n[l],c=n[l+1]??h,d={duration:(c?.data?.time-h.data.time)*1e3,delay:l===0?n[0].data.time*1e3:0};l<n.length-1&&(s.t.push({...d,value:l%2===0?1:0,easing:Na(h.data.easing.type,{control1:Or(h.data.easing.cubicControls?.control1,[0,0]),control2:Or(c.data.easing.cubicControls?.control2,[1,1])},h.data.easing.springParameters)}),s.index.push({...d,value:l,easing:"linear"}))}if(n.length>1){let l={t:0,index:0};r.push({targets:l,...s,update:h=>{let c=Math.ceil(l.index),d=c%2===0?l.t:1-l.t,u=n?.[c].data.value,p=n?.[c+1]?.data.value;if(u!==void 0&&p!==void 0){let f={[a]:u[a]+(p[a]-u[a])*d};i?.(f)}}})}}return r}function PK(e,t,i){let r={},a=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time),s=a[0];s&&i?.(e,s.data.value),r={index:[],t:[]};for(let n=0;n<a.length-1;n++){let o=a[n],l=a[n+1]??o,h={duration:(l?.data?.time-o.data.time)*1e3,delay:n===0?a[0].data.time*1e3:0};n<a.length-1&&(r.t.push({...h,value:n%2===0?1:0,easing:Na(o.data.easing.type,{control1:Or(o.data.easing.cubicControls?.control1,[0,0]),control2:Or(l.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),r.index.push({...h,value:n,easing:"linear"}))}if(a.length>1){let n={t:0,index:0};return{targets:n,...r,update:o=>{let l=Math.ceil(n.index),h=l%2===0?n.t:1-n.t,c=a?.[Math.min(l,a.length-1)].data.value,d=a?.[Math.min(l,a.length-1)+1]?.data.value;i?.(e,Kse(e,c,d,h))}}}}function DK(e,t,i){let r={},a=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time),s=a[0];s&&i?.(s.data.value),r={index:[],t:[]};for(let n=0;n<a.length-1;n++){let o=a[n],l=a[n+1]??o,h={duration:(l?.data?.time-o.data.time)*1e3,delay:n===0?a[0].data.time*1e3:0};n<a.length-1&&(r.t.push({...h,value:n%2===0?1:0,easing:Na(o.data.easing.type,{control1:Or(o.data.easing.cubicControls?.control1,[0,0]),control2:Or(l.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),r.index.push({...h,value:n,easing:"linear"}))}if(a.length>1){let n={t:0,index:0};return{targets:n,...r,update:o=>{let l=Math.ceil(n.index),h=l%2===0?n.t:1-n.t,c=a?.[Math.min(l,a.length-1)].data.value,d=a?.[Math.min(l,a.length-1)+1]?.data.value;i?.(Zse(e,c,d,h))}}}}function RE(e,t,i,r){if(t){let a={},s=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time);if("data"in e){let n=s[0];n&&i?.(n.data.value,e),a={index:[],t:[]};for(let o=0;o<s.length-1;o++){let l=s[o],h=s[o+1]??l,c={duration:(h?.data?.time-l.data.time)*1e3,delay:o===0?s[0].data.time*1e3:0};o<s.length-1&&(a.t.push({...c,value:o%2===0?1:0,easing:Na(l.data.easing.type,{control1:Or(l.data.easing.cubicControls?.control1,[0,0]),control2:Or(h.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters)}),a.index.push({...c,value:o,easing:"linear"}))}if(s.length>1){let o={t:0,index:0};return{targets:o,...a,update:l=>{let h=Math.ceil(o.index),c=h%2===0?o.t:1-o.t,d=s?.[Math.min(h,s.length-1)].data.value,u=s?.[Math.min(h,s.length-1)+1]?.data.value,p={},f={};if(Object.keys(d).length>0&&Object.keys(u).length>0){for(let m in e.data)if(m in d&&m in u){let g=Jw(d[m],u[m],c,r);g!==void 0&&(p[m]=g,f[m]={start:d,end:u,t:c})}}i?.({...p},e,f)}}}}}}function IK(e,t){if(e){let i={},r=[...e.keyframes??[]].sort((s,n)=>s.data.time-n.data.time),a=r[0];a&&t?.(a.data.value),i={index:[],t:[]};for(let s=0;s<r.length-1;s++){let n=r[s],o=r[s+1]??n,l={duration:(o?.data?.time-n.data.time)*1e3,delay:s===0?r[0].data.time*1e3:0};s<r.length-1&&(i.t.push({...l,value:s%2===0?1:0,easing:Na(n.data.easing.type,{control1:Or(n.data.easing.cubicControls?.control1,[0,0]),control2:Or(o.data.easing.cubicControls?.control2,[1,1])},n.data.easing.springParameters)}),i.index.push({...l,value:s,easing:"linear"}))}if(r.length>1){let s={t:0,index:0};return{targets:s,...i,update:n=>{let o=Math.ceil(s.index),l=o%2===0?s.t:1-s.t,h=r?.[Math.min(o,r.length-1)].data.value,c=r?.[Math.min(o,r.length-1)+1]?.data.value,d=tt.lerp(h,c,l);t?.(d)}}}}}function OK(e,t,i){let r={},a=[...t.keyframes??[]].sort((n,o)=>n.data.time-o.data.time),s=a[0];s&&i?.(e,s.data.value,s.data.value),r={index:[],t:[]};for(let n=0;n<a.length-1;n++){let o=a[n],l=a[n+1]??o,h={duration:(l?.data?.time-o.data.time)*1e3,delay:n===0?a[0].data.time*1e3:0};n<a.length-1&&(r.t.push({...h,value:n%2===0?1:0,easing:Na(o.data.easing.type,{control1:Or(o.data.easing.cubicControls?.control1,[0,0]),control2:Or(l.data.easing.cubicControls?.control2,[1,1])},o.data.easing.springParameters)}),r.index.push({...h,value:n,easing:"linear"}))}if(a.length>1){let n={t:0,index:0};return{targets:n,...r,update:o=>{let l=Math.ceil(n.index),h=l%2===0?n.t:1-n.t,c=a?.[Math.min(l,a.length-1)].data.value,d=a?.[Math.min(l,a.length-1)+1]?.data.value;i?.(e,c.randomnessObject?void 0:MK(c,d,h,e),c.randomnessObject?EK(c,d,h,e):void 0)}}}}function Jw(e,t,i,r){if(typeof e=="string"&&r&&(e=r.color(e)),typeof t=="string"&&r&&(e=r.color(t)),typeof e=="number")return e===t?void 0:tt.lerp(e,t,i);if(_i.is(e))return _i.lerp(e,t,i);if(Cr.is(e))return Cr.lerp(e,t,i);if(Array.isArray(e))return(e.length>t.length?t:e).map((a,s,n)=>{if(Array.isArray(a)){let o=e[s].length>t[s].length?t[s].length:e[s].length;return(o===4?Lp:o===3?Ul:kn).lerp(e[s],t[s],i)}else return tt.lerp(e[s],t[s],i)});if(typeof e=="object"&&e!==null){let a={};for(let s in e){let n=Jw(e[s],t[s],i,r);n!==void 0&&(a[s]=n)}return a}}function RK(e,t,i,r){if(t){let a={[r]:[]},s=[...t.keyframes??[]].sort((o,l)=>o.data.time-l.data.time),n=s[0];n&&(e[r]=n.data.value,n&&i?.(r,n.data.value));for(let o=0;o<s.length-1;o++){let l=s[o];if(!Number.isFinite(l.data.value))continue;let h=s[o+1]??l,c=h.data.value;a[r].push({value:c,easing:Na(l.data.easing.type,{control1:Or(l.data.easing.cubicControls?.control1,[0,0]),control2:Or(h.data.easing.cubicControls?.control2,[1,1])},l.data.easing.springParameters),duration:(h?.data?.time-l.data.time)*1e3,delay:o===0?s[0].data.time*1e3:0})}if(s.length>1)return{targets:e,...a,update:()=>{i?.(r,e[r])}}}}function LK(e,t,i,r,a){if(t){let s={},n=[...t.keyframes??[]].sort((l,h)=>l.data.time-h.data.time),o=n[0];if(o){let l=o.data.value;e[r]=l,i?.(r,l)}s={index:[],t:[]};for(let l=0;l<n.length-1;l++){let h=n[l],c=n[l+1]??h,d={duration:(c?.data?.time-h.data.time)*1e3,delay:l===0?n[0].data.time*1e3:0};l<n.length-1&&(s.t.push({...d,value:l%2===0?1:0,easing:Na(h.data.easing.type,{control1:Or(h.data.easing.cubicControls?.control1,[0,0]),control2:Or(c.data.easing.cubicControls?.control2,[1,1])},h.data.easing.springParameters)}),s.index.push({...d,value:l,easing:"linear"}))}if(n.length>1){let l={t:0,index:0};return{targets:l,...s,update:()=>{let h=Math.ceil(l.index),c=h%2===0?l.t:1-l.t,d=n?.[Math.min(h,n.length-1)].data.value,u=n?.[Math.min(h,n.length-1)+1]?.data.value,p=Jw(d,u,c,a);i?.(r,p)}}}}}var BK=class{constructor(e=1,t=100,i=10,r=0){this.mass=e,this.stiffness=t,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(t/e),this.m_zeta=i/(2*Math.sqrt(t*e)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0+-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+this.m_w0)}solve(e){return this.m_zeta<1?e=Math.exp(-e*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*e)+this.m_B*Math.sin(this.m_wd*e)):e=(this.m_A+this.m_B*e)*Math.exp(-e*this.m_w0),1-e}getDuration(){let e=.16666666666666666,t=0,i=0;for(;;)if(t+=e,this.solve(t)===1){if(i++,i>=16)break}else i=0;return t*e*1e3}},zK=Math.pow(2,-24),cm=class{constructor(){}};function Bn(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function LE(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let a=e[r+3]-e[r];a>i&&(i=a,t=r)}return t}function BE(e,t){t.set(e)}function zE(e,t,i){let r,a;for(let s=0;s<3;s++){let n=s+3;r=e[s],a=t[s],i[s]=r<a?r:a,r=e[n],a=t[n],i[n]=r>a?r:a}}function dm(e,t,i){for(let r=0;r<3;r++){let a=t[e+2*r],s=t[e+2*r+1],n=a-s,o=a+s;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function Eu(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function kK(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,a;i>65535?a=new Uint32Array(new r(4*i)):a=new Uint16Array(new r(2*i)),e.setIndex(new Pt(a,1));for(let s=0;s<i;s++)a[s]=s}}function FK(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let a of e.groups)i.add(a.start),i.add(a.start+a.count);let r=Array.from(i.values()).sort((a,s)=>a-s);for(let a=0;a<r.length-1;a++){let s=r[a],n=r[a+1];t.push({offset:s/3,count:(n-s)/3})}return t}function S1(e,t,i,r,a=null){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,d=1/0,u=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,y=a!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],S=e[x+1],A=_-S,E=_+S;A<s&&(s=A),E>l&&(l=E),y&&_<d&&(d=_),y&&_>f&&(f=_);let M=e[x+2],T=e[x+3],P=M-T,R=M+T;P<n&&(n=P),R>h&&(h=R),y&&M<u&&(u=M),y&&M>m&&(m=M);let z=e[x+4],U=e[x+5],L=z-U,j=z+U;L<o&&(o=L),j>c&&(c=j),y&&z<p&&(p=z),y&&z>g&&(g=z)}r[0]=s,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,y&&(a[0]=d,a[1]=u,a[2]=p,a[3]=f,a[4]=m,a[5]=g)}function UK(e,t,i,r){let a=1/0,s=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,d=(t+i)*6;c<d;c+=6){let u=e[c+0];u<a&&(a=u),u>o&&(o=u);let p=e[c+2];p<s&&(s=p),p>l&&(l=p);let f=e[c+4];f<n&&(n=f),f>h&&(h=f)}r[0]=a,r[1]=s,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function NK(e,t,i,r,a){let s=i,n=i+r-1,o=a.pos,l=a.axis*2;for(;;){for(;s<=n&&t[s*6+l]<o;)s++;for(;s<=n&&t[n*6+l]>=o;)n--;if(s<n){for(let h=0;h<3;h++){let c=e[s*3+h];e[s*3+h]=e[n*3+h],e[n*3+h]=c;let d=t[s*6+h*2+0];t[s*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=d;let u=t[s*6+h*2+1];t[s*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=u}s++,n--}else return s}}var xo=32,VK=(e,t)=>e.candidate-t.candidate,ol=new Array(xo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),um=new Float32Array(6);function jK(e,t,i,r,a,s){let n=-1,o=0;if(s===0)n=LE(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(s===1)n=LE(e),n!==-1&&(o=HK(i,r,a,n));else if(s===2){let l=Eu(e),h=1.25*a,c=r*6,d=(r+a)*6;for(let u=0;u<3;u++){let p=t[u],f=(t[u+3]-p)/xo;if(a<xo/4){let m=[...ol];m.length=a;let g=0;for(let x=c;x<d;x+=6,g++){let b=m[g];b.candidate=i[x+2*u],b.count=0;let{bounds:_,leftCacheBounds:S,rightCacheBounds:A}=b;for(let E=0;E<3;E++)A[E]=1/0,A[E+3]=-1/0,S[E]=1/0,S[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;dm(x,i,_)}m.sort(VK);let y=a;for(let x=0;x<y;x++){let b=m[x];for(;x+1<y&&m[x+1].candidate===b.candidate;)m.splice(x+1,1),y--}for(let x=c;x<d;x+=6){let b=i[x+2*u];for(let _=0;_<y;_++){let S=m[_];b>=S.candidate?dm(x,i,S.rightCacheBounds):(dm(x,i,S.leftCacheBounds),S.count++)}}for(let x=0;x<y;x++){let b=m[x],_=b.count,S=a-b.count,A=b.leftCacheBounds,E=b.rightCacheBounds,M=0;_!==0&&(M=Eu(A)/l);let T=0;S!==0&&(T=Eu(E)/l);let P=1+1.25*(M*_+T*S);P<h&&(n=u,h=P,o=b.candidate)}}else{for(let y=0;y<xo;y++){let x=ol[y];x.count=0,x.candidate=p+f+y*f;let b=x.bounds;for(let _=0;_<3;_++)b[_]=1/0,b[_+3]=-1/0}for(let y=c;y<d;y+=6){let x=~~((i[y+2*u]-p)/f);x>=xo&&(x=xo-1);let b=ol[x];b.count++,dm(y,i,b.bounds)}let m=ol[xo-1];BE(m.bounds,m.rightCacheBounds);for(let y=xo-2;y>=0;y--){let x=ol[y],b=ol[y+1];zE(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let g=0;for(let y=0;y<xo-1;y++){let x=ol[y],b=x.count,_=x.bounds,S=ol[y+1].rightCacheBounds;b!==0&&(g===0?BE(_,um):zE(_,um,um)),g+=b;let A=0,E=0;g!==0&&(A=Eu(um)/l);let M=a-g;M!==0&&(E=Eu(S)/l);let T=1+1.25*(A*g+E*M);T<h&&(n=u,h=T,o=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:n,pos:o}}function HK(e,t,i,r){let a=0;for(let s=t,n=t+i;s<n;s++)a+=e[s*6+r*2];return a/i}function GK(e,t){let i=e.attributes.position,r=e.index.array,a=r.length/3,s=new Float32Array(a*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let d=0;d<a;d++){let u=d*3,p=d*6,f,m,g;n?(f=r[u+0],m=r[u+1],g=r[u+2]):(f=r[u+0]*h+l,m=r[u+1]*h+l,g=r[u+2]*h+l);for(let y=0;y<3;y++){let x,b,_;n?(x=i[c[y]](f),b=i[c[y]](m),_=i[c[y]](g)):(x=o[f+y],b=o[m+y],_=o[g+y]);let S=x;b<S&&(S=b),_<S&&(S=_);let A=x;b>A&&(A=b),_>A&&(A=_);let E=(A-S)/2,M=y*2;s[p+M+0]=S+E,s[p+M+1]=E+(Math.abs(S)+E)*zK,S<t[y]&&(t[y]=S),A>t[y+3]&&(t[y+3]=A)}}return s}function WK(e,t){function i(y){u&&u(y/p)}function r(y,x,b,_=null,S=0){if(!f&&S>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=c||S>=l)return i(x+b),y.offset=x,y.count=b,y;let A=jK(y.boundingData,_,n,x,b,d);if(A.axis===-1)return i(x+b),y.offset=x,y.count=b,y;let E=NK(o,n,x,b,A);if(E===x||E===x+b)i(x+b),y.offset=x,y.count=b;else{y.splitAxis=A.axis;let M=new cm,T=x,P=E-x;y.left=M,M.boundingData=new Float32Array(6),S1(n,T,P,M.boundingData,s),r(M,T,P,s,S+1);let R=new cm,z=E,U=b-P;y.right=R,R.boundingData=new Float32Array(6),S1(n,z,U,R.boundingData,s),r(R,z,U,s,S+1)}return y}kK(e,t);let a=new Float32Array(6),s=new Float32Array(6),n=GK(e,a),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,d=t.strategy,u=t.onProgress,p=e.index.count/3,f=!1,m=[],g=FK(e);if(g.length===1){let y=g[0],x=new cm;x.boundingData=a,UK(n,y.offset,y.count,s),r(x,y.offset,y.count,s),m.push(x)}else for(let y of g){let x=new cm;x.boundingData=new Float32Array(6),S1(n,y.offset,y.count,x.boundingData,s),r(x,y.offset,y.count,s),m.push(x)}return m}function qK(e,t){let i=WK(e,t),r,a,s,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<i.length;c++){let d=i[c],u=l(d),p=new o(32*u);r=new Float32Array(p),a=new Uint32Array(p),s=new Uint16Array(p),h(0,d),n.push(p)}return n;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function h(c,d){let u=c/4,p=c/2,f=!!d.count,m=d.boundingData;for(let g=0;g<6;g++)r[u+g]=m[g];if(f){let g=d.offset,y=d.count;return a[u+6]=g,s[p+14]=y,s[p+15]=65535,c+32}else{let g=d.left,y=d.right,x=d.splitAxis,b;if(b=h(c+32,g),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return a[u+6]=b/4,b=h(b,y),a[u+7]=x,b}}}var qn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let a=0,s=e.length;a<s;a++){let n=e[a][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let a=0,s=t.length;a<s;a++){let n=t[a],o=e.dot(n);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};qn.prototype.setFromBox=function(){let e=new O;return function(t,i){let r=i.min,a=i.max,s=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+a.x*(1-o),e.y=r.y*l+a.y*(1-l),e.z=r.z*h+a.z*(1-h);let c=t.dot(e);s=Math.min(c,s),n=Math.max(c,n)}this.min=s,this.max=n}}();var lhe=function(){let e=new qn;return function(t,i){let r=t.points,a=t.satAxes,s=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let c=s[h],d=a[h];if(e.setFromPoints(d,n),c.isSeparated(e))return!1}for(let h=0;h<3;h++){let c=l[h],d=o[h];if(e.setFromPoints(d,r),c.isSeparated(e))return!1}}}(),XK=function(){let e=new O,t=new O,i=new O;return function(r,a,s){let n=r.start,o=e,l=a.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(a.end,a.start);let c=i.dot(h),d=h.dot(o),u=h.dot(h),p=i.dot(o),f=o.dot(o)*u-d*d,m,g;f!==0?m=(c*d-p*u)/f:m=0,g=(c+m*d)/u,s.x=m,s.y=g}}(),$w=function(){let e=new ae,t=new O,i=new O;return function(r,a,s,n){XK(r,a,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,s),a.at(l,n);return}else if(o>=0&&o<=1){l<0?a.at(0,n):a.at(1,n),r.closestPointToPoint(n,!0,s);return}else if(l>=0&&l<=1){o<0?r.at(0,s):r.at(1,s),a.closestPointToPoint(s,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=a.start:c=a.end;let d=t,u=i;if(r.closestPointToPoint(c,!0,t),a.closestPointToPoint(h,!0,i),d.distanceToSquared(c)<=u.distanceToSquared(h)){s.copy(d),n.copy(c);return}else{s.copy(h),n.copy(u);return}}}}(),YK=function(){let e=new O,t=new O,i=new Ka,r=new zs;return function(a,s){let{radius:n,center:o}=a,{a:l,b:h,c}=s;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let d=s.getPlane(i);if(Math.abs(d.distanceToPoint(o))<=n){let u=d.projectPoint(o,t);if(s.containsPoint(u))return!0}return!1}}(),QK=1e-15;function Tc(e){return Math.abs(e)<QK}var Go=class extends ya{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new O),this.satBounds=new Array(4).fill().map(()=>new qn),this.points=[this.a,this.b,this.c],this.sphere=new cs,this.plane=new Ka,this.needsUpdate=!0}intersectsSphere(e){return YK(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,a=this.satAxes,s=this.satBounds,n=a[0],o=s[0];this.getNormal(n),o.setFromPoints(n,r);let l=a[1],h=s[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=a[2],d=s[2];c.subVectors(t,i),d.setFromPoints(c,r);let u=a[3],p=s[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};Go.prototype.closestPointToSegment=function(){let e=new O,t=new O,i=new zs;return function(r,a=null,s=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let d=0;d<3;d++){let u=(d+1)%3;i.start.copy(l[d]),i.end.copy(l[u]),$w(i,r,e,t),h=e.distanceToSquared(t),h<c&&(c=h,a&&a.copy(e),s&&s.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(o)),Math.sqrt(c)}}();Go.prototype.intersectsTriangle=function(){let e=new Go,t=new Array(3),i=new Array(3),r=new qn,a=new qn,s=new O,n=new O,o=new O,l=new O,h=new zs,c=new zs,d=new zs;return function(u,p=null,f=!1){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let m=this.plane,g=u.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let y=this.satBounds,x=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let S=0;S<4;S++){let A=y[S],E=x[S];if(r.setFromPoints(E,i),A.isSeparated(r))return!1}let b=u.satBounds,_=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){let A=b[S],E=_[S];if(r.setFromPoints(E,t),A.isSeparated(r))return!1}for(let S=0;S<4;S++){let A=x[S];for(let E=0;E<4;E++){let M=_[E];if(s.crossVectors(A,M),r.setFromPoints(s,t),a.setFromPoints(s,i),r.isSeparated(a))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let y=this.points,x=!1,b=0;for(let U=0;U<3;U++){let L=y[U],j=y[(U+1)%3];h.start.copy(L),h.end.copy(j),h.delta(n);let q=x?c.start:c.end,Q=Tc(g.distanceToPoint(L));if(Tc(g.normal.dot(n))&&Q){c.copy(h),b=2;break}if((g.intersectLine(h,q)||Q)&&!Tc(q.distanceTo(j))){if(b++,x)break;x=!0}}if(b===1&&u.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let _=u.points,S=!1,A=0;for(let U=0;U<3;U++){let L=_[U],j=_[(U+1)%3];h.start.copy(L),h.end.copy(j),h.delta(o);let q=S?d.start:d.end,Q=Tc(m.distanceToPoint(L));if(Tc(m.normal.dot(o))&&Q){d.copy(h),A=2;break}if((m.intersectLine(h,q)||Q)&&!Tc(q.distanceTo(j))){if(A++,S)break;S=!0}}if(A===1&&this.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(A!==2)return!1;if(c.delta(n),d.delta(o),n.dot(o)<0){let U=d.start;d.start=d.end,d.end=U}let E=c.start.dot(n),M=c.end.dot(n),T=d.start.dot(n),P=d.end.dot(n),R=M<T,z=E<P;return E!==P&&T!==M&&R===z?!1:(p&&(l.subVectors(c.start,d.start),l.dot(n)>0?p.start.copy(c.start):p.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(d.end)),!0)}}}();Go.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Go.prototype.distanceToTriangle=function(){let e=new O,t=new O,i=["a","b","c"],r=new zs,a=new zs;return function(s,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(s,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let d,u=i[c],p=s[u];this.closestPointToPoint(p,e),d=p.distanceToSquared(e),d<h&&(h=d,n&&n.copy(e),o&&o.copy(p));let f=this[u];s.closestPointToPoint(f,e),d=f.distanceToSquared(e),d<h&&(h=d,n&&n.copy(f),o&&o.copy(e))}for(let c=0;c<3;c++){let d=i[c],u=i[(c+1)%3];r.set(this[d],this[u]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];a.set(s[f],s[m]),$w(r,a,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Xn=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new O,this.max=new O,this.matrix=new je,this.invMatrix=new je,this.points=new Array(8).fill().map(()=>new O),this.satAxes=new Array(3).fill().map(()=>new O),this.satBounds=new Array(3).fill().map(()=>new qn),this.alignedSatBounds=new Array(3).fill().map(()=>new qn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Xn.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let d=1*l|2*h|4*c,u=r[d];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=c?i.z:t.z,u.applyMatrix4(e)}let a=this.satBounds,s=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=s[l],c=a[l],d=1<<l,u=r[d];h.subVectors(n,u),c.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Xn.prototype.intersectsBox=function(){let e=new qn;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,a=this.satBounds,s=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=s[o],h=a[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Xn.prototype.intersectsTriangle=function(){let e=new Go,t=new Array(3),i=new qn,r=new qn,a=new O;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(e.copy(s),e.update(),s=e);let n=this.satBounds,o=this.satAxes;t[0]=s.a,t[1]=s.b,t[2]=s.c;for(let d=0;d<3;d++){let u=n[d],p=o[d];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=s.satBounds,h=s.satAxes,c=this.points;for(let d=0;d<3;d++){let u=l[d],p=h[d];if(i.setFromPoints(p,c),u.isSeparated(i))return!1}for(let d=0;d<3;d++){let u=o[d];for(let p=0;p<4;p++){let f=h[p];if(a.crossVectors(u,f),i.setFromPoints(a,t),r.setFromPoints(a,c),i.isSeparated(r))return!1}}return!0}}();Xn.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Xn.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Xn.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new zs),i=new Array(12).fill().map(()=>new zs),r=new O,a=new O;return function(s,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(a),this.closestPointToPoint(a,r),s.closestPointToPoint(r,a),o&&o.copy(r),l&&l.copy(a)),0;let h=n*n,c=s.min,d=s.max,u=this.points,p=1/0;for(let m=0;m<8;m++){let g=u[m];a.copy(g).clamp(c,d);let y=g.distanceToSquared(a);if(y<p&&(p=y,o&&o.copy(g),l&&l.copy(a),y<h))return Math.sqrt(y)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let y=0;y<=1;y++){let x=(m+1)%3,b=(m+2)%3,_=g<<x|y<<b,S=1<<m|g<<x|y<<b,A=u[_],E=u[S];t[f].set(A,E);let M=e[m],T=e[x],P=e[b],R=i[f],z=R.start,U=R.end;z[M]=c[M],z[T]=g?c[T]:d[T],z[P]=y?c[P]:d[T],U[M]=d[M],U[T]=g?c[T]:d[T],U[P]=y?c[P]:d[T],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let y=0;y<=1;y++){a.x=m?d.x:c.x,a.y=g?d.y:c.y,a.z=y?d.z:c.z,this.closestPointToPoint(a,r);let x=a.distanceToSquared(r);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(a),x<h))return Math.sqrt(x)}for(let m=0;m<12;m++){let g=t[m];for(let y=0;y<12;y++){let x=i[y];$w(g,x,r,a);let b=r.distanceToSquared(a);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(a),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var Pc=new O,Dc=new O,Ic=new O,pm=new ae,fm=new ae,mm=new ae,kE=new O,FE=new O,UE=new O,gm=new O;function KK(e,t,i,r,a,s){let n;return s===na?n=e.intersectTriangle(r,i,t,!0,a):n=e.intersectTriangle(t,i,r,s!==Pa,a),n===null?null:{distance:e.origin.distanceTo(a),point:a.clone()}}function ZK(e,t,i,r,a,s,n,o,l){Pc.fromBufferAttribute(t,s),Dc.fromBufferAttribute(t,n),Ic.fromBufferAttribute(t,o);let h=KK(e,Pc,Dc,Ic,gm,l);if(h){r&&(pm.fromBufferAttribute(r,s),fm.fromBufferAttribute(r,n),mm.fromBufferAttribute(r,o),h.uv=ya.getInterpolation(gm,Pc,Dc,Ic,pm,fm,mm,new ae)),a&&(pm.fromBufferAttribute(a,s),fm.fromBufferAttribute(a,n),mm.fromBufferAttribute(a,o),h.uv1=ya.getInterpolation(gm,Pc,Dc,Ic,pm,fm,mm,new ae)),i&&(kE.fromBufferAttribute(i,s),FE.fromBufferAttribute(i,n),UE.fromBufferAttribute(i,o),h.normal=ya.getInterpolation(gm,Pc,Dc,Ic,kE,FE,UE,new O),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let c={a:s,b:n,c:o,normal:new O,materialIndex:0};ya.getNormal(Pc,Dc,Ic,c.normal),h.face=c,h.faceIndex=s}return h}function iI(e,t,i,r,a){let s=r*3,n=e.index.getX(s),o=e.index.getX(s+1),l=e.index.getX(s+2),{position:h,normal:c,uv:d,uv1:u}=e.attributes,p=ZK(i,h,c,d,u,n,o,l,t);return p?(p.faceIndex=r,a&&a.push(p),p):null}function JK(e,t,i,r,a,s){for(let n=r,o=r+a;n<o;n++)iI(e,t,i,n,s)}function $K(e,t,i,r,a){let s=1/0,n=null;for(let o=r,l=r+a;o<l;o++){let h=iI(e,t,i,o);h&&h.distance<s&&(n=h,s=h.distance)}return n}function On(e,t,i,r){let a=e.a,s=e.b,n=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),a.x=r.getX(o),a.y=r.getY(o),a.z=r.getZ(o),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function NE(e,t,i,r,a,s,n){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(On(n,h*3,o,l),n.needsUpdate=!0,r(n,h,a,s))return!0;return!1}var rI=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function Ml(e,t){return t[e+15]===65535}function dd(e,t){return t[e+6]}function Up(e,t){return t[e+14]}function Np(e){return e+8}function Vp(e,t){return t[e+6]}function eZ(e,t){return t[e+7]}var ad=new wr,hv=new O,tZ=["x","y","z"];function tb(e,t,i,r,a){let s=e*2,n=Jd,o=Nl,l=Vl;if(Ml(s,o)){let h=dd(e,l),c=Up(s,o);JK(t,i,r,h,c,a)}else{let h=Np(e);cv(h,n,r,hv)&&tb(h,t,i,r,a);let c=Vp(e,l);cv(c,n,r,hv)&&tb(c,t,i,r,a)}}function ib(e,t,i,r){let a=e*2,s=Jd,n=Nl,o=Vl;if(Ml(a,n)){let l=dd(e,o),h=Up(a,n);return $K(t,i,r,l,h)}else{let l=eZ(e,o),h=tZ[l],c=r.direction[h]>=0,d,u;c?(d=Np(e),u=Vp(e,o)):(d=Vp(e,o),u=Np(e));let p=cv(d,s,r,hv)?ib(d,t,i,r):null;if(p){let m=p.point[h];if(c?m<=s[u+l]:m>=s[u+l+3])return p}let f=cv(u,s,r,hv)?ib(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var iZ=function(){let e,t,i=[],r=new rI(()=>new wr);return function(...s){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=a(...s);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function a(s,n,o,l,h=null,c=0,d=0){function u(x){let b=x*2,_=Nl,S=Vl;for(;!Ml(b,_);)x=Np(x),b=x*2;return dd(x,S)}function p(x){let b=x*2,_=Nl,S=Vl;for(;!Ml(b,_);)x=Vp(x,S),b=x*2;return dd(x,S)+Up(b,_)}let f=s*2,m=Jd,g=Nl,y=Vl;if(Ml(f,g)){let x=dd(s,y),b=Up(f,g);return Bn(s,m,e),l(x,b,!1,d,c+s,e)}else{let x=Np(s),b=Vp(s,y),_=x,S=b,A,E,M,T;if(h&&(M=e,T=t,Bn(_,m,M),Bn(S,m,T),A=h(M),E=h(T),E<A)){_=b,S=x;let q=A;A=E,E=q,M=T}M||(M=e,Bn(_,m,M));let P=Ml(_*2,g),R=o(M,P,A,d+1,c+_),z;if(R===2){let q=u(_),Q=p(_)-q;z=l(q,Q,!0,d+1,c+_,M)}else z=R&&a(_,n,o,l,h,c,d+1);if(z)return!0;T=t,Bn(S,m,T);let U=Ml(S*2,g),L=o(T,U,E,d+1,c+S),j;if(L===2){let q=u(S),Q=p(S)-q;j=l(q,Q,!0,d+1,c+S,T)}else j=L&&a(S,n,o,l,h,c,d+1);return!!j}}}(),rZ=function(){let e=new Go,t=new Go,i=new je,r=new Xn,a=new Xn;return function s(n,o,l,h,c=null){let d=n*2,u=Jd,p=Nl,f=Vl;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),c=r),Ml(d,p)){let m=o,g=m.index,y=m.attributes.position,x=l.index,b=l.attributes.position,_=dd(n,f),S=Up(d,p);if(i.copy(h).invert(),l.boundsTree)return Bn(n,u,a),a.matrix.copy(i),a.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>a.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let E=_*3,M=(S+_)*3;E<M;E+=3)if(On(t,E,g,y),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=_*3,E=S+_*3;A<E;A+=3){On(e,A,g,y),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let M=0,T=x.count;M<T;M+=3)if(On(t,M,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return Bn(m,u,ad),!!(c.intersectsBox(ad)&&s(m,o,l,h,c)||(Bn(g,u,ad),c.intersectsBox(ad)&&s(g,o,l,h,c)))}}}();function cv(e,t,i,r){return Bn(e,t,ad),i.intersectBox(ad,r)}var rb=[],lg,Jd,Nl,Vl;function Ku(e){lg&&rb.push(lg),lg=e,Jd=new Float32Array(e),Nl=new Uint16Array(e),Vl=new Uint32Array(e)}function vm(){lg=null,Jd=null,Nl=null,Vl=null,rb.length&&Ku(rb.pop())}var A1=Symbol("skip tree generation"),M1=new wr,E1=new wr,Oc=new je,hh=new Xn,Cu=new Xn,Tu=new O,ym=new O,aZ=new O,sZ=new O,nZ=new O,VE=new wr,yn=new rI(()=>new Go),dp=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),dp.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,a=i.getIndex(),s;return t.cloneBuffers?s={roots:r.map(n=>n.slice()),index:a.array.slice()}:s={roots:r,index:a.array},s}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),dp.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:a}=e,s=new dp(t,{...i,[A1]:!0});if(s._roots=a,i.setIndex){let n=t.getIndex();if(n===null){let o=new Pt(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return s}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[A1]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[A1]||(this._roots=qK(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new wr))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,a,s,n,o,l=0,h=this._roots;for(let d=0,u=h.length;d<u;d++)a=h[d],s=new Uint32Array(a),n=new Uint16Array(a),o=new Float32Array(a),c(0,l),l+=a.byteLength;function c(d,u,p=!1){let f=d*2;if(n[f+15]===65535){let m=s[d+6],g=n[f+14],y=1/0,x=1/0,b=1/0,_=-1/0,S=-1/0,A=-1/0;for(let E=3*m,M=3*(m+g);E<M;E++){let T=i[E],P=r.getX(T),R=r.getY(T),z=r.getZ(T);P<y&&(y=P),P>_&&(_=P),R<x&&(x=R),R>S&&(S=R),z<b&&(b=z),z>A&&(A=z)}return o[d+0]!==y||o[d+1]!==x||o[d+2]!==b||o[d+3]!==_||o[d+4]!==S||o[d+5]!==A?(o[d+0]=y,o[d+1]=x,o[d+2]=b,o[d+3]=_,o[d+4]=S,o[d+5]=A,!0):!1}else{let m=d+8,g=s[d+6],y=m+u,x=g+u,b=p,_=!1,S=!1;e?b||(_=e.has(y),S=e.has(x),b=!_&&!S):(_=!0,S=!0);let A=b||_,E=b||S,M=!1;A&&(M=c(m,u,b));let T=!1;E&&(T=c(g,u,b));let P=M||T;if(P)for(let R=0;R<3;R++){let z=m+R,U=g+R,L=o[z],j=o[z+3],q=o[U],Q=o[U+3];o[d+R]=L<q?L:q,o[d+R+3]=j>Q?j:Q}return P}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),a=new Uint16Array(i);s(0);function s(n,o=0){let l=n*2,h=a[l+15]===65535;if(h){let c=r[n+6],d=a[l+14];e(o,h,new Float32Array(i,n*4,6),c,d)}else{let c=n+8,d=r[n+6],u=r[n+7];e(o,h,new Float32Array(i,n*4,6),u)||(s(c,o+1),s(d,o+1))}}}raycast(e,t=nn){let i=this._roots,r=this.geometry,a=[],s=t.isMaterial,n=Array.isArray(t),o=r.groups,l=s?t.side:t;for(let h=0,c=i.length;h<c;h++){let d=n?t[o[h].materialIndex].side:l,u=a.length;if(Ku(i[h]),tb(0,r,d,e,a),vm(),n){let p=o[h].materialIndex;for(let f=u,m=a.length;f<m;f++)a[f].face.materialIndex=p}}return a}raycastFirst(e,t=nn){let i=this._roots,r=this.geometry,a=t.isMaterial,s=Array.isArray(t),n=null,o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let d=s?t[o[h].materialIndex].side:l;Ku(i[h]);let u=ib(0,r,d,e);vm(),u!=null&&(n==null||u.distance<n.distance)&&(n=u,s&&(u.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let a of this._roots)if(Ku(a),r=rZ(0,i,e,t),vm(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let d=t;t=(u,p,f,m)=>{let g=p*3;return d(u,g,g+1,g+2,f,m)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let a=yn.getPrimitive(),{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let d=o;o=(u,p,f,m,g)=>d(u,p,f,m,g)?!0:NE(u,p,r,l,f,m,a)}else o||(l?o=(d,u,p,f)=>NE(d,u,r,l,p,f,a):o=(d,u,p)=>p);let h=!1,c=0;for(let d of this._roots){if(Ku(d),h=iZ(0,r,n,o,s,c),vm(),h)break;c+=d.byteLength}return yn.releasePrimitive(a),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:a}=i,s=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Oc.copy(t).invert();let h=yn.getPrimitive(),c=yn.getPrimitive();if(a){let u=function(p,f,m,g,y,x,b,_){for(let S=m,A=m+g;S<A;S++){On(c,S*3,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let E=p,M=p+f;E<M;E++)if(On(h,E*3,s,n),h.needsUpdate=!0,a(h,c,E,S,y,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,m,g,y,x,b,_,S){return p(f,m,g,y,x,b,_,S)?!0:u(f,m,g,y,x,b,_,S)}}else r=u}e.getBoundingBox(E1),E1.applyMatrix4(t);let d=this.shapecast({intersectsBounds:u=>E1.intersectsBox(u),intersectsRange:(u,p,f,m,g,y)=>(M1.copy(y),M1.applyMatrix4(Oc),e.shapecast({intersectsBounds:x=>M1.intersectsBox(x),intersectsRange:(x,b,_,S,A)=>r(u,p,x,b,m,g,S,A)}))});return yn.releasePrimitive(h),yn.releasePrimitive(c),d}intersectsBox(e,t){return hh.set(e.min,e.max,t),hh.needsUpdate=!0,this.shapecast({intersectsBounds:i=>hh.intersectsBox(i),intersectsTriangle:i=>hh.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},a=0,s=1/0){e.boundingBox||e.computeBoundingBox(),hh.set(e.boundingBox.min,e.boundingBox.max,t),hh.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,d=yn.getPrimitive(),u=yn.getPrimitive(),p=ym,f=aZ,m=null,g=null;r&&(m=sZ,g=nZ);let y=1/0,x=null,b=null;return Oc.copy(t).invert(),Cu.matrix.copy(Oc),this.shapecast({boundsTraverseOrder:_=>hh.distanceToBox(_),intersectsBounds:(_,S,A)=>A<y&&A<s?(S&&(Cu.min.copy(_.min),Cu.max.copy(_.max),Cu.needsUpdate=!0),!0):!1,intersectsRange:(_,S)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Cu.distanceToBox(A),intersectsBounds:(A,E,M)=>M<y&&M<s,intersectsRange:(A,E)=>{for(let M=A*3,T=(A+E)*3;M<T;M+=3){On(u,M,c,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let P=_*3,R=(_+S)*3;P<R;P+=3){On(d,P,l,o),d.needsUpdate=!0;let z=d.distanceToTriangle(u,p,m);if(z<y&&(f.copy(p),g&&g.copy(m),y=z,x=P/3,b=M/3),z<a)return!0}}}});{let A=c?c.count:h.count;for(let E=0,M=A;E<M;E+=3){On(u,E,c,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let T=_*3,P=(_+S)*3;T<P;T+=3){On(d,T,l,o),d.needsUpdate=!0;let R=d.distanceToTriangle(u,p,m);if(R<y&&(f.copy(p),g&&g.copy(m),y=R,x=T/3,b=E/3),R<a)return!0}}}}}),yn.releasePrimitive(d),yn.releasePrimitive(u),y===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=y,i.faceIndex=x,r&&(r.point?r.point.copy(g):r.point=g.clone(),r.point.applyMatrix4(Oc),f.applyMatrix4(Oc),r.distance=f.sub(r.point).length(),r.faceIndex=b),i)}closestPointToPoint(e,t={},i=0,r=1/0){let a=i*i,s=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Tu.copy(e).clamp(h.min,h.max),Tu.distanceToSquared(e)),intersectsBounds:(h,c,d)=>d<n&&d<s,intersectsTriangle:(h,c)=>{h.closestPointToPoint(e,Tu);let d=e.distanceToSquared(Tu);return d<n&&(ym.copy(Tu),n=d,o=c),d<a}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(ym):t.point=ym.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Bn(0,new Float32Array(t),VE),e.union(VE)}),e}},ab=Xl(pz()),oZ=.5*(Math.sqrt(3)-1),Pu=(3-Math.sqrt(3))/6,lZ=1/3,xn=1/6,hhe=(Math.sqrt(5)-1)/4,che=(5-Math.sqrt(5))/20,up=e=>Math.floor(e)|0,jE=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]),C1=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 hZ(e=Math.random){let t=aI(e),i=new Float64Array(t).map(a=>jE[a%12*2]),r=new Float64Array(t).map(a=>jE[a%12*2+1]);return function(a,s){let n=0,o=0,l=0,h=(a+s)*oZ,c=up(a+h),d=up(s+h),u=(c+d)*Pu,p=c-u,f=d-u,m=a-p,g=s-f,y,x;m>g?(y=1,x=0):(y=0,x=1);let b=m-y+Pu,_=g-x+Pu,S=m-1+2*Pu,A=g-1+2*Pu,E=c&255,M=d&255,T=.5-m*m-g*g;if(T>=0){let z=E+t[M],U=i[z],L=r[z];T*=T,n=T*T*(U*m+L*g)}let P=.5-b*b-_*_;if(P>=0){let z=E+y+t[M+x],U=i[z],L=r[z];P*=P,o=P*P*(U*b+L*_)}let R=.5-S*S-A*A;if(R>=0){let z=E+1+t[M+1],U=i[z],L=r[z];R*=R,l=R*R*(U*S+L*A)}return 70*(n+o+l)}}function cZ(e=Math.random){let t=aI(e),i=new Float64Array(t).map(s=>C1[s%12*3]),r=new Float64Array(t).map(s=>C1[s%12*3+1]),a=new Float64Array(t).map(s=>C1[s%12*3+2]);return function(s,n,o){let l,h,c,d,u=(s+n+o)*lZ,p=up(s+u),f=up(n+u),m=up(o+u),g=(p+f+m)*xn,y=p-g,x=f-g,b=m-g,_=s-y,S=n-x,A=o-b,E,M,T,P,R,z;_>=S?S>=A?(E=1,M=0,T=0,P=1,R=1,z=0):_>=A?(E=1,M=0,T=0,P=1,R=0,z=1):(E=0,M=0,T=1,P=1,R=0,z=1):S<A?(E=0,M=0,T=1,P=0,R=1,z=1):_<A?(E=0,M=1,T=0,P=0,R=1,z=1):(E=0,M=1,T=0,P=1,R=1,z=0);let U=_-E+xn,L=S-M+xn,j=A-T+xn,q=_-P+2*xn,Q=S-R+2*xn,X=A-z+2*xn,ie=_-1+3*xn,oe=S-1+3*xn,te=A-1+3*xn,re=p&255,fe=f&255,ce=m&255,de=.6-_*_-S*S-A*A;if(de<0)l=0;else{let Ae=re+t[fe+t[ce]];de*=de,l=de*de*(i[Ae]*_+r[Ae]*S+a[Ae]*A)}let se=.6-U*U-L*L-j*j;if(se<0)h=0;else{let Ae=re+E+t[fe+M+t[ce+T]];se*=se,h=se*se*(i[Ae]*U+r[Ae]*L+a[Ae]*j)}let Pe=.6-q*q-Q*Q-X*X;if(Pe<0)c=0;else{let Ae=re+P+t[fe+R+t[ce+z]];Pe*=Pe,c=Pe*Pe*(i[Ae]*q+r[Ae]*Q+a[Ae]*X)}let ve=.6-ie*ie-oe*oe-te*te;if(ve<0)d=0;else{let Ae=re+1+t[fe+1+t[ce+1]];ve*=ve,d=ve*ve*(i[Ae]*ie+r[Ae]*oe+a[Ae]*te)}return 32*(l+h+c+d)}}function aI(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),a=t[i];t[i]=t[r],t[r]=a}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var qs=new ya,dZ=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let a=1;qs.a.fromBufferAttribute(e,r),qs.b.fromBufferAttribute(e,r+1),qs.c.fromBufferAttribute(e,r+2),a*=qs.getArea(),t[r/3]=a}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,a=-1;for(;i<=r;){let s=Math.ceil((i+r)/2);if(s===0||t[s-1]<=e&&t[s]>e){a=s;break}else e<t[s]?r=s-1:i=s+1}return a}sampleFace(e,t,i){let r=this.randomFunction(),a=this.randomFunction();return r+a>1&&(r=1-r,a=1-a),qs.a.fromBufferAttribute(this.positionAttribute,e*3),qs.b.fromBufferAttribute(this.positionAttribute,e*3+1),qs.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(qs.a,r).addScaledVector(qs.b,a).addScaledVector(qs.c,1-(r+a)),qs.getNormal(i),this}},uZ=Xl(v3()),pZ=new je,fZ=new je,mZ=new je,jh;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(jh||(jh={}));var e_=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new je,this.copyPreviousMatrix=!0,this.hiddenMatrix=new je,this.pivotMatrix=new je,this.matrixWorldRigid=new je,this.shearScale=new je,this.shearScaleInv=new je}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Ci&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)jh.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)jh.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:a,q:s}=(0,uZ.SVD)(i),n=pZ.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=fZ.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),l=mZ.copy(o).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),s.every(h=>Math.abs(s[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new je().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof je?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,a,s,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},gZ=class extends e_(Ci){},vZ=e=>e.type==="Mesh",wa=class extends gZ{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new wa(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix,i.pivotMatrix=t.pivotMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return vZ(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}},yh=new O,xh=new O,ud=new je,sI=[new O(-1,1,1),new O(-1,-1,1),new O(1,-1,1),new O(1,1,1),new O(-1,1,-1),new O(-1,-1,-1),new O(1,-1,-1),new O(1,1,-1)],yZ=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],xZ=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],HE=(e,t,i)=>{e.updateEntityBoxSize(yh,xh),ud.copy(t).multiply(e.matrixWorld),xh.x===0&&xh.y===0&&xh.z===0?i.push(new O(yh.x,yh.y,yh.z).applyMatrix4(ud)):sI.forEach(r=>{i.push(r.clone().multiply(xh).add(yh).applyMatrix4(ud))})},GE=class extends wr{constructor(){super(...arguments),this.matrix=new je,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new je().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){r.push(new O);return}HE(a,t,r)}}):HE(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(ud.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(xh).multiplyScalar(.5),this.getCenter(yh),ud.copy(this.matrix).setPosition(yh),this.vertices=sI.map(e=>e.clone().multiply(xh).applyMatrix4(ud))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=yZ.map(([e,t])=>new zs(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new O))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=xZ.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},Ol={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},bZ=class extends X3{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),a=r[r.length-1]/r.length;for(let s=0,n=this.curves;s<n.length;s++){let o=n[s],l=s===0?r[s]:r[s]-r[s-1],h=Math.ceil(e*l/a),c=o.getPoints(h);for(let d=0;d<c.length;d++){let u=c[d];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},sb=.001;function nb(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=sb}function T1(e,t){let i=new O(...e.position),r=new O(...e.controlNext.position),a=new O(...t.controlPrevious.position),s=new O(...t.position);return nb(i,r,s)&&nb(i,a,s)}function nI(e){let t=e.points.map(c=>new O(...c.data.position)),i=[e.points[0]],r=new O(...i[0].data.position);for(let c=0;c<e.points.length-1;c++)nb(r,t[c],t[c+1])||(i.push(e.points[c]),r=t[c]);i.push(e.points[e.points.length-1]);let a=e.isClosed,s=i.length-(a?0:1),n=i.length,o=[];for(let c=0;c<n;c++){let d=i[c].data,u=new O(...d.position),p=new O(...d.controlPrevious.position),f=new O(...d.controlNext.position),m={position:u,baseRoundness:d.roundness,controlPrevious:p,controlNext:f};if(d.roundness===0||!e.isClosed&&(c===0||c===n-1)){o[c]={...m,removedLength:0};continue}let g=a&&c==0?n-1:c-1,y=a&&c==n-1?0:c+1,x=i[g].data,b=i[y].data,_=new O(...x.position),S=new O(...b.position),A=_.clone().sub(u).normalize(),E=S.clone().sub(u).normalize();Object.assign(m,{prevDir:A,nextDir:E});let M=T1(x,d),T=T1(d,b);if(!M||!T)o[c]={...m,removedLength:0};else{let P=A.clone().add(E).normalize(),R=P.clone().cross(A).length()/A.dot(P);o[c]={...m,tan:R,removedLength:d.roundness/R}}}for(let c=0;c<s;c++){let d=c,u=a&&c===n-1?0:c+1,p=o[d],f=o[u];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let d=c,u=a&&c===n-1?0:c+1,p=o[d],f=o[u],m=null;if(!T1(i[d].data,i[u].data))p.position.distanceTo(f.position)>sb&&(m=new ig(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),y=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&y.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(y)>sb&&(m=new ig(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c<n;c++){let d=o[c];if(d.removedLength===0){l[2*c]=null;continue}let u=d.position,p=d.prevDir.clone().multiplyScalar(d.removedLength).add(u),f=d.nextDir.clone().multiplyScalar(d.removedLength).add(u),m=d.tan*d.removedLength,g=d.prevDir.clone().add(d.nextDir).normalize(),y=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(x,2))).add(y),_=g.clone().multiplyScalar(-m).add(b),S=u.distanceTo(_)/u.distanceTo(y),A=d.prevDir.clone().multiplyScalar(S*u.distanceTo(p)).add(u),E=A.clone().lerp(_,2),M=p.clone().lerp(A,4/3),T=f.clone().lerp(E,4/3);l[2*c]=new ig(p,M,T,f)}let h=new bZ;return l.forEach(c=>{c&&h.add(c)}),h}var oi;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(oi||(oi={}));var Mo=e=>oi.is(e),wZ={type:"completeState",isfromEntity:!0},_Z=["x","y","z"],Du=new O,WE=new O(1,1,1),P1=new Rt,qE=new xr,SZ=new O().set(0,1,0),t_=e=>class extends e_(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new GE,this._recursiveBBox=new GE,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(oi.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(oi.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(oi.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let a of this.data.states)Il.toOps(this.data,a.data).forEach(s=>{let n=Ng.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=Il.patch(this.data,a),Il.toOps(this.data,a).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{Mo(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(oi.is(i[r]))return i[r];if(oi.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&oi.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)Mo(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{oi.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Mo(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Mo(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Mo(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>Mo(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*tt.RAD2DEG,this.rotation.y*tt.RAD2DEG,this.rotation.z*tt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return sx(i,t)}getTransformValues(t,i,r){return i[t].map((a,s)=>r?.shared.getVariable(a,[this.uuid,t,_Z[s]])??a)}updateTransformState(t,i){let r=!1;if(t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Du.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(tt.DEG2RAD),this.rotation.setFromVector3(Du),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Cd.identity)),t.pivot!==void 0||t.pivotRotation!==void 0){if(r=!0,t.pivot!==void 0&&t.pivotRotation!==void 0)this.pivotMatrix.compose(Du.fromArray(t.pivot).negate(),P1.setFromEuler(qE.fromArray(t.pivotRotation.map(a=>a*tt.DEG2RAD))).invert(),WE);else if(t.pivot!==void 0)this.pivotMatrix.setPosition(-t.pivot[0],-t.pivot[1],-t.pivot[2]);else if(t.pivotRotation!==void 0){let a=Du.setFromMatrixPosition(this.pivotMatrix);P1.setFromEuler(qE.fromArray(t.pivotRotation.map(s=>s*tt.DEG2RAD))).invert(),this.pivotMatrix.compose(a,P1,WE)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)oi.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{oi.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return sx(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,a){let s=this.data;this.data=i;let n=t,o=Bi(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let d=Gr.zoom(c,t.path.slice(2));if(d)for(let u in t.props)t.props[u]===void 0&&u in d&&(h[u]=d[u])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:c,...d}=l;l=d}let h=Gr.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Il.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Bi(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[c],d.updateState(kl.apply(d.component.data,d.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let d=Gr.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(u===t.props&&(u={...t.props}),u[p]=d[p]);t={...t,props:u}}c.overrideData=$g.resolve(i.overrides,l),c.updateByOp(t,aa.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of Dl.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of Dl.rootOverrideProps)if(Bi(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=kl.filterOp(h.overrideData,l);c&&h.updateByOp(c,aa.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=kl.filterOp(h.overrideData,t);if(c){let d;s===h.data&&t===c?d=i:d=aa.applySimple(h.data,c),h.updateByOp(c,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Vh.is(t.props.type)&&Ol.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Ol.changeEntityProptotype(this,i,r);for(let a of this.children)oi.is(a)&&a.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let a=i.morphTargetInfluences.get(t.path[1])?.data.name;a&&this.updateMorphInfluences(a,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",a]))}if(Bi(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Bi(t.path,["cloner"])!==null){let a=aa.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=nI(o.geometry.path),h=(r+a)%1;r+a===1&&h===0&&(h=1);let c=null;try{c=l.curves.length?l.getPointAt(h):null}catch{}if(c===null)return;let d=this.parent?this.parent?.matrixWorld:new je;n.updateMatrixWorld();let u=new je().multiplyMatrices(d.clone().invert(),n.matrixWorld);c.applyMatrix4(u);let p={position:c.toArray(),rotation:o.rotation};if(s==="tangential"){let f=new je().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(c),g=new je().lookAt(c,m,SZ),y=Du.setFromEuler(new xr().setFromRotationMatrix(g)).multiplyScalar(tt.RAD2DEG);p={...p,rotation:y.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(wZ)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof Ol.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Ol.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},oI=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,a=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);a.thetaLength=tt.clamp(a.thetaLength,0,360);let s=a.width/2,n=a.radiusTop??s,o=a.radiusBottom??s;if(n===o?(n=s,o=s):n>o?(n=s,o=o*s/n):(n=n*s/o,o=s),a.shapeBlendNode){n=i??s,o=r??s;let l=Math.max(n,o)*2;a.width=l,a.depth=l}return{parameters:Object.assign(a,{width:Math.abs(a.width),height:Math.abs(a.height??a.width),depth:Math.abs(a.depth??a.width),radiusTop:n,radiusBottom:o})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:d,cornerSegments:u,hollow:p}=e.parameters,f;return l===0?(f=new vt,f.setAttribute("position",new nt([],3))):d||p?f=new lI(h,c,r,a,s,n,o,l*Math.PI/180,d,d,u,p):f=new iw(h,c,r,a,s,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function ll(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function XE(e){return new ae(e.y,-e.x)}var lI=class extends vt{constructor(e,t,i,r,a,s,n,o,l,h,c,d,u=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,a=Math.floor(a)||1,s=s!==void 0?s:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,s&&(l=0,h=0);let p=[],f=[],m=[],g=[],y=0,x=i/2,b=new O,_=new O;u&&e==0&&(e=l),u&&t==0&&(t=h);let S=new ae(e,x),A=new ae(t,-x),E=null,M=null,T=null,P=null,R=S.clone().sub(A),z=0,U=0,L=0;d>0&&(z=Math.min(e,t)*(1-d),U=e-z,L=t-z);let j=S.clone();j.x-=z;let q=Math.PI-R.angle(),Q=R.angle(),X=Math.tan(Q/2),ie=Math.tan(q/2),oe=X+ie,te=d?oe:ie,re=d?oe:X;if(l=Math.min(l,(e-U)/te,R.length()/oe),h=Math.min(h,(t-L)/re,R.length()/oe),l>0){let ve=l/X;E=S.clone().sub(new ae(ve,l)),d&&(T=E.clone(),T.x-=z-oe*l),S.sub(R.clone().setLength(ve))}if(h>0){let ve=h/ie;M=A.clone().sub(new ae(ve,-h)),A.add(R.clone().setLength(ve)),d&&(P=M.clone(),P.x-=z-oe*h,j.sub(R.clone().setLength(ve)))}R=S.clone().sub(A);let fe=R.length()<.5,ce=[];for(let ve=0;ve<=r;ve++){let Ae=[],ye=ve/r,Ve=ye*o+n,Ie=new ae(Math.sin(Ve),Math.cos(Ve));P&&M?(de(Ae,ye,Ie,q,h,P,-1,!0),de(Ae,ye,Ie,Q,h,M,-1,!1)):M?(se(Ae,Ie,M.x,0,-1),de(Ae,ye,Ie,Q,h,M,-1,!1)):s||se(Ae,Ie,t,L,-1);let Ce=XE(R).normalize();if(ll(Ce,Ie,b),!fe)for(let rt=0;rt<=a;rt++){let Je=rt/a,st=R.clone().multiplyScalar(Je).add(A);ll(st,Ie,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(ye,.5+_.y/i),Ae.push(y++)}if(T&&E?(de(Ae,ye,Ie,q,l,E,1,!1),de(Ae,ye,Ie,Q,l,T,1,!0)):E?(de(Ae,ye,Ie,q,l,E,1,!1),se(Ae,Ie,E.x,0,1)):s||se(Ae,Ie,e,U,1),d&&!fe){let rt=XE(R).multiplyScalar(-1).normalize();ll(rt,Ie,b);for(let Je=0;Je<=a;Je++){let st=Je/a,ot=R.clone().multiplyScalar(-st).add(j);ll(ot,Ie,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(ye,.5+_.y/i),Ae.push(y++)}}d&&!s&&Ae.push(Ae[0]),ce.push(Ae)}for(let ve=0;ve<ce.length-1;ve++)for(let Ae=0;Ae<ce[0].length-1;Ae++){if(s&&d&&Ae==a)continue;let ye=ce[ve][Ae],Ve=ce[ve+1][Ae],Ie=ce[ve+1][Ae+1],Ce=ce[ve][Ae+1],rt=f[Ie*3+0],Je=f[Ie*3+2];p.push(ye,Ve,Ce),(rt!=0||Je!=0)&&p.push(Ve,Ie,Ce)}o<Math.PI*2&&(Pe(-1,ce[0],n),Pe(1,ce[ce.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new nt(f,3)),this.setAttribute("normal",new nt(m,3)),this.setAttribute("uv",new nt(g,2));function de(ve,Ae,ye,Ve,Ie,Ce,rt,Je){for(let st=0;st<c+1;st++){let ot=st/c,Ke=rt<0?ot:1-ot;Je&&(Ke-=1),Ke*=Ve;let Qe=new ae(Math.sin(Ke),Math.cos(Ke)*rt),ft=Qe.clone().multiplyScalar(Ie).add(Ce);ll(ft,ye,_),f.push(_.x,_.y,_.z),ll(Qe,ye,b),m.push(b.x,b.y,b.z),g.push(Ae,.5+_.y/i),ve.push(y++)}}function se(ve,Ae,ye,Ve,Ie){let Ce=new O,rt=new ae,Je=[ye,Ve];Ie<0&&Je.reverse();for(let st of Je)rt.set(st,x*Ie),ll(rt,Ae,Ce),f.push(Ce.x,Ce.y,Ce.z),m.push(0,Ie,0),g.push(.5,.5),ve.push(y++)}function Pe(ve,Ae,ye){let Ve=new ae(Math.sin(ye),Math.cos(ye)),Ie=new ae(-Math.cos(ye),Math.sin(ye)),Ce=new O,rt=ve<0?(ot,Ke,Qe)=>p.push(ot,Ke,Qe):(ot,Ke,Qe)=>p.push(ot,Qe,Ke),Je=new ae((e+t+U+L)/4,0);ll(Je,Ve,Ce),f.push(Ce.x,Ce.y,Ce.z),m.push(Ie.x,0,Ie.y),g.push(.5,.5);let st=y++;for(let ot of Ae){let Ke=f.slice(ot*3,ot*3+3);f.push(...Ke),m.push(Ie.x,0,Ie.y);let Qe=g.slice(ot*2,ot*2+2);g.push(...Qe),y++}for(let ot=st+1;ot<y-1;ot++)rt(st,ot,ot+1);rt(st,y-1,st+1)}}},AZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=tt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:c,cornerSegments:d}=e.parameters,u;return l===0?(u=new vt,u.setAttribute("position",new nt([],3))):h>0||c>0||l<360?u=new lI(0,t/2,r,a,s,n,o,l*Math.PI/180,h,c,d,0,!0):u=new rw(t/2,r,a,s,n),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},MZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:a,heightSegments:s,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o===0?h=new ln(t,i,r,a,s,n):h=new EZ(t,i,r,a,s,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},D1=Math.PI/2,EZ=class extends vt{constructor(e=1,t=1,i=1,r=1,a=1,s=1,n=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),a=Math.floor(a),s=Math.floor(s),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let l=[],h=[],c=[],d=[],u=0;p("z","y","x",-1,-1,i,t,e,s,a),p("z","y","x",1,-1,i,t,-e,s,a),p("x","z","y",1,1,e,i,t,r,s),p("x","z","y",1,-1,e,i,-t,r,s),p("x","y","z",1,-1,e,t,i,r,a),p("x","y","z",-1,-1,e,t,-i,r,a),n>0&&(f("z","y","x",-1,-1,1,i,t,e,s),f("z","y","x",1,-1,-1,i,t,e,s),f("z","y","x",-1,1,-1,i,t,e,s),f("z","y","x",1,1,1,i,t,e,s),f("x","y","z",-1,-1,-1,e,t,i,r),f("x","y","z",1,-1,1,e,t,i,r),f("x","y","z",-1,1,1,e,t,i,r),f("x","y","z",1,1,-1,e,t,i,r),f("y","x","z",-1,-1,1,t,e,i,a),f("y","x","z",1,-1,-1,t,e,i,a),f("y","x","z",1,1,1,t,e,i,a),f("y","x","z",-1,1,-1,t,e,i,a),m(1,1,1),m(-1,1,1),m(1,-1,1),m(-1,-1,1),m(1,1,-1),m(-1,1,-1),m(1,-1,-1),m(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new nt(h,3)),this.setAttribute("normal",new nt(c,3)),this.setAttribute("uv",new nt(d,2));function p(g,y,x,b,_,S,A,E,M,T){let P=(S-2*n)/M,R=(A-2*n)/T,z=S/2-n,U=A/2-n,L=E/2,j=M+1,q=T+1,Q=0,X=new O;for(let ie=0;ie<q;ie++){let oe=ie*R-U;for(let te=0;te<j;te++){let re=te*P-z;X[g]=re*b,X[y]=oe*_,X[x]=L,h.push(X.x,X.y,X.z),X[g]=0,X[y]=0,X[x]=E>0?1:-1,c.push(X.x,X.y,X.z),d.push(te/M),d.push(1-ie/T),Q+=1}}for(let ie=0;ie<T;ie++)for(let oe=0;oe<M;oe++){let te=u+oe+j*ie,re=u+oe+j*(ie+1),fe=u+(oe+1)+j*(ie+1),ce=u+(oe+1)+j*ie;l.push(te,re,ce),l.push(re,fe,ce)}u+=Q}function f(g,y,x,b,_,S,A,E,M,T){let P=(A-2*n)/T,R=A/2-n,z=E/2-n,U=M/2,L=T+1,j=0,q=new O,Q=new O;for(let X=0;X<o+1;X++){let ie=X/o*D1,oe=Math.sin(ie)*n,te=(1-Math.cos(ie))*n,re=Math.sin(ie),fe=Math.cos(ie);q[y]=(z+oe)*_,q[x]=(U-te)*S,Q[g]=0,Q[y]=re*Math.sign(q[y]),Q[x]=fe*Math.sign(q[x]);for(let ce=0;ce<L;ce++){let de=ce*P-R;q[g]=de*b,h.push(q.x,q.y,q.z),c.push(Q.x,Q.y,Q.z),d.push(ce/T),d.push(0),j+=1}}for(let X=0;X<o;X++)for(let ie=0;ie<T;ie++){let oe=u+ie+L*X,te=u+ie+L*(X+1),re=u+(ie+1)+L*(X+1),fe=u+(ie+1)+L*X;l.push(oe,te,fe),l.push(te,re,fe)}u+=j}function m(g,y,x){let b=new O,_=new O(e/2,t/2,i/2);_.subScalar(n);let S=[],A=g*y*x>0?(M,T,P)=>l.push(M,T,P):(M,T,P)=>l.push(M,P,T);for(let M=0;M<=o;M++){let T=[],P=D1*(1-M/o),R=Math.cos(P),z=Math.sin(P),U=0;for(let L=0;L<=M;L++){let j=Math.cos(U),q=Math.sin(U);b.x=R*j,b.y=z,b.z=R*q;let Q=_.clone().addScaledVector(b,n);h.push(g*Q.x,y*Q.y,x*Q.z),c.push(g*b.x,y*b.y,x*b.z),d.push(0,0),T.push(u++),U+=D1/M}S.push(T)}let E=S.length-1;for(let M=0;M<E;M++){let T=S[M],P=S[M+1],R=T.length-1;A(T[0],P[1],P[0]);for(let z=1;z<=R;z++)A(T[z-1],T[z],P[z]),A(T[z],P[z+1],P[z])}}}},i_=class extends vt{constructor(e=[],t=[],i="",r=1,a=.2,s=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),c(),this.setAttribute("position",new nt(n,3)),this.setAttribute("normal",new nt(l,3)),this.setAttribute("uv",new nt(o,2));return;function h(){a=Math.min(1-1e-5,a),a==0&&(s=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new O,p=u.clone(),f=new ya,m=a*r,g=r-m,y=s+1,x=new O,b=(Q,X)=>x.subVectors(Q,X).normalize(),_=(Q,X)=>Array(Q).fill(void 0).map(X),S=_(e.length/3,(Q,X)=>new O().fromArray(e,X*3).setLength(r)),A=[],E=1e6;for(let Q=0;Q<S.length;Q++){let X=S[Q],ie=[],oe,te,re,fe=1e10,ce=-1;for(;(ce=t.indexOf(Q,ce+1))!=-1;){let ve=ce-ce%3;oe=t[ve+(ce+1)%3],te=t[ve+(ce+2)%3],re=X.distanceToSquared(S[oe]),fe=Math.min(fe,re),ie.push([oe,te,re])}fe+=1e-6;let de=[],se=0,Pe=ie.length;for(let ve=0;ve<Pe;ve++){[oe,te,re]=ie[se];let Ae=A[oe]?.includes(Q)==!0;re<=fe&&de.push(oe+ +Ae*E),se=ie.findIndex(ye=>ye[0]==te)}A.push(de)}let M=[];{let Q=0,X=0,ie,oe,te=d==3;for(let re=0;re<=s;re++){ie=re*(re+1)/2,oe=(re+1)*(re+2)/2;for(let fe=0;fe<s-re;fe++)[Q,X]=[ie+fe+re+2,oe+fe+re+3],M.push(ie,oe,...te?[X,ie]:[Q,oe],X,Q),[ie,oe]=[Q,X];M.push(ie,oe,ie+s+2)}}let T=u.clone(),P=u.clone(),R=u.clone(),z=u.clone(),U=u.clone(),L=[],j=_(S.length,()=>_(d,()=>u.clone()));for(let Q=0;Q<S.length;Q++){u.copy(S[Q]).normalize(),T.copy(u).multiplyScalar(g);let X=A[Q];for(let de=0;de<X.length;de++){let se=X[de],Pe=X[(de+1)%d];f.setFromPointsAndIndices(S,Q,se%E,Pe%E),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(T,j[Q][de])}let ie=[],oe=[],te=[],re=new O;s==0&&[...j[Q]].reduce((de,se)=>de.add(se),re).multiplyScalar(1/d);for(let de=0;de<d;de++){let se=[],Pe=(de-1+d)%d,ve=j[Q][Pe],Ae=j[Q][de];u.copy(ve).sub(T),p.copy(Ae).sub(T);let ye=T.angleTo(u),Ve=u.angleTo(p),Ie=Math.cos(ye)*m;s==0?P.copy(re):P.copy(T).setLength(g+Ie),oe.push(Ie);let Ce=[P,ve,Ae];for(let rt=0;rt<2;rt++){let Je=Ce[rt],st=Ce[rt+1];z.subVectors(Je,T),U.subVectors(st,T),R.crossVectors(z,U).normalize();for(let ot=0;ot<y;ot++){let Ke=[ye,Ve][rt]*ot/y;u.copy(z).applyAxisAngle(R,Ke).add(T),ie.push(u.clone()),rt&&(b(u,T),se.push([ot==0?Je:u.clone(),x.clone()]))}rt&&(b(st,T),se.push([st,x.clone()]))}te.push(se)}L.push(te);let fe=2*y,ce=2;for(let de=0;de<d;de++){let se=fe*de,Pe=fe*((de+1)%d),ve=[ie[se]];for(let ye=1;ye<y;ye++){z=ie[se+ye],U=ie[Pe+ye],ve.push(z);for(let Ve=1,Ie=ye-ce+1;Ve<=Ie;Ve++)u.lerpVectors(z,U,Ve/(Ie+1)),u.sub(T).setLength(oe[de]).add(T),ve.push(u.clone());ve.push(U)}for(let ye=0;ye<y;ye++)ve.push(ie[ye+y+se]);ve.push(ie[Pe+y]);let Ae=M.map(ye=>ve[ye]);n.push(...Ae.map(ye=>[ye.x,ye.y,ye.z]).flat()),l.push(...Ae.map(ye=>(b(ye,T),[x.x,x.y,x.z])).flat())}}let q=[];for(let Q=0;Q<A.length;Q++)for(let X=0;X<d;X++){let ie=A[Q][X];if(ie<E){let oe=A[ie].findIndex(fe=>fe%E==Q),te=L[Q][X],re=L[ie][oe];for(let fe=0;fe<y;fe++){let ce=te[fe],de=re[y-fe],se=te[fe+1],Pe=re[y-(fe+1)];[ce,de,se,se,de,Pe].forEach(ve=>{n.push(ve[0].x,ve[0].y,ve[0].z),l.push(ve[1].x,ve[1].y,ve[1].z)})}q.push(te[0][0],re[y][0],te[y][0],re[0][0])}}for(;q.length;){let Q,X,ie,oe;[Q,X]=q.splice(0,2);let te=[Q];for(;Q!=X;)te.push(X),ie=q.indexOf(X),oe=ie%2,X=q.splice(ie-oe,2)[1-oe];x.subVectors(te[0],te[1]).cross(u.subVectors(te[0],te[2])).normalize();let re=x.dot(te[0])<0;re&&x.negate();for(let fe=1;fe<=te.length-2;fe++)[te[fe+ +re],te[fe+1-+re],te[0]].forEach(ce=>{n.push(ce.x,ce.y,ce.z),l.push(x.x,x.y,x.z)})}}function c(){let d=new O;for(let A=0;A<n.length;A+=3){d.x=n[A+0],d.y=n[A+1],d.z=n[A+2];let E=_(d)/2/Math.PI+.5,M=S(d)/Math.PI+.5;o.push(E,1-M)}let u=new O,p=new O,f=new O,m=new O,g=new ae,y=new ae,x=new ae,b=(A,E,M,T)=>{T<0&&A.x===1&&(o[E]=A.x-1),M.x===0&&M.z===0&&(o[E]=T/2/Math.PI+.5)};for(let A=0,E=0;A<n.length;A+=9,E+=6){u.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[E+0],o[E+1]),y.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),m.copy(u).add(p).add(f).divideScalar(3);let M=_(m);b(g,E+0,u,M),b(y,E+2,p,M),b(x,E+4,f,M)}for(let A=0;A<o.length;A+=6){let E=o[A+0],M=o[A+2],T=o[A+4],P=Math.max(E,M,T),R=Math.min(E,M,T);P>.9&&R<.1&&(E<.2&&(o[A+0]+=1),M<.2&&(o[A+2]+=1),T<.2&&(o[A+4]+=1))}function _(A){return Math.atan2(A.z,-A.x)}function S(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new i_(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},CZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:a,corner:s,cornerSides:n}=e.parameters,o=a===0&&s!==0?new hI(t*.5,s,n):new Q3(t*.5,a);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},hI=class extends i_{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,a=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,-a,-r,0,-a,r,0,a,-r,0,a,r,-a,-r,0,-a,r,0,a,-r,0,a,r,0,-r,0,-a,r,0,-a,-r,0,a,r,0,a],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(s,n,o,e,t,i),this.type=o}static fromJSON(e){return new hI(e.radius,e.corner,e.cornerSides)}},Iu=1e-12,r_=class{constructor(e){this.position=new ae,this.startPosition=new ae,this.uuid=tt.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new r_(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ob=class extends r_{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new ob(this.parent).copy(this)}},pd=class extends r_{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new ob(this),new ob(this))}static create(e,t){let i=new pd(e,new ae(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let a=this.controls[i];this.position.distanceTo(a.position)<=t?a.position.copy(this.position):a.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 pd(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new ae,t=new ae){let[i,r]=this.computeTangents();return i&&r&&(YE(i,e),YE(r,t)),[e,t]}computeTangent(e=new ae){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new ae){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function YE(e,t=new ae){let i=e.length();return t.set(-e.y/i,e.x/i)}var a_=e=>e,$d=new ae,qv=new ae,TZ=new ae,PZ=new ae,DZ=new ae,IZ=new ae,cI=new O,dI=new O;function OZ(e){let t=new ae;t.addVectors(e.v0,$d.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new ae;return i.addVectors(e.v2,qv.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new tn(e.v0,t,i,e.v2)}function Zu(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function RZ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function LZ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function uI(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((a*a+r*r-s*s)/(2*a*r))}function BZ(e,t,i){return KE(e,t)&&KE(t,i)&&lb(e.position,t.position,i.position)}function lb(e,t,i){return $d.copy(t).sub(e).cross(qv.copy(i).sub(e))===0}function zZ(e,t,i,r,a){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,h=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,n+h),a.set(o-l,n-h),[r,a]}function kZ(e,t,i){let r=e.distanceTo(i),a=t.distanceTo(i);return r<a?t:e}function FZ(e,t,i,r,a,s){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,c=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),d;return uI(t,e,i)>Math.PI&&(c*=-1),Zu(h,o)?d=(o+h)*(r/c-.5)*8/3/(n-l):d=(n+l)*(r/c-.5)*8/3/(h-o),a.set(t.x-d*o,t.y+d*n),s.set(i.x+d*h,i.y-d*l),[a,s]}function QE(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function KE(e,t){return lb(e.position,e.controls[1].position,t.position)&&lb(e.position,t.controls[0].position,t.position)}function UZ(e,t,i,r,a=.5){let s=$d.subVectors(t,e).multiplyScalar(a).add(e),n=qv.subVectors(i,t).multiplyScalar(a).add(t),o=TZ.subVectors(r,i).multiplyScalar(a).add(i),l=s,h=PZ.subVectors(n,s).multiplyScalar(a).add(s),c=DZ.subVectors(o,n).multiplyScalar(a).add(n),d=o,u=IZ.subVectors(c,h).multiplyScalar(a).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,c.x,c.y,d.x,d.y,r.x,r.y]}function NZ(e,t,i=12,r=!0){let a=dI.set(0,0,0),s,n=0,o=[];for(let l=0;l<t.length;l++){let h=a_(t[l]),c=$d,d=zh(h,i);o.push(d);for(let u=0;u<=d;u++)if(h instanceof tn||h instanceof Hl||h instanceof sn){if(h.getPoint(u/d,c),a.set(c.x,c.y,0),s!==void 0&&LZ(s,a))continue;s===void 0&&(s=cI),s.copy(a),e.setXYZ(n,a.x,a.y,a.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function VZ(e,t,i,r=12,a=!0){let s=dI.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,c=a_(t[l]),d=$d,u=zh(c,r);o.push(u);for(let p=0;p<=u;p++)if(c instanceof tn||c instanceof Hl||c instanceof sn){if(c.getPoint(p/u,d),s.set(d.x,d.y,0),h?.equals(s))continue;h===void 0?h=cI:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,s.x,s.y,s.z),n++),h.copy(s)}}return a&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function ZE(e,t=12,i=!1){let r=[];for(let a=0,s=e.length;a<s;a++){let n=e[a],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=zh(n.roundedCurveCorner,t)*.5;a>0&&(r[a-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=zh(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=zh(e[0].roundedCurveCorner,t)*.5),r}function zh(e,t=12){return e&&e instanceof Tv?t*2:e&&(e instanceof sn||e instanceof q3)?1:e&&e instanceof tw?t*e.points.length:t}function jZ(e,t,i=12,r=!0){let a,s=0;for(let n=0;n<t.length;n++){let o=a_(t[n]),l=zh(o,i),h=$d;for(let c=0;c<=l;c++)if(o instanceof tn||o instanceof Hl||o instanceof sn){if(o.getPoint(c/l,h),a!==void 0&&RZ(a,h,Iu))continue;a===void 0&&(a=qv),a.copy(h),e.push(h.x,h.y),s++}}return Zu(e[0],e[e.length-2],Iu)&&Zu(e[1],e[e.length-1],Iu)&&(e.pop(),e.pop()),r&&s>1&&!(Zu(e[s-1],e[1],Iu)&&Zu(e[s-2],e[0],Iu))&&(e.push(e[0],e[1]),s++),e}var I1=new ae,HZ=new ae,GZ=new ae,WZ=new ae,qZ=new ae,XZ=new ae,hr=class extends Mg{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ka(new O(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=tt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new hr;return r.isClosed=e.isClosed,r.points=e.points.map(a=>pd.create(a.id,a.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(a=>hr.createFromState(a)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let a=0,s=this.shapeHoles.length;a<s;a++){let n=this.shapeHoles[a],o=n.points.length,l=n.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=e-t;if(s<=a.points.length-1)return a.points[s];t+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=a.points.indexOf(e);if(s>=0)return t+s;t+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=I1.set(e,t);for(let r=0,a=this.points.length;r<a;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,a=this.shapeHoles.length;r<a;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=tt.generateUUID()){let r;e instanceof ae?r=e:r=new ae(e,t);let a=new pd(i,r);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return NZ(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=ZE(this.points,e,!1),this.roundedCurveDivisions=ZE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return VZ(e,this.curves,t,i,this.autoClose).reduce((r,a)=>r+a,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),jZ(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=zh(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(s<i+l)return[n,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,n=s[e];if(QE(r,a)){let l=r.position.distanceTo(a.position);return r.position.distanceTo(I1.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){QE(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(r,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let a=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=a.roundness,l=s&&n&&BZ(s,a,n);if(!a.controlsMoved()&&o>0&&!l){let h=a.curveBefore,c=a.curveAfter;if(h===void 0||c===void 0)continue;let d=a.roundedCurveBefore,u=a.roundedCurveAfter,p=h.getLength(),f=c.getLength(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),y=Math.min(m,g),x=1-y/p,b=y/f,_=h.getPointAt(x,I1),S=c.getPointAt(b,HZ);this._subSplitCurve(h,d,x,_,void 0),this._subSplitCurve(c,u,b,void 0,S);let A;if(this.useCubicForRoundedCorners){let E=uI(_,a.position,S)/2,M=Math.tan(E)*_.distanceTo(a.position),[T,P]=zZ(_,S,M,GZ,WZ),R=kZ(T,P,a.position),[z,U]=FZ(R,_,S,M,qZ,XZ);A=new tn(_.clone(),z.clone(),U.clone(),S.clone())}else A=new Hl(_.clone(),a.position.clone(),S.clone());a.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,a){if(e instanceof sn)r!==void 0&&t.v2.copy(r),a!==void 0&&t.v1.copy(a);else{let s=e,n=t,o=s.getUtoTmapping(i,0),l=UZ(s.v0,s.v1,s.v2,s.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),a!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new hr(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,a=e.points[r+0],s=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],c=e.points[r+6],d=new pd(tt.generateUUID(),new ae(a,s));d.controls[0].position.set(n,o),d.controls[1].position.set(l,h),d.roundness=c,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new hr;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(a,s)=>{s instanceof tn&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},r=a=>{let s=[],n,o;for(n=0,o=a.length;n<o;n++)a[n]instanceof Hl&&(a[n]=OZ(a[n]));for(n=0,o=a.length;n<o;n++){let c=a[n],d=n>0?a[n-1]:null,u;c instanceof tn?(u=this.createPoint(c.v0),u.controls[1].position.copy(c.v1)):c instanceof sn&&(u=this.createPoint(c.v1)),u!==void 0&&(d!==null&&i(u,d),s.push(u))}let l=a[a.length-1],h=!1;return l instanceof tn?l.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(l.v2),h=!0):l instanceof sn&&l.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=r(e.curves),e instanceof Mg&&(this.shapeHoles=e.holes.map(a=>{let s=new hr;return s.fromShape(a),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},hb=Math.PI*2;function O1({x:e,y:t},i,r,a,s){return{x:e*i+a,y:t*r+s}}function YZ(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),a=Math.sin(e),s=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-a*i,y:a+r*i},{x:s+n*i,y:n-s*i},{x:s,y:n}]}function JE(e,t,i,r){let a=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return a*Math.acos(s)}function QZ(e,t,i,r,a,s,n,o,l,h){let c=Math.pow(a,2),d=Math.pow(s,2),u=Math.pow(n,2),p=Math.pow(o,2),f=c*d-c*p-d*u;f<0&&(f=0),f/=c*p+d*u,f=Math.sqrt(f)*(l===h?-1:1);let m=f*a/s*o,g=f*-s/a*n,y=m+(e+i)/2,x=g+(t+r)/2,b=(n-m)/a,_=(o-g)/s,S=(-n-m)/a,A=(-o-g)/s,E=JE(1,0,b,_),M=JE(b,_,S,A);return!h&&M>0&&(M-=hb),h&&M<0&&(M+=hb),{centerx:y,centery:x,ang1:E,ang2:M}}function KZ({px:e,py:t,cx:i,cy:r,rx:a,ry:s,largeArcFlag:n,sweepFlag:o}){let l=[];if(a===0||s===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];a=Math.abs(a),s=Math.abs(s);let d=Math.pow(h,2)/Math.pow(a,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(a*=Math.sqrt(d),s*=Math.sqrt(d));let u=QZ(e,t,i,r,a,s,h,c,n,o),{ang1:p,ang2:f}=u,{centerx:m,centery:g}=u,y=Math.abs(f)/(hb/4);Math.abs(1-y)<1e-7&&(y=1);let x=Math.max(Math.ceil(y),1);f/=x;for(let b=0;b<x;b++)l.push(YZ(p,f)),p+=f;return l.map(b=>{let{x:_,y:S}=O1(b[0],a,s,m,g),{x:A,y:E}=O1(b[1],a,s,m,g),{x:M,y:T}=O1(b[2],a,s,m,g);return{x1:_,y1:S,x2:A,y2:E,x:M,y:T}})}var Ii;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ii||(Ii={}));var Pr;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Pr||(Pr={}));function Bt(e,t){if(!e)throw t||"Assertion Failed!"}var Et=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Bt(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?a<s?i.t-t.t+(t.t-r.t)*(a/(a+s)):i.t-r.t+(r.t-t.t)*(s/(a+s)):0},e.edgeSign=function(t,i,r){Bt(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?(i.t-r.t)*a+(i.t-t.t)*s:0},e.transEval=function(t,i,r){Bt(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?a<s?i.s-t.s+(t.s-r.s)*(a/(a+s)):i.s-r.s+(r.s-t.s)*(s/(a+s)):0},e.transSign=function(t,i,r){Bt(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?(i.s-r.s)*a+(i.s-t.s)*s:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,a){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+a)/2:i+(a-i)*(t/(t+r)):a+(i-a)*(r/(t+r))},e.intersect=function(t,i,r,a,s){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,a)||(l=r,r=a,a=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.vertLeq(r,i)?e.vertLeq(i,a)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,a),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,a,i),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,a.s)):s.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,a)||(l=r,r=a,a=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.transLeq(r,i)?e.transLeq(i,a)?(n=e.transEval(t,r,i),o=e.transEval(r,i,a),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,a,i),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,a.t)):s.t=(r.t+i.t)/2},e}(),Ou=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),xm=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Kc=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),$E=function(){function e(){var t=new Kc,i=new Ou,r=new xm(0),a=new xm(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=a,a.next=a,a.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=a}return e.prototype.makeEdge_=function(t){var i=new xm(0),r=new xm(1);t.Sym.side<t.side&&(t=t.Sym);var a=t.Sym.next;return r.next=a,a.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,a=i.Onext;r.Sym.Lnext=i,a.Sym.Lnext=t,t.Onext=a,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var a=t;Bt(a,"Vertex can't be null!");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i;var n=i;do n.Org=a,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var a=t;Bt(a,"Face can't be null");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i,a.trail=null,a.marked=!1,a.inside=r.inside;var n=i;do n.Lface=a,n=n.Lnext;while(n!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,a=r;do a.Org=i,a=a.Onext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,a=r;do a.Lface=i,a=a.Lnext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.makeEdge=function(){var t=new Kc,i=new Kc,r=new Ou,a=this.makeEdge_(this.eHead);return this.makeVertex_(t,a,this.vHead),this.makeVertex_(i,a.Sym,this.vHead),this.makeFace_(r,a,this.fHead),a},e.prototype.splice=function(t,i){var r=!1,a=!1;if(t!==i){if(i.Org!==t.Org&&(a=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!a){var s=new Kc;this.makeVertex_(s,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Ou;this.makeFace_(n,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var a=new Ou;this.makeFace_(a,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var a=new Kc;return this.makeVertex_(a,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,a=this.makeEdge_(t),s=a.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(a,t.Lnext),this.splice_(s,i),a.Org=t.Dst,s.Org=i.Org,a.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var n=new Ou;this.makeFace_(n,a,t.Lface)}return a},e.prototype.zapFace=function(t){var i=t.anEdge,r,a,s,n,o;a=i.Lnext;do r=a,a=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!=i);n=t.prev,o=t.next,o.prev=n,n.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,a,s,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;a=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(s.Lface),o+l-2<=t&&Et.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Et.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(a=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===n);)r=a;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,a,s,n,o,l,h;for(s=t,s=t;(a=s.next)!==t;s=a){Bt(a.prev===s),l=a.anEdge;do Bt(l.Sym!==l),Bt(l.Sym.Sym===l),Bt(l.Lnext.Onext.Sym===l),Bt(l.Onext.Sym.Lnext===l),Bt(l.Lface===a),l=l.Lnext;while(l!==a.anEdge)}for(Bt(a.prev===s&&a.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Bt(n.prev===o),l=n.anEdge;do Bt(l.Sym!==l),Bt(l.Sym.Sym===l),Bt(l.Lnext.Onext.Sym===l),Bt(l.Onext.Sym.Lnext===l),Bt(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Bt(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Bt(l.Sym.next===h.Sym),Bt(l.Sym!==l),Bt(l.Sym.Sym===l),Bt(l.Org!==null),Bt(l.Dst!==null),Bt(l.Lnext.Onext.Sym===l),Bt(l.Onext.Sym.Lnext===l);Bt(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),eC=function(){function e(){this.handle=null}return e}(),tC=function(){function e(){this.key=null,this.node=0}return e}(),ZZ=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new eC,this.handles[r]=new tC;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Bt(n<=this.max),s=i[n].handle,n>this.size||this.leq(r[a].key,r[s].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t>>1,s=i[n].handle,n===0||this.leq(r[s].key,r[a].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var a,s;for(s=this.nodes.length,this.nodes.length=this.max+1,a=s;a<this.nodes.length;a++)this.nodes[a]=new eC;for(s=this.handles.length,this.handles.length=this.max+1,a=s;a<this.handles.length;a++)this.handles[a]=new tC}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,a=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),a},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,a;Bt(t>=1&&t<=this.max&&r[t].key!==null),a=r[t].node,i[a].handle=i[this.size].handle,r[i[a].handle].node=a,--this.size,a<=this.size&&(a<=1||this.leq(r[i[a>>1].handle].key,r[i[a].handle].key)?this.floatDown_(a):this.floatUp_(a)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),R1=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),iC=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),JZ=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new iC,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new iC;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),$Z=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var a=t.event,s=i.eUp,n=r.eUp;if(s.Dst===a)return n.Dst===a?Et.vertLeq(s.Org,n.Org)?Et.edgeSign(n.Dst,s.Org,n.Org)<=0:Et.edgeSign(s.Dst,n.Org,s.Org)>=0:Et.edgeSign(n.Dst,a,n.Org)<=0;if(n.Dst===a)return Et.edgeSign(s.Dst,a,s.Org)>=0;var o=Et.edgeEval(s.Dst,a,s.Org),l=Et.edgeEval(n.Dst,a,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Bt(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Bt(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,a;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(a=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),a===null)return null;e.fixUpperEdge(t,i,a),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var a=new R1;return a.eUp=r,a.nodeUp=t.dict.insertBefore(i.nodeUp,a),a.fixUpperEdge=!1,a.sentinel=!1,a.dirty=!1,r.activeRegion=a,a},e.isWindingInside=function(t,i){switch(t.windingRule){case Ii.ODD:return(i&1)!==0;case Ii.NONZERO:return i!==0;case Ii.POSITIVE:return i>0;case Ii.NEGATIVE:return i<0;case Ii.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,a=r.Lface;a.inside=i.inside,a.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var a,s=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,s=e.regionBelow(n),a=s.eUp,a.Org!=o.Org){if(!s.fixUpperEdge){e.finishRegion(t,n);break}a=t.mesh.connect(o.Lprev,a.Sym),e.fixUpperEdge(t,s,a)}o.Onext!==a&&(t.mesh.splice(a.Oprev,a),t.mesh.splice(o,a)),e.finishRegion(t,n),o=s.eUp,n=s}return o},e.addRightEdges=function(t,i,r,a,s,n){var o,l,h,c,d=!0;h=r;do Bt(Et.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==a);for(s===null&&(s=e.regionBelow(i).eUp.Rprev),l=i,c=s;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!d&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=o,c=h;l.dirty=!0,Bt(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var a=Et.vertL1dist(i,t),s=Et.vertL1dist(r,t),n=.5*s/(a+s),o=.5*a/(a+s);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,a,s,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,a),e.vertexWeights(i,s,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp;if(Et.vertLeq(a.Org,s.Org)){if(Et.edgeSign(s.Dst,a.Org,s.Org)>0)return!1;Et.vertEq(a.Org,s.Org)?a.Org!==s.Org&&(t.pq.delete(a.Org.pqHandle),e.spliceMergeVertices(t,s.Oprev,a)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(a,s.Oprev),i.dirty=r.dirty=!0)}else{if(Et.edgeSign(a.Dst,s.Org,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Oprev,a)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n;if(Bt(!Et.vertEq(a.Dst,s.Dst)),Et.vertLeq(a.Dst,s.Dst)){if(Et.edgeSign(a.Dst,s.Dst,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Sym,n),n.Lface.inside=i.inside}else{if(Et.edgeSign(s.Dst,a.Dst,s.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Lnext,s.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n=a.Org,o=s.Org,l=a.Dst,h=s.Dst,c,d,u=new Kc,p,f;if(Bt(!Et.vertEq(h,l)),Bt(Et.edgeSign(l,t.event,n)<=0),Bt(Et.edgeSign(h,t.event,o)>=0),Bt(n!==t.event&&o!==t.event),Bt(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),d=Math.max(o.t,h.t),c>d))return!1;if(Et.vertLeq(n,o)){if(Et.edgeSign(h,n,o)>0)return!1}else if(Et.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Et.intersect(l,n,h,o,u),Bt(Math.min(n.t,l.t)<=u.t),Bt(u.t<=Math.max(o.t,h.t)),Bt(Math.min(h.s,l.s)<=u.s),Bt(u.s<=Math.max(o.s,n.s)),Et.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Et.vertLeq(n,o)?n:o,Et.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Et.vertEq(u,n)||Et.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Et.vertEq(l,t.event)&&Et.edgeSign(l,t.event,u)>=0||!Et.vertEq(h,t.event)&&Et.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Sym,a),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,a.Oprev,a,a,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Lnext,s.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=s.Oprev,s=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,s.Onext,a.Rprev,f,!0),!0):(Et.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),Et.edgeSign(h,t.event,u)<=0&&(i.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(a.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,a),a.Org.s=u.s,a.Org.t=u.t,a.Org.pqHandle=t.pq.insert(a.Org),e.getIntersectData(t,a.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),a,s;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,a=i.eUp,s=r.eUp,a.Dst!==s.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(s),r=e.regionBelow(i),s=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r),a=i.eUp)),a.Org!==s.Org)if(a.Dst!==s.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(a.Dst===t.event||s.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);a.Org===s.Org&&a.Dst===s.Dst&&(e.addWinding(s,a),e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var a,s=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Et.vertEq(o.Org,t.event)&&(t.mesh.splice(s.Oprev,o),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Et.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,s,s,!0);return}Et.vertLeq(l.Org,o.Org)?a=l.Oprev:a=o,a=t.mesh.connect(r.Lprev,a),e.addRightEdges(t,i,a,a.Onext,a.Onext,!1),a.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var a,s,n,o,l;if(a=i.eUp,Et.vertEq(a.Org,r)){Bt(!1),e.spliceMergeVertices(t,a,r.anEdge);return}if(!Et.vertEq(a.Dst,r)){t.mesh.splitEdge(a.Sym),i.fixUpperEdge&&(t.mesh.delete(a.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,a),e.sweepEvent(t,r);return}Bt(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,s=o=n.Onext,l.fixUpperEdge&&(Bt(s!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=s.Oprev),t.mesh.splice(r.anEdge,n),Et.edgeGoesLeft(s)||(s=null),e.addRightEdges(t,i,n.Onext,o,s,!0)},e.connectLeftVertex=function(t,i){var r,a,s,n,o,l,h=new R1;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,a=e.regionBelow(r),!!a){if(n=r.eUp,o=a.eUp,Et.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(s=Et.vertLeq(o.Dst,n.Dst)?r:a,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}s.fixUpperEdge?e.fixUpperEdge(t,s,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var a=e.topLeftRegion(t,r.activeRegion);Bt(a!==null);var s=e.regionBelow(a),n=s.eUp,o=e.finishLeftRegions(t,s,null);o.Onext===n?e.connectRightVertex(t,a,o):e.addRightEdges(t,a,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,a){var s=new R1,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=a,n.Dst.s=i,n.Dst.t=a,t.event=n.Dst,s.eUp=n,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},e.initEdgeDict=function(t){t.dict=new JZ(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],a=t.bmin[0]-i,s=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,a,s,n),e.addSentinel(t,a,s,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Bt(i.fixUpperEdge),Bt(++r===1)),Bt(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,a,s=t.mesh.eHead;for(i=s.next;i!==s;i=r)r=i.next,a=i.Lnext,Et.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,a,i),t.mesh.delete(i),i=a,a=i.Lnext),a.Lnext===i&&(a!==i&&((a===r||a===r.Sym)&&(r=r.next),t.mesh.delete(a)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,a,s=0;for(a=t.mesh.vHead,r=a.next;r!==a;r=r.next)s++;for(s+=8,i=t.pq=new ZZ(s,Et.vertLeq),a=t.mesh.vHead,r=a.next;r!==a;r=r.next)r.pqHandle=i.insert(r);return r!==a?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,a,s;for(r=i.fHead.next;r!==i.fHead;r=a)a=r.next,s=r.anEdge,Bt(s.Lnext!==s),s.Lnext.Lnext===s&&(e.addWinding(s.Onext,s),t.mesh.delete(s));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,a;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;a=t.pq.min(),!(a===null||!Et.vertEq(a,r));)a=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,a.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),eJ=function(){function e(){this.mesh=new $E,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=Ii.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,a,s,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)s=i.coords[g],h[g]=s,f[g]=i,l[g]=s,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var y=0;y<3;++y)s=i.coords[y],s<h[y]&&(h[y]=s,f[y]=i),s>l[y]&&(l[y]=s,p[y]=i);var x=0;if(l[1]-h[1]>l[0]-h[0]&&(x=1),l[2]-h[2]>l[x]-h[x]&&(x=2),h[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[x],a=p[x],c[0]=r.coords[0]-a.coords[0],c[1]=r.coords[1]-a.coords[1],c[2]=r.coords[2]-a.coords[2],i=m.next;i!==m;i=i.next)d[0]=i.coords[0]-a.coords[0],d[1]=i.coords[1]-a.coords[1],d[2]=i.coords[2]-a.coords[2],u[0]=c[1]*d[2]-c[2]*d[1],u[1]=c[2]*d[0]-c[0]*d[2],u[2]=c[0]*d[1]-c[1]*d[0],n=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],n>o&&(o=n,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,a,s=0,n=t.next;n!==t;n=n.next)if(a=n.anEdge,!(a.winding<=0))do s+=(a.Org.s-a.Dst.s)*(a.Org.t+a.Dst.t),a=a.Lnext;while(a!==n.anEdge);if(s<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,a,s=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),s=!0),r=this.sUnit,a=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,a[n]=0,a[(n+1)%3]=0,a[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,a);s&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,a;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Et.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Et.vertLeq(r.Org,r.Dst);r=r.Lnext);a=r.Lprev;for(var s=void 0;r.Lnext!==a;)if(Et.vertLeq(r.Dst,a.Org)){for(;a.Lnext!==r&&(Et.edgeGoesLeft(a.Lnext)||Et.edgeSign(a.Org,a.Dst,a.Lnext.Dst)<=0);)s=t.connect(a.Lnext,a),a=s.Sym;a=a.Lprev}else{for(;a.Lnext!==r&&(Et.edgeGoesRight(r.Lprev)||Et.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(a.Lnext===r)throw"Mono region invalid";for(;a.Lnext.Lnext!==r;)s=t.connect(a.Lnext,a),a=s.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var a,s=t.eHead.next;s!==t.eHead;s=a)a=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?i:-i:r?t.delete(s):s.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,a){var s,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var h=s.Org;h.n===-1&&(h.n=o,o++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===Pr.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*a,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var d=h.n*a;this.vertices[d+0]=h.coords[0],this.vertices[d+1]=h.coords[1],a>2&&(this.vertices[d+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var u=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){s=c.anEdge,l=0;do{var h=s.Org;this.elements[u++]=h.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===Pr.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[u++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,a,s=0,n=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==a);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,c=0;s=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=0,a=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==a);this.elements[c++]=s,this.elements[c++]=n,s+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new $E),t<2&&(t=2),t>3&&(t=3);for(var r=null,a=0;a<i.length;a+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[a+0],r.Org.coords[1]=i[a+1],t>2?r.Org.coords[2]=i[a+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,a,s,n){if(t===void 0&&(t=Ii.ODD),i===void 0&&(i=Pr.POLYGONS),n===void 0&&(n=!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,a<2&&(a=2),a>3&&(a=3),!this.mesh)return!1;this.projectPolygon_(),$Z.computeInterior(this,n);var o=this.mesh;return i===Pr.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===Pr.BOUNDARY_CONTOURS?this.outputContours_(o,a):this.outputPolymesh_(o,i,r,a),!0},e}();function Rl(e){var t=e.windingRule,i=t===void 0?Ii.ODD:t,r=e.elementType,a=r===void 0?Pr.POLYGONS:r,s=e.polySize,n=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,d=e.contours,u=d===void 0?[]:d,p=e.strict,f=p===void 0?!0:p,m=e.debug,g=m===void 0?!1:m;if(!u&&f)throw new Error("Contours can't be empty");if(u){var y=new eJ;e.edgeCreateCallback&&(y.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(y.vertexIdCallback=e.vertexIdCallback);for(var x=0;x<u.length;x++)y.addContour(l||2,u[x]);return y.tesselate(i,a,n,l,c,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var dhe=Ii.ODD,uhe=Ii.NONZERO,phe=Ii.POSITIVE,fhe=Ii.NEGATIVE,mhe=Ii.ABS_GEQ_TWO,ghe=Pr.POLYGONS,vhe=Pr.CONNECTED_POLYGONS,yhe=Pr.BOUNDARY_CONTOURS,cb=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*cb.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,a=0;this.positions=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.normals=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.uvs=new Float32Array(this.buffer,a*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*cb.eSize,r=new ArrayBuffer(i),a=Float32Array.BYTES_PER_ELEMENT,s=0,n=new Float32Array(r,s*a,3*e);s+=3*e;let o=new Float32Array(r,s*a,3*e);s+=3*e;let l=new Float32Array(r,s*a,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},pI=cb;pI.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var tJ=class{constructor(e=[],t=(i,r)=>i<r?-1:i>r?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,s=t[a];if(i(r,s)>=0)break;t[e]=s,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let s=(e<<1)+1,n=s+1;if(n<this.length&&i(t[n],t[s])<0&&(s=n),i(t[s],a)>=0)break;t[e]=t[s],e=s}t[e]=a}};function iJ(e,t,i=1,r=!1){let a=1/0,s=1/0,n=-1/0,o=-1/0;for(let[x,b]of e[0])x<a&&(a=x),b<s&&(s=b),x>n&&(n=x),b>o&&(o=b);let l=n-a,h=o-s,c=Math.max(i,Math.min(l,h));if(c===i){let x=[a,s];return x.distance=0,x.distance}let d=new tJ([],(x,b)=>b.max-x.max),u=aJ(e),p=new dv(a+l/2,s+h/2,0,e);p.d>u.d&&(u=p);let f=2;function m(x,b,_){let S=new dv(x,b,_,e);if(f++,S.max>u.d+i&&d.push(S),S.d>u.d&&(u=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${f} probes`),u.d>t))return t}let g=c/2;for(let x=a;x<n;x+=c)for(let b=s;b<o;b+=c)m(x+g,b+g,g);for(;d.length;){let{max:x,x:b,y:_,h:S}=d.pop();if(x-u.d<=i)break;g=S/2,m(b-g,_-g,g),m(b+g,_-g,g),m(b-g,_+g,g),m(b+g,_+g,g)}r&&console.log(`num probes: ${f}
3176
3176
  best distance: ${u.d}`);let y=[u.x,u.y];return y.distance=u.d,y.distance}function dv(e,t,i,r){this.x=e,this.y=t,this.h=i,this.d=rJ(e,t,r),this.max=this.d+this.h*Math.SQRT2}function rJ(e,t,i){let r=!1,a=1/0;for(let s of i)for(let n=0,o=s.length,l=o-1;n<o;l=n++){let h=s[n],c=s[l];h[1]>t!=c[1]>t&&e<(c[0]-h[0])*(t-h[1])/(c[1]-h[1])+h[0]&&(r=!r),a=Math.min(a,sJ(e,t,h,c))}return a===0?0:(r?1:-1)*Math.sqrt(a)}function aJ(e){let t=0,i=0,r=0,a=e[0];for(let n=0,o=a.length,l=o-1;n<o;l=n++){let h=a[n],c=a[l],d=h[0]*c[1]-c[0]*h[1];i+=(h[0]+c[0])*d,r+=(h[1]+c[1])*d,t+=d*3}let s=new dv(i/t,r/t,0,e);return t===0||s.d<0?new dv(a[0][0],a[0][1],0,e):s}function sJ(e,t,i,r){let a=i[0],s=i[1],n=r[0]-a,o=r[1]-s;if(n!==0||o!==0){let l=((e-a)*n+(t-s)*o)/(n*n+o*o);l>1?(a=r[0],s=r[1]):l>0&&(a+=n*l,s+=o*l)}return n=e-a,o=t-s,n*n+o*o}var s_={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},fI={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},mI={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},L1=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),n_=class extends vt{constructor(e,t,i=0,r=12,a=3,s=Ii.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=a;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(T=>{let P=T.extractShapePointsToFlatArray([],r),R=[];for(let z=P.length-1;z>=1;z-=2){let U=P[z-1],L=P[z-0];R.push(U,L)}return R}),h=[],c=[];for(let T=0;T<o.length;T+=2)c.push([o[T],o[T+1]]);h.push(c);for(let T=0;T<l.length;T++){let P=l[T],R=[];for(let z=0;z<P.length;z+=2)R.push([P[z],P[z+1]]);h.push(R)}let d;e.isText?d=new lw().setFromPoints(e.points.map(T=>T.position)).getSize(new ae).length()*.1:h[0].length===0?d=i:i>0?d=iJ(h,i):d=1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,d,t/2),this._bevelSegments=Math.floor(a));let u;try{u=Rl({windingRule:s,elementType:Pr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{u=s_}let p;try{p=Rl({windingRule:Ii.ODD,elementType:Pr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=fI}if(!u)throw new Error("error generating geometry");let f=u.elementCount;if(p){u.elementCount+=p.elementCount;for(let T=0;T<p.elements.length;T++){let P=p.elements[T],R=T%2===0?u.vertexCount:0;u.elements.push(P+R)}for(let T=0;T<p.vertexIndices.length;T++){let P=p.vertexIndices[T],R=u.vertexCount;u.vertexIndices.push(P+R)}for(let T=0;T<p.vertices.length;T++){let P=p.vertices[T];u.vertices.push(P)}}let m=1/0,g=-1/0,y=1/0,x=-1/0;for(let T=0,P=u.vertexCount;T<P;T++){let R=T*2,z=u.vertices[R+0],U=u.vertices[R+1];z<m&&(m=z),z>g&&(g=z),U<y&&(y=U),U>x&&(x=U)}this._minX=m,this._minY=y,this._width=g-m,this._height=x-y,this._buffer=new pI(this._computeBufferEstimatedSize(u));let b=[],_=[];for(let T=u.elementCount-1;T>=0;T--){let P=T>=f,R=T*2,z=u.elements[R+0],U=u.elements[R+1],L=z+U,j={start:z,count:U,normals:[],continuous:[],concave:[]},q=z,Q=L-1,X=z+1,ie=this._shape.roundedCurves.length;do{let ce=q-z,de=u.vertices[Q*2+0],se=u.vertices[Q*2+1],Pe=u.vertices[q*2+0],ve=u.vertices[q*2+1],Ae=u.vertices[X*2+0],ye=u.vertices[X*2+1],Ve=Pe-de,Ie=ve-se,Ce=Math.sqrt(Ve*Ve+Ie*Ie);Ve/=Ce,Ie/=Ce;let rt=Pe-Ae,Je=ve-ye,st=Math.sqrt(rt*rt+Je*Je);rt/=st,Je/=st,j.normals[ce*2+0]=-Je,j.normals[ce*2+1]=rt,j.concave[ce]=Ve*Je-Ie*rt>0;let ot=u.vertexIndices[q];if(Array.isArray(ot))j.continuous[ce]=!1;else{let[Ke,Qe]=this._shape.getCurveIndexFromVertexId(ot-1,!0);if(Qe>0&&Qe<1)j.continuous[ce]=!0;else{let ft=Qe===1?Ke+1:Ke-1;ft=(ft+ie)%ie;let St=Qe===1?0:1,ee=this._shape.roundedCurves[Ke].getTangent(Qe),W=this._shape.roundedCurves[ft].getTangent(St);j.continuous[ce]=ee.dot(W)>.95}}P&&(j.normals[ce*2+0]*=-1,j.normals[ce*2+1]*=-1),[Q,q,X]=[q,X,X+1],X>=L&&(X-=U)}while(X!==z+1);let oe=[];oe.push({bevelI:0,angle:0,size:0,boundary:{vertices:u.vertices.slice(z*2,L*2),vertexCount:U,vertexIndices:new Array(U).fill(!0).map((ce,de)=>[de,de]),elements:[0,U],elementCount:1,mesh:null},reverseMap:[],insetPoints:u.vertices.slice(z*2,L*2)});let te=0;for(let ce=1;ce<=this._bevelSegments;ce++){let de=ce/this._bevelSegments*Math.PI/2,se=(1-Math.cos(de))*this._bevel,Pe=[],ve=[],Ae=[],ye=[],Ve=0;for(let Ce=0;Ce<U;Ce++){let rt=Ce*2,Je=(Ce-1+U)%U*2,st=u.vertices[j.start*2+rt+0],ot=u.vertices[j.start*2+rt+1],Ke=-j.normals[Je+0]*se,Qe=-j.normals[Je+1]*se,ft=-j.normals[rt+0]*se,St=-j.normals[rt+1]*se;if(j.concave[Ce]||!j.concave[Ce]&&P){let ee=Math.atan2(Qe,Ke),W=Math.atan2(St,ft);W>ee&&(W-=Math.PI*2);let _e=W-ee;if(j.continuous[Ce]||P){let We=ee+_e/2,V=Math.cos(We)*se,Oe=Math.sin(We)*se;Pe[2*Ve+0]=st+V*(P?-1:1),Pe[2*Ve+1]=ot+Oe*(P?-1:1),ye[Ve]=Ce,Ve++}else{let We=Math.max(1,Math.floor(r/4*Math.abs(_e)/Math.PI));for(let V=0;V<=We;V++){let Oe=ee+_e*(V/We),dt=Math.cos(Oe)*se,He=Math.sin(Oe)*se;Pe[2*Ve+0]=st+dt,Pe[2*Ve+1]=ot+He,ye[Ve]=Ce,Ve++}}}else Pe[2*Ve+0]=st+Ke,Pe[2*Ve+1]=ot+Qe,ye[Ve]=Ce,ve[Ce]=Ve,Ve++,Pe[2*Ve+0]=st,Pe[2*Ve+1]=ot,ye[Ve]=Ce,Ve++,Pe[2*Ve+0]=st+ft,Pe[2*Ve+1]=ot+St,ye[Ve]=Ce,Ae[Ce]=Ve,Ve++}let Ie=Rl({windingRule:Ii.POSITIVE,elementType:Pr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Pe],edgeCreateCallback:Ce=>{let rt=Ce.Org.idx,Je=ye[rt],st=ye[(rt+1)%ye.length];Ce.idx=[Je,st],Ce.Sym.idx=[st,Je]},vertexIdCallback:Ce=>{let rt=Ce.Lprev.idx;return[rt?rt[1]:0,Ce.idx?Ce.idx[0]:0]}});if(!Ie)throw console.log("Error"),new Error(`error generating bevel geometry for ${ce}'th loop`);if(!Ie.vertexCount){let Ce=(ce-1)/this._bevelSegments*Math.PI/2;te=(1-Math.sin(Ce))*this._bevel;break}for(let Ce=0;Ce<Ie.vertexIndices.length;Ce++){let[rt,Je]=Ie.vertexIndices[Ce];if(rt===Je)continue;let st=Je;Je<rt&&(st+=U);for(let ot=rt;ot<st;ot++){let Ke=ot%U,Qe=(ot+1)%U;if(!j.continuous[Ke]||!j.continuous[Qe]){Ie.vertexIndices[Ce]=[rt,Ke],Ie.vertexIndices.splice(Ce+1,0,[Qe,Je]),Ie.vertices.splice((Ce+1)*2,0,Ie.vertices[Ce*2],Ie.vertices[Ce*2+1]);break}}}oe.push({bevelI:ce,angle:de,size:se,boundary:Ie,reverseMap:ye,insetPoints:Pe})}let re=(ce,de,se)=>{let Pe=0,ve=ce.boundary.vertexIndices.length;for(;Pe<ve&&se(ce.boundary.vertexIndices[de]);)de=(de+1)%ve,Pe++;return Pe},fe=b.length;for(let ce=1;ce<oe.length;ce++){let de=oe[ce-1],se=oe[ce],Pe=de.boundary.vertexIndices.length,ve=se.boundary.vertexIndices.length;if(!Pe||!ve)break;let Ae=j.concave.length,ye=0,Ve=L1(ye,U);for(;!de.boundary.vertexIndices.filter(Ve).length||!se.boundary.vertexIndices.filter(Ve).length;)ye++,Ve=L1(ye,U);let Ie=de.boundary.vertexIndices.findIndex(Ve),Ce=se.boundary.vertexIndices.findIndex(Ve);do Ie=(Ie+1)%Pe;while(Ve(de.boundary.vertexIndices[Ie]));do Ce=(Ce+1)%ve;while(Ve(se.boundary.vertexIndices[Ce]));ye=(ye+1)%U;let rt=ye,Je=0,st=this._buildBevelVert(j,de,(Ie-1+Pe)%Pe,void 0,Je),ot=this._buildBevelVert(j,se,(Ce-1+ve)%ve,void 0,Je),Ke=st,Qe=ot,ft,St,ee=!1;do{Je=(ye||Ae)/Ae,Ve=L1(ye,U);let W=re(de,Ie,Ve),_e=re(se,Ce,Ve),We=ee;if(ee=!1,W&&!_e){for(let V=0;V<W;V++)ft=this._buildBevelVert(j,de,(Ie+V)%Pe,V/(W-1),Je),b.push(Ke.topN,ft.topP,Qe.topN),n===!1&&b.push(ft.bottomP,Ke.bottomN,Qe.bottomN),Ke=ft;ee=!0}else if(!W&&_e)for(let V=0;V<_e;V++)St=this._buildBevelVert(j,se,(Ce+V)%ve,V/(_e-1),Je),b.push(Qe.topN,Ke.topP,St.topP),n===!1&&b.push(Ke.bottomP,Qe.bottomN,St.bottomP),Qe=St;else if(W&&_e)if(ft=this._buildBevelVert(j,de,Ie,0,Je),St=this._buildBevelVert(j,se,Ce,0,Je),We?(b.push(Ke.topN,St.topP,Qe.topN),b.push(Ke.topN,ft.topP,St.topP),n===!1&&(b.push(St.bottomP,Ke.bottomN,Qe.bottomN),b.push(St.bottomP,ft.bottomP,Ke.bottomN))):(b.push(Qe.topN,Ke.topN,ft.topP),b.push(Qe.topN,ft.topP,St.topP),n===!1&&(b.push(ft.bottomP,Ke.bottomN,Qe.bottomN),b.push(ft.bottomP,Qe.bottomN,St.bottomP))),Ke=ft,Qe=St,W===_e)for(let V=1;V<W;V++)ft=this._buildBevelVert(j,de,(Ie+V)%Pe,V/(W-1),Je),St=this._buildBevelVert(j,se,(Ce+V)%ve,V/(_e-1),Je),b.push(Ke.topN,ft.topP,Qe.topN),b.push(Qe.topN,ft.topP,St.topP),n===!1&&(b.push(ft.bottomP,Ke.bottomN,Qe.bottomN),b.push(ft.bottomP,Qe.bottomN,St.bottomP)),Ke=ft,Qe=St;else if(W>_e){let V=W/_e,Oe=0;for(let dt=1;dt<W;dt++)ft=this._buildBevelVert(j,de,(Ie+dt)%Pe,dt/(W-1),Je),b.push(Ke.topN,ft.topP,Qe.topN),n===!1&&b.push(ft.bottomP,Ke.bottomN,Qe.bottomN),Ke=ft,dt>(Oe+1)*V&&(Oe++,St=this._buildBevelVert(j,se,(Ce+Oe)%ve,Oe/(_e-1),Je),b.push(Qe.topN,ft.topP,St.topP),n===!1&&b.push(ft.bottomP,Qe.bottomN,St.bottomP),Qe=St)}else{let V=_e/W,Oe=0;for(let dt=1;dt<_e;dt++)St=this._buildBevelVert(j,se,(Ce+dt)%ve,dt/(_e-1),Je),b.push(Qe.topN,ft.topP,St.topP),n===!1&&b.push(ft.bottomP,Qe.bottomN,St.bottomP),Qe=St,dt>(Oe+1)*V&&(Oe++,ft=this._buildBevelVert(j,de,(Ie+Oe)%Pe,Oe/(W-1),Je),b.push(Ke.topN,ft.topP,Qe.topN),n===!1&&b.push(ft.bottomP,Ke.bottomN,Qe.bottomN),Ke=ft)}Ie=(Ie+W)%Pe,Ce=(Ce+_e)%ve,ye=(ye+1)%Ae}while(ye!==rt)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(oe,j,b),P){let ce=[];for(let de=b.length-1;de>=fe+2;de-=3){let se=b[de-2],Pe=b[de-1],ve=b[de-0];ce.push(ve,Pe,se)}b.splice(fe,b.length-fe,...ce)}if(P){let ce=[];for(let de=oe[oe.length-1].boundary.vertices.length-1;de>=1;de-=2){let se=oe[oe.length-1].boundary.vertices[de-1],Pe=oe[oe.length-1].boundary.vertices[de-0];ce.push(se,Pe)}_.push(ce)}if(!P){let ce=oe[oe.length-1],de;try{de=Rl({windingRule:oe.length>1?Ii.POSITIVE:Ii.ODD,elementType:Pr.POLYGONS,vertexSize:2,strict:!0,contours:[ce.insetPoints,..._]})}catch{de=mI}if(!de)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<d&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let se=0;se<de.elementCount*3;se+=3){let Pe=this._buildSurfaceVert(de,de.elements[se+0],te),ve=this._buildSurfaceVert(de,de.elements[se+1],te),Ae=this._buildSurfaceVert(de,de.elements[se+2],te);b.push(Pe.top,ve.top,Ae.top),n===!1&&b.push(Ae.bottom,ve.bottom,Pe.bottom)}}this.vertexCache={}}this._buffer.shrink();let S=new Pt(Uint32Array.from(b),1),A=new Pt(this._buffer.positions,3),E=new Pt(this._buffer.normals,3),M=new Pt(this._buffer.uvs,2);A.needsUpdate=!0,E.needsUpdate=!0,M.needsUpdate=!0,S.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",E),this.setAttribute("uv",M),this.setIndex(S)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let a=0,s=r.boundary.vertexCount;a<s;a++){let n=this._buildBevelVert(t,r,a),o=this._buildBevelVert(t,r,(a+1)%s);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let a=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(a-this._minX)/this._width,o=(s-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,c=l*2,d={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=a,this._buffer.positions[h+1]=s,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[c+0]=n,this._buffer.uvs[c+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=a,this._buffer.positions[h+4]=s,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[c+2]=n,this._buffer.uvs[c+3]=o),this.vertexCache[r]=d,d}_buildBevelVert(e,t,i,r=1,a){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[n,o]=t.boundary.vertexIndices[i],l,h,c,d;n!==o?(h=n,l=o,d=!1,c=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,d=e.concave[l]&&t.bevelI>0,c=e.continuous[l]||d);let u=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,g=h*2,y=t.boundary.vertices[f+0],x=t.boundary.vertices[f+1],b=(1-p)*this._bevel,_=(y-this._minX)/this._width,S=(x-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(_=a),S=1);let A=e.normals[m+0],E=e.normals[m+1],M=e.normals[g+0],T=e.normals[g+1];if(d){let L=M-A,j=T-E;A=A+L*(1-r),E=E+j*(1-r);let q=Math.sqrt(A*A+E*E);A/=q,E/=q}let P=this.forPathBevel?this._buffer.get(c?1:2):this._buffer.get(c?2:4),R=P*3,z=P*2,U={i,fi:l,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1,pathBevelUCoord:a};return this._buffer.positions[R+0]=y,this._buffer.positions[R+1]=x,this._buffer.positions[R+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[R+0]=A*u,this._buffer.normals[R+1]=E*u,this._buffer.normals[R+2]=p,this._buffer.uvs[z+0]=_,this._buffer.uvs[z+1]=S,this.forPathBevel===!1&&(this._buffer.positions[R+3]=y,this._buffer.positions[R+4]=x,this._buffer.positions[R+5]=b,this._buffer.normals[R+3]=A*u,this._buffer.normals[R+4]=E*u,this._buffer.normals[R+5]=-p,this._buffer.uvs[z+2]=S,this._buffer.uvs[z+3]=_),c||(this.forPathBevel?(P+=1,R+=3,z+=2):(P+=2,R+=6,z+=4),U.topP=P+0,U.bottomP=P+1,this._buffer.positions[R+0]=y,this._buffer.positions[R+1]=x,this._buffer.positions[R+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[R+0]=M*u,this._buffer.normals[R+1]=T*u,this._buffer.normals[R+2]=p,this._buffer.uvs[z+0]=_,this._buffer.uvs[z+1]=S,this.forPathBevel===!1&&(this._buffer.positions[R+3]=y,this._buffer.positions[R+4]=x,this._buffer.positions[R+5]=b,this._buffer.normals[R+3]=M*u,this._buffer.normals[R+4]=T*u,this._buffer.normals[R+5]=-p,this._buffer.uvs[z+2]=S,this._buffer.uvs[z+3]=_)),this.vertexCache[s]=U,U}clone(){let e=new n_(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=zv(this.userData),e}},gI=class extends vt{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Ii.ODD,this.elementType=Pr.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Ii.ODD,elementType:Pr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),s,n=!0,o=!0,l,h;for(let u=0,p=r.length/2;u<p;u++){let f=u*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!n&&!o)break}if(!n&&!o)try{s=Rl({contours:[r,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=s_}let c=s?.vertexCount??1,d=s?.elementCount??1;if(this._positionAttribute=new Pt(new Float32Array(c*3),3),this._normalAttribute=new Pt(new Float32Array(c*3),3),this._uvAttribute=new Pt(new Float32Array(c*2),2),this._indexAttribute=new Pt(new Uint32Array(d*3),1),s){let u=1/0,p=-1/0,f=1/0,m=-1/0;for(let x=0,b=c;x<b;x++){let _=x*2,S=s.vertices[_+0],A=s.vertices[_+1];S<u&&(u=S),S>p&&(p=S),A<f&&(f=A),A>m&&(m=A)}let g=p-u,y=m-f;for(let x=0,b=c;x<b;x++){let _=x*2,S=s.vertices[_+0],A=s.vertices[_+1],E=(S-u)/g,M=(A-f)/y;this._positionAttribute.setXYZ(x,S,A,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,E,M)}for(let x=0,b=d;x<b;x++){let _=x*3,S=s.elements[_+0],A=s.elements[_+1],E=s.elements[_+2];this._indexAttribute.setX(_+0,S),this._indexAttribute.setX(_+1,A),this._indexAttribute.setX(_+2,E)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new gI(this._shape,this._curveSegments);return e.userData=zv(this.userData),e}},vI=class extends n_{constructor(e,t,i=0,r=12,a=3,s=Ii.ODD){super(e,t,i,r,a,s),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let a=0,s=r.boundary.vertexCount;a<s;a++){let n=this._buildBevelVert(t,r,a),o=this._buildBevelVert(t,r,(a+1)%s);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new vI(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=zv(this.userData),e}},Kh=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Ii.ODD},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width),s=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof hr?(n.width!==r||n.height!==a)&&n.applySize(r,a):n=new hr(r,a).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new hr(r,a);return{parameters:Object.assign(i,{width:r,height:a,depth:s,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:a,roundness:s,windingRule:n}=e.parameters;e.shape.roundness=s;let o;return t<=0?o=new gI(e.shape,a,{windingRule:n}):o=new vI(e.shape,t,i,a,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},yI=Math.PI*2,o_=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=tt.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof hr?e.shape:new hr,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:a,innerRadius:s,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,c=t*.5,d=i*.5,u=nJ(h,c,d,a*Math.PI/180,r,s);h.isClosed=!0,h.update();let p;return a===0?(p=new vt,p.setAttribute("position",new nt([],3))):p=Kh.create({shape:h,parameters:{subdivisions:u,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function nJ(e,t,i,r,a,s){if(r>=yI)return a>30||a%4===0?(lJ(e,t,i,s),Math.round(a/4)):rC(e,r,a,t,i,s);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=KZ({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return a>30||a%h.length===0?oJ(e,n.x,n.y,h,a,t,i,s):rC(e,r,a,t,i,s)}function oJ(e,t,i,r,a,s,n,o){let l=Math.round(a/r.length);e.addPoint(fd(t,i));for(let h=0,c=r.length;h<c;h++){let d=r[h],u=e.points[h],p=fd(d.x,d.y);u.controls[1].position.set(d.x1,d.y1),p.controls[0].position.set(d.x2,d.y2),e.addPoint(p)}return o>0?xI(e,s,n,o):e.addPoint(fd(0,0)),l}function rC(e,t,i,r,a,s){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,c=Math.cos(l)*a;e.addPoint(fd(h,c))}return t<yI?s>0?xI(e,r,a,s):e.addPoint(fd(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&bI(e,r,a,s)),1}function lJ(e,t,i,r=0,a=0,s=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(bm(a-t,s,a-t,s-l,a-t,s+l)),e.addPoint(bm(a,s+i,a-o,s+i,a+o,s+i)),e.addPoint(bm(a+t,s,a+t,s+l,a+t,s-l)),e.addPoint(bm(a,s-i,a+o,s-i,a-o,s-i)),r>0&&bI(e,t,i,r)}function fd(e,t){return new pd(tt.generateUUID(),new ae(e,t))}function bm(e,t,i,r,a,s){let n=fd(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(a,s),n}function xI(e,t,i,r){wI(e,t,i,r).forEach(a=>e.addPoint(a))}function bI(e,t,i,r){let a=wI(e,t,i,r),s=new hr;a.forEach(n=>s.addPoint(n)),s.isClosed=!0,e.shapeHoles.push(s)}function wI(e,t,i,r){let a=r*t/100,s=a*(Math.abs(i)/Math.abs(t)),n=new ae(a/t,s/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=tt.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),c=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(c),l.controls[1].position.copy(h)}),o}var hJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??r),s=Math.abs(i.depth??r),n=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(i,{width:r,height:a,depth:s,radius:n,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:a,revolutions:s,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:c,cornerSegments:d}=e.parameters,u=new _I(!1,t,i,r,a,s,n,o,l,h,c,d);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},B1=new od([0,0,0],1),_I=class extends vt{constructor(e=!0,t=1,i=1,r=1,a=1,s=1,n=1,o=1,l=1,h=1,c=1,d=1){if(super(),s===0)return;let u=e&&s===1;u&&(d=0),c>100&&(c=100),c===0&&(d=0);let p=()=>new O,f=new O,m=p(),g=p(),y=p(),x,b,_,S,A,E,M,T,P=p(),R=p(),z=p(),U=p(),L=p(),j=p(),q=p(),Q=p(),X=i-2*o+.001,ie=X/s,oe=Math.ceil(n*s),te=oe+1,re=X/oe,fe=-X/2,ce=h+1,de=2*Math.PI/h,se=Math.PI/2/d,Pe=.01,ve=Math.min((1-c/100)*o,o-Pe),Ae=o-ve,ye=0,Ve=2,Ie=d*Ve+Ve,Ce=ce*Ie/Ve,rt=Ce+ce*te,Je=Math.max(0,ce*(te+Ie)),[st,ot,Ke]=[3,3,2].map(Fe=>Array(Je*Fe).fill(0)),Qe=[],ft=a-o;function St(Fe,ut){let lt=Math.PI/2;E=ut*re,T=2*Math.PI*(E%ie)/ie+lt,E+=fe,M=Math.sin(T)*ft,A=Math.cos(T)*ft,e?Fe.set(A,M,E):Fe.set(A,E,M)}St(f,-1e-10),St(m,0),P.copy(f),St(f,1);let ee=f.distanceTo(m),W=u?0:Ae+ve,_e=ee*oe+2*W,We=ve,V=_e-W;for(let Fe=0;Fe<=oe;Fe++){St(g,Fe),Q.subVectors(g,P).normalize(),P.copy(g),j.copy(g).setComponent(+e+1,0).normalize(),q.crossVectors(Q,j).normalize();let ut=Fe===0,lt=Fe===oe,At=ut?3*Math.PI/2:se,_t=ut?We:V,ai=ut?ce:rt,yi=ut?0:Je-ce,ri=Q.clone().multiplyScalar(ut?-Ae:Ae).add(g),me=Q.clone().multiplyScalar(ut?-1:1).normalize();for(let Ee=0;Ee<ce;Ee++){let Xe=Ee*de;if(R.addVectors(f.copy(j).multiplyScalar(o*Math.cos(Xe)),m.copy(q).multiplyScalar(o*Math.sin(Xe))),z.copy(R).normalize(),ut||lt){u||(ye=yi+Ee,[0,1,2].forEach(Ze=>{st[ye*3+Ze]=ri.getComponent(Ze),ot[ye*3+Ze]=me.getComponent(Ze)}),Ke[ye*2]=+lt,Ke[ye*2+1]=Ee/h),m.copy(z).multiplyScalar(ve),y.addVectors(g,m);for(let Ze=0;Ze<d;Ze++){let yt=Ze*se+At;U.addVectors(f.copy(Q).multiplyScalar(Ae*Math.sin(yt)),m.copy(z).multiplyScalar(Ae*Math.cos(yt))),L.copy(U).normalize(),m.addVectors(y,U),U.normalize(),ye=ai+Ze*ce+Ee,[0,1,2].forEach(Si=>{st[ye*3+Si]=m.getComponent(Si),ot[ye*3+Si]=L.getComponent(Si)});let Tt=+ut+Math.sin(yt);Ke[ye*2]=(_t+Ae*Tt)/_e,Ke[ye*2+1]=Ee/h}}m.addVectors(g,R),ye=Ce+Fe*ce+Ee,[0,1,2].forEach(Ze=>{st[ye*3+Ze]=m.getComponent(Ze),ot[ye*3+Ze]=z.getComponent(Ze)}),Ke[ye*2]=(W+Fe*ee)/_e,Ke[ye*2+1]=Ee/h}}let Oe=te+2*d+Ve,dt=1,[He,ze]=[+u,Oe-1];for(let Fe=He;Fe<=ze-1;Fe++){let ut=u&&Fe===ze-1;for(let lt=0;lt<ce-1;lt++)x=Fe*ce+lt,b=x+1,_=(ut?lt:x)+ce,S=(ut?lt+1:b)+ce,Fe===0?Qe.push(b,S,_):Fe===Oe-2?Qe.push(x,b,_):Qe.push(x,b,_,b,S,_)}this.setIndex(Qe),this.setAttribute("position",new nt(st,3)),this.setAttribute("normal",new nt(ot,3)),this.setAttribute("uv",new nt(Ke,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),a,s,n,o,l=6*(t-1)*e.radialSegments,h=t,c=h===t;for(let d=0;d<e.radialSegments;d++)a=h*i+d,s=a+1,n=(c?d:a)+i,o=(c?d+1:s)+i,r[l++]=a,r[l++]=s,r[l++]=n,r[l++]=s,r[l++]=o,r[l++]=n;return r.length=l,B1.array=r,B1.count=r.length,B1}},cJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:a,corner:s,cornerSides:n}=e.parameters,o=a===0&&s!==0?new SI(t*.5,s,n):new eP(t*.5,a);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},SI=class extends i_{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,a=[-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],n="IcosahedronGeometry";super(a,s,n,e,t,i),this.type=n}static fromJSON(e){return new SI(e.radius,e.corner,e.cornerSides)}},dJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,a=new Mg;a.moveTo(t[0].x,t[0].y),a.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Y3(a.extractPoints(r).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...e,type:"LatheGeometry"}})}},bn=new je,z1=new Ci,wm=new O,uv=class extends ha{constructor(){super(),this.uuid=tt.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Dr().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i];a.normal.applyMatrix3(t).normalize();for(let s=0,n=a.vertexNormals.length;s<n;s++)a.vertexNormals[s].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return bn.makeRotationX(e),this.applyMatrix4(bn),this}rotateY(e){return bn.makeRotationY(e),this.applyMatrix4(bn),this}rotateZ(e){return bn.makeRotationZ(e),this.applyMatrix4(bn),this}translate(e,t,i){return bn.makeTranslation(e,t,i),this.applyMatrix4(bn),this}scale(e,t,i){return bn.makeScale(e,t,i),this.applyMatrix4(bn),this}lookAt(e){return z1.lookAt(e),z1.updateMatrix(),this.applyMatrix4(z1.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let a=r.position,s=r.normal,n=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<a.count;d++)t.vertices.push(new O().fromBufferAttribute(a,d)),n!==void 0&&t.colors.push(new Ct().fromBufferAttribute(n,d));function h(d,u,p,f){let m=n===void 0?[]:[t.colors[d].clone(),t.colors[u].clone(),t.colors[p].clone()],g=s===void 0?[]:[new O().fromBufferAttribute(s,d),new O().fromBufferAttribute(s,u),new O().fromBufferAttribute(s,p)],y=new db(d,u,p,g,m,f);t.faces.push(y),o!==void 0&&t.faceVertexUvs[0].push([new ae().fromBufferAttribute(o,d),new ae().fromBufferAttribute(o,u),new ae().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new ae().fromBufferAttribute(l,d),new ae().fromBufferAttribute(l,u),new ae().fromBufferAttribute(l,p)])}let c=e.groups;if(c.length>0)for(let d=0;d<c.length;d++){let u=c[d],p=u.start,f=u.count;for(let m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),u.materialIndex):h(m,m+1,m+2,u.materialIndex)}else if(i!==void 0)for(let d=0;d<i.count;d+=3)h(i.getX(d),i.getX(d+1),i.getX(d+2));else for(let d=0;d<a.count;d+=3)h(d,d+1,d+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wm).negate(),this.translate(wm.x,wm.y,wm.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new je;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new O,t=new O;for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i],s=this.vertices[a.a],n=this.vertices[a.b],o=this.vertices[a.c];e.subVectors(o,n),t.subVectors(s,n),e.cross(t),e.normalize(),a.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new O;if(e){let i=new O,r=new O;for(let a=0,s=this.faces.length;a<s;a++){let n=this.faces[a],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i];t[a.a].add(a.normal),t[a.b].add(a.normal),t[a.c].add(a.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i],s=a.vertexNormals;s.length===3?(s[0].copy(t[a.a]),s[1].copy(t[a.b]),s[2].copy(t[a.c])):(s[0]=t[a.a].clone(),s[1]=t[a.b].clone(),s[2]=t[a.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let a=0,s=r.vertexNormals.length;a<s;a++)r.__originalVertexNormals[a]?r.__originalVertexNormals[a].copy(r.vertexNormals[a]):r.__originalVertexNormals[a]=r.vertexNormals[a].clone()}let e=new uv;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let a=this.morphNormals[t].faceNormals,s=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new O,h={a:new O,b:new O,c:new O};a.push(l),s.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let a=0,s=this.faces.length;a<s;a++){let n=this.faces[a],o=r.faceNormals[a],l=r.vertexNormals[a];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wr),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cs),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,a=this.vertices.length,s=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,c=e.colors;t!==void 0&&(r=new Dr().getNormalMatrix(t));for(let d=0,u=n.length;d<u;d++){let p=n[d].clone();t!==void 0&&p.applyMatrix4(t),s.push(p)}for(let d=0,u=c.length;d<u;d++)h.push(c[d].clone());for(let d=0,u=l.length;d<u;d++){let p=l[d],f,m,g=p.vertexNormals,y=p.vertexColors,x=new db(p.a+a,p.b+a,p.c+a);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,_=g.length;b<_;b++)f=g[b].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),x.vertexNormals.push(f);x.color.copy(p.color);for(let b=0,_=y.length;b<_;b++)m=y[b],x.vertexColors.push(m.clone());x.materialIndex=p.materialIndex+i,o.push(x)}for(let d=0,u=e.faceVertexUvs.length;d<u;d++){let p=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],y=[];for(let x=0,b=g.length;x<b;x++)y.push(g[x].clone());this.faceVertexUvs[d].push(y)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],a=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],c=Math.round(h.x*a)+"_"+Math.round(h.y*a)+"_"+Math.round(h.z*a);t[c]===void 0?(t[c]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[c]]}let s=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let c=[h.a,h.b,h.c];for(let d=0;d<3;d++)if(c[d]===c[(d+1)%3]){s.push(o);break}}for(let o=s.length-1;o>=0;o--){let l=s[o];this.faces.splice(l,1);for(let h=0,c=this.faceVertexUvs.length;h<c;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new O(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],a=this.faceVertexUvs[1],s,n;r&&r.length===t&&(s=[]),a&&a.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;s&&s.push(r[l]),n&&n.push(a[l])}s&&(this.faceVertexUvs[0]=s),n&&(this.faceVertexUvs[1]=n)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],a={},s=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,y=this.faceVertexUvs[0][p]!==void 0,x=f.normal.length()>0,b=f.vertexNormals.length>0,_=f.color.r!==1||f.color.g!==1||f.color.b!==1,S=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,m),A=h(A,2,g),A=h(A,3,y),A=h(A,4,x),A=h(A,5,b),A=h(A,6,_),A=h(A,7,S),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),y){let E=this.faceVertexUvs[0][p];i.push(u(E[0]),u(E[1]),u(E[2]))}if(x&&i.push(c(f.normal)),b){let E=f.vertexNormals;i.push(c(E[0]),c(E[1]),c(E[2]))}if(_&&i.push(d(f.color)),S){let E=f.vertexColors;i.push(d(E[0]),d(E[1]),d(E[2]))}}function h(p,f,m){return m?p|1<<f:p&~(1<<f)}function c(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return a[f]!==void 0||(a[f]=r.length/3,r.push(p.x,p.y,p.z)),a[f]}function d(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return n[f]!==void 0||(n[f]=s.length,s.push(p.getHex())),n[f]}function u(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,s.length>0&&(e.data.colors=s),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new uv().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let d=0,u=t.length;d<u;d++)this.vertices.push(t[d].clone());let i=e.colors;for(let d=0,u=i.length;d<u;d++)this.colors.push(i[d].clone());let r=e.faces;for(let d=0,u=r.length;d<u;d++)this.faces.push(r[d].clone());for(let d=0,u=e.faceVertexUvs.length;d<u;d++){let p=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],y=[];for(let x=0,b=g.length;x<b;x++){let _=g[x];y.push(_.clone())}this.faceVertexUvs[d].push(y)}}let a=e.morphTargets;for(let d=0,u=a.length;d<u;d++){let p={};if(p.name=a[d].name,a[d].vertices!==void 0){p.vertices=[];for(let f=0,m=a[d].vertices.length;f<m;f++)p.vertices.push(a[d].vertices[f].clone())}if(a[d].normals!==void 0){p.normals=[];for(let f=0,m=a[d].normals.length;f<m;f++)p.normals.push(a[d].normals[f].clone())}this.morphTargets.push(p)}let s=e.morphNormals;for(let d=0,u=s.length;d<u;d++){let p={};if(s[d].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=s[d].vertexNormals.length;f<m;f++){let g=s[d].vertexNormals[f],y={};y.a=g.a.clone(),y.b=g.b.clone(),y.c=g.c.clone(),p.vertexNormals.push(y)}}if(s[d].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=s[d].faceNormals.length;f<m;f++)p.faceNormals.push(s[d].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let d=0,u=n.length;d<u;d++)this.skinWeights.push(n[d].clone());let o=e.skinIndices;for(let d=0,u=o.length;d<u;d++)this.skinIndices.push(o[d].clone());let l=e.lineDistances;for(let d=0,u=l.length;d<u;d++)this.lineDistances.push(l[d]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new uJ().fromGeometry(this),t=new vt,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",_m.call(new Pt(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",_m.call(new Pt(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",aC.call(new Pt(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",sC.call(new Pt(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",sC.call(new Pt(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let a=[],s=e.morphTargets[r];for(let n=0,o=s.length;n<o;n++){let l=s[n],h=new nt(l.data.length*3,3);h.name=l.name,a.push(_m.call(h,l.data))}t.morphAttributes[r]=a}if(e.skinIndices.length>0){let r=new nt(e.skinIndices.length*4,4);t.setAttribute("skinIndex",nC.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new nt(e.skinWeights.length*4,4);t.setAttribute("skinWeight",nC.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new vt,i=e.geometry;if(e.isPoints||e.isLine){let r=new nt(i.vertices.length*3,3),a=new nt(i.colors.length*3,3);if(t.setAttribute("position",_m.call(r,i.vertices)),t.setAttribute("color",aC.call(a,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let s=new nt(i.lineDistances.length,1);t.setAttribute("lineDistance",pJ.call(s,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};uv.prototype.isGeometry=!0;var uJ=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,a,s=e.faces;for(r=0;r<s.length;r++){let n=s[r];n.materialIndex!==a&&(a=n.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:a})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,a=r[0]&&r[0].length>0,s=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:n[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,c=h.length,d;if(c>0){d=[];for(let g=0;g<c;g++)d[g]={name:h[g].name,data:[]};this.morphTargets.normal=d}let u=e.skinIndices,p=e.skinWeights,f=u.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let y=t[g];this.vertices.push(i[y.a],i[y.b],i[y.c]);let x=y.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let _=y.normal;this.normals.push(_,_,_)}let b=y.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let _=y.color;this.colors.push(_,_,_)}if(a===!0){let _=r[0][g];_!==void 0?this.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ae,new ae,new ae))}if(s===!0){let _=r[1][g];_!==void 0?this.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ae,new ae,new ae))}for(let _=0;_<o;_++){let S=n[_].vertices;l[_].data.push(S[y.a],S[y.b],S[y.c])}for(let _=0;_<c;_++){let S=h[_].vertexNormals[g];d[_].data.push(S.a,S.b,S.c)}f&&this.skinIndices.push(u[y.a],u[y.b],u[y.c]),m&&this.skinWeights.push(p[y.a],p[y.b],p[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},db=class{constructor(e,t,i,r,a,s=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new O,this.vertexNormals=Array.isArray(r)?r:[],this.color=a&&a.isColor?a:new Ct,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function pJ(e){return this.array.set(e),this}function aC(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new Ct),t[i++]=s.r,t[i++]=s.g,t[i++]=s.b}return this}function sC(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new ae),t[i++]=s.x,t[i++]=s.y}return this}function _m(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new O),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z}return this}function nC(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Lt),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z,t[i++]=s.w}return this}var fJ=["a","b","c"];function mJ(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function k1(e,t,i){let r=Math.min(e,t),a=Math.max(e,t),s=r+"_"+a;return i.get(s)}function F1(e,t,i,r,a,s){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let c=i[n],d=i[o];h={a:c,b:d,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(a),s[e].edges.push(h),s[t].edges.push(h)}function gJ(e,t,i,r){let a,s,n;for(a=0,s=e.length;a<s;a++)i[a]={edges:[]};for(a=0,s=t.length;a<s;a++)n=t[a],F1(n.a,n.b,e,r,n,i),F1(n.b,n.c,e,r,n,i),F1(n.c,n.a,e,r,n,i)}function Sm(e,t,i,r,a){e.push(new db(t,i,r,void 0,void 0,a))}function Rc(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Am(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var vJ=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof vt?e=new uv().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new O,i,r,a,s,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],c=h!==void 0&&h.length>0,d=[],u=new Map;gJ(o,l,d,u);let p=[],f,m,g,y,x,b,_;for(let Pe of Array.from(u.keys())){for(m=u.get(Pe),g=new O,x=3/8,b=1/8,_=m.faces.length,_!=2&&(x=.5,b=0,_!=1),g.addVectors(m.a,m.b).multiplyScalar(x),t.set(0,0,0),s=0;s<_;s++){for(y=m.faces[s],n=0;n<3&&(f=o[mJ(y,fJ[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(b),g.add(t),m.newEdge=p.length,p.push(g)}let S,A,E,M,T,P,R,z=[];for(r=0,a=o.length;r<a;r++){for(P=o[r],T=d[r].edges,i=T.length,i==3?S=3/16:i>3&&(S=3/(8*i)),A=1-i*Number(S),E=S,i<=2&&(i==2?(A=3/4,E=1/8):i==1||i==0),R=P.clone().multiplyScalar(A),t.set(0,0,0),s=0;s<i;s++)M=T[s],f=M.a!==P?M.a:M.b,t.add(f);t.multiplyScalar(Number(E)),R.add(t),z.push(R)}let U=z.concat(p),L=z.length,j,q,Q,X=[],ie=[],oe,te,re,fe,ce=new ae,de=new ae,se=new ae;for(r=0,a=l.length;r<a;r++)y=l[r],j=Number(k1(y.a,y.b,u).newEdge)+L,q=Number(k1(y.b,y.c,u).newEdge)+L,Q=Number(k1(y.c,y.a,u).newEdge)+L,Sm(X,j,q,Q,y.materialIndex),Sm(X,y.a,j,Q,y.materialIndex),Sm(X,y.b,q,j,y.materialIndex),Sm(X,y.c,Q,q,y.materialIndex),c&&(oe=h[r],te=oe[0],re=oe[1],fe=oe[2],ce.set(Rc(te.x,re.x),Rc(te.y,re.y)),de.set(Rc(re.x,fe.x),Rc(re.y,fe.y)),se.set(Rc(te.x,fe.x),Rc(te.y,fe.y)),Am(ie,ce,de,se),Am(ie,te,ce,se),Am(ie,re,de,ce),Am(ie,fe,se,de));e.vertices=U,e.faces=X,c&&(e.faceVertexUvs[0]=ie)}},Nr=new O,yJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new vt().copy(new ln(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Nr),r={width:Nr.x,height:Nr.y,depth:Nr.z,subdivisions:0}):r=t.parameters;let a={...r,...e.parameters};return{parameters:{width:Math.abs(a.width),height:Math.abs(a.height),depth:Math.abs(a.depth),subdivisions:Math.abs(a.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:a}=e.parameters,s=e.geometry??new vt().copy(new ln(100,100,100)),n=s.userData.parameters;n===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Nr)):Nr.set(n.width,n.height,n.depth),(t!==Nr.x||i!==Nr.y||r!==Nr.z)&&s.scale(Nr.x===0?1:t/Nr.x,Nr.y===0?1:i/Nr.y,Nr.z===0?1:r/Nr.z);let o=s.originalGeometry;try{a>0?(o===void 0||n?.subdivisions!==a)&&(o===void 0&&(o=s),s=new vJ(a).modify(o).toBufferGeometry()):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete e.geometry,Object.assign(s,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new hP(i).load(e,r=>{let a=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Nr);let s=100/Nr.x;Object.assign(a.parameters,{width:100,height:Nr.y*s,depth:Nr.z*s}),t(this.build(a))})}},AI=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof hr?e.shape:new hr,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:a,depth:s,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5,d=0,u=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,y=d+Math.sin(g)*h,x=u+Math.cos(g)*c;l.addPoint(l.createPoint(y,x))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=a;l.roundness=a,l.update();let f=Kh.create({shape:l,parameters:{roundness:a,depth:s,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},xJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:a,heightSegments:s,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new wJ(t*.5,i,a,s,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Ru(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function U1(e,t,i,r,a,s){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===a){let h=n.add(o).normalize();s.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);s.copy(e),s.addScaledVector(n,a/Math.sin(h)),s.addScaledVector(o,r/Math.sin(h))}}function bJ(e,t,i){let r=e.clone().sub(t),a=i.clone().sub(t);return r.projectOnVector(a),r.add(t)}var wJ=class extends vt{constructor(e=.5,t=1,i=4,r=1,a=!1,s=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],c=[],d=0,u=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,y=Math.PI-g,x=new O(0,-u,0),b=new O(0,u,0),_=new ae(e,-u),S=new ae(f,-u),A=new ae(0,b.y).sub(S),E=new ae(0,b.y).sub(_),M=new ae(A.y,-A.x).normalize(),T=new ae(E.y,-E.x).normalize(),P=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;s=Math.min(s,P);let R;{let X=new O(M.x,M.y,0),ie=new O(Math.cos(m)*X.x,X.y,Math.sin(m)*X.x);R=X.angleTo(ie)}let z=s/Math.tan((Math.PI-A.angle())/2),U=s/Math.tan((Math.PI-R)/2),L=new O;if(!a){l.push(x.x,x.y,x.z),h.push(0,-1,0),c.push(0,0);let X=d++,ie=[],oe=_.clone(),te=z/Math.cos(Math.PI/i);oe.x-=te;for(let re=0;re<i;re++){let fe=re/i*Math.PI*2+p,ce=new ae(Math.sin(fe),Math.cos(fe));Ru(oe,ce,L),l.push(L.x,L.y,L.z),h.push(0,-1,0),c.push(0,0),ie.push(d++)}for(let re=0;re<ie.length;re++)o.push(ie[re],X,ie[(re+1)%ie.length])}let j=[];{let X=new O,ie=new O,oe=new O,te=new O,re=new O,fe=new O;for(let ce=0;ce<i;ce++){let de=ce/i*Math.PI*2+p,se=(ce+.5)/i*Math.PI*2+p,Pe=(ce+1)/i*Math.PI*2+p,ve=new ae(Math.sin(de),Math.cos(de)),Ae=new ae(Math.sin(se),Math.cos(se)),ye=new ae(Math.sin(Pe),Math.cos(Pe));Ru(_,ve,ie),Ru(_,ye,oe),Ru(M,Ae,X),U1(b,ie,oe,U,U,te),l.push(te.x,te.y,te.z),U1(ie,b,oe,U,z,re),l.push(re.x,re.y,re.z),U1(oe,ie,b,z,U,fe),l.push(fe.x,fe.y,fe.z),h.push(X.x,X.y,X.z),h.push(X.x,X.y,X.z),h.push(X.x,X.y,X.z),c.push(0,0),c.push(0,0),c.push(0,0);let Ve=d++,Ie=d++,Ce=d++;if(o.push(Ve,Ie,Ce),s>0){{let st=ie.clone().add(oe).multiplyScalar(.5),ot=b.clone().sub(st).normalize(),Ke=x.clone().sub(st).normalize().add(ot).normalize().multiplyScalar(-1),Qe=fe.clone().sub(re);q(st,Qe,Ke,A.angle())}let rt,Je;{let st=new O;Ru(T,ye,st);let ot=fe.clone().add(te).multiplyScalar(.5);ot=bJ(ot,oe,b);let Ke=fe.clone().sub(te);[rt,Je]=q(ot,Ke,st,R,te.y)}{let st=rt,ot=st.clone().setY(0).normalize(),Ke=new O(0,-1,0),Qe=ot.clone().cross(Ke);Q(st,ot,Ke,Qe)}j.concat(Je);{let st=A.angle(),ot=Math.PI-st,Ke=b.clone();Ke.y-=s/Math.sin(st-Math.PI/2);let Qe=new O,ft=[];for(let ee=0;ee<n;ee++){let W=[],_e=Math.PI/2-ot*ee/n,We=Math.cos(_e),V=Math.sin(_e),Oe=se;for(let dt=0;dt<=ee;dt++){let He=Math.cos(Oe),ze=Math.sin(Oe);X.x=We*ze,X.y=V,X.z=We*He,Qe.copy(Ke).addScaledVector(X,s),l.push(Qe.x,Qe.y,Qe.z),h.push(X.x,X.y,X.z),c.push(0,0),W.push(d++),Oe+=Math.PI*2/ee/i}ft.push(W)}Je.reverse(),ft.push(Je);let St=ft.length-1;for(let ee=0;ee<St;ee++){let W=ft[ee],_e=ft[ee+1],We=W.length-1;o.push(_e[1],W[0],_e[0]);for(let V=1;V<=We;V++)o.push(W[V],W[V-1],_e[V]),o.push(_e[V+1],W[V],_e[V])}}}}}this.setIndex(o),this.setAttribute("position",new nt(l,3)),this.setAttribute("normal",new nt(h,3)),this.setAttribute("uv",new nt(c,2));function q(X,ie,oe,te,re){let fe=-te/2,ce=(Math.PI-te)/2,de=ie.clone().normalize().cross(oe);X.addScaledVector(oe,-s/Math.sin(ce));let se=new O,Pe=new O,ve=1,Ae=d,ye=[];for(let Ve=0;Ve<=n;Ve++){let Ie=fe+Ve/n*te;Pe.set(0,0,0),Pe.addScaledVector(de,Math.sin(Ie)),Pe.addScaledVector(oe,Math.cos(Ie));for(let Ce=0;Ce<=ve;Ce++){let rt=Ce/ve-.5;if(se.copy(X),se.addScaledVector(ie,rt),se.addScaledVector(Pe,s),re!=null){let Je=Math.max(0,se.y-re);se.addScaledVector(ie,-Je/ie.y)}l.push(se.x,se.y,se.z),h.push(Pe.x,Pe.y,Pe.z),c.push(0,0),Ce===0&&ye.push(d),d++}}for(let Ve=0;Ve<n;Ve++)for(let Ie=0;Ie<ve;Ie++){let Ce=Ae+Ie+(ve+1)*Ve,rt=Ce+(ve+1),Je=rt+1,st=Ce+1;o.push(Ce,rt,st),o.push(rt,Je,st)}return[X.clone().addScaledVector(ie,.5),ye]}function Q(X,ie,oe,te){let re=Math.PI/2,fe=E.angle()-re,ce=[],de=new O,se=new O;for(let ve=0;ve<=n;ve++){let Ae=[],ye=ve/n;for(let Ve=0;Ve<=ve;Ve++){let Ie=((ve?Ve/ve:0)-.5)*y,Ce=Math.cos(Ie),rt=Math.sin(Ie),Je=Math.atan(Math.tan(fe)*Ce),st=(re+Je)*ye,ot=Math.cos(st),Ke=Math.sin(st);de.set(0,0,0),de.addScaledVector(ie,Ke*Ce),de.addScaledVector(oe,ot),de.addScaledVector(te,Ke*rt),se.copy(X).addScaledVector(de,s),l.push(se.x,se.y,se.z),h.push(de.x,de.y,de.z),c.push(0,0),Ae.push(d++)}ce.push(Ae)}let Pe=ce.length-1;for(let ve=0;ve<Pe;ve++){let Ae=ce[ve],ye=ce[ve+1],Ve=Ae.length-1;o.push(Ae[0],ye[1],ye[0]);for(let Ie=1;Ie<=Ve;Ie++)o.push(Ae[Ie-1],Ae[Ie],ye[Ie]),o.push(Ae[Ie],ye[Ie+1],ye[Ie])}}}},l_=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof hr?e.shape:new hr,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:a,cornerType:s,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},c={x:-h.x,y:-h.y},d={x:h.x,y:h.y};function u(_,S,A){return S>i&&A>r?Math.min(_*i/S,_*r/A):S>i?_*i/S:A>r?_*r/A:_}let p=[];p[0]=a[0]===0?0:u(a[0],a[0]+a[3],a[0]+a[1]),p[1]=a[1]===0?0:u(a[1],a[1]+a[2],a[1]+a[0]),p[2]=a[2]===0?0:u(a[2],a[2]+a[1],a[2]+a[3]),p[3]=a[3]===0?0:u(a[3],a[3]+a[0],a[3]+a[2]);let f=c.x,m=d.x,g=d.y,y=c.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(f,y)),t.isClosed=!0;let x=!0;for(let _=0,S=t.points.length;_<S;_++)t.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(x=!1);x&&(t.roundness=p[0]),t.useCubicForRoundedCorners=s!==1,t.update();let b=Kh.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},_J=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=tt.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:a=64,heightSegments:s=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,c;return h===0?(c=new vt,c.setAttribute("position",new nt([],3))):c=new ld(.5*t,a,s,n,o,l,h*tt.DEG2RAD),c.scale(1,i/t,r/t),Object.assign(c,{userData:{...e,type:"SphereGeometry"}})}},SJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:a=8}=e.parameters,s=new Gn(t,i,r,a);return s.scale(1,1,1),Object.assign(s,{userData:{...e,type:"PlaneGeometry"}})}},AJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:a,cornerRadius:s,cornerSegments:n}=e.parameters,o=new MJ(t,i,r,a,s,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},MJ=class extends vt{constructor(e=1,t=1,i=1,r=90,a=10,s=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;a==0&&(s=1),s=Math.max(1,Math.floor(s)),a=Math.min(a,100),r=Math.min(180-h,r),r*=Math.PI/180;let c=[],d=Math.PI/2,u=(Pe=0,ve=0,Ae=0)=>new O(Pe,ve,Ae),p=u(),f=u(),[m,g,y]=[t/2,e/2,i/2],x=-g,b=+g,[_,S,A]=[u(x,-m,+y),u(x,-m,-y),u(x,+m,-y)],E=(Pe,ve=!1)=>Math.sin(Pe-Math.PI/(1+ +ve)),M=(Pe,ve=!1)=>Math.cos(Pe-Math.PI/(1+ +ve));A.y=Math.sin(r)*t-m;let T=Math.cos(r)*t-y,P=_.z-h;r<=d?(A.z=Math.min(T,P),A.z==P&&(A.y-=(T-P)/Math.tan(d-r))):S.z=Math.min(S.z-T-y,_.z-h),p.subVectors(_,S),f.subVectors(A,S);let R=Math.min(p.length(),f.length())*a/100,z=R*Math.tan(r/2),U=R/Math.cos(r/2),L=p.clone().normalize().add(f.normalize()).setLength(U).add(S);p.set(0,E(r,!0),M(r,!0)),c.push([A,p.clone()]);let j=(Math.PI-r)/s;for(let Pe=0;Pe<=s;Pe++){let ve=d+r+Pe*j;p.set(0,Math.sin(ve)*z,Math.cos(ve)*z),p.add(L),f.set(0,E(ve),M(ve)),c.push([p.clone(),f.clone()])}c.push([_,u(0,1,0)]);let q=Math.sin(j/2)*z*2,Q=c.length-1,X=c[0][0].distanceTo(c[1][0]),ie=c[Q-1][0].distanceTo(c[Q][0]),oe=X+q*s+ie;c[0].push(1);for(let Pe=0;Pe<=s;Pe++)c[Pe+1].push(1-(X+Pe*q)/oe);c[Q].push(0);let[te,re,fe]=c[0],ce,de,se;for(let Pe=1;Pe<c.length;Pe++)[ce,de,se]=c[Pe],n.push(x,te.y,te.z,x,ce.y,ce.z,b,te.y,te.z,b,te.y,te.z,x,ce.y,ce.z,b,ce.y,ce.z),o.push(0,re.y,re.z,0,de.y,de.z,0,re.y,re.z,0,re.y,re.z,0,de.y,de.z,0,de.y,de.z),l.push(0,fe,0,se,1,fe,1,fe,0,se,1,se),[te,re,fe]=[ce,de,se];this.setAttribute("position",new nt(n,3)),this.setAttribute("normal",new nt(o,3)),this.setAttribute("uv",new nt(l,2))}},MI=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof hr?e.shape:new hr,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:a,cornerRadius:s,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,c=e.shape,d=t*.5,u=i*.5,p=0,f=0,m=n*Math.PI/360/a,g=Math.PI/2*3*-1,y=d*r/100,x=u*r/100;if(a===3&&r===50){m=2*Math.PI/a;for(let _=0;_<a;_++){let S=m*_,A=p+Math.sin(S)*d,E=f+Math.cos(S)*u;c.addPoint(c.createPoint(A,E))}}else for(let _=0;_<a;_++){let S=p+Math.cos(g)*d,A=f+Math.sin(g)*u;c.addPoint(c.createPoint(S,A)),g+=m,S=p+Math.cos(g)*y,A=f+Math.sin(g)*x,_<=a,c.addPoint(c.createPoint(S,A)),g+=m}c.isClosed=!0;for(let _=0,S=c.points.length;_<S;_++)c.points[_].roundness=s;c.roundness=s,c.update();let b=Kh.create({shape:c,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},EJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new Gn(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},CJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width);i.shapeBlendNode&&(a=r);let s=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:a,depth:s})}}static build(e){let{width:t,height:i,depth:r,radialSegments:a,tubularSegments:s,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=TJ(t,i,r,t*.5,n,s,0,0,a,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function TJ(e,t,i,r,a,s,n,o,l,h,c){[t,i]=[i,t],n=t/2;let d=tt.clamp(a/360,0,1);if(d===0){let u=new vt;return u.setAttribute("position",new nt([],3)),u}return d===1&&(h=0),new _I(!0,e,t,i,r,d,s,n,o,l,h,c)}var PJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:a,p:s,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new iP(o,i,r,a,s,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},DJ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof hr?e.shape:new hr,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:a,extrudeBevelSize:s,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5;o?(l.addPoint(l.createPoint(-h,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))),l.isClosed=!0;for(let u=0,p=l.points.length;u<p;u++)l.points[u].roundness=r;l.roundness=r,l.update();let d=Kh.create({shape:l,parameters:{roundness:r,depth:a,extrudeBevelSize:s,extrudeBevelSegments:n}});return Object.assign(d,{userData:{...e,type:"TriangleGeometry"}})}};function IJ(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function OJ(e){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(e.toLowerCase())}function RJ(e,t,i){let r,a,s,n=Math.floor(e*6),o=e*6-n,l=i*(1-t),h=i*(1-o*t),c=i*(1-(1-o)*t);switch(n%6){case 0:r=i,a=c,s=l;break;case 1:r=h,a=i,s=l;break;case 2:r=l,a=i,s=c;break;case 3:r=l,a=h,s=i;break;case 4:r=c,a=l,s=i;break;case 5:default:r=i,a=l,s=h;break}return{r:r*255,g:a*255,b:s*255}}function LJ(e,t,i){e/=255,t/=255,i/=255;let r=Math.max(e,t,i),a=Math.min(e,t,i),s=r,n=r-a,o=r==0?0:n/r,l;if(r==a)l=0;else{switch(r){case e:l=(t-i)/n+(t<i?6:0);break;case t:l=(i-e)/n+2;break;case i:default:l=(e-t)/n+4;break}l/=6}return{h:l,s:o,v:s}}function BJ(e){return e=Math.floor(e),{r:e>>16&255,g:e>>8&255,b:e&255}}function zJ(e,t,i){return(e<<16)+(t<<8)+i}function kJ(e,t,i){return e=Math.round(e),t=Math.round(t),i=Math.round(i),"#"+[e,t,i].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function FJ(e){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,(r,a,s,n)=>String(a+a+s+s+n+n));let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null}var UJ={parseRgba:OJ,hsvToRgb:RJ,rgbToHsv:LJ,hexToRgb:BJ,rgbToHex:zJ,rgbToHexString:kJ,hexStringToRgb:FJ},NJ=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},VJ=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},Le=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Le.version}static addUnaryOp(e){return Le.max_unop_len=Math.max(e.length,Le.max_unop_len),Le.unary_ops[e]=1,Le}static addBinaryOp(e,t,i){return Le.max_binop_len=Math.max(e.length,Le.max_binop_len),Le.binary_ops[e]=t,i?Le.right_associative.add(e):Le.right_associative.delete(e),Le}static addIdentifierChar(e){return Le.additional_identifier_chars.add(e),Le}static addLiteral(e,t){return Le.literals[e]=t,Le}static removeUnaryOp(e){return delete Le.unary_ops[e],e.length===Le.max_unop_len&&(Le.max_unop_len=Le.getMaxKeyLen(Le.unary_ops)),Le}static removeAllUnaryOps(){return Le.unary_ops={},Le.max_unop_len=0,Le}static removeIdentifierChar(e){return Le.additional_identifier_chars.delete(e),Le}static removeBinaryOp(e){return delete Le.binary_ops[e],e.length===Le.max_binop_len&&(Le.max_binop_len=Le.getMaxKeyLen(Le.binary_ops)),Le.right_associative.delete(e),Le}static removeAllBinaryOps(){return Le.binary_ops={},Le.max_binop_len=0,Le}static removeLiteral(e){return delete Le.literals[e],Le}static removeAllLiterals(){return Le.literals={},Le}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new Le(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return Le.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!Le.binary_ops[String.fromCharCode(e)]||Le.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return Le.isIdentifierStart(e)||Le.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(Le.hooks[e]){let i={context:this,node:t};return Le.hooks.run(e,i),i.node}return t}searchHook(e){if(Le.hooks[e]){let t={context:this};return Le.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===Le.SPACE_CODE||e===Le.TAB_CODE||e===Le.LF_CODE||e===Le.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:Le.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===Le.SEMCOL_CODE||i===Le.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,Le.max_binop_len),t=e.length;for(;t>0;){if(Le.binary_ops.hasOwnProperty(e)&&(!Le.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Le.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,a,s,n,o,l;if(s=this.gobbleToken(),!s||(t=this.gobbleBinaryOp(),!t))return s;for(a={value:t,prec:Le.binaryPrecedence(t),right_a:Le.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[s,a,n];t=this.gobbleBinaryOp();){if(i=Le.binaryPrecedence(t),i===0){this.index-=t.length;break}a={value:t,prec:i,right_a:Le.right_associative.has(t)},l=t;let h=c=>a.right_a&&c.right_a?i>c.prec:i<=c.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,s=r.pop(),e={type:Le.BINARY_EXP,operator:t,left:s,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(a,e)}for(o=r.length-1,e=r[o];o>1;)e={type:Le.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,Le.isDecimalDigit(e)||e===Le.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===Le.SQUOTE_CODE||e===Le.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===Le.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,Le.max_unop_len),i=t.length;i>0;){if(Le.unary_ops.hasOwnProperty(t)&&(!Le.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Le.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let a=this.gobbleToken();return a||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Le.UNARY_EXP,operator:t,argument:a,prefix:!0})}t=t.substr(0,--i)}Le.isIdentifierStart(e)?(r=this.gobbleIdentifier(),Le.literals.hasOwnProperty(r.name)?r={type:Le.LITERAL,value:Le.literals[r.name],raw:r.name}:r.name===Le.this_str&&(r={type:Le.THIS_EXP})):e===Le.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===Le.PERIOD_CODE||t===Le.OBRACK_CODE||t===Le.OPAREN_CODE||t===Le.QUMARK_CODE;){let i;if(t===Le.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Le.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===Le.OBRACK_CODE?(e={type:Le.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==Le.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===Le.OPAREN_CODE?e={type:Le.CALL_EXP,arguments:this.gobbleArguments(Le.CPAREN_CODE),callee:e}:(t===Le.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:Le.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;Le.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===Le.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);Le.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));Le.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);Le.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,Le.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===Le.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===Le.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Le.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let a=this.expr.charAt(this.index++);if(a===i){r=!0;break}else if(a==="\\")switch(a=this.expr.charAt(this.index++),a){case"n":e+=`
3177
3177
  `;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=a}else e+=a}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:Le.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(Le.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,Le.isIdentifierPart(e));)this.index++;return{type:Le.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){i=!0,this.index++,e===Le.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(a===Le.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===Le.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===Le.CBRACK_CODE)for(let s=t.length;s<r;s++)t.push(null)}}else if(t.length!==r&&r!==0)this.throwError("Expected comma");else{let s=this.gobbleExpression();(!s||s.type===Le.COMPOUND)&&this.throwError("Expected comma"),t.push(s)}}return i||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(Le.CPAREN_CODE);if(this.code===Le.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:Le.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Le.ARRAY_EXP,elements:this.gobbleArguments(Le.CBRACK_CODE)}}},jJ=new NJ;Object.assign(Le,{hooks:jJ,plugins:new VJ(Le),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"});Le.max_unop_len=Le.getMaxKeyLen(Le.unary_ops);Le.max_binop_len=Le.getMaxKeyLen(Le.binary_ops);var Bd=e=>new Le(e).parse(),HJ=Object.getOwnPropertyNames(Le);HJ.forEach(e=>{Bd[e]===void 0&&e!=="prototype"&&(Bd[e]=Le[e])});Bd.Jsep=Le;var GJ="ConditionalExpression",WJ={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let i=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:GJ,test:i,consequent:r,alternate:a},i.operator&&e.binary_ops[i.operator]<=.9){let s=i;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=i}}else this.throwError("Expected :")}})}};Bd.plugins.register(WJ);function Xv(e){return{all:e=e||new Map,on:function(t,i){var r=e.get(t);r?r.push(i):e.set(t,[i])},off:function(t,i){var r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var r=e.get(t);r&&r.slice().map(function(a){a(i)}),(r=e.get("*"))&&r.slice().map(function(a){a(t,i)})}}}var EI=class{constructor(e,t,i){this.id=e,this.userAPI=t,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(r=>r()),this.emitter=Xv(),this._innerCallUserAPI=async r=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await KJ(this.userAPI,r),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(a){let s=a.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=s,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0},t?.integration?.type==="OpenAI"?this.result={content:""}:t.method==="GET"&&t.url!==""&&(this.prefetchPromise=this.prefetch(i)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=Dp(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?Dp(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(e){await this.callUserAPI(e)}async callUserAPI(e){await this._debouncedCallUserAPI(e)}update(e,t,i=!0){this.userAPI=e,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&i&&this._debouncedPrefetch(t)}retrieveValue(e){if(this.result)try{return Gr.zoom(this.result,e)}catch(t){console.error(t)}}retrieveZoomedKeyValues(e){if(this.result){let t=e&&e.length?Gr.zoom(this.result,e):this.result;if(QJ(t))return Object.entries(t);if(YJ(t))return t.map((i,r)=>[r.toString(),i]);throw XJ(t)?new Error("This path points to a value, use retrieveValue() instead. "+e?.join(".")):new Error("Path error"+e?.join("."))}}dispose(){}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}get autostart(){return this.userAPI.autoStart}};function qJ(e){let t=new Headers;return e.headers.forEach(i=>{i.data.key!==""&&t.append(i.data.key,i.data.value)}),t}function XJ(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function YJ(e){return Array.isArray(e)}function QJ(e){return typeof e=="object"&&e!==null}async function KJ(e,t,i=new AbortController){let r,a=e.url,s=e.proxy?.enabled??!1,n;if(e.integration?.type==="OpenAI"){let l=Ju(e.integration.prompt===""?[]:JSON.parse(e.integration.prompt),t),h=e.integration.behavior===""?[]:Ju(JSON.parse(e.integration.behavior),t);n=`{
3178
3178
  "model": "${e.integration.model}",
@@ -3189,7 +3189,7 @@ best distance: ${u.d}`);let y=[u.x,u.y];return y.distance=u.d,y.distance}functio
3189
3189
  }`}if(s){a=`https://apis.spline.design/file/${e.proxy.fileId}/external-api/request?uuidexternalapi=${e.proxy.proxyId}`;let l;n!==void 0?l=n:e.method==="POST"&&e.body&&(l=Ju(JSON.parse(e.body),t)),l!==void 0&&(a+=`&data=${encodeURIComponent(l.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else e.integration?.type==="OpenAI"?r=n:e.method==="POST"&&e.body&&(r=Ju(JSON.parse(e.body),t));let o=await fetch(a,{method:s?"GET":e.method,headers:s?void 0:qJ(e),signal:i.signal,body:r});if(!o.ok)throw new Error("status:"+o.status+"_:_"+o.statusText);if(e.integration?.type==="OpenAI"){let l=await o.json();return s&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await o.json();return s&&(l=l.response),l}}var CI=(e,t)=>{if(typeof e=="string"){let i=t.getVariable(e);if(i)return CI(i,t)}return ba.isBoolean(e)?ba.getDisplayedValue(e).toLowerCase():ba.getDisplayedValue(e)},Ju=(e,t)=>e.map((i,r)=>{if("text"in i)return i.text;if("type"in i){if(i.type==="paragraph")return(r>0?`
3190
3190
  `:"")+Ju(i.children,t);if(i.type==="variable"){let a=t.getVariable(i.variableId);if(a!==void 0)return CI(a,t)}}return""}).join(""),ZJ=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],JJ=["0","1","2","3","4","5","6","7","8","9","."],$J=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function e$(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}Bd.addBinaryOp("^",11,!0);function TI(e,t,i="number"){let r="";for(let n=0;n<e.length;n++){let o=e[n];if("objType"in o&&o.objType==="api"){let l=JSON.parse(o.id),h=l[0],c=t.getUserAPI(h);if(c!==void 0&&c instanceof EI){let d=c.retrieveValue(l.slice(1));d!==void 0&&(r+=d)}continue}if("objType"in o&&o.objType==="webhook"){let l=JSON.parse(o.id),[h,c]=l,d=t.getUserWebhook(h);if(d!==void 0){let u=d.getParameterValue(c);u!==void 0&&(r+=u)}continue}if("objType"in o&&o.objType==="aiAssistant"){let l=t.openAIRealtime;if("objId"in o&&o.objId!==void 0){let h;if(t.scene.data.objects.traverse((c,d)=>{let u=d.events?.find(p=>p.id===o.objId);u&&(h=u)}),h!==void 0&&h.data.type==="AIAssistantListener"){let c=l?.computeAnalysisForListenerEvent(h.data);if(c!==void 0){r+=c;continue}}}r+=l?.voice??0;continue}if("id"in o){let l=e[n-1];if(n>0&&"id"in l){console.error("Two variables in a row",e);return}let h=t.getVariable(o.id),c=ba.getDisplayedValue(h);i==="number"&&ba.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?c=parseFloat(c).toString():i==="boolean"&&ba.isBoolean(h)?c=h?"true":"false":i==="boolean"&&ba.isTextValue(h)&&!Array.isArray(h.textValue)&&(c='"'+c+'"'),r+=c;continue}else if(i==="string"){o.name!=='"'&&(o.name!=="+"||o.escaped)&&(r+=o.name),o.name==="+"&&!o.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+o.name);continue}if(o.name==="and"){r+="&&";continue}if(o.name==="or"){r+="||";continue}if(o.name==="True"){r+="true";continue}if(o.name==="False"){r+="false";continue}if(i==="boolean"&&!e$(o.name)&&!JJ.includes(o.name)&&!ZJ.includes(o.name)&&!$J.includes(o.name.replace(/\($/g,""))){r+='"'+o.name+'"';continue}r+=o.name}if(i==="string")return r;if(e.length===0){if(i==="number")return 0;if(i==="boolean")return!1}let a;try{a=Bd(r)}catch(n){console.error(r,n);return}let s;try{s=mi(a)}catch(n){console.error(r,a,n)}return s}function mi(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return Number(mi(e.left)===mi(e.right));case"!=":return Number(mi(e.left)!==mi(e.right));case">":return Number(mi(e.left)>mi(e.right));case">=":return Number(mi(e.left)>=mi(e.right));case"<":return Number(mi(e.left)<mi(e.right));case"<=":return Number(mi(e.left)<=mi(e.right));case"+":return mi(e.left)+mi(e.right);case"-":return mi(e.left)-mi(e.right);case"*":return mi(e.left)*mi(e.right);case"/":return mi(e.left)/mi(e.right);case"%":return mi(e.left)%mi(e.right);case"&&":return mi(e.left)&&mi(e.right);case"||":return mi(e.left)||mi(e.right);case"^":return Math.pow(mi(e.left),mi(e.right));default:throw new Error("Unknown operator: "+e.operator)}case"UnaryExpression":switch(e.operator){case"-":return-mi(e.argument);case"!":return Number(!mi(e.argument));default:throw new Error("Unknown operator: "+e.operator)}case"Identifier":throw new Error("Unknown identifier: "+e.name);case"Literal":return e.value;case"CallExpression":if(e.callee.type==="Identifier"){if(e.callee.name==="random"){let t=0,i=1;if(e.arguments.length>=1)try{t=mi(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=mi(e.arguments[1])}catch(r){console.warn(r)}return t=Math.min(i,t),i=Math.max(i,t),t+Math.random()*(i-t)}return Math[e.callee.name].apply(null,e.arguments.map(mi))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var t$=new je,i$=new je;function r$(e,t,i){let r=[new O,new O,new O],a=[new O,new O,new O];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(a[0],a[1],a[2]),r.forEach((s,n)=>{let o=a[n],l=tt.lerp(s.length(),o.length(),i);s.lerp(o,i).setLength(l)}),new je().makeBasis(r[0],r[1],r[2])}var a$=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width),s=Math.abs(i.depth??0),n=t?.shapeData??o_.create({parameters:{...Yc,width:typeof Yc.width=="number"?Yc.width:100,height:typeof Yc.height=="number"?Yc.height:100}}).userData.shape;return{path:e.path??Kg.defaultData(),parameters:Object.assign(i,{width:r,height:a,depth:s,extrusion:{...BD,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new s$(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new vt,{userData:{...e,type:"PathGeometry"}})}},s$=class extends vt{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)||!IJ(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),r=Math.max(0,Math.min(r,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(r*a),n=this.inputs.path.isClosed?Math.ceil((i+r)*a):Math.ceil(Math.min(1,i+r)*a),o=Math.min(Math.max(2,n-s+1),a+2),l=[],h=[];for(let Q=0;Q<o;Q++){let X=this.inputs.path.isClosed?(Q+s)%e.length:Math.min(Q+s,e.length-1);l.push(e[X].clone()),h.push(t[X].clone())}let c=(Q,X,ie)=>{l[Q]=l[Q].clone().lerp(l[X],ie),h[Q]=r$(h[Q],h[X],ie)},d=0,u=r*a%1;(!this.inputs.path.isClosed||i<=1)&&(u||r===0)&&(d=u,c(0,1,d));let p=0,f=(r+i)*a%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,c(l.length-1,l.length-2,1-p)),i===0){let Q=l.length-1;l[Q].copy(l[0]),h[Q].copy(h[0])}this._applyPathModifiers(h,d,p);let{bevel:m,bevelSides:g}=this.inputs.parameters.extrusion,y=m>0?this.inputs.parameters.extrusion.capType:"flat",x=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(x=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:b,infos:_,vertices:S}=this._computeShapePoints(x),A=0,E;y==="round"&&(E=new n_(this.inputs.shapeData,2*m,m,x,g,void 0,!0),A=E.getAttribute("position").count);let M=0,T=0;_.sort((Q,X)=>Q.start-X.start),_.forEach(Q=>{Q.verticesStart=M,Q.verticesCount=Q.continuous.reduce((X,ie,oe)=>X+(oe===0||!ie?2:1),0),T+=Q.verticesCount,M=T});let P=T*o,R,z=0;if(this._isOpenEnded()&&y==="flat"){try{R=Rl({windingRule:Ii.ODD,elementType:Pr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{R=mI}z=R.vertexCount}let U=P+2*z+A*2,L=P+2*z,j={positions:new Float32Array(U*3),normals:new Float32Array(U*3),uvs:new Float32Array(U*2)},q=[];if(_.forEach(Q=>{this._extrudeRegion(Q,S,h,l,j,q,this._isGeometryClosed()&&!this._isOpenEnded())}),R&&(this._closeEnd(R,P,q,j,h[0],l[0],!1),this._closeEnd(R,P+z,q,j,h[h.length-1],l[l.length-1],!0)),E){j.positions.set(E.getAttribute("position").array,L*3),j.normals.set(E.getAttribute("normal").array,L*3),j.uvs.set(E.getAttribute("uv").array,L*2);for(let oe=L;oe<L+A;oe++)j.uvs[oe*2+1]=1e-4;let Q=q.length;q.push(...E.getIndex().array.map(oe=>oe+L)),L+=A,j.positions.set(E.getAttribute("position").array,L*3),j.normals.set(E.getAttribute("normal").array,L*3),j.uvs.set(E.getAttribute("uv").array,L*2);let X=q.length;q.push(...E.getIndex().array.map(oe=>oe+L)),this.setAttribute("position",new Pt(j.positions,3)),this.setAttribute("normal",new Pt(j.normals,3)),this.setAttribute("uv",new Pt(j.uvs,2)),this.setIndex(q);let ie=t$;ie.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(ie,L,U),ie.copy(h[0]).setPosition(l[0]).multiply(i$.makeScale(1,1,-1)),this.applyMatrix4OnRange(ie,L-A,L),this.reverseIndicesOnRange(Q,X)}else this.setAttribute("position",new Pt(j.positions,3)),this.setAttribute("normal",new Pt(j.normals,3)),this.setAttribute("uv",new Pt(j.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=nI(this.inputs.path),t=this.inputs.path.subdivisions,i=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(t*4):e.getPoints(t);if(i.length<2)return[];let r=[i[0]];return i.forEach(a=>{r[r.length-1].distanceToSquared(a)>.001&&r.push(a)}),this.inputs.path.isClosed&&r[r.length-1].distanceTo(r[0])<.001&&r.pop(),r}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,a=new O,s=new O,n=new O,o=new O,l=new O(0,1,0);for(let f=0;f<i;f++){let m=e[f],g;f===0?g=r?e[e.length-2]:m.clone().multiplyScalar(2).sub(e[1]):g=e[f-1];let y;f===i-1?y=r?e[1]:m.clone().multiplyScalar(2).sub(e[f-1]):y=e[f+1];let x=m.clone().sub(g).normalize(),b=y.clone().sub(m).normalize(),_=x.clone().add(b).normalize();n.copy(_),f===0&&(_.equals(l)||_.clone().negate().equals(l))&&l.set(0,0,1);let S=l.clone().cross(_).normalize(),A=_.clone().cross(S).normalize();l.copy(A),o.copy(S),f===0&&(a.copy(A),s.copy(_));let E=new je().makeBasis(S,A,_);t.push(E)}let h=r?s:n,c=r?a:new O(0,1,0),d=h.clone().cross(o).normalize(),u=Math.acos(c.dot(d));if(isNaN(u))return t;let p=c.clone().cross(d);h.dot(p)>0&&(u*=-1);for(let f=1;f<t.length;f++){let m=new je().makeRotationZ(u*f/t.length);t[f].multiply(m)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:a,twist:s,startScale:n,endScale:o}=this.inputs.parameters.extrusion,l=new je,h=new je;return e.forEach((c,d)=>{let u=d===0?0:d===r-1?1:(d-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(tt.lerp(a,a+s,u)*tt.DEG2RAD);let p=tt.lerp(n,o,u);h.makeScale(p,p,p),c.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=Ii.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),a=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),m=[];for(let g=f.length-1;g>=1;g-=2){let y=f[g-1],x=f[g-0];m.push(y,x)}return m}),s;try{s=Rl({windingRule:t,elementType:Pr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{s=s_}let n;try{n=Rl({windingRule:Ii.ODD,elementType:Pr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{n=fI}if(!s)throw new Error("error generating geometry");let o=s.elementCount;if(n){s.elementCount+=n.elementCount;for(let p=0;p<n.elements.length;p++){let f=n.elements[p],m=p%2===0?s.vertexCount:0;s.elements.push(f+m)}for(let p=0;p<n.vertexIndices.length;p++){let f=n.vertexIndices[p],m=s.vertexCount;s.vertexIndices.push(f+m)}for(let p=0;p<n.vertices.length;p++){let f=n.vertices[p];s.vertices.push(f)}}let l=1/0,h=-1/0,c=1/0,d=-1/0;for(let p=0,f=s.vertexCount;p<f;p++){let m=p*2,g=s.vertices[m+0],y=s.vertices[m+1];g<l&&(l=g),g>h&&(h=g),y<c&&(c=y),y>d&&(d=y)}let u=[];for(let p=s.elementCount-1;p>=0;p--){let f=p>=o,m=p*2,g=s.elements[m+0],y=s.elements[m+1],x=g+y,b={start:g,count:y,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};u.push(b);let _=g,S=x-1,A=g+1,E=i.roundedCurves.length;do{let M=_-g,T=s.vertices[S*2+0],P=s.vertices[S*2+1],R=s.vertices[_*2+0],z=s.vertices[_*2+1],U=s.vertices[A*2+0],L=s.vertices[A*2+1],j=R-T,q=z-P,Q=Math.sqrt(j*j+q*q);j/=Q,q/=Q;let X=R-U,ie=z-L,oe=Math.sqrt(X*X+ie*ie);X/=oe,ie/=oe,b.normals[M*2+0]=-ie,b.normals[M*2+1]=X;let te=s.vertexIndices[_];if(Array.isArray(te))b.continuous[M]=!1;else{let[re,fe]=i.getCurveIndexFromVertexId(te-1,!0);if(fe>0&&fe<1)b.continuous[M]=!0;else{let ce=fe===1?re+1:re-1;ce=(ce+E)%E;let de=fe===1?0:1,se=i.roundedCurves[re].getTangent(fe),Pe=i.roundedCurves[ce].getTangent(de);b.continuous[M]=se.dot(Pe)>.95}}f&&(b.normals[M*2+0]*=-1,b.normals[M*2+1]*=-1),[S,_,A]=[_,A,A+1],A>=x&&(A-=y)}while(A!==g+1)}return{regions:[r,...a],infos:u,vertices:s.vertices}}_insertVertex(e,t,i,r,a){let s=t*2,n=t*3;e.positions[n+0]=i.x,e.positions[n+1]=i.y,e.positions[n+2]=i.z,e.normals[n+0]=r.x,e.normals[n+1]=r.y,e.normals[n+2]=r.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,i,r,a,s,n){let o=new O,l=new O,h=new O,c=new O,d=new ae;i.forEach((p,f)=>{let m=r[f],g=e.verticesStart*i.length+e.verticesCount*f;for(let y=0;y<e.count;y++){let x=(e.start+y)*2;if(o.set(t[x+0],t[x+1],0),h.copy(o).applyMatrix4(p).add(m),e.continuous[y])c.set(e.normals[y*2+0],e.normals[y*2+1],0);else{let b=y===0?(e.start+e.count-1)*2:x-2;l.set(t[b+0],t[b+1],0),c.copy(o).sub(l),c.set(-c.y,c.x,0),e.isHole||c.negate()}if(c.applyMatrix4(p).normalize(),d.set(y===0?1:y/e.count,f/(i.length-1)),this._insertVertex(a,g,h,c,d),g++,!e.continuous[y]||y===0){if(y===0)c.set(e.normals[y*2+0],e.normals[y*2+1],0),d.set(0,f/(i.length-1));else{let b=y===e.count-1?e.start*2:x+2;l.set(t[b+0],t[b+1],0),c.copy(l).sub(o),c.set(-c.y,c.x,0),e.isHole||c.negate()}c.applyMatrix4(p).normalize(),this._insertVertex(a,g,h,c,d),g++}}});let u=i.length-1;for(let p=0;p<u;p++){let f=e.verticesStart*i.length+e.verticesCount*p,m=e.verticesStart*i.length+e.verticesCount*(p+1),g=0;for(let y=0;y<e.count;y++){(!e.continuous[y]||y===0)&&g++;let x=y===e.count-1?0:g+1,b=f+g,_=f+x,S=m+x,A=m+g;e.isHole?s.push(b,S,_,b,A,S):s.push(b,_,S,b,S,A),g++}}}_closeEnd(e,t,i,r,a,s,n){let o=e.vertexCount,l=new O(0,0,n?-1:1).applyMatrix4(a),h=new O,c=new ae;for(let u=0;u<o;u++){let p=2*u;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(a).add(s),this._insertVertex(r,t+u,h,l,c)}let d=e.elements;for(let u=0;u<e.elementCount;u++){let p=3*u,f=d[p+0]+t,m=d[p+(n?1:2)]+t,g=d[p+(n?2:1)]+t;i.push(f,m,g)}}applyMatrix4OnRange(e,t,i){let r=e.elements,a=new Dr().getNormalMatrix(e).elements,s,n,o,l,h=this.attributes.position,c=this.attributes.normal;if(!h||!c)return;let d=h.array,u=c.array,p=h.itemSize;for(let f=t*p,m=i*p;f<m;f+=p){if(f===t)debugger;s=d[f+0],n=d[f+1],o=d[f+2],l=1/(r[3]*s+r[7]*n+r[11]*o+r[15]),d[f+0]=(r[0]*s+r[4]*n+r[8]*o+r[12])*l,d[f+1]=(r[1]*s+r[5]*n+r[9]*o+r[13])*l,d[f+2]=(r[2]*s+r[6]*n+r[10]*o+r[14])*l,s=u[f+0],n=u[f+1],o=u[f+2],u[f+0]=a[0]*s+a[3]*n+a[6]*o,u[f+1]=a[1]*s+a[4]*n+a[7]*o,u[f+2]=a[2]*s+a[5]*n+a[8]*o}h.needsUpdate=!0,c.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let a=i.getX(r),s=i.getX(r+1),n=i.getX(r+2);i.setXYZ(r,n,s,a)}i.needsUpdate=!0}}};function PI(){let e=new vt;return e.setAttribute("position",new Pt(new Float32Array([]),3)),e.setIndex(new Pt(new Uint16Array([]),1)),e}var n$=PI().attributes,o$=12,l$=1,ub=class extends vt{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,n$),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:a,depth:s,extrudeBevelSize:n,extrudeBevelSegments:o,text:l,textTransform:h}=e,c=ba.getDisplayedValue(l),d=h===2?c.toUpperCase():h===3?c.toLowerCase():c,u=h$(e,i,d,t),{shapes:p,charWidths:f,charCoords:m}=i.generateShapes(u,e,t),g=(typeof r=="number"?r:Number(t.getVariable(r)))*.5,y=(typeof a=="number"?a:Number(t.getVariable(a)))*.5,x=p.map(S=>new hr().fromShape(S,!0));this.vectorShapes=x;let b=x.map(S=>Kh.create({shape:S,parameters:{depth:s,extrudeBevelSegments:o,extrudeBevelSize:n,windingRule:s<=0?Ii.NONZERO:Ii.ODD,subdivisions:this.isLowResolution&&s>0?l$:o$}})),_=b.length?Ch(b):PI();_.translate(-g,y,0),this.dispose(),this.wrappedText=u,this.charCoords=m,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(_.attributes).forEach(([S,A])=>{this.setAttribute(S,A)}),this.setIndex(_.index),this.computeBoundingSphere()}clone(){let e=rs(new vt,ub.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}};function h$(e,t,i,r){let a=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,s=[""],n="";for(let o of i)n+=o,o===" "||o===`
3191
3191
  `?(s[s.length-1]+=n,n="",o===`
3192
- `&&s.push("")):t.getTextWidth(s[s.length-1]+n,e)>a&&(s[s.length-1].length&&s.push(""),t.getTextWidth(s[s.length-1]+n,e)>a&&(n.length===1?(s[s.length-1]+=n,n=""):(s[s.length-1]+=n.slice(0,-1),n=n[n.length-1],s.push(""))));return s[s.length-1]+=n,s}var DI,II=new Promise(e=>{DI=e}),oC=!1,Mm;function c$(e){if(oC)return;if(Mm)return Mm;async function t(){let i=e??"https://unpkg.com/@splinetool/modelling-wasm@1.12.54/build",r=import("./process.js"),[a,s]=await Promise.all([r,fetch(`${i}/process.wasm`).then(l=>l.arrayBuffer())]),n=a.default,o=await n({wasmBinary:s});DI(o),oC=!0}return Mm=t(),Mm}var d$=["font"];function zd(e,t,i,r){let a,s,n;e.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(s={...e},n=[[]]);for(let h of n){let c=s;for(let d of h)c=c[d];for(a in c){let d=c[a];KM(d)&&!d$.includes(a)&&(c[a]=t.getVariable(d,[r.uuid,"geometry",...h,a]),KM(c[a])&&(c[a]=1))}}let o={parameters:s,type:s.type};if(s.type==="PathGeometry")o.path=s.path;else if(s.type==="VectorGeometry"){let h=hr.createFromState(s.shape,s.width,s.height);o.shape=h}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new hP().parse(s),o.geometry.groups.length===0){let h=o.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else if(s.type==="SubdivGeometry"){let h=new Ua(s,i);return h.data=e,h}else{if(s.type==="TextGeometry")return new ub(s,t);if(s.type==="InputGeometry")return new ub(s,t);if(s.type==="UIGeometry")return l_.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=uC(o)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${o}`);let c=hr.createFromState(Qg.defaultData(),100,100);o.shape=c,o.type="VectorGeometry",l=uC(o)}return l}var u$=new je;function pb(e,t,i,r){let a=e.position.array,s=e.normal.array,n=u$.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,d=a.length;c<d;c+=3)a[c]*=t,a[c+1]*=i,a[c+2]*=r,o=s[c],l=s[c+1],h=s[c+2],s[c]=n[0]*o+n[4]*l+n[8]*h,s[c+1]=n[1]*o+n[5]*l+n[9]*h,s[c+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var Em=new wr,Lc=new O,Dt;II.then(e=>{Dt=e});var lC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),hC=new Uint32Array([0,1,2,3]),cC=new Uint8Array([4]),Ua=class extends vt{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked.map(n=>typeof n=="number"?n:1),r=Ul.div(t.map(n=>typeof n=="number"?n:0),i);if(r.every(n=>n===1))return;this.subdividedGeometry&&pb(this.subdividedGeometry.attributes,...r),this.originalGeometry&&pb(this.originalGeometry.attributes,...r),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*r[0],height:a.height*r[1],depth:a.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Lc.fromArray(r));let s=Lc.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Ua.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ln(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ua.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new cs,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Em.setFromBufferAttribute(t),Em.getCenter(i),e.boundingSphere.radius=i.distanceTo(Em.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Em.getSize(Lc);let r={width:Lc.x,height:Lc.y,depth:Lc.z};return this.userData.parameters=r,r}static build(e,t,i,r){let a,s,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Dt.free_bvh(t),Dt.free_subdivision_surface(t));try{a=Ua.allocate(e,r)}catch(l){console.error(l,e),a=Ua.allocate({positionWASM:lC,indexWASM:hC,verticesPerFaceWASM:cC},r)}if(Dt.set_destination_refinement_level(a,0),s=Ua.buildLevel(a,!0,o),e.subdivisions>0)try{Dt.set_destination_refinement_level(a,e.subdivisions),n=Ua.buildLevel(a,!1,o)}catch{try{Dt.set_destination_refinement_level(a,e.subdivisions-1),n=Ua.buildLevel(a,!1,o)}catch{n=null}}else n=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:zd(e,i,!1,t),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=r.getClosedTorusIndicesForBooleanOrSubdiv():a=r.getIndex();let s,n,o,l;({positions:s,triIndices:l}=Yv(r.getAttribute("position"),a));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,d=c+e.radialSegments*3;h=[c,d]}return{indices:n,verticesPerFace:o}=OI(s,l,r,h),{positions:s,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,a,s=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,a=e.verticesPerFaceWASM):(i=lC,r=hC,a=cC);let o=i.length,l=r.length,h=a.length,c=i.length+s.length+n.length,d=r.length+a.length,u=c*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=Dt._malloc(u),m=new Float32Array(Dt.HEAPF32.buffer,f,c),g=new Uint32Array(Dt.HEAPU32.buffer,f+p,d);m.set(i,0),m.set(s,i.length),m.set(n,i.length+s.length),g.set(r,0),g.set(a,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new je().makeScale(...e.scaleBaked.map(b=>typeof b=="number"?b:1))),t&&(y?y.premultiply(t):y=t);let x=y?Dt.alloc_subdivision_surface2(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Dt.alloc_subdivision_surface(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Dt._free(f),x}static buildLevel(e,t,i,r,a){let s=a?Dt.get_mesh_data2(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i,a.elements):Dt.get_mesh_data(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i),n=8,o=Dt.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(4,4+4),h=0,c=Dt.HEAPU32[o[h]>>2],d=Dt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=Dt.HEAPU32[o[h]>>2],p=Dt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=Dt.HEAPU32[o[h]>>2],m=Dt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=Dt.HEAPU32[o[h]>>2],y=Dt.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let x=new vt;if(x.setIndex(new od(y,1)),x.setAttribute("position",new nt(d,3)),x.setAttribute("normal",new nt(p,3)),t){x.setAttribute("faceMap",new od(m,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new Pt(b,4))}return Dt.free_mesh_data(s),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Dt.free_mesh_data(s)}static freeSubdivPointer(e){Dt.free_bvh(e),Dt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Dt.get_wireframe_data_for_base_level(e),a=4,s=Dt.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(2,2+2),o=0,l=Dt.HEAPU32[s[o]>>2],h=Dt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=Dt.HEAPU32[s[o]>>2],d=Dt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let u=new vt;u.setAttribute("position",new nt(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Pt(p,3)),u.setIndex(new od(d,1)),Dt.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Dt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Dt.set_destination_refinement_level(e,t);let a=i?Dt.get_topological_data2(e,r?Dt.Level.CONTROL:Dt.Level.REFINED,i.elements):Dt.get_topological_data(e,r?Dt.Level.CONTROL:Dt.Level.REFINED),s=6,n=Dt.HEAPU32.subarray(a>>2,(a>>2)+s),o=n.subarray(3,3+3),l=0,h=Dt.HEAPU32[n[l]>>2],c=new Float32Array(Dt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let d=Dt.HEAPU32[n[l]>>2],u=new Uint32Array(Dt.HEAPU32.subarray(d>>2,(d>>2)+o[l]));l++;let p=Dt.HEAPU32[n[l]>>2],f=new Uint8Array(Dt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Dt.free_topological_data(a),{positions:c,indices:u,verticesPerFace:f}}},dC=["getX","getY","getZ"];function Yv(e,t){let i={},r=t?t.count:e.count,a=0,s=[],n=[],o=1e4;for(let h=0;h<r;h++){let c=t?t.getX(h):h,d="";for(let u=0;u<3;u++)d+=`${~~(e[dC[u]](c)*o)},`;if(d in i)s.push(i[d]);else{for(let u=0;u<3;u++)n.push(e[dC[u]](c));i[d]=a,s.push(a),a++}}let l=[];for(let h=0;h<s.length;h+=3)s[h]===s[h+1]||s[h]===s[h+2]||s[h+1]===s[h+2]||l.push(s[h],s[h+1],s[h+2]);return{positions:n,triIndices:l}}var Cm=new O,N1=new O,V1=new O,j1=new O;function OI(e,t,i,r){let a=[],s=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let c=0;for(let u=0;u<l.length;u+=2)c+=(l[u]-l[(u===0?l.length:u)-2])*(l[u+1]+l[(u===0?l.length:u)-1]);e.length=0;let d=0;if(c<0)for(let u=0;u<l.length;u+=2)e.push(l[u],l[u+1],0),a.push(d++);else for(let u=l.length-2;u>=0;u-=2)e.push(l[u],l[u+1],0),a.push(d++);return s.push(d),{indices:a,verticesPerFace:s}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Cm.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),N1.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),V1.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),j1.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),N1.sub(Cm).normalize(),V1.sub(Cm).normalize(),j1.sub(Cm).normalize();let l=N1.cross(V1).dot(j1),h=o;Math.abs(l)>.005||r&&r.some((c,d)=>d%2===1?!1:h>=r[d]&&h<r[d+1])?(a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(a.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],c=0;for(let d=0,u=0;d<e.length;d+=3,u++)e[d+2]===0&&(l.push(u),c++),e[d+2]===n&&h.push(u);if(i.userData.parameters.extrudeBevelSize===0){let d=h[0];h[0]=h[1],h[1]=d}l.reverse(),a.push(...l,...h),s.push(c,c)}return{indices:a,verticesPerFace:s}}var _o={};dz(_o,{calcBoolean:()=>v$,calcBooleanTopological:()=>g$,freeMeshSet:()=>w$,getMeshSet:()=>y$,hasOpenEdges:()=>x$,transformMeshSet:()=>b$});var RI,p$=new Promise(e=>{RI=e}),Tm;function f$(e){if(Tm)return Tm;async function t(){let i=e??"https://unpkg.com/@splinetool/boolean-wasm@1.12.54/build",r=import("./boolean.js"),[a,s]=await Promise.all([r,fetch(`${i}/boolean.wasm`).then(l=>l.arrayBuffer())]),n=a.default,o=await n({wasmBinary:s});RI(o)}return Tm=t(),Tm}var ni,md;p$.then(e=>ni=e);function m$(e,t,i){let r,a;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?a=e.getClosedTorusIndicesForBooleanOrSubdiv():a=e.getIndex();let{positions:s,triIndices:n}=Yv(e.getAttribute("position"),a),o;if(t&&i){let{indices:l,verticesPerFace:h}=OI(s,n,e);o=h.length,r=[];for(let c=0,d=0;c<o;c++){r.push(h[c]);for(let u=0;u<h[c];u++)r.push(l[d++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,c=0;c<r.length;)r[c++]=3,o++,r[c++]=n[h++],r[c++]=n[h++],r[c++]=n[h++]}return{positions:s,faceIndices:r,nFaces:o}}function LI(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,a=Number.isInteger(e[0])?i:r,s=ni._malloc(a);return(Number.isInteger(e[0])?new Uint32Array(ni.HEAPU32.buffer,s,t):new Float32Array(ni.HEAPF32.buffer,s,t)).set(e,0),s}function BI(e){switch(e){case 0:return ni.OP.UNION;case 1:return ni.OP.INTERSECTION;case 2:return ni.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+e)}}function g$(e,t){md===void 0&&(md=ni.init_csg());let i=LI(e),r=ni.csg_calc_topological(md,i,e.length,BI(t));ni._free(i);let a=6,s=ni.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(3,3+3),o=0,l=ni.HEAPU32[s[o]>>2],h=new Float32Array(ni.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=ni.HEAPU32[s[o]>>2],d=new Uint32Array(ni.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let u=ni.HEAPU32[s[o]>>2],p=new Uint8Array(ni.HEAPU32.subarray(u>>2,(u>>2)+n[o]));return ni.free_mesh_data(r),{positions:h,indices:d,verticesPerFace:p}}function v$(e,t,i,r){md===void 0&&(md=ni.init_csg());let a=LI(e),s=ni.csg_calc(md,a,e.length,r,BI(t));ni._free(a);let n=5,o=ni.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(2,2+3),h=0,c=ni.HEAPU32[o[h]>>2],d=ni.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=ni.HEAPU32[o[h]>>2],p=ni.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new nt(d,3)),i.setAttribute("normal",new nt(p,3));let m=ni.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new cs),i.boundingSphere.center.set(m[0],m[1],m[2]),i.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ni.free_mesh_data(s),f}function y$(e,t,i){if(ni===void 0)return-1;let r,a,s;if(t&&e.userData.positions!==void 0){let y=e.userData;s=y.verticesPerFace.length,r=y.positions,a=Array(y.verticesPerFace.reduce((x,b)=>x+b,0)+s);for(let x=0,b=0,_=0;x<y.verticesPerFace.length;x++){a[_++]=y.verticesPerFace[x];for(let S=0;S<y.verticesPerFace[x];S++)a[_++]=y.indices[b++]}}else({positions:r,faceIndices:a,nFaces:s}=m$(e,t,i));let n=r.length,o=a.length,l=r.length,h=a.length,c=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=ni._malloc(c),f=new Float32Array(ni.HEAPF32.buffer,p,l),m=new Uint32Array(ni.HEAPU32.buffer,p+d,h);f.set(r,0),m.set(a,0);let g=ni.get_csg_mesh(p,n,p+d,o,s);return ni._free(p),g}function x$(e){return ni.has_open_edges(e)}function b$(e,t){ni.transform_csg_mesh(e,t.elements)}function w$(e){ni.free_csg_mesh(e)}var _$={ConeGeometry:AZ,CubeGeometry:MZ,CylinderGeometry:oI,DodecahedronGeometry:CZ,EllipseGeometry:o_,HelixGeometry:hJ,IcosahedronGeometry:cJ,LatheGeometry:dJ,NonParametricGeometry:yJ,PolygonGeometry:AI,PyramidGeometry:xJ,RectangleGeometry:l_,SphereGeometry:_J,PlaneGeometry:SJ,BackdropGeometry:AJ,StarGeometry:MI,TextFrameGeometry:EJ,TorusGeometry:CJ,TorusKnotGeometry:PJ,TriangleGeometry:DJ,PathGeometry:a$,VectorGeometry:Kh},uC=e=>_$[e.type].create(e);function Bc(e){return e!==null&&"booleanOp"in e}var zI=class extends t_(Fi){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new je}updateVisible(e){super.updateVisible(e),this.visible=!Bc(this.parent)&&this.visible,Bc(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(_o.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Bc(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof zI&&(e.freeBooleanPointer(),Bc(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Bc(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Bc(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Pm=new wr;function h_(e,t=0,i=e.count,r,a){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let d=t;d<i;d++){let u=e.getX(d),p=e.getY(d),f=e.getZ(d);u<s&&(s=u),p<n&&(n=p),f<o&&(o=f),u>l&&(l=u),p>h&&(h=p),f>c&&(c=f)}Pm.min.set(s,n,o),Pm.max.set(l,h,c),Pm.getCenter(r),Pm.getSize(a).multiplyScalar(.5)}var S$=new vt,A$=new Vo,Sa=class extends zI{constructor(e,t){super(S$,A$),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?h_(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},xl=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},xl.uuidContext===null)throw new Error("plz startContext");xl.uuidContext===xl.globalContext?this.uuid="_gid"+xl.uuidContext.nodeContextUuid++:this.uuid="_uid"+xl.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===xl.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,a,s){return""}generate(e,t,i,r,a){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},Hr=xl;Hr.globalContext={nodeContextUuid:0},Hr.uuidContext=xl.globalContext;var pC=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},M$=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},$a=new M$,Oi=class extends Hr{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=tt.generateUUID()),i=e.getUUID(i??this.getUUID(),!a);let s=e.getNodeData(i),n=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,i)):super.build(e,t,i);if(a)return s.name=s.name||super.build(e,t,i),s.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||s.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,s.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,a){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),a,this.getLabel()).name}},as=class extends Oi{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,a,s){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,a,s):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,a,s,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,a,s,this.getLabel())),e.format(n.fragment.name,r,t))}},ga=class extends as{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof ae?e:new ae(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Ts=class extends as{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof O?e:new O(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},So=class extends as{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof qr?e:new qr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},E$=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,fC=/[a-z_0-9]+/gi,it=class extends Oi{constructor(e,t,i,r,a){super(a),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,a){let s,n=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;s=fC.exec(this.src);)l.push(s);for(let h=0;h<l.length;h++){let c=l[h],d=c[0],u=this.isMethod?!this.getInputByName(d):!0,p=d;if(this.keywords[d]||this.useKeywords&&u&&$a.containsKeyword(d)){let f=this.keywords[d];if(!f){let m=$a.getKeywordData(d);m.cache&&(f=e.keywords[d]),f=f||$a.getKeyword(d,e),m.cache&&(e.keywords[d]=f)}p=f.build(e)}d!==p&&o[c.index+n-1]!=="."&&(o=o.substring(0,c.index+n)+p+o.substring(c.index+d.length+n),n+=p.length-d.length),this.getIncludeByName(p)===void 0&&$a.contains(p)&&e.include($a.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let a=E$.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(fC);if(s){let n=0;for(;n<s.length;){let o=s[n++],l;o==="in"||o==="out"||o==="inout"?l=s[n++]:(l=o,o="");let h=s[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},C$=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,kI=class extends Oi{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||kI.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,a){this.src=e||"";let s,n,o="",l=C$.exec(e);this.useDefine=a??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],s=l[2],o=l[3]):(s=this.src,n="f"),this.name=s,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,a){return e.format(this.name,this.getType(e),t)}},wi=kI;wi.PI="PI",wi.PI2="PI2",wi.RECIPROCAL_PI="RECIPROCAL_PI",wi.RECIPROCAL_PI2="RECIPROCAL_PI2",wi.LOG2="LOG2",wi.EPSILON="EPSILON";var T$=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3192
+ `&&s.push("")):t.getTextWidth(s[s.length-1]+n,e)>a&&(s[s.length-1].length&&s.push(""),t.getTextWidth(s[s.length-1]+n,e)>a&&(n.length===1?(s[s.length-1]+=n,n=""):(s[s.length-1]+=n.slice(0,-1),n=n[n.length-1],s.push(""))));return s[s.length-1]+=n,s}var DI,II=new Promise(e=>{DI=e}),oC=!1,Mm;function c$(e){if(oC)return;if(Mm)return Mm;async function t(){let i=e??"https://unpkg.com/@splinetool/modelling-wasm@1.12.56/build",r=import("./process.js"),[a,s]=await Promise.all([r,fetch(`${i}/process.wasm`).then(l=>l.arrayBuffer())]),n=a.default,o=await n({wasmBinary:s});DI(o),oC=!0}return Mm=t(),Mm}var d$=["font"];function zd(e,t,i,r){let a,s,n;e.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(s={...e},n=[[]]);for(let h of n){let c=s;for(let d of h)c=c[d];for(a in c){let d=c[a];KM(d)&&!d$.includes(a)&&(c[a]=t.getVariable(d,[r.uuid,"geometry",...h,a]),KM(c[a])&&(c[a]=1))}}let o={parameters:s,type:s.type};if(s.type==="PathGeometry")o.path=s.path;else if(s.type==="VectorGeometry"){let h=hr.createFromState(s.shape,s.width,s.height);o.shape=h}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new hP().parse(s),o.geometry.groups.length===0){let h=o.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else if(s.type==="SubdivGeometry"){let h=new Ua(s,i);return h.data=e,h}else{if(s.type==="TextGeometry")return new ub(s,t);if(s.type==="InputGeometry")return new ub(s,t);if(s.type==="UIGeometry")return l_.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=uC(o)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${o}`);let c=hr.createFromState(Qg.defaultData(),100,100);o.shape=c,o.type="VectorGeometry",l=uC(o)}return l}var u$=new je;function pb(e,t,i,r){let a=e.position.array,s=e.normal.array,n=u$.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,d=a.length;c<d;c+=3)a[c]*=t,a[c+1]*=i,a[c+2]*=r,o=s[c],l=s[c+1],h=s[c+2],s[c]=n[0]*o+n[4]*l+n[8]*h,s[c+1]=n[1]*o+n[5]*l+n[9]*h,s[c+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var Em=new wr,Lc=new O,Dt;II.then(e=>{Dt=e});var lC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),hC=new Uint32Array([0,1,2,3]),cC=new Uint8Array([4]),Ua=class extends vt{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked.map(n=>typeof n=="number"?n:1),r=Ul.div(t.map(n=>typeof n=="number"?n:0),i);if(r.every(n=>n===1))return;this.subdividedGeometry&&pb(this.subdividedGeometry.attributes,...r),this.originalGeometry&&pb(this.originalGeometry.attributes,...r),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*r[0],height:a.height*r[1],depth:a.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Lc.fromArray(r));let s=Lc.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Ua.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ln(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ua.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new cs,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Em.setFromBufferAttribute(t),Em.getCenter(i),e.boundingSphere.radius=i.distanceTo(Em.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Em.getSize(Lc);let r={width:Lc.x,height:Lc.y,depth:Lc.z};return this.userData.parameters=r,r}static build(e,t,i,r){let a,s,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Dt.free_bvh(t),Dt.free_subdivision_surface(t));try{a=Ua.allocate(e,r)}catch(l){console.error(l,e),a=Ua.allocate({positionWASM:lC,indexWASM:hC,verticesPerFaceWASM:cC},r)}if(Dt.set_destination_refinement_level(a,0),s=Ua.buildLevel(a,!0,o),e.subdivisions>0)try{Dt.set_destination_refinement_level(a,e.subdivisions),n=Ua.buildLevel(a,!1,o)}catch{try{Dt.set_destination_refinement_level(a,e.subdivisions-1),n=Ua.buildLevel(a,!1,o)}catch{n=null}}else n=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:zd(e,i,!1,t),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=r.getClosedTorusIndicesForBooleanOrSubdiv():a=r.getIndex();let s,n,o,l;({positions:s,triIndices:l}=Yv(r.getAttribute("position"),a));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,d=c+e.radialSegments*3;h=[c,d]}return{indices:n,verticesPerFace:o}=OI(s,l,r,h),{positions:s,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,a,s=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,a=e.verticesPerFaceWASM):(i=lC,r=hC,a=cC);let o=i.length,l=r.length,h=a.length,c=i.length+s.length+n.length,d=r.length+a.length,u=c*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=Dt._malloc(u),m=new Float32Array(Dt.HEAPF32.buffer,f,c),g=new Uint32Array(Dt.HEAPU32.buffer,f+p,d);m.set(i,0),m.set(s,i.length),m.set(n,i.length+s.length),g.set(r,0),g.set(a,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new je().makeScale(...e.scaleBaked.map(b=>typeof b=="number"?b:1))),t&&(y?y.premultiply(t):y=t);let x=y?Dt.alloc_subdivision_surface2(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Dt.alloc_subdivision_surface(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Dt._free(f),x}static buildLevel(e,t,i,r,a){let s=a?Dt.get_mesh_data2(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i,a.elements):Dt.get_mesh_data(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i),n=8,o=Dt.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(4,4+4),h=0,c=Dt.HEAPU32[o[h]>>2],d=Dt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=Dt.HEAPU32[o[h]>>2],p=Dt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=Dt.HEAPU32[o[h]>>2],m=Dt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=Dt.HEAPU32[o[h]>>2],y=Dt.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let x=new vt;if(x.setIndex(new od(y,1)),x.setAttribute("position",new nt(d,3)),x.setAttribute("normal",new nt(p,3)),t){x.setAttribute("faceMap",new od(m,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new Pt(b,4))}return Dt.free_mesh_data(s),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Dt.free_mesh_data(s)}static freeSubdivPointer(e){Dt.free_bvh(e),Dt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Dt.get_wireframe_data_for_base_level(e),a=4,s=Dt.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(2,2+2),o=0,l=Dt.HEAPU32[s[o]>>2],h=Dt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=Dt.HEAPU32[s[o]>>2],d=Dt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let u=new vt;u.setAttribute("position",new nt(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Pt(p,3)),u.setIndex(new od(d,1)),Dt.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Dt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Dt.set_destination_refinement_level(e,t);let a=i?Dt.get_topological_data2(e,r?Dt.Level.CONTROL:Dt.Level.REFINED,i.elements):Dt.get_topological_data(e,r?Dt.Level.CONTROL:Dt.Level.REFINED),s=6,n=Dt.HEAPU32.subarray(a>>2,(a>>2)+s),o=n.subarray(3,3+3),l=0,h=Dt.HEAPU32[n[l]>>2],c=new Float32Array(Dt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let d=Dt.HEAPU32[n[l]>>2],u=new Uint32Array(Dt.HEAPU32.subarray(d>>2,(d>>2)+o[l]));l++;let p=Dt.HEAPU32[n[l]>>2],f=new Uint8Array(Dt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Dt.free_topological_data(a),{positions:c,indices:u,verticesPerFace:f}}},dC=["getX","getY","getZ"];function Yv(e,t){let i={},r=t?t.count:e.count,a=0,s=[],n=[],o=1e4;for(let h=0;h<r;h++){let c=t?t.getX(h):h,d="";for(let u=0;u<3;u++)d+=`${~~(e[dC[u]](c)*o)},`;if(d in i)s.push(i[d]);else{for(let u=0;u<3;u++)n.push(e[dC[u]](c));i[d]=a,s.push(a),a++}}let l=[];for(let h=0;h<s.length;h+=3)s[h]===s[h+1]||s[h]===s[h+2]||s[h+1]===s[h+2]||l.push(s[h],s[h+1],s[h+2]);return{positions:n,triIndices:l}}var Cm=new O,N1=new O,V1=new O,j1=new O;function OI(e,t,i,r){let a=[],s=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let c=0;for(let u=0;u<l.length;u+=2)c+=(l[u]-l[(u===0?l.length:u)-2])*(l[u+1]+l[(u===0?l.length:u)-1]);e.length=0;let d=0;if(c<0)for(let u=0;u<l.length;u+=2)e.push(l[u],l[u+1],0),a.push(d++);else for(let u=l.length-2;u>=0;u-=2)e.push(l[u],l[u+1],0),a.push(d++);return s.push(d),{indices:a,verticesPerFace:s}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Cm.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),N1.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),V1.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),j1.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),N1.sub(Cm).normalize(),V1.sub(Cm).normalize(),j1.sub(Cm).normalize();let l=N1.cross(V1).dot(j1),h=o;Math.abs(l)>.005||r&&r.some((c,d)=>d%2===1?!1:h>=r[d]&&h<r[d+1])?(a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(a.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],c=0;for(let d=0,u=0;d<e.length;d+=3,u++)e[d+2]===0&&(l.push(u),c++),e[d+2]===n&&h.push(u);if(i.userData.parameters.extrudeBevelSize===0){let d=h[0];h[0]=h[1],h[1]=d}l.reverse(),a.push(...l,...h),s.push(c,c)}return{indices:a,verticesPerFace:s}}var _o={};dz(_o,{calcBoolean:()=>v$,calcBooleanTopological:()=>g$,freeMeshSet:()=>w$,getMeshSet:()=>y$,hasOpenEdges:()=>x$,transformMeshSet:()=>b$});var RI,p$=new Promise(e=>{RI=e}),Tm;function f$(e){if(Tm)return Tm;async function t(){let i=e??"https://unpkg.com/@splinetool/boolean-wasm@1.12.56/build",r=import("./boolean.js"),[a,s]=await Promise.all([r,fetch(`${i}/boolean.wasm`).then(l=>l.arrayBuffer())]),n=a.default,o=await n({wasmBinary:s});RI(o)}return Tm=t(),Tm}var ni,md;p$.then(e=>ni=e);function m$(e,t,i){let r,a;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?a=e.getClosedTorusIndicesForBooleanOrSubdiv():a=e.getIndex();let{positions:s,triIndices:n}=Yv(e.getAttribute("position"),a),o;if(t&&i){let{indices:l,verticesPerFace:h}=OI(s,n,e);o=h.length,r=[];for(let c=0,d=0;c<o;c++){r.push(h[c]);for(let u=0;u<h[c];u++)r.push(l[d++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,c=0;c<r.length;)r[c++]=3,o++,r[c++]=n[h++],r[c++]=n[h++],r[c++]=n[h++]}return{positions:s,faceIndices:r,nFaces:o}}function LI(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,a=Number.isInteger(e[0])?i:r,s=ni._malloc(a);return(Number.isInteger(e[0])?new Uint32Array(ni.HEAPU32.buffer,s,t):new Float32Array(ni.HEAPF32.buffer,s,t)).set(e,0),s}function BI(e){switch(e){case 0:return ni.OP.UNION;case 1:return ni.OP.INTERSECTION;case 2:return ni.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+e)}}function g$(e,t){md===void 0&&(md=ni.init_csg());let i=LI(e),r=ni.csg_calc_topological(md,i,e.length,BI(t));ni._free(i);let a=6,s=ni.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(3,3+3),o=0,l=ni.HEAPU32[s[o]>>2],h=new Float32Array(ni.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=ni.HEAPU32[s[o]>>2],d=new Uint32Array(ni.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let u=ni.HEAPU32[s[o]>>2],p=new Uint8Array(ni.HEAPU32.subarray(u>>2,(u>>2)+n[o]));return ni.free_mesh_data(r),{positions:h,indices:d,verticesPerFace:p}}function v$(e,t,i,r){md===void 0&&(md=ni.init_csg());let a=LI(e),s=ni.csg_calc(md,a,e.length,r,BI(t));ni._free(a);let n=5,o=ni.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(2,2+3),h=0,c=ni.HEAPU32[o[h]>>2],d=ni.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=ni.HEAPU32[o[h]>>2],p=ni.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new nt(d,3)),i.setAttribute("normal",new nt(p,3));let m=ni.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new cs),i.boundingSphere.center.set(m[0],m[1],m[2]),i.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ni.free_mesh_data(s),f}function y$(e,t,i){if(ni===void 0)return-1;let r,a,s;if(t&&e.userData.positions!==void 0){let y=e.userData;s=y.verticesPerFace.length,r=y.positions,a=Array(y.verticesPerFace.reduce((x,b)=>x+b,0)+s);for(let x=0,b=0,_=0;x<y.verticesPerFace.length;x++){a[_++]=y.verticesPerFace[x];for(let S=0;S<y.verticesPerFace[x];S++)a[_++]=y.indices[b++]}}else({positions:r,faceIndices:a,nFaces:s}=m$(e,t,i));let n=r.length,o=a.length,l=r.length,h=a.length,c=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=ni._malloc(c),f=new Float32Array(ni.HEAPF32.buffer,p,l),m=new Uint32Array(ni.HEAPU32.buffer,p+d,h);f.set(r,0),m.set(a,0);let g=ni.get_csg_mesh(p,n,p+d,o,s);return ni._free(p),g}function x$(e){return ni.has_open_edges(e)}function b$(e,t){ni.transform_csg_mesh(e,t.elements)}function w$(e){ni.free_csg_mesh(e)}var _$={ConeGeometry:AZ,CubeGeometry:MZ,CylinderGeometry:oI,DodecahedronGeometry:CZ,EllipseGeometry:o_,HelixGeometry:hJ,IcosahedronGeometry:cJ,LatheGeometry:dJ,NonParametricGeometry:yJ,PolygonGeometry:AI,PyramidGeometry:xJ,RectangleGeometry:l_,SphereGeometry:_J,PlaneGeometry:SJ,BackdropGeometry:AJ,StarGeometry:MI,TextFrameGeometry:EJ,TorusGeometry:CJ,TorusKnotGeometry:PJ,TriangleGeometry:DJ,PathGeometry:a$,VectorGeometry:Kh},uC=e=>_$[e.type].create(e);function Bc(e){return e!==null&&"booleanOp"in e}var zI=class extends t_(Fi){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new je}updateVisible(e){super.updateVisible(e),this.visible=!Bc(this.parent)&&this.visible,Bc(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(_o.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Bc(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof zI&&(e.freeBooleanPointer(),Bc(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Bc(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Bc(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Pm=new wr;function h_(e,t=0,i=e.count,r,a){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let d=t;d<i;d++){let u=e.getX(d),p=e.getY(d),f=e.getZ(d);u<s&&(s=u),p<n&&(n=p),f<o&&(o=f),u>l&&(l=u),p>h&&(h=p),f>c&&(c=f)}Pm.min.set(s,n,o),Pm.max.set(l,h,c),Pm.getCenter(r),Pm.getSize(a).multiplyScalar(.5)}var S$=new vt,A$=new Vo,Sa=class extends zI{constructor(e,t){super(S$,A$),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?h_(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},xl=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},xl.uuidContext===null)throw new Error("plz startContext");xl.uuidContext===xl.globalContext?this.uuid="_gid"+xl.uuidContext.nodeContextUuid++:this.uuid="_uid"+xl.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===xl.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,a,s){return""}generate(e,t,i,r,a){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},Hr=xl;Hr.globalContext={nodeContextUuid:0},Hr.uuidContext=xl.globalContext;var pC=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},M$=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},$a=new M$,Oi=class extends Hr{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=tt.generateUUID()),i=e.getUUID(i??this.getUUID(),!a);let s=e.getNodeData(i),n=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,i)):super.build(e,t,i);if(a)return s.name=s.name||super.build(e,t,i),s.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||s.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,s.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,a){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),a,this.getLabel()).name}},as=class extends Oi{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,a,s){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,a,s):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,a,s,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,a,s,this.getLabel())),e.format(n.fragment.name,r,t))}},ga=class extends as{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof ae?e:new ae(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Ts=class extends as{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof O?e:new O(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},So=class extends as{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof qr?e:new qr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},E$=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,fC=/[a-z_0-9]+/gi,it=class extends Oi{constructor(e,t,i,r,a){super(a),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,a){let s,n=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;s=fC.exec(this.src);)l.push(s);for(let h=0;h<l.length;h++){let c=l[h],d=c[0],u=this.isMethod?!this.getInputByName(d):!0,p=d;if(this.keywords[d]||this.useKeywords&&u&&$a.containsKeyword(d)){let f=this.keywords[d];if(!f){let m=$a.getKeywordData(d);m.cache&&(f=e.keywords[d]),f=f||$a.getKeyword(d,e),m.cache&&(e.keywords[d]=f)}p=f.build(e)}d!==p&&o[c.index+n-1]!=="."&&(o=o.substring(0,c.index+n)+p+o.substring(c.index+d.length+n),n+=p.length-d.length),this.getIncludeByName(p)===void 0&&$a.contains(p)&&e.include($a.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let a=E$.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(fC);if(s){let n=0;for(;n<s.length;){let o=s[n++],l;o==="in"||o==="out"||o==="inout"?l=s[n++]:(l=o,o="");let h=s[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},C$=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,kI=class extends Oi{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||kI.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,a){this.src=e||"";let s,n,o="",l=C$.exec(e);this.useDefine=a??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],s=l[2],o=l[3]):(s=this.src,n="f"),this.name=s,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,a){return e.format(this.name,this.getType(e),t)}},wi=kI;wi.PI="PI",wi.PI2="PI2",wi.RECIPROCAL_PI="RECIPROCAL_PI",wi.RECIPROCAL_PI2="RECIPROCAL_PI2",wi.LOG2="LOG2",wi.EPSILON="EPSILON";var T$=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3193
3193
  )*?)}`,"gim"),P$=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),FI=class extends Oi{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=T$.exec(e);if(t){let i=t[2],r;for(;r=P$.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},c_=class extends Oi{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};$a.addKeyword("uv",function(){return new c_});$a.addKeyword("uv2",function(){return new c_(1)});var Zc=class extends Oi{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Zc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case on:return["Linear"];case Wt:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),a=Zc.Nodes[this.method],s=e.include(a);if(s===Zc.LINEAR_TO_LINEAR)return e.format(i,r,t);if(a.inputs?.length===2){let n=this.factor.build(e,"f");return e.format(s+"( "+i+", "+n+" )",r,t)}else return e.format(s+"( "+i+" )",r,t)}fromEncoding(e){let t=Zc.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Zc.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Un=Zc;Un.Nodes={LinearToLinear:new it(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3194
3194
  `)),sRGBToLinear:new it(["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(`
3195
3195
  `)),LinearTosRGB:new it(["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(`
@@ -5047,7 +5047,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5047
5047
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
5048
5048
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
5049
5049
  return displaced_position;
5050
- }`,[e,t])}}();var wt={normalRenderTarget:new Do,normalRenderTargetDepth:new Do,transmissionRenderTarget:new Do,aspectRatio:new ga,transmissionSize:new ga(2048,2048),transmissionRenderTargetDepth:new Do,aoRenderTarget:new Do,aoEnabled:new Ca,pixelRatioNode:new ht(1),resolution:new ga,penumbraSize:new mh(5,.5),frameIndex:new Li(0),transmissionLod:new Li(2),taaEnabled:new Ca(!0)};for(let e of Object.values(wt))e.isRenderGlobal=!0;var lO={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.54/build/ui.wasm"},p_=class extends Hr{constructor(){super("basic"),this.nodeType="Basic",this.color=new cr(us),this.shadingAlpha=new ht(1),this.shadingBlend=new Li(0),this.previousModelViewMatrix=new Yn,this.previouseProjectionMatrix=new Yn}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:wt.frameIndex}),e.mergeUniform({resolution:wt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Nd.merge([et.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
5050
+ }`,[e,t])}}();var wt={normalRenderTarget:new Do,normalRenderTargetDepth:new Do,transmissionRenderTarget:new Do,aspectRatio:new ga,transmissionSize:new ga(2048,2048),transmissionRenderTargetDepth:new Do,aoRenderTarget:new Do,aoEnabled:new Ca,pixelRatioNode:new ht(1),resolution:new ga,penumbraSize:new mh(5,.5),frameIndex:new Li(0),transmissionLod:new Li(2),taaEnabled:new Ca(!0)};for(let e of Object.values(wt))e.isRenderGlobal=!0;var lO={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.56/build/ui.wasm"},p_=class extends Hr{constructor(){super("basic"),this.nodeType="Basic",this.color=new cr(us),this.shadingAlpha=new ht(1),this.shadingBlend=new Li(0),this.previousModelViewMatrix=new Yn,this.previouseProjectionMatrix=new Yn}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:wt.frameIndex}),e.mergeUniform({resolution:wt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Nd.merge([et.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
5051
5051
  `));let r=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
5052
5052
  #include <skinbase_vertex>
5053
5053
  #include <skinnormal_vertex>
@@ -8139,7 +8139,7 @@ void main() {
8139
8139
  gVelocity = vec4(0.0); // so it is ignored by TAA
8140
8140
  }`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ae},viewport:{type:"v2",value:new ae},basisViewport:{type:"v2",value:new ae},debugColor:{type:"v3",value:new Ct},covariancesTextureSize:{type:"v2",value:new ae(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ae(1024,1024)},orthoZoom:{type:"f",value:-1}};return new di({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:Dh,depthTest:!0,depthWrite:!1,side:Pa})}static buildGeomtery(e){let t=new vt;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new Pt(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let a=new lP().copy(t),s=new Uint32Array(e),n=new Sp(s,1,!1);return n.setUsage(c5),a.setAttribute("splatIndex",n),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,i=0;for(let r of this.splatBuffers){let a=r.nsplats;this.colors.subarray(e,e+a*4).set(r.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(r.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(i,i+a*6).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new ae(4096,1024);for(;t.x*t.y*2<e*6;)t.y*=2;let i=new ae(4096,1024);for(;i.x*i.y*4<e*4;)i.y*=2;let r,a;if(this.halfPrecisionCovariancesOnGPU){a=new Uint16Array(t.x*t.y*2);for(let c=0;c<this.covariances.length;c++)a[c]=V8.toHalfFloat(this.covariances[c]);r=new ja(a,t.x,t.y,vg,No)}else a=new Float32Array(t.x*t.y*2),a.set(this.covariances),r=new ja(a,t.x,t.y,vg,Di);r.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=r,this.material.uniforms.covariancesTextureSize.value.copy(t);let s=new Uint32Array(i.x*i.y*4);for(let c=0;c<e;c++){let d=c*4,u=c*3,p=c*4;s[p]=Ase(this.colors[d],this.colors[d+1],this.colors[d+2],this.colors[d+3]),s[p+1]=fy(this.centers[u]),s[p+2]=fy(this.centers[u+1]),s[p+3]=fy(this.centers[u+2])}let n=new ja(s,i.x,i.y,A3,Oo);n.internalFormat="RGBA32UI",n.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=n,this.material.uniforms.centersColorsTextureSize.value.copy(i);let o=256*4,l=new Float32Array(256*16);for(let c=0;c<this.meshMatrixWorlds.length;c++)l.set(this.meshMatrixWorlds[c].elements,c*16);let h=new ja(l,o,1,Ki,Di);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:a,texture:r,size:t},centerColors:{data:s,texture:n,size:i},meshMatrixWorlds:{data:l,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(Wm.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Wm),this.material.uniforms.basisViewport.value.set(2/Wm.x,2/Wm.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}},WO,Mse=new Promise(e=>{WO=e}),CT=!1,qm;function Ese(){if(CT)return;if(qm)return qm;async function e(){let t=await Promise.resolve().then(()=>(aS(),rS));WO(t),CT=!0}return qm=e(),qm}var qO;Mse.then(e=>qO=e);var Cse=class{constructor(e={}){qu(this,"updateView",function(){let t=new je,i=[],r=new O(0,0,-1),a=new O(0,0,-1),s=new O,n=new O;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),c=this.cropsChanged();if(!o){a.set(0,0,-1).applyQuaternion(l.quaternion);let u=!1,p=!1;if(a.dot(r)<=.95&&(u=!0),n.copy(l.position).sub(s).length()>=1&&(p=!0),!u&&!p&&!h&&!c&&!this.needsInitialRender)return}this.needsInitialRender=!1,s.copy(l.position),r.copy(a),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...h?{newMatrixWorlds:this.meshMatrixWorlds}:{},...c?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}()),this.scene=e.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 je().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new ae;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new O().fromArray(e.position)),e.orientation&&(e.orientation=new Rt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(s=>{s.data.type==="Splat"&&t.push(s)}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(s=>s.matrixWorld),this.meshMatrixWorldsOld=t.map(s=>s.matrixWorld.clone()),this.cropsArray=t.map(s=>s.data.crops.map(n=>n.data));let i=t.map(s=>new qO.GSplineBuffer(new Uint8Array(s.data.buffer).buffer)),r=0,a=[0];for(let s of i)r+=s.getSplatCount(),a.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,a,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,t*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((r,a)=>{this.cropsArray[i][a]===void 0?(e=!0,this.cropsArray[i][a]=r.data):Object.entries(r.data).forEach(([s,n])=>{Array.isArray(n)&&n.some((o,l)=>o!==this.cropsArray[i][a][s][l])?(e=!0,this.cropsArray[i][a][s]=n):n!==this.cropsArray[i][a]?.[s]&&(e=!0,this.cropsArray[i][a][s]=n)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new O,r=new Rt,a=!1,s=1,n,o){this.splatMesh=pg.buildMesh(e,t,a,s,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(l,h,c)=>this.update(l,c)}setupSortWorker(e){this.sortWorker=Sse(e),this.sortWorker.onmessage=t=>{t.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){this.splatMesh!==null&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}},Lb=new Vo;Lb.wireframe=!0;var TT=new O,I_=class extends is{constructor(e,t){super(),this.data=e,this.sharedAssets=t,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new bse,this.invisibleObjects=new yd("jflkdsafjasdifjaslk",{...Bx.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new ia("fdasfa",{...Od.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=gse(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=mse(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof ia&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let a=r;r=r.parent;let s=r.children.indexOf(a);i.splice(0,0,s)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>nD(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Zd)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof ia&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof ia&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&i instanceof Ta&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof ia&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(t=>{t.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(t=>{t.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(this),r.resetBBoxNeedsUpdate(),zn(r)&&zo(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");i.traverseEntity(a=>{a instanceof Wh&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),zo(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),zn(i)&&(i.freeBooleanPointer(),r instanceof Gh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof e0&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(i),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),zn(i)&&(i.invalidateUpstreamBooleanData(),zo(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Gh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof ia&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{ose(a,t,i,{scene:this,shared:r}),a instanceof Xi&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,i,r,a,s=[]){e.updateEntityByOp(t,i,r,a),this.traverseEntity(n=>{(n instanceof Ta||n instanceof ia)&&(s.includes(n.frameId??"")||n.frameId===t)&&n.updateEntity2DByOp(t,i,r,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,a)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{r instanceof Xr&&r.updateUp()}),this.doPendingExpandCloner({scene:this,shared:t}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){oi.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{oi.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,a,s,n){if(e){let o=r.find(e);o&&o!==r&&a.forInstancesRec(l=>{l.data=Rp(l.data,h=>{let c=h.events.data(n.id),d=l.goUp(s);if(d){let u=[...sD(d.identity),e].join("-"),p=this.entityIdentityToEntity[u];if(p){let f=p.uuid,m=Gr.zoom(c,t);m[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,a,s){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,a,s):n.data.type==="Animation"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,a,s):n.data.type==="Conditional"&&(this.rewriteActions(n.data.ifActions,[...t,n.id,"ifActions"],i,r,a,s),this.rewriteActions(n.data.elseActions,[...t,n.id,"elseActions"],i,r,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof xd&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=Rp(s.data,n=>{s.isInstanceRoot||(n.events.delete(r.id),a=!0)}).data}),a===!1)for(let s of tv.list)this.rewriteActions(r.data.gameActions[s],["gameActions",s],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(a=>{if(a instanceof xd&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||a.resetBBoxNeedsUpdate(),i&&a.traverseEntity(s=>{i.addClip(s)}),!0});for(let a of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),P_(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof xd&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)oi.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=a=>{for(let s of a.children){let n=s.cloner;if(oi.is(s)&&!s.raycastLock&&(s.visible||n?.object.data.visible))if(t===!0&&s.isInstanceRoot){let o=[];if(e.intersectObject(s,!0,o),o.length){let l=o[0];l.object=s,l.point.applyMatrix4(l.object.matrixWorld);let h=s.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(zn(s)||_b(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,i),Rb(s,e,i)),r(s)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let a of r.children){let s=a.cloner;oi.is(a)&&(a.visible||s?.object.data.visible)&&((zn(a)||_b(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Rb(a,e,t,!0)),i(a))}};return i(this),t}forEachEntity(e){for(let t of this.children)oi.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)oi.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)oi.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof Xi&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===e){let r=i.geometry,a=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(a,t);let s=i.invalidateDownstreamBooleanData();zo(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)jh.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)oi.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,a,s){let n={scene:this,shared:s},o=D_(e,t,n);return o instanceof Wh&&this.shapeBlendIntances.push(o),o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(a,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,s)),o.updateState(t,n),o instanceof Xi&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{let h=l.dataPatched;if(l instanceof Xi&&h.bones&&h.boneInverses){let c=h.bones.map(p=>this.find(p)),d=h.boneInverses.map(p=>new je().fromArray(p)),u=new $b(c,d);l.bind(u,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,a=e.length;r<a;++r){let{id:s,recursive:n}=e[r],o=this.find(s),l=n?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new wr;return i.setFromPoints(t),i.getCenter(TT),TT}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Sa)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof Wo&&e(t.material[i]);else t.material instanceof Wo&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Xr&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new Cse({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}},fg=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},Tse=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Dse(Math.atan2(r,i))},Pse=(e,t,i)=>{let r={x:0,y:0};return i=Bb(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Bb=e=>e*(Math.PI/180),Dse=e=>e*(180/Math.PI),Ise=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,Xm=new Map,Ose=e=>{Xm.has(e)&&clearTimeout(Xm.get(e)),Xm.set(e,setTimeout(function(){Xm.delete(e),e()},100))},bv=(e,t,i)=>{let r=t.split(/[ ,]+/g),a;for(let s=0;s<r.length;s+=1)a=r[s],e.addEventListener?e.addEventListener(a,i,!1):e.attachEvent&&e.attachEvent(a,i)},wv=(e,t,i)=>{let r=t.split(/[ ,]+/g),a;for(let s=0;s<r.length;s+=1)a=r[s],e.removeEventListener?e.removeEventListener(a,i):e.detachEvent&&e.detachEvent(a,i)},XO=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),PT=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},zb=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},O_=(e,t,i)=>{let r=YO(e);for(let a in r)if(r.hasOwnProperty(a))if(typeof t=="string")r[a]=t+" "+i;else{let s="";for(let n=0,o=t.length;n<o;n+=1)s+=t[n]+" "+i+", ";r[a]=s.slice(0,-2)}return r},Rse=(e,t)=>{let i=YO(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},YO=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},my=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},Lse=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},kb=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},Bse=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(QO="ontouchstart"in window,KO=!!window.PointerEvent,ZO=!!window.MSPointerEvent);var QO,KO,ZO,Fu={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"}},nd,Hp={};KO?nd=Fu.pointer:ZO?nd=Fu.MSPointer:QO?(nd=Fu.touch,Hp=Fu.mouse):nd=Fu.mouse;function Zh(){}Zh.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),a;i._handlers_=i._handlers_||{};for(var s=0;s<r.length;s+=1)a=r[s],i._handlers_[a]=i._handlers_[a]||[],i._handlers_[a].push(t);return i};Zh.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};Zh.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),a;i._handlers_=i._handlers_||{};for(var s=0;s<r.length;s+=1)a=r[s],i._handlers_[a]&&i._handlers_[a].length&&i._handlers_[a].forEach(function(n){n.call(i,{type:a,target:i},t)})};Zh.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=Lse(t.options,e))};Zh.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},bv(e,nd[t],i._domHandlers_[t]),Hp[t]&&bv(e,Hp[t],i._domHandlers_[t]),i};Zh.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},wv(e,nd[t],i._domHandlers_[t]),Hp[t]&&wv(e,Hp[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var R_=Zh;function Kr(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Kr.id,Kr.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}Kr.prototype=new R_;Kr.constructor=Kr;Kr.id=0;Kr.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Kr.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=Rse("borderRadius","50%"),i=O_("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},my(r.el,i),this.options.shape==="circle"&&my(r.back,t),my(r.front,t),this.applyStyles(r),this};Kr.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};Kr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Kr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Kr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null};Kr.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};Kr.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};Kr.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",a={};a.front=O_("transition",["top","left"],r);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(a),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};Kr.prototype.restCallback=function(){var e=this,t={};t.front=O_("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};Kr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Kr.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,a,s,n;if(t>i&&t<i*3&&!e.lockX?a="up":t>-i&&t<=i&&!e.lockY?a="left":t>-i*3&&t<=-i&&!e.lockX?a="down":e.lockY||(a="right"),e.lockY||(t>-r&&t<r?s="left":s="right"),e.lockX||(t>0?n="up":n="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:s,y:n,angle:a},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+s,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+a,e)}else this.resetDirection();return e};var zse=Kr;function _r(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=_r.id,_r.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}_r.prototype=new R_;_r.constructor=_r;_r.id=0;_r.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,a=t.length;r<a;r+=1)if(t[r].identifier===i)return t[r];return!1}};_r.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};_r.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};_r.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,a={},s=i.options,n={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)a={x:e.x-n.x,y:e.y-n.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",s.zone.appendChild(o);var l=o.getBoundingClientRect();s.zone.removeChild(o),a=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new zse(i,{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:e,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(zb(h.ui.el,a),zb(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};_r.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};_r.prototype.bindNipple=function(e){var t=this,i,r=function(a,s){i=a.type+" "+s.id+":"+a.type,t.trigger(i,s)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};_r.prototype.pressureFn=function(e,t,i){var r=this,a=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var s=e.force||e.pressure||e.webkitForce||0;s!==a&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),a=s)}.bind(r),100)};_r.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=XO(e),t.updateBox();var a=function(s){t.actives.length<i.maxNumberOfNipples?t.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(l){return l.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(s))};return kb(e,a),t.manager.bindDocument(),!1};_r.prototype.processOnStart=function(e){var t=this,i=t.options,r,a=t.manager.getIdentifier(e),s=e.force||e.pressure||e.webkitForce||0,n={x:e.pageX,y:e.pageY},o=t.getOrCreate(a,n);o.identifier!==a&&t.manager.removeIdentifier(o.identifier),o.identifier=a;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(e,c,c.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=fg(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};_r.prototype.getOrCreate=function(e,t){var i=this,r=i.options,a;return/(semi|static)/.test(r.mode)?(a=i.idles[0],a?(i.idles.splice(0,1),a):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(a=i.createNipple(t,e),a)};_r.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),a=t.nipples.get(r),s=t.manager.scroll;if(!Ise(e)){this.processOnEnd(e);return}if(!a){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var n=a.el.getBoundingClientRect();a.position={x:s.x+n.left,y:s.y+n.top}}a.identifier=r;var o=a.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=a.position.y),i.lockY&&(l.x=a.position.x);var h=fg(l,a.position),c=Tse(l,a.position),d=Bb(c),u=h/o,p={distance:h,position:l},f,m;if(a.options.shape==="circle"?(f=Math.min(h,o),m=Pse(a.position,f,c)):(m=Bse(l,a.position,o),f=fg(m,a.position)),i.follow){if(h>o){let b=l.x-m.x,_=l.y-m.y;a.position.x+=b,a.position.y+=_,a.el.style.top=a.position.y-(t.box.top+s.y)+"px",a.el.style.left=a.position.x-(t.box.left+s.x)+"px",h=fg(l,a.position)}}else l=m,h=f;var g=l.x-a.position.x,y=l.y-a.position.y;a.frontPosition={x:g,y},i.dataOnly||zb(a.ui.front,a.frontPosition);var x={identifier:a.identifier,position:l,force:u,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:d,degree:c},vector:{x:g/o,y:-y/o},raw:p,instance:a,lockX:i.lockX,lockY:i.lockY};x=a.computeDirection(x),x.angle={radian:Bb(180-c),degree:180-c},a.trigger("move",x),t.trigger("move "+a.id+":move",x)};_r.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),a=t.nipples.get(r),s=t.manager.removeIdentifier(a.identifier);!a||(i.dataOnly||a.hide(function(){i.mode==="dynamic"&&(a.trigger("removed",a),t.trigger("removed "+a.id+":removed",a),t.manager.trigger("removed "+a.id+":removed",a),a.destroy())}),clearInterval(t.pressureIntervals[a.identifier]),a.resetDirection(),a.trigger("end",a),t.trigger("end "+a.id+":end",a),t.ids.indexOf(a.identifier)>=0&&t.ids.splice(t.ids.indexOf(a.identifier),1),t.actives.indexOf(a)>=0&&t.actives.splice(t.actives.indexOf(a),1),/(semi|static)/.test(i.mode)?t.idles.push(a):t.nipples.indexOf(a)>=0&&t.nipples.splice(t.nipples.indexOf(a),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[s.id]=s.identifier))};_r.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};_r.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off(),e.pressureIntervals={},e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.manager=null};var kse=_r;function Rr(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=PT(),t._windowBound=!1,t.config(e),t.prepareCollections();var i=function(){var r;t.collections.forEach(function(a){a.forEach(function(s){r=s.el.getBoundingClientRect(),s.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){Ose(i)},t._onScroll=function(){t.scroll=PT()},t.collections}Rr.prototype=new R_;Rr.constructor=Rr;Rr.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};Rr.prototype.create=function(e){return this.createCollection(e)};Rr.prototype.bindWindowEvents=function(){var e=this;e._windowBound||typeof window>"u"||(e._windowBound=!0,bv(window,"resize",e._onResize),bv(window,"scroll",e._onScroll))};Rr.prototype.unbindWindowEvents=function(){var e=this;!e._windowBound||typeof window>"u"||(e._windowBound=!1,wv(window,"resize",e._onResize),wv(window,"scroll",e._onScroll))};Rr.prototype.createCollection=function(e){var t=this,i=new kse(t,e);return t.bindCollection(i),t.collections.push(i),t.bindWindowEvents(),i};Rr.prototype.bindCollection=function(e){var t=this,i,r=function(a,s){i=a.type+" "+s.id+":"+a.type,t.trigger(i,s)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};Rr.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};Rr.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Rr.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};Rr.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};Rr.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};Rr.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};Rr.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};Rr.prototype.onAny=function(e,t){var i=this,r,a="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=XO(t);var s=function(o,l,h){h.ids.indexOf(l)>=0&&(h[a](o),o._found_=!0)},n=function(o){r=i.getIdentifier(o),kb(i.collections,s.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return kb(t,n),!1};Rr.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.unbindWindowEvents(),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.collections=[],e.off()};Rr.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1),i.collections.length===0&&i.unbindWindowEvents()};var Fse=Rr,bd=null;function DT(){return bd||(bd=new Fse),bd}var Use={create:function(e){return DT().create(e)},destroy:function(){bd&&(bd.destroy(),bd=null)},get factory(){return DT()}},Nse=Use,JO=new Map,yp=new Map,Th=class{constructor(e,t,i,r){this.data=t;let{audio:a,volume:s,delay:n,loop:o}=t;if(!a)throw new Error("Missing property");try{let l=typeof a=="string"?r.getAudio(a).src:a.data;this.audioPlayer=new ip({src:l,volume:s,delay:n,loop:o})}catch{console.warn(`Could not create an audio player for this object: "${i.name}" and this audio: "${a}"`)}yp.has(i.uuid)?yp.get(i.uuid).push(this):yp.set(i.uuid,[this]),JO.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},Fb=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=JO.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=yp.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let e=[...yp.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},$O=class{constructor(e,t,i,r,a){if(this.data=t,this.shared=r,this.condition=a,t.interaction==="play")this.interaction=new Th(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Fb(t);else throw new Error("Missing property")}dispatchBasic(){if(Hi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Th?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Hi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Th?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(e){if(Hi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Th&&(e==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}},e4=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.delay=0,this.emission=e.emission,e.delay!==void 0&&(this.delay=e.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(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},e);return}this.particleSystem.start()}stop(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},e);return}this.particleSystem.stop()}freeze(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},e);return}this.particleSystem.froze()}unFreeze(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},e);return}this.particleSystem.unFroze()}reset(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},e);return}this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(Hi(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(Hi(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(e){if(Hi(this.shared,this.condition)===!1||!this.particleSystem)return!1;e==="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)}},Vse="text/plain",jse="us-ascii",IT=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),Hse=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:a,hash:s}=i.groups,n=r.split(";");s=t?"":s;let o=!1;n[n.length-1]==="base64"&&(n.pop(),o=!0);let l=(n.shift()||"").toLowerCase(),h=[...n.map(c=>{let[d,u=""]=c.split("=").map(p=>p.trim());return d==="charset"&&(u=u.toLowerCase(),u===jse)?"":`${d}${u?`=${u}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==Vse)&&h.unshift(l),`data:${h.join(";")},${o?a.trim():a}${s?`#${s}`:""}`};function Gse(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return Hse(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let s=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,n=0,o="";for(;;){let h=s.exec(r.pathname);if(!h)break;let c=h[0],d=h.index,u=r.pathname.slice(n,d);o+=u.replace(/\/{2,}/g,"/"),o+=c,n=d+c.length}let l=r.pathname.slice(n,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let s=r.pathname.split("/"),n=s[s.length-1];IT(n,t.removeDirectoryIndex)&&(s=s.slice(0,-1),r.pathname=s.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let s of[...r.searchParams.keys()])IT(s,t.removeQueryParameters)&&r.searchParams.delete(s);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let a=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!a.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var Wse=class{constructor({url:e,context:t},i,r,a){if(this.controlsManager=i,this.shared=r,this.condition=a,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:Gse(e,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=t??"tab"}dispatch(){if(Hi(this.shared,this.condition)===!1)return!1;Qd?window.location.assign(this.url):(this.context==="tab"||aD&&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(Ot[0]),eY())}},t4=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=a,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=s=>{this.timeoutIdQueue.shift();let n=this.page.scene.find(s);if(n===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=o?n.dataPatched.physics?.fusedBody:!0;if(n.cloner){for(let h of n.cloner.children)l?(h.playModeVisible=!1,h.rigidBody&&n.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,h.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0)):h.playModeVisible===void 0&&(h.playModeVisible=!0);(l||this.clone===void 0||this.clone===!1)&&(n.visible=!1,n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0))}else n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0),n.visible=!1;o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),n.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...e.objects]}dispatch(e){if(Hi(this.shared,this.condition)===!1)return!1;this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(Hi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},i4=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.shared=i,this.eventManager=r,this.condition=a,this.shared=i}dispatch(){if(Hi(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),L_(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};function qse(e,t,i,r){let a=[],s=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let o=s??e.zoom,l=n;o!==l&&a.push({update:h=>{e.zoom=tt.lerp(o,l,h),e.updateProjectionMatrix()},start:()=>{e.zoom=o,e.updateProjectionMatrix()},end:()=>{e.zoom=l,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let o=va("targetOffset",e,t,i,r);o&&a.push(o)}return a}function Xse(e,t,i,r){if(i.scaleBaked===void 0)return;let a=(t.scaleBaked??e.data.geometry.scaleBaked).map(o=>typeof o=="string"?Number(r.shared.getVariable(o)??0):o),s=i.scaleBaked.map(o=>typeof o=="string"?Number(r.shared.getVariable(o)??0):o);if(Ul.isEqual(a,s))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[tt.lerp(a[0],s[0],o),tt.lerp(a[1],s[1],o),tt.lerp(a[2],s[2],o)]},r.shared),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions(r)},start:()=>{e.updateGeometryInteractions({scaleBaked:a},r.shared),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions(r)},end:()=>{e.updateGeometryInteractions({scaleBaked:s},r.shared),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions(r)}}),n}function Yse(e,t,i,r){if(!i.extrusion)return;let a=e.extrusion,s=t.extrusion??{},n=i.extrusion,o=[];return Vw.forEach(l=>{let h=Kl(l,a,s,n,r);h&&o.push(h)}),o}function Qse(e,t,i,r){let a=[];if(!("geometry"in i))return a;let s=e.geometry.userData.parameters,n="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof jp){let l=Xse(e,n,o,r);l&&a.push(...l)}else{let l={};if(Object.assign(l,Vn(s,b1),Vn(n,b1)),b1.forEach(h=>{let c=Kl(h,l,n,o,r.shared);c&&a.push(c)}),e instanceof e0){Object.assign(l,{extrusion:{...s.extrusion}});let h=Yse(l,n,o,r.shared);h&&a.push(...h)}a.length&&a.push({update:h=>{e.updateGeometryInteractions(l,r.shared),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions(r)},start:h=>{e.updateGeometryInteractions(l,r.shared),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions(r)},end:h=>{e.updateGeometryInteractions(l,r.shared),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions(r)}})}return a}function Kse(e,t,i,r){let a=e.geometry.userData.parameters.extrusion;if(a)return Vw.forEach(s=>{Al(s,a,t,i,r)}),a}function Zse(e,t,i,r){let a=e.updatedPathSnapping;if(a)return qY.forEach(s=>{Al(s,a,t,i,r)}),a}function Jse(e,t,i,r){let a=[];if(i.intensity!==void 0){let s=va("intensity",e,t,i,r);s&&a.push(s)}if(i.color!==void 0){let s=yK("color",e,t,i,r);s&&a.push(s)}return a}function $se(e,t,i,r){let a=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return a;let s="materials"in t&&t.materials?t.materials:[],n=i.materials;e.material.forEach((o,l)=>{if(!n[l])return;let h=s[l]??{},c=n[l];typeof h=="string"||typeof c=="string"||a.push(...OT(o,h,c,r))})}else{if(!("material"in i&&i.material))return a;let s="material"in t&&t.material?t.material:{},n=i.material;if(typeof s=="string"||typeof n=="string")return a;a.push(...OT(e.material,s,n,r))}return a}function OT(e,t,i,r){let a=[],s=sd(i,r)||!!t.layers&&sd(t,r);a.push(ene(e,s));for(let n of e.layers){let o=t.layers?.data(n.uuid),l=i.layers.data(n.uuid);if(!l||n.type!=="light"&&(!(n.visible??!0)||!(l.visible??!0)))continue;let h=n.getNames().filter(c=>!LD.some(d=>c.includes(d)));for(let c of h)try{let d=n.getValue(c),u;if(c==="colors")u=h4(n,o,l,c);else if(Array.isArray(d))c==="steps"&&(u=l4(n,o,l,c));else if(typeof d=="number")u=r4(n,o,l,c,r);else{if(typeof d=="boolean")continue;d instanceof ae?u=a4(n,o,l,c):d instanceof O?u=s4(n,o,l,c,r):d instanceof qr?u=o4(n,o,l,c,r):d instanceof Ct?u=n4(n,o,l,c,r):"isTexture"in d&&(u=c4(n,o,l,c))}u&&(Array.isArray(u)?a.push(...u):a.push(u))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${c}`,d)}}return a}function r4(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:e.getValue(r),n=i[r],o=typeof s=="string"?Number(a.getVariable(s)??0):s,l=typeof n=="string"?Number(a.getVariable(n)??0):n;if(o!==l)return{update:h=>{e.setValue(r,tt.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function a4(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let a=e.getValue(r),s=t?new ae().fromArray(t[r]):a.clone(),n=new ae().fromArray(i[r]);if(!s.equals(n))return{update:o=>{a.lerpVectors(s,n,o)},start:()=>{a.copy(s)},end:()=>{a.copy(n)}}}function s4(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?t[r]:void 0,o=i[r],l=n?ov(new O,n,a):s.clone(),h=ov(new O,o,a);if(!l.equals(h))return{update:c=>{s.lerpVectors(l,h,c)},start:()=>{s.copy(l)},end:()=>{s.copy(h)}}}function n4(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=s?typeof s=="string"?a.getColor(s).clone():new Ct().setRGB(s.r,s.g,s.b):o.clone(),h=typeof n=="string"?a.getColor(n).clone():new Ct().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:d=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,d)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function o4(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=s?typeof s=="string"?a.color(s).clone():new Ct().setRGB(s.r,s.g,s.b):o.clone(),h=typeof n=="string"?a.getColor(n).clone():new qr(n.r,n.g,n.b,n.a);if(l.equals(h))return;let c=o.clone();return{update:d=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,d)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function l4(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let a=[],s=e.getValue(r),n=t?t[r]:s,o=i[r];return Mw(n,o)||a.push({update:l=>{let h=[...s];for(let c=0;c<s.length;++c){let d=n[c],u=o[c];h[c]=tt.lerp(d,u,l)}e.setValue(r,h)},start:()=>{e.setValue(r,n)},end:()=>{e.setValue(r,o)}}),a.length?a:void 0}function h4(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let a=[],s=e.getValue(r),n=t?t[r]:s.map(l=>l.toArray()),o=i[r];for(let l=0;l<s.length;++l){let h=[...n[l]],c=[...o[l]];Lp.isEqual(h,c)||a.push({update:d=>{s[l].fromArray(Lp.lerp(h,c,d))},start:()=>{s[l].fromArray(h)},end:()=>{s[l].fromArray(c)}})}return a.length?a:void 0}function c4(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let a=e.getNode("rotation"),s=t?.[r]?.rotation??0,n=i[r]?.rotation??0;if(a&&s!==n)return{update:g=>{a.value=tt.lerp(s,n,g)*tt.DEG2RAD},start:()=>{a.value=s*tt.DEG2RAD},end:()=>{a.value=n*tt.DEG2RAD}};let o=e.getNode("mat");if(!o)return;let l=t?t[r]:o,h=i[r],c=[...l.repeat],d=[...l.offset],u=[...h.repeat],p=[...h.offset],f=l.rotation??0,m=h.rotation??0;if(!kn.isEqual(c,u)||!kn.isEqual(d,p)||f!==m)return{update:g=>{o.repeat=kn.lerp(c,u,g),o.offset=kn.lerp(d,p,g),o.rotation=tt.lerp(f,m,g),o.updateMatrix()},start:()=>{o.repeat=[...c],o.offset=[...d],o.rotation=f,o.updateMatrix()},end:()=>{o.repeat=[...u],o.offset=[...p],o.rotation=m,o.updateMatrix()}}}function RT(e,t,i,r,a,s,n){if(e==="colors")h4(t,i,r,e)?.forEach(o=>o.update(a));else if(Array.isArray(s))e==="steps"&&l4(t,i,r,e)?.forEach(o=>o.update(a));else if(typeof s=="number")r4(t,i,r,e,n)?.update(a);else{if(typeof s=="boolean")return;s instanceof ae?a4(t,i,r,e)?.update(a):s instanceof O?s4(t,i,r,e,n)?.update(a):s instanceof qr&&n?o4(t,i,r,e,n)?.update(a):s instanceof Ct&&n?n4(t,i,r,e,n)?.update(a):"isTexture"in s&&c4(t,i,r,e)?.update(a)}}function ene(e,t){return{update:()=>{e.transparent=t}}}var gy=new O,LT=new xr;function tne(e,t,i,r,a){let s=[],n,o,l,h,c,d,u,p;if(e instanceof la?(n=lv("position",e,t,i,a),n&&s.push(n),l=va("rotation",e,t,i,a),l&&s.push(l),h=lv("shear",e,t,i,a),h&&s.push(h)):(p={slide:t.pathSnapping?.slide??e.updatedPathSnapping?.slide??e.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??e.updatedPathSnapping?.offset??e.dataPatched.pathSnapping?.offset??0},d=va("slide",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,a),d&&s.push(d),u=va("offset",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,a),u&&s.push(u),!d&&!u&&(n=PE("position",e,t,i,a),n&&s.push(n),o=PE("scale",e,t,i,a),o&&s.push(o),l=ine(e,t,i,r,a),l&&s.push(l),c=vK("hiddenMatrix",e,t,i),c&&s.push(c))),n||o||l||c||d||u){let f=e instanceof la?()=>{e.updateWorldMatrix(!0,!1,!0),e.resetBBoxNeedsUpdate()}:()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),zn(e)&&zo(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,p))};s.push({update:f,start:f,end:f})}return s}function ine(e,t,i,r,a){let s=t?.rotation?t.rotation.map(c=>(typeof c=="string"?Number(a.getVariable(c)??0):c)*tt.DEG2RAD):void 0,n=i.rotation?.map(c=>(typeof c=="string"?Number(a.getVariable(c)??0):c)*tt.DEG2RAD);if(!n)return;let o=s?new O().fromArray(s):new O().setFromEuler(e.rotation),l=new O().fromArray(n);if(o.equals(l))return;let h=gy.subVectors(l,o);if(r&&h.toArray().every(c=>Math.abs(c)<2*Math.PI)){let c=new Rt().setFromEuler(LT.setFromVector3(o)),d=new Rt().setFromEuler(LT.setFromVector3(l));return{update:u=>{gK(c,d,e.quaternion,u)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:c=>{gy.lerpVectors(o,l,c),e.rotation.setFromVector3(gy)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function rne(e,t){return{update:()=>{e instanceof ra&&(e.fill.enabled=t)}}}function ane(e,t){return{update:()=>{e instanceof ra&&(e.stroke.enabled=t)}}}function sne(e,t){return{update:()=>{e instanceof ra&&(e.dropShadow.enabled=t)}}}function nne(e,t){return{update:()=>{e instanceof ra&&(e.innerShadow.enabled=t)}}}function one(e,t){return{update:()=>{e instanceof ra&&(e.backgroundBlur.enabled=t)}}}function lne(e,t){return{update:()=>{e instanceof ra&&(e.layerBlur.enabled=t)}}}function hne(e,t,i,r,a){let s=[],n,o,l,h,c,d,u,p,f,m,g,y,x,b,_;if("width"in e&&(n=va("width",e,t,i,a),n&&s.push(n)),"height"in e&&(o=va("height",e,t,i,a),o&&s.push(o)),e instanceof ra||e instanceof Hn){let S={...t.fill},A={...i.fill};S.enabled!==void 0&&S.enabled!==A.enabled&&(s.push(rne(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),l=hm("color",e.fill,S,A,a),l&&s.push(l)}if(e instanceof ra){let S={...t.stroke},A={...i.stroke};(S.enabled||A.enabled)&&(s.push(ane(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),h=hm("color",e.stroke,S,A,a),h&&s.push(h),c=va("thickness",e.stroke,S,A,a),c&&s.push(c)}if(e instanceof ra){let S={...t.dropShadow},A={...i.dropShadow};(S.enabled||A.enabled)&&(s.push(sne(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),d=hm("color",e.dropShadow,S,A,a),d&&s.push(d),u=va("blurRadius",e.dropShadow,S,A,a),u&&s.push(u),f=va("spread",e.dropShadow,S,A,a),f&&s.push(f),p=lv("offset",e.dropShadow,S,A,a),p&&s.push(p)}if(e instanceof ra){let S={...t.innerShadow},A={...i.innerShadow};(S.enabled||A.enabled)&&(s.push(nne(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),m=hm("color",e.innerShadow,S,A,a),m&&s.push(m),g=va("blurRadius",e.innerShadow,S,A,a),g&&s.push(g),x=va("spread",e.innerShadow,S,A,a),x&&s.push(x),y=lv("offset",e.innerShadow,S,A,a),y&&s.push(y)}if(e instanceof ra||e instanceof Hn){let S={...t.backgroundBlur},A={...i.backgroundBlur};(S.enabled||A.enabled)&&(s.push(one(e,!0)),S.enabled||Object.assign(S,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),b=va("radius",e.backgroundBlur,S,A,a),b&&s.push(b)}if(e instanceof ra){let S={...t.layerBlur},A={...i.layerBlur};(S.enabled||A.enabled)&&(s.push(lne(e,!0)),S.enabled||Object.assign(S,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),_=va("radius",e.layerBlur,S,A,a),_&&s.push(_)}if(e instanceof Hn||e instanceof sf){let S=Zw("cornerRadius",e,t,i,a);S&&s.push(S)}return s}function BT(e,t,i,r,a){let s=[];return e.data.visible&&s.push(...tne(e,t,i,a,r.shared)),e instanceof la?s.push(...hne(e,t,i,a,r.shared)):(e.data.visible&&s.push(...xK(e,t,i,r)),e instanceof Sa?(e instanceof Xi&&e.data.visible&&s.push(...Qse(e,t,i,r)),e.data.visible&&s.push(...$se(e,t,i,r.shared))):gv.is(e)?e.data.visible&&s.push(...Jse(e,t,i,r.shared)):e instanceof Xr&&s.push(...qse(e,t,i,r.shared))),s.length?{update:n=>{s.forEach(o=>o.update(n))},start:n=>{s.forEach(o=>o.start?.(n))},end:n=>{s.forEach(o=>o.end?.(n))}}:void 0}function cne(e,t){return{position(i){Object.assign(e.position,i),(i.x!==void 0||i.y!==void 0||i.z!==void 0)&&(e.updateMatrix(),e.resetBBoxNeedsUpdate(),e instanceof Xi&&e.invalidateDownstreamBooleanData(),e.dispatchEvent({type:"requestRender"}))},rotation(i){let r=Object.keys(i)[0];e.rotation[r]=i[r]*tt.DEG2RAD,(i.x!==void 0||i.y!==void 0||i.z!==void 0)&&(e.updateMatrix(),e.resetBBoxNeedsUpdate(),e instanceof Xi&&e.invalidateDownstreamBooleanData(),e.dispatchEvent({type:"requestRender"}))},scale(i){Object.assign(e.scale,i),(i.x!==void 0||i.y!==void 0||i.z!==void 0)&&(e.updateMatrix(),e.resetBBoxNeedsUpdate(),e instanceof Xi&&e.invalidateDownstreamBooleanData(),e.dispatchEvent({type:"requestRender"}))},shapeSize(i){e instanceof Xi&&(e.userData.value={...e.userData.value,...i},(i.x!==void 0||i.y!==void 0||i.z!==void 0)&&(e.updateGeometryInteractions({width:e.userData.value.x,height:e.userData.value.y,depth:e.userData.value.z},t.shared),e.resetBBoxNeedsUpdate(),e.invalidateDownstreamBooleanData(),e.dispatchEvent({type:"requestRender"})))},material(i,r,a){a&&(Object.entries(a).forEach(([s,{start:n,end:o,t:l}])=>{let h=r.getValue(s);h!==void 0&&RT(s,r,n,o,l,h,t.shared)}),e.dispatchEvent({type:"requestRender"}))},opacity(i){if(e instanceof Sa&&!Array.isArray(e.material)){let r=e.material.getLayersOfType("light")[0];e.material.transparent=!0,RT("alphaOverride",r,{alphaOverride:i},{alphaOverride:i+1},0,i,t.shared),e.dispatchEvent({type:"requestRender"})}},light(i,r){(e instanceof Zv||e instanceof C_||e instanceof Jv)&&(e[i]=r,e.dispatchEvent({type:"requestRender"}))},cloner(i){i.cloner?.update(t),i instanceof Xi&&i.invalidateDownstreamBooleanData(),i.dispatchEvent({type:"requestRender"})},pathExtrusion(i,r){i.geometry.userData.parameters.extrusion={...i.geometry.userData.parameters.extrusion,...r},i.updateGeometryInteractions({extrusion:{...i.geometry.userData.parameters.extrusion}},t.shared),i.resetBBoxNeedsUpdate(),i.invalidateDownstreamBooleanData(),i.dispatchEvent({type:"requestRender"})},pathSnapping(i){e.userData.pathSnapping={...e.userData.pathSnapping,...i},e.updatePathSnapping(e.userData.pathSnapping),e.dispatchEvent({type:"requestRender"})}}}var zT=new O;function L_(e,t,i=!1){let r=[],a=s=>{let n=s.data;delete s.states,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let o of n.states){let l={...o.data};s.states||(s.states={}),s.states[o.id]=Eh.patch(n,l)}FT(e.scene,s,null,t,n.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),kT(e)};e.scene.traverse2D(a),e.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(zT,!0),s.rigidBody?.setAngvel(zT,!0)),!oi.is(s))return;let n=s.uuid,o=s.data;if(delete s.states,s.uuid===Zd)return;let l=!1;r.some(h=>e.scene.find(n)?.isDescendantOf(h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&r.push(n),s.data=o,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let h of o.states){let c={...h.data};e.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0&&delete c.position,h.data.rotation!==void 0&&delete c.rotation,h.data.hiddenMatrix!==void 0&&delete c.hiddenMatrix),s.states||(s.states={}),s.states[h.id]=Il.patch(o,c)}FT(e.scene,s,null,t,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0),s instanceof Ta&&s.frame&&(s.frame.traverse(h=>a(h)),s.uiCanvas?.applySize())}),kT(e),e.frame&&(e.frame.traverse(s=>a(s)),e.uiCanvas?.applySize())}function kT(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let a of Object.values(i.data.gameActions))r.push(...a);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let a of r)if(a.data.type==="Create"&&a.data.hideBase==="Yes"){let s=e.scene.find(a.data.object);s&&(s.visible=!1)}}})}function FT(e,t,i,r,a=!1){if(t instanceof Xi&&!(t instanceof Wh)&&t.removeInteractionGeometry(r),t instanceof la?t.changeSelectedState(i,{shared:r},a):t.changeSelectedState(i,{scene:e,shared:r},a),t instanceof Xi&&t.updateGeometryGroupsIfNeeded(),t instanceof Xr&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),!(t instanceof la)){if(t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}}function d4(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
8141
8141
  ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
8142
- )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:a,velocity:s}=e;t=`spring( ${i}, ${r}, ${a}, ${s} )`}else{let i;switch(e.easing){case 0:i=yl.linear;break;case 1:i=yl.ease;break;case 2:i=yl.easeIn;break;case 3:i=yl.easeOut;break;case 4:i=yl.easeInOut;break;default:i=yl.linear}let[r,a,s,n]=i;t=`cubicBezier( ${r}, ${a}, ${s}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function _v(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var u4={type:"beginState"},p4={type:"completeState",isfromEntity:!1},Ub=class{constructor(e,t,i,r,a,s,n){if(this.object=e,this.data=r,this.sharedAssets=a,this.allowSlerp=s,this.page=n,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 o=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=o,this.object.dispatchEvent({type:"beginState",state:o}),this.object instanceof la||this.object.traverseEntity(l=>{l!==this.object&&l instanceof Xr&&l.dispatchEvent(u4)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let o=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=o,this.object.dispatchEvent({type:"completeState",state:o}),this.object instanceof la||this.object.traverseEntity(l=>{l!==this.object&&l instanceof Xr&&l.dispatchEvent(p4)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=BT(this.object,this.from.data,this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp))},t===void 0){let o=mg(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!o)throw new Error("Missing property");this.from=o}else{let o=mg(this.object,t);if(!o)throw new Error("Missing property");this.from=o}if(i===void 0)throw new Error("Missing property");{let o=mg(this.object,i);if(!o)throw new Error("Missing property");this.to=o}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,..._v(r),...d4(r),change:this.onChange},this.callback=BT(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Nb=class extends ha{constructor(e,t,i,r,a){if(super(),this.eventType=e,this.data=t,this.page=i,this.shared=r,this.condition=a,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.hasPlayedOnce=!1,this.pauseOnNextLoopEnd=!1,this.onTimelineChangeComplete=()=>{if(this.pauseOnNextLoopEnd){this.pauseOnNextLoopEnd=!1,this.timeline?.pause();return}this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!t.object)throw new Error("Missing property");let s=this.page.scene.find(t.object)??this.page.uiCanvas?.find(t.object)??this.page.scene.find2DInUIObjects(t.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,t.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=t.tweens[0].data.delayDirection==="start-once"?t.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=mg(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&px(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=_v(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=Uo.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let a=this.tweens.findIndex(s=>s?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let s=a===-1?0:a;for(let n=s;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Xr&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new Ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1,this.page);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.delay:0))}this.timeline.duration+=r.endDelay}else{let s=a===-1?this.data.tweens.length-1:a+1;for(let n=s;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Xr&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new Ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1,this.page);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n-1]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Hi(this.shared,this.condition)===!1||px(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;this.startTimeout?.pause();let e=_v(this.data.tweens[0].data).pingPongDelayCorrection;this.startTimeout=Uo({targets:{},duration:this.startOnceDelay+e,easing:"linear",complete:()=>{this.startTimeout=void 0;try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}}})}pause(){this.timeline?.pause(),this.startTimeout?.pause(),this.tweens=Array(this.data.tweens.length-1),delete this.startTimeout}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof la?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(Hi(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(Hi(this.shared,this.condition)===!1)return!1;this.startTimeout?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.pauseOnNextLoopEnd=!0,this.timeline.play()):this.startTimeout=Uo({targets:{},duration:this.startOnceDelay,easing:"linear",complete:()=>{this.startTimeout=void 0,this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()}})}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function mg(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var dne={type:"beginState"},UT={type:"completeState",isfromEntity:!1},NT={type:"requestRender"},f4=class extends ha{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.posStart=new O,this.posEnd=new O,this.qStart=new Rt,this.qEnd=new Rt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=Uo({targets:i,t:1,...d4(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(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(dne));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(NT),i.t===1&&r.dispatchEvent(UT)}})}switchCamera(e){let t=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),t.dispatchEvent({type:"cameraChange",camera:i})}play(){if(Hi(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(Hi(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(UT),this.page.activeCamera.dispatchEvent(NT))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},m4=class extends ha{constructor(e,t,i,r,a){super(),this.id=e,this.data=t,this.scene=i,this.sharedAssets=r,this.eventType=a,this.toggleIsForward=!1,this._finished=!1,this.hasPlayedOnce=!1,this._shouldForwardLoop=!1,this._shouldPauseOnNextLoopComplete=!1,this._onLoopComplete=()=>{this._shouldPauseOnNextLoopComplete&&(this.timeline.pause(),this._shouldPauseOnNextLoopComplete=!1)};try{let s=_v(this.data);typeof s.loop=="number"&&s.loop--,this.timeline=Uo.timeline({...s,autoplay:!1}),this._shouldForwardLoop=s.loop===!0||typeof s.loop=="number"&&s.loop>1;let n=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.entries(n).forEach(([o,l])=>{let h=this.scene.find(o);if(!h)return;let c=h.data.timelineAnimations[l];if(!c)return;let d=eb.addKeyframesToTimeline(h,{...c},cne(h,{scene:i,shared:r}),this.sharedAssets),u=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay:0)+(this.data.delayDirection==="start-once"?this.data.delay:0);d.forEach(p=>{this.timeline.add(p,u)}),this.timeline.duration=c.to*1e3+u}),this.timeline.delay=0,this.timeline.duration+=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="end"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay*2:0)+(this.data.delayDirection==="start-once"?this.data.delay*2:0),this.timeline.finished.then(()=>{Object.keys(n).forEach(o=>{let l=this.scene.find(o);l instanceof Xr&&l.dispatchEvent(p4)}),this._finished=!0}),this.timeline.loopComplete=this._onLoopComplete}catch{throw new Error("Missing property")}}get playing(){return this.timeline.paused===!1}get finished(){return this._finished}get paused(){return this.timeline.paused}play(){if(this.eventType!==void 0&&px(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0;let e=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.keys(e).forEach(t=>{let i=this.scene.find(t);i instanceof Xr&&i.dispatchEvent(u4)}),this.timeline.restart()}pause(){this.timeline.pause()}stop(){this.pause(),this.seek(0),this.timeline.reset(),this._finished=!1}seek(e){this.timeline.seek(e*this.timeline.duration,!0)}toggle(e){if(this.toggleIsForward=e??!this.toggleIsForward,this.playing){if(!this.toggleIsForward&&this.timeline.reversed&&this._shouldForwardLoop&&this.timeline.remaining%2===1){this._shouldPauseOnNextLoopComplete=!0;return}this.timeline.reverse(this.timeline.duration-this.timeline.currentTime),this._shouldForwardLoop&&this.timeline.loop&&this.timeline.reversed&&(this._shouldPauseOnNextLoopComplete=!0)}else(!this.toggleIsForward!==this.timeline.reversed||!this.toggleIsForward&&this.timeline.reversed&&this.timeline.direction==="alternate")&&this.timeline.reverse(),typeof this.timeline.loop=="number"&&typeof this.timeline.remaining=="number"&&this.timeline.remaining<this.timeline.loop&&this.toggleIsForward&&(this.timeline.remaining=this.timeline.loop),this.timeline.play()}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function g4(e){let t=e?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(t?.length){let i=bX(t);return i&&i>2?i:2}return 2}var v4=class extends ha{constructor(e,t,i,r,a){super(),this.data=e,this.page=t,this.animationControls=i,this.shared=r,this.condition=a,this.startOnceDelay=0,this.toggleIsForward=!1;let s=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(s=n.identity[0]),this.data={...e,object:s};let o=this.animationControls.clipIdToAction[e.clipId+"/"+s];if(this.duration=o?.getClip()?.duration??1,this.data.crop2){let l=g4(o?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=o?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Hi(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let a=i.split("/")[1];this.threeAnimAction!==r&&a===t&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=tt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(Hi(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,a])=>{let s=r.split("/")[1];this.threeAnimAction!==a&&s===i&&a.isRunning()&&(t?a.fadeOut(.2):a.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},y4=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=a,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(Hi(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target||t.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{t.type==="ParticleSystem"&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),L_(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},x4=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Hi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=TI(this.data.expression,this.shared,ba.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},b4=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(Hi(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}},une=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Hi(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 t=this.shared.data.variables.data(e)?.value;t!==void 0&&this.shared.updateVariable(e,t),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(bb(e))})}dispose(){}},pne=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Hi(this.shared,this.condition)===!1)return!1;if(this.data.userAPIId){let e=this.shared.getUserAPI(this.data.userAPIId);e&&"callUserAPI"in e&&e.callUserAPI(this.shared)}}dispose(){}};function Hi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=TI(t.expression,e,"boolean");return t.negate?!i:!!i}function Lr(e,t,i,r,a,s){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},o=l=>({id:h,data:c})=>{try{c.type==="Audio"?ua[e.type].includes("Audio")&&n.Audio.push(new $O(h,c,s,r,l)):c.type==="Video"&&!(s instanceof la)?ua[e.type].includes("Video")&&n.Video.push(new _4(h,c,s,r,l)):c.type==="Particles"?ua[e.type].includes("Particles")&&n.Particles.push(new e4(c,i,r,l)):c.type==="Link"?ua[e.type].includes("Link")&&n.Link.push(new Wse(c,a.controlsManager,r,l)):c.type==="Create"?ua[e.type].includes("Create")&&n.Create.push(new S4(c,i,a.controlsManager,r,l)):c.type==="Destroy"?ua[e.type].includes("Destroy")&&n.Destroy.push(new t4(c,i,a.controlsManager,r,l)):c.type==="Reset"?ua[e.type].includes("Reset")&&n.Reset.push(new i4(c,i,r,a,l)):c.type==="Transition"?ua[e.type].includes("Transition")&&n.Transition.push(new Nb(e.type,c,i,r,l)):c.type==="SwitchCamera"?ua[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new f4(c,i,r,l)):c.type==="SceneTransition"?ua[e.type].includes("SceneTransition")&&n.SceneTransition.push(new y4(c,i,a,r,l)):c.type==="Animation"?ua[e.type].includes("Animation")&&n.Animation.push(new v4(c,i,a.animationControls,r,l)):c.type==="SetVariable"?ua[e.type].includes("SetVariable")&&n.SetVariable.push(new x4(c,i,r,l)):c.type==="DynamicVariablePlay"?ua[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new b4(c,i,r,l)):c.type==="Conditional"?ua[e.type].includes("Conditional")&&(c.ifActions.forEach(o({expression:c.condition,negate:!1})),c.elseActions.forEach(o({expression:c.condition,negate:!0}))):c.type==="ClearLocalStorage"?ua[e.type].includes("ClearLocalStorage")&&n.ClearLocalStorage.push(new une(c,i,r,l)):c.type==="UserAPI"?ua[e.type].includes("UserAPI")&&n.UserAPI.push(new pne(c,i,r,l)):c.type==="TimelineAnimation"&&ua[e.type].includes("TimelineAnimation")&&n.TimelineAnimation.push(new m4(h,c,i.scene,r,e.type))}catch{}};return t.forEach(o()),n}function oa(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof $O||i instanceof _4||i instanceof Nb||i instanceof m4||i instanceof e4||i instanceof v4||i instanceof Nb||i instanceof S4||i instanceof t4||i instanceof f4||i instanceof y4||i instanceof i4||i instanceof x4||i instanceof b4)&&i.dispose()})})}function fne(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(a=>a.uuid===t):i=e.material.layers.find(a=>a.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var w4=new Map,xp=new Map,Bl=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:a,volume:s,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=fne(i,r);o&&(this.videoElement=o,this.videoElement.loop=a===1/0,Qd&&(this.videoElement.autoplay=!0),s!==void 0&&(this.videoElement.volume=s)),n!==void 0&&(this.delay=n),xp.has(i.uuid)?xp.get(i.uuid).push(this):xp.set(i.uuid,[this]),w4.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(e){return new Promise(t=>{if(!this.videoElement)return t();let i=this.videoElement.duration;if(i>0){let r=e%i;this.videoElement.currentTime=r}this.videoElement.addEventListener("seeked",()=>t(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Vb=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=w4.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=xp.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...xp.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},_4=class{constructor(e,t,i,r,a){if(this.data=t,this.shared=r,this.condition=a,t.interaction==="play")this.interaction=new Bl(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Vb(t);else throw new Error("Missing property")}dispatchBasic(){if(Hi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Bl?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Hi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Bl?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},vy=(()=>{let e,t,i,r,a=!1;function s(h){!e&&!VT()&&(t?.sharedGameControlGlobals.createdObjects.length??0)>0&&(e=requestAnimationFrame(n)),h&&(t=h,r=h.requestRender,!a&&typeof document<"u"&&(document.addEventListener("visibilitychange",o),a=!0))}function n(h){if(!t||!r){e=void 0,i=void 0;return}let c=i?h-i:0,d=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,p=d.length,f=0;for(;f<p;){let m=d[f];m.userData.createdTime===void 0&&(m.userData.createdTime=h),m.userData.lifetime===void 0&&m.userData.quantity===void 0||m.userData.lifetime&&h-m.userData.createdTime<m.userData.lifetime||m.userData.quantity&&u[m.userData.actionId]<=m.userData.quantity?(m.userData.velocity&&(m.position.addScaledVector(m.userData.velocity,c/1e3),m.updateMatrix(),r()),f++):(u[m.userData.actionId]>m.userData.quantity&&u[m.userData.actionId]--,d.splice(f,1),m.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&m.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(m.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(m.rigidBody)):(m.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(g=>g.bvhGeometry!==void 0)),p--,r())}e=f>0?requestAnimationFrame(n):void 0,i=f>0?h:void 0}function o(){VT()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}function l(){e&&(cancelAnimationFrame(e),e=void 0),a&&typeof document<"u"&&(document.removeEventListener("visibilitychange",o),a=!1),t=void 0,r=void 0,i=void 0}return{play:s,dispose:l}})();function VT(){return!!document&&document.hidden}var jT=new Rt,mne=new O,gne=new O,S4=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=a,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=tt.generateUUID(),this.dispatch=()=>{if(Hi(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(Hi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=FX(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new wa(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.scale.copy(this.object.scale),n.position.fromArray(this.data.position.map(l=>typeof l=="number"?l:0)),n.rotation.fromArray(this.data.rotation.map(l=>typeof l=="number"?l:0)),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),vy.play(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Ls)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof wa)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Ls)return;n instanceof wa?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new O().fromArray(this.data.velocity.map(c=>typeof c=="number"?c:0)),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(mne,jT,gne),l.applyQuaternion(jT),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let s=this.page.scene.find(this.data.object);if(!s)throw new Error("Missing Property");if(this.object=s,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");vy.play(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],vy.dispose()}},A4=200,yy=.02,xy=.3,vne=65,HT=new O,GT=new O,yne=new O,ka=new O,Ya=new O,fl=new O,by=new je,WT=new je,xne=new je,Ks=new Rt,mo=new Rt,An=new xr(0,0,0,"YXZ"),bne=new O(1,0,0),Zs=new O(0,1,0),wne=new O(0,0,1),qT=new O(1,1,1),_ne=1,Sne=.025,Ane=16e-6,XT=12,Mne=20,ea=new zs,Es=new wr,Ene={type:"requestRender"},Cne={type:"updateMatrix"},YT=Math.PI/6,jb=class extends ha{constructor(e,t,i,r,a,s,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=a,this.cameraFollow=s,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new je,this.target0=new O,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=A4,this.euler0=new xr(0,0,0,"YXZ"),this.position0Cam=new O,this.quat0Cam=new Rt,this.scale0Cam=new O,this.hiddenMatrix0Cam=new je,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new zs(new O(0,-40,0),new O(0,40,0)),matrix:new je,position:new O,rotation:new Rt},this.euler=new xr(0,0,0,"YXZ"),this.eulerDelta=new O,this.lastPosition=new O,this.lastCameraQuaternion=new Rt,this.lastCameraPosition=new O,this.PI_2=Math.PI/2,this.prevMouse=new ae,this.velocityTarget=new O,this.velocity=new O,this.directionXZ=new O,this.rotVelocityStick=new O,this.rotVelocityTarget=new O,this.rotVelocity=new O,this.rotDirection=new O,this.nonColliderRotOffset=new je,this.nonColliderPosOffset=new je,this.firstPointerId=-1,this.rot=new O,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 je,this.objectToTarget=new O,this.objectToTarget0=new O,this.objectToCamXZ=new O,this.objectToCamXZ0=new O,this.targetToCamera=new O,this.targetToCamera0=new O,this.cameraPolarAxis0=new O,this.targetPos=new O,this.targetQuat=new Rt,this.lerpFactorPos=new O().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Rt,this.objXZQuatInv=new Rt,this.objXZRotMat=new je,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new O,this.pushedVelocity=new O,this.groundYRotation=0,this.objectRealQuat=new Rt,this.colliderWorldQuat=new Rt,this.groundNormal=new O,this.groundTilt=new Rt,this.groundTiltInv=new Rt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new O,this.quaternion=new Rt,this.scale=new O,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!hs&&!wM&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(wM&&JX<15.5&&!hs?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?jb.isLocked=!0:jb.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let y=f.axes[g];m===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(y)>=.3&&(this.vrEulerYOffset+=y<0?1:-1),this.movementState.rotPosY=y):this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),c=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,c,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new O(0,0,-1).applyQuaternion(this.camera.quaternion),m=new O().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,y;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,y=m.projectOnVector(f)):m.y/f.y>0?y=f.multiplyScalar(m.y/f.y):y=f.multiplyScalar(m.length()),this.targetToCamera0.copy(y).negate(),g=this.camera.position.clone().add(y),this.objectToTarget0.subVectors(g,this.position);let x=new xr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-x.x,x.x=0,x.z=0,x.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(x)}if(this.object instanceof Xr&&(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)*_ne,this.speedOrbit=(i.speedRotate??100)*Sne,this.mouseOrbitSensitivity=(i.speedRotate??100)*Ane,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Dd.defaultData.gravity)*XT,this.usePhysics=this.gloabalPhysics.usePhysics??Dd.defaultData.usePhysics,this.jumpPower=i.jumpPower*Mne,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??iv.defaultDataThirdPerson.orientWith,this.slopeThresh=vne*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*yy/this.pixelsPerMeter,this.stepThresh=i.collider.height*xy/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*yy/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*xy/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*yy/this.pixelsPerMeter,this.stepThresh=i.collider.height*xy/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new O().fromArray(i.collider.position.map(f=>typeof f=="number"?f:0)),u=new Rt().setFromEuler(new xr().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(u),this.collider.matrix.compose(d,u,qT),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new pt;f.push({fi:0,data:{...yr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...yr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new m_({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Fi(oI.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new xr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Xr?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},tv.list.forEach(i=>{this.actions[i]=Lr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),oa(this.actions.idle),oa(this.actions.move),oa(this.actions.run),oa(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(t=>{t.play()}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(t=>{t.stop()}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return ka.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let a=r*60,s=!1;if(this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let o=Ya.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*XT),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(s=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(c.rigidBody===h&&c.userData.isFollowingObj!==this.object.uuid){(c.hasNonUniformScale?c.matrixWorldRigid:c.matrixWorld).decompose(ka,mo,Ya),this.groundVelocity.subVectors(ka,c.prevT),this.object.getWorldPosition(Ya).add(this.collider.position).sub(ka),this.groundYRotation=An.setFromQuaternion(mo).y-c.prevR.y,fl.copy(Ya).applyAxisAngle(Zs,this.groundYRotation),this.groundVelocity.add(fl.sub(Ya)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*a),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=ka.subVectors(this.path[1],this.position),h=Ya.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**a),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**a),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**a)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=yne.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Ya.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let o=ka;this.camera.getWorldDirection(o);let l=fl.copy(Zs).multiplyScalar(o.dot(Zs));o.sub(l);let h=Ya.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(An.setFromVector3(this.rot),this.moveMode==="walk"&&(An.x=0),n.applyEuler(An),s&&(mo.setFromUnitVectors(Zs,this.groundNormal),n.applyQuaternion(mo)),i){let o=An.set(0,this.vrEulerYOffset*YT,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0&&this.object.rigidBody){let o=Ya;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=fl.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),c=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),ka.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let d=oi.is(l)?l:l.object;if(c!==null&&this.lastHitObj!==d){let u;l instanceof wa&&(u=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[d.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(u),d.dispatchEvent(Gb));this.lastHitObj=d}if(c!==null){this.pushedVelocity.copy(h),o.copy(c.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**a):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**a),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Zs,this.euler.y-this.euler0.y);let o=Ya.copy(this.objectToCamXZ).normalize(),l=fl.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(ka.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=tt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=tt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=tt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(An.copy(t),An.y=0):(An.copy(this.euler),An.y=0),this.nonColliderRotOffset.makeRotationFromEuler(An)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*YT),Ks.setFromAxisAngle(bne,this.rot.x),mo.setFromAxisAngle(Zs,this.rot.y),mo.multiply(Ks),Ks.setFromAxisAngle(wne,this.rot.z),mo.multiply(Ks),this.quaternion.copy(mo),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let o=Ya.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new O;for(let c=0;c<5;c++){let d=o.length(),u=fl.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,u,this.object.rigidBody.collider(0).shape,d,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&c===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let x of y)if(x.data.target==="character"){let b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,_;if(p.cloner){for(let S of p.cloner.children)if(S.rigidBody===b){_=S;break}}x.dispatch(_),p.dispatchEvent(Gb)}}}let f=HT.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=GT.copy(u).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(u,g)),o.copy(u).multiplyScalar(d-g),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=fl.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);x.y=0;let b=y.add(x);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{c===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(ka.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Ks.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);by.lookAt(l,o,Zs).setPosition(l),by.decompose(this.targetPos,this.targetQuat,ka),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**a),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**a),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=tt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=tt.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(Cne),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(Ene),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ks.setFromAxisAngle(Zs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?tt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=tt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=tt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=ka.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=mo.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Zs.angleTo(e)*180/Math.PI<15||Zs.angleTo(e)*180/Math.PI>85?Ks.identity():Ks.setFromUnitVectors(Zs,e),this.groundTilt.slerp(Ks,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=GT.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=by.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(ka,Ks,Ya).compose(ka,Ks,qT);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Es.makeEmpty(),a.updateMatrixWorldSVD();let s=a.matrixWorldRigid,n=WT.copy(s).invert(),o=xne.copy(WT).multiply(i);ea.copy(this.collider.segment),ea.start.applyMatrix4(o),ea.end.applyMatrix4(o);let l=HT.copy(this.position).applyMatrix4(n);Es.expandByPoint(ea.start),Es.expandByPoint(ea.end),Es.min.addScalar(-this.collider.radius),Es.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(ea.end)},intersectsBounds:h=>h.intersectsBox(Es),intersectsTriangle:h=>{let c=ka,d=Ya,u=h.closestPointToSegment(ea,c,d);if(u<this.collider.radius){let p=this.collider.radius-u,f=d.sub(c).normalize(),m=fl.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),ea.start.addScaledVector(f,p),ea.end.addScaledVector(f,p)}}})}),Es.makeEmpty(),ea.copy(this.collider.segment),ea.start.applyMatrix4(i),ea.end.applyMatrix4(i),Es.expandByPoint(ea.start),Es.expandByPoint(ea.end),Es.min.addScalar(-this.collider.radius),Es.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(a){return a.distanceToPoint(ea.end)},intersectsBounds:a=>a.intersectsBox(Es),intersectsTriangle:a=>{let s=ka,n=Ya,o=a.closestPointToSegment(ea,s,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),ea.start.addScaledVector(h,l),ea.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},M4=jb;M4.isLocked=!1;var Tne=Xl(v3());function E4(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,a=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,n=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||a<l||s<l||n<l||o<l}function Eo(e,t){let i=new vt;if(t&&E4(t))return i.setAttribute("position",new nt([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new nt([],3)),i.setIndex([]),i;let{positions:r,triIndices:a}=Yv(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new nt(r,3)),i.setIndex(a),t&&i.applyMatrix4(t),i}var Pne=new je,Dne=new je,Mn=[[0,0,0],[0,0,0],[0,0,0]];function C4(e){let t=e.elements;Mn[0][0]=t[0],Mn[0][1]=t[4],Mn[0][2]=t[8],Mn[1][0]=t[1],Mn[1][1]=t[5],Mn[1][2]=t[9],Mn[2][0]=t[2],Mn[2][1]=t[6],Mn[2][2]=t[10];let{u:i,v:r}=(0,Tne.SVD)(Mn),a=Pne.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),s=Dne.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 a.multiply(s.transpose())}var Ine=class extends cP{constructor(){super(),this.layers.enable(3),this.layers.enable(8),this.layers.enable(9)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new Ql({color:65280,linewidth:10}),t=new O(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new O(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,a=new O().addVectors(t,i.multiplyScalar(r)),s=new vt;return s.setFromPoints([t,a]),new Sg(s,e)}},T4=e=>e instanceof yd||e instanceof xd;function One(e,t){return e.distance-t.distance}function P4(e,t,i){if(!(!Mo(t)||!t.visible)){zn(t)&&t.raycast(e,i);for(let r of t.children)P4(e,r,i)}}function gg(e,t,i,r=!1){if(!r&&!i.some(s=>Sv(e,s)!==void 0))return[];let a=[];return t.children.forEach(s=>P4(e,s,a)),a.sort(One),a}function Hb(e){let t=[];if(e.length){let i=e[0].object;Mo(i)&&t.push(i);let r=i.parent;for(;r;)T4(r)&&t.push(r),r=r.parent}return t}function Co(e,t,i,r){let a=e.frame;if(a){let s=t[0]*a.width,n=(1-t[1])*a.height;for(let o of i){let l=o===a.uuid?a:a.find(o);if(l?.intersects(s,n))return r(l),!0}}return!1}function Sv(e,t){if(zn(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(T4(t))return D4(e,t)}function D4(e,t){if(!(!Mo(t)||!t.visible)){if(zn(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=D4(e,i);if(r)return r}}}function Rne(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}function Lne(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var Bne=class{constructor(e,t,i,r,a,s,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=a,this.requestRender=s,this.isExport=n,this.frame=o,this.raycaster=new Ine,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.pointerWorld=Rne(t,i,this._domRect),this.pointerScreen=Lne(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}dispose(){this.scene=void 0,this.sharedAssets=void 0,this.publish=void 0,this.getCamera=void 0,this.requestRender=void 0,this.frame=void 0,this.isExport=void 0}},Ia=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}dispose(){this.disconnect(),this.eventContext=void 0}},B_=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],I4=e=>B_.find(([t,i])=>i===e)?.[0],nf=e=>B_.find(([t])=>t===e)?.[1],zne=(e,t)=>{let i=I4(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},kne=class extends Ia{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let t=this.splineEvents[I4(e.eventName)]?.[e.target.uuid];if(!t)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(t,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(t)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(t=>{if(t.data?.events.length){for(let[i,r]of B_)if(t.data.events.some(a=>a.data.type===r&&!a.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(t):this.objectsPerEvents.set(i,[t]);let a={id:t.uuid,name:t.name},s=zne(r,a),n=this.splineEvents[i];n?n[t.uuid]=s:this.splineEvents[i]={[t.uuid]:s}}}}),this.objectsPerEvents.forEach(t=>{t.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Fne=class{constructor(e,t,i,r,a,s){if(this.id=e,this.data=t,this.object=i,this.entered=!1,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Lr(t,t.actions,r,a,s,i)}disconnect(){oa(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.SwitchCamera.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,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.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},Une=class extends Ia{constructor(e,t,i){super(e),this.eventManager=t,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=r=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(r);let{raycaster:a,page:s}=this.eventContext,n=gg(a,s,[],!0);this.sceneInterects=n,n.length&&(this.eventContext.sharedAssets.raycastProperty={x:n[0].point.x,y:n[0].point.y,z:n[0].point.z,objX:n[0].object.matrixWorld.elements[12],objY:n[0].object.matrixWorld.elements[13],objZ:n[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(a=>{(a.data.type==="MouseDown"||a.data.type==="MousePress")&&(this.onCanvasRaycast(r),a.dispatch())})},this.onCanvasMouseUp=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(a=>{a.data.type==="MouseUp"?(this.onCanvasRaycast(r),a.dispatch()):a.data.type==="MousePress"&&a.dispatchRelease()})},this.onMouseDown=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseDown"))},this.onMouseUp=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent())},this.onMousePressRelease=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent(!0))},this.onKeyDown=r=>{this.heldKeys[r.key]||(this.handleKeyEvent(r,"KeyDown"),this.handleKeyEventHeld(r,"KeyDown",!0)),this.heldKeys[r.key]=!0},this.onKeyUp=r=>{this.handleKeyEvent(r,"KeyUp"),this.handleKeyEventHeld(r,"KeyUp",!0)},this.onKeyPressDown=r=>{this.heldKeysPress[r.key]?this.handleKeyEventHeld(r,"KeyPress"):(this.handleKeyEvent(r,"KeyPress"),this.handleKeyEventHeld(r,"KeyPress",!0)),this.heldKeysPress[r.key]=!0},this.onKeyPressUp=r=>{this.handleKeyEvent(r,"KeyPress",!0)},this.releaseHeldKey=r=>{delete this.heldKeys[r.key]},this.releaseHeldKeyPress=r=>{delete this.heldKeysPress[r.key]},this._onUserEvent=({eventName:r,target:a,reverse:s})=>{if(!r||!a)return;let n=nf(r);n&&(n==="MouseDown"||n==="MouseUp"||n==="MousePress"?(a.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[a.uuid]?.forEach(o=>{o.dispatchUserEvent(s)}),this.canvasMouseEvents.forEach(o=>{o.dispatchUserEvent(s)})):(n==="KeyDown"||n==="KeyUp"||n==="KeyPress")&&(a.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[a.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext,r=(a,s)=>{if(!a.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];if(a.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:c})=>{try{let d=new Fne(h,c,a,e,t,this.eventManager);d.actions.Video.length&&(this.hasVideoAction=!0),(c.type==="MouseDown"||c.type==="MouseUp"||c.type==="MousePress")&&(c.mode==="Canvas"||c.mode==="Window")?this.canvasMouseEvents.push(d):(l[a.uuid]?l[a.uuid].some(u=>u.id===d.id)||l[a.uuid].push(d):l[a.uuid]=[d],a instanceof Wh&&a.traverseChildren(u=>{if(!u.visible)return!0;u instanceof Xi&&"shapeBlendNode"in u.data.geometry&&u.data.geometry.shapeBlendNode?.operation!==2&&(l[u.uuid]?l[u.uuid].push(d):l[u.uuid]=[d])}))}catch{}}),l[a.uuid]?.length&&(this.objectsPerTypes[o].push(a instanceof la&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress")?s:a),a instanceof Wh)){let h=this.objectsPerTypes[o];a.traverseChildren(c=>{if(!c.visible)return!0;c instanceof Xi&&h.indexOf(c)===-1&&h.push(c)})}}};e.traverseEntity(a=>{(a instanceof Ta||a instanceof ia)&&a.frame?.traverse(s=>{r(s,a)}),r(a)}),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(([a,s])=>{s.forEach(n=>{n.addEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(a=>{a.object.addEventListener("userEvent",this._onUserEvent)})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(t=>{t.object.removeEventListener("userEvent",this._onUserEvent)})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r,pointerScreen:a}=this.eventContext,s=this.objectsPerTypes[e],n=s.filter(o=>!(o instanceof la));if(!(!s.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&Co(r,[a.x,a.y],Object.keys(this.eventsPerObjects[e]),o=>{this.handleObjectMouseEventDispatch(o,e)}))){if(t||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=gg(i,r,n,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),t){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];Hb(o).forEach(h=>{h instanceof Ta&&Co(h,l,Object.keys(this.eventsPerObjects[e]),c=>{this.handleObjectMouseEventDispatch(c,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=Sv(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof Ta&&Co(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(s=>!(s instanceof la)),a=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=Co(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),c=>{a.push(c)})),s&&!h){let c=gg(n,o,r);a=Hb(c),c.forEach(d=>{d.object instanceof Ta&&Co(d.object,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),u=>{a.push(u)})})}else r.forEach(c=>{let d=Sv(n,c);d&&(a.push(c),c instanceof Ta&&Co(c,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),u=>{a.push(u)}))})}this._prevObjects.length&&this._prevObjects.forEach(s=>{a.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),a.length&&a.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=a}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let a=this.eventsPerObjects[t][r.uuid];a.some(({data:s})=>"key"in s&&s.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),a.forEach(s=>{"key"in s.data&&s.data.key===e.key&&(i?s.dispatchRelease():s.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}},Nne=new O,Vne=new O,O4=class{constructor(e,t,i,r,a){this.actionsIn=Lr(e,e.inActions,i,r,a,t),this.actionsOut=Lr(e,e.outActions,i,r,a,t)}disconnect(){oa(this.actionsIn),oa(this.actionsOut)}},jne=class extends O4{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let u of this.objects)if(!u.visible)return;let h=Nne.setFromMatrixPosition(this.objects[0].matrixWorld),c=Vne.setFromMatrixPosition(this.objects[1].matrixWorld),d=h.distanceTo(c)<=this.distance?"in":"out";if(this.stage!==d){this.stage=d;let u=d==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Particles.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Link.forEach(p=>p.dispatch()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.Animation.forEach(p=>p.play()),u.TimelineAnimation.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),u.SceneTransition.forEach(p=>p.dispatch()),u.SetVariable.forEach(p=>p.checkConditions()),u.SetVariable.forEach(p=>p.dispatch()),u.DynamicVariablePlay.forEach(p=>p.dispatch()),u.ClearLocalStorage.forEach(p=>p.dispatch()),u.UserAPI.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let c=r.find(h);if(!c)throw new Error("Missing property");this.objects.push(c)}}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)})}},Hne=class extends O4{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(c=>c.dispatchConditional()),this.actionsOut.Particles.forEach(c=>c.dispatchConditional()),this.actionsOut.Video.forEach(c=>c.dispatchConditional()),this.actionsOut.Link.forEach(c=>c.dispatch()),this.actionsOut.Create.forEach(c=>c.dispatch()),this.actionsOut.Destroy.forEach(c=>c.dispatch()),this.actionsOut.Reset.forEach(c=>c.dispatch()),this.actionsIn.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(c=>c.play()),this.actionsOut.Animation.forEach(c=>c.play()),this.actionsOut.TimelineAnimation.forEach(c=>c.play()),this.actionsIn.SwitchCamera.forEach(c=>c.pause()),this.actionsOut.SwitchCamera.forEach(c=>c.play()),this.actionsOut.SceneTransition.forEach(c=>c.dispatch()),this.actionsOut.SetVariable.forEach(c=>c.checkConditions()),this.actionsOut.SetVariable.forEach(c=>c.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(c=>c.dispatchConditional()),this.actionsIn.Particles.forEach(c=>c.dispatchConditional()),this.actionsIn.Video.forEach(c=>c.dispatchConditional()),this.actionsIn.Link.forEach(c=>c.dispatch()),this.actionsIn.Create.forEach(c=>c.dispatch()),this.actionsIn.Destroy.forEach(c=>c.dispatch()),this.actionsIn.Reset.forEach(c=>c.dispatch()),this.actionsOut.Transition.forEach(c=>c.pause()),this.actionsOut.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(c=>c.play()),this.actionsIn.Animation.forEach(c=>c.play()),this.actionsIn.TimelineAnimation.forEach(c=>c.play()),this.actionsOut.SwitchCamera.forEach(c=>c.pause()),this.actionsIn.SwitchCamera.forEach(c=>c.play()),this.actionsIn.SceneTransition.forEach(c=>c.dispatch()),this.actionsIn.SetVariable.forEach(c=>c.checkConditions()),this.actionsIn.SetVariable.forEach(c=>c.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object)??r.scene.find2D(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){Sh(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),Sh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),Sh(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),Sh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Gne=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:t}=this.eventContext;e.traverseEntity(i=>{if(i.data?.events.length){for(let{id:r,data:a}of i.data.events)if(!a.disabled&&a.type==="Conditional")try{let s;a.condition.type==="Comparison"||(a.condition.type==="Distance"?s=new jne(r,a,i,e,t,this.eventManager):a.condition.type==="State"&&(s=new Hne(r,a,i,e,t,this.eventManager))),s&&(this.eventsPerConditions[a.condition.type].push(s),(s.actionsIn.Video.length||s.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Uu=new O,ml=new O,dh=new O,QT=new Ka,Wne=.01,bi=new O,jr=new O,KT=new O,Ph=new Rt,wy=new xr,qne=new je,_y=new Dr,Nc=new O,En=new O,Vc=.2;function Sy(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Xne=function(){let e=new je;return(t,i,r)=>{let a=t.obj;e.copy(a.hiddenMatrix),a.parent!==null&&e.premultiply(a.parent.matrixWorld),e.invert(),a.position.copy(i),t.reference==="global"&&Sy(a.position,t.limits),a.position.applyMatrix4(e),t.reference==="parent"?Sy(a.position,t.limits):t.reference==="local"&&(Ph.copy(t.quat0).invert(),a.position.sub(t.position0),a.position.applyQuaternion(Ph),Sy(a.position,t.limits),Ph.invert(),a.position.applyQuaternion(Ph),a.position.add(t.position0)),e.multiply(r??a.matrixWorld).decompose(bi,a.quaternion,jr),a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldSVD()),a instanceof Sa&&zo(a.parent)&&a.invalidateDownstreamBooleanData(!0)}}(),Yne=class{constructor(e,t,i,r,a,s,n){this.object=e,this.id=t,this.data=i,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=Lr(i,i.dragDropActions.drag,r,a,s,this.object),this.actionsDrop=Lr(i,i.dragDropActions.drop,r,a,s,this.object);let o=[];this.data.objects.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(o.push(h),n[h.uuid]&&n[h.uuid].forEach(c=>{let d=r.find(c);!d||d.data.visible!==!1&&o.push(d)}))}),this.data.dropDestinations.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(this.dropDestIds.push(h.uuid),n[h.uuid]&&n[h.uuid].forEach(c=>{let d=r.find(c);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=o.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new O().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new O().setFromMatrixPosition(l.matrixWorld),pointStart:new O,pointEnd:new O,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new O().copy(l.position),quat0:new Rt().copy(l.quaternion),snapped:!1,orientationMatrix:new je,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){oa(this.actionsDrag),oa(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},Qne=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=i=>{if(Ot.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:a}=this.eventContext,s=a.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let n of this.events){let o=0;for(let{obj:l,pointEnd:h,pointStart:c}of n.dragItems){if(l===s[0].object||l===s[0].object.object||oi.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(n.activeIdx=o,n.activeDragItem.reset=!1,n.activeDragItem.currentDampingFactor=n.data.dampingFactor,n.activeDragItem.snapped=!1,n.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){n.activeDragItem.obj.rigidBody&&n.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=n.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(bi,Ph,jr),wy.setFromQuaternion(Ph),d.prevR===void 0?(d.prevR=wy.clone(),d.prevT=bi.clone()):(d.prevR.copy(wy),d.prevT.copy(bi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(n.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,n.data.plane,n.data.referenceFrame),h.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||n.data.drop===!1||n.data.resetOnSnapFail===!1)&&n.activeDragItem.fromPosition.setFromMatrixPosition(n.activeDragItem.obj.matrixWorld),this.activeEvent=n,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}o++}}this.activeEvent=null},this.onPointerMove=i=>{if(Ot.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:a}=this.eventContext,s=a.raycastWithClones(r);if(Ot.length===0){let n=!1;for(let o of this.events){for(let{obj:l}of o.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||oi.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(n=!0,o.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(n)break}n||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let n=this.activeEvent.activeDragItem;n.snapped=!1;let o;if(this.activeEvent.data.drop&&(o=s.filter(l=>n.obj!==l.object&&!n.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof yd)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(h=>h===l.object.uuid||a.scene.find(h).isAncestorOf(l.object.uuid))))[0]),o){let l=KT.copy(o.face.normal).applyMatrix3(_y.getNormalMatrix(o.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")n.fromPosition.setFromMatrixPosition(o.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(n.fromPosition.copy(o.point),this.activeEvent.data.snapSurfaceMode==="bbox"){bi.copy(l).applyMatrix3(_y.setFromMatrix4(n.obj.matrixWorld).transpose());let h=n.obj;bi.x>Vc?jr.x=-h.recursiveBBox.min.x:bi.x<-Vc&&(jr.x=-h.recursiveBBox.max.x),bi.y>Vc?jr.y=-h.recursiveBBox.min.y:bi.y<-Vc&&(jr.y=-h.recursiveBBox.max.y),bi.z>Vc?jr.z=-h.recursiveBBox.min.z:bi.z<-Vc&&(jr.z=-h.recursiveBBox.max.z),jr.applyMatrix3(_y.invert())}else jr.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);n.fromPosition.add(jr)}this.activeEvent.data.autoOrient&&(bi.set(0,1,0).cross(l),bi.length()<1e-4&&bi.set(-1,0,0).cross(l),jr.crossVectors(KT,bi),n.orientationMatrix.makeBasis(bi,jr,l)),n.pointStart.copy(n.fromPosition),n.pointEnd.copy(n.pointStart),n.currentDampingFactor=this.activeEvent.snapDampingFactor,n.snapped=!0,this.lastDropDestination!==o.object&&(this.lastDropDestination=o.object,this.activeEvent.actionsDrop.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(h=>{h.dispatchThrottled()}))}else n.orientationMatrix.makeRotationFromQuaternion(n.quat0),this.lastDropDestination=null,n.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(n.obj,n.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(n),n.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=i=>{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(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(a=>a.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(r=>r.data.type==="DragDrop"&&!r.data.disabled).forEach(r=>{this.events.push(new Yne(i,r.id,r.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let t=this.eventContext.domElement;t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:a,raycaster:s}=this.eventContext;a().getWorldDirection(ml),ml.negate();let n=Ph.identity();switch(r==="parent"?qne.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(bi,n,jr):r==="local"&&e.matrixWorld.decompose(bi,n,jr),i){case"x":bi.set(1,0,0).applyQuaternion(n),Nc.copy(ml).cross(bi),En.copy(bi).cross(Nc);break;case"y":bi.set(0,1,0).applyQuaternion(n),Nc.copy(ml).cross(bi),En.copy(bi).cross(Nc);break;case"z":bi.set(0,0,1).applyQuaternion(n),Nc.copy(ml).cross(bi),En.copy(bi).cross(Nc);break;case"xy":En.set(0,0,1).applyQuaternion(n);break;case"yz":En.set(1,0,0).applyQuaternion(n);break;case"xz":En.set(0,1,0).applyQuaternion(n);break;case"adaptive":ml.angleTo(jr.set(0,1,0))>Math.PI/6?(bi.crossVectors(jr.set(0,1,0),ml),En.crossVectors(bi,jr)):En.set(0,1,0);break;default:En.copy(ml);break}dh.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:dh;if(QT.setFromNormalAndCoplanarPoint(En,o),!!s.ray.intersectPlane(QT,t)&&(i==="x"||i==="y"||i==="z")){let l=jr.subVectors(t,o).dot(bi);t.copy(o).addScaledVector(bi,l)}}updateDragItem(e,t=!1){dh.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Uu.subVectors(e.fromPosition,dh).divideScalar(e.currentDampingFactor):e.reset==="original"?(Uu.subVectors(e.obj.userData.worldPosition0,dh).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Uu.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(dh).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Uu.length()<Wne:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Xne(e,Uu.add(dh),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},jc=new O,Ay=new O,go=new O,vo=new O,ZT=new Ka,Kne=.01,Zne={type:"requestRender"},Jne=function(){let e=new O,t=new O;return(i,r,a)=>a>0?(e.subVectors(i,r),e.length()<=a?i:t.copy(r).add(e.normalize().multiplyScalar(a))):r}(),JT=function(){let e=new je;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Sa&&zo(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),$ne=class{constructor(e,t,i,r,a,s){this.data=e,this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new O,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...mx.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Lr(e,e.actions,r,a,s,i)}},eoe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(Ot.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let a=r.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);a&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new $ne(a.data,a.id,r,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),hs&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let a=r.target,s=this.onTargetChange(r);this.pairOfEventListeners.push([a,s]),a.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),hs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,oa(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:a}=e.data;if(e.object.getWorldPosition(go),e.isReset)vo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(vo);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(Ay),Ay.negate(),jc.copy(Ay)):i==="xy"?jc.set(0,0,1):i==="xz"?jc.set(0,1,0):i==="yz"&&jc.set(1,0,0),ZT.setFromNormalAndCoplanarPoint(jc,go),!o.ray.intersectPlane(ZT,vo))return}if(!e.isReset){if(vo.distanceTo(e.worldPosition0)>r&&a&&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)vo.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&&(vo.x=go.x),e.data.enabledTranslation[1]===!1&&(vo.y=go.y),e.data.enabledTranslation[2]===!1&&(vo.z=go.z);let s=Jne(go,vo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=jc.subVectors(s,go).divideScalar(e.currentDampingFactor);go.add(n),t&&JT(e.object,go),e.paused=n.length()<Kne}else JT(e.object,s),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(Zne)}},Nu=new O,Ym=new O,Vu=new je,Hc=new Rt,gl=new Rt,ju=new O,Hu=new O,uh=new O,yo=new O,My=new Ka,toe=1e-6,ioe={type:"requestRender"},roe={type:"changeRotation"},$T=function(){let e=new je;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(C4(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Sa&&zo(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),aoe=class{constructor(e,t,i,r){this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new Rt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...gx.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),isNaN(this.worldQuaternion0.x)&&(this.worldQuaternion0.x=0),isNaN(this.worldQuaternion0.y)&&(this.worldQuaternion0.y=0),isNaN(this.worldQuaternion0.z)&&(this.worldQuaternion0.z=0),isNaN(this.worldQuaternion0.w)&&(this.worldQuaternion0.w=1),this.resetDampingFactor=80/this.data.resetSpeed+1}},soe=class extends Ia{constructor(){super(...arguments),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=e=>{if(!(Ot.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let t of this.events)t.target===void 0&&this.updateSingleEvent(t)}},this.onMouseEnter=e=>{for(let t of this.events)t.target===void 0&&(t.isReset=!1,t.currentDampingFactor=t.data.dampingFactor)},this.onMouseLeave=e=>{for(let t of this.events)t.target===void 0&&(t.data.resetOnPointerLeave&&(t.isReset=!0,t.currentDampingFactor=t.resetDampingFactor),this.updateSingleEvent(t))},this.onScroll=e=>{if(this._lastMouseEvent){let t=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(t)}},this.onTargetChange=e=>()=>{this.updateSingleEvent(e)},this.createUserEventListener=e=>({eventName:t,target:i})=>{if(!t||!i)return;let r=nf(t);r&&r==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let a=r.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);a&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new aoe(a.data,a.id,r,e))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),hs&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let n=this.onTargetChange(r),o=r.target;this.pairOfEventListeners.push([o,n]),o.addEventListener("requestRender",n)}let a=this.createUserEventListener(r),s=r.object;this.pairOfUserEventListeners.push([s,a]),s.addEventListener("userEvent",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),hs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:a,limitDistance:s,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:c,target:d}=e;if(c.getWorldPosition(ju),!e.isReset)if(e.target)e.target.getWorldPosition(Hu);else{if(a==="custom"?(l().getWorldDirection(Ym),Ym.negate(),My.setFromNormalAndCoplanarPoint(Ym,ju)):(a==="xy"?Nu.set(0,0,1):a==="xz"?Nu.set(0,1,0):a==="yz"&&Nu.set(1,0,0),My.setFromNormalAndCoplanarPoint(Nu,ju)),!h.ray.intersectPlane(My,Hu))return;r>0&&(a==="custom"||a===void 0)&&Hu.addScaledVector(Ym,r)}if(e.isReset||(d?t==="target"?uh.copy(d.up).applyMatrix4(Vu.extractRotation(d.matrixWorld)).normalize():n.some(u=>u===!1)?(i==="x"?(yo.set(0,0,1),n[2]===!1&&yo.set(0,1,0)):i==="y"?(yo.set(1,0,0),n[0]===!1&&yo.set(0,0,1)):(yo.set(0,1,0),n[1]===!1&&yo.set(1,0,0)),uh.copy(yo).applyQuaternion(e.worldQuaternion0).normalize()):uh.set(0,1,0):a==="custom"?uh.set(0,1,0):uh.copy(Nu)),e.isReset)gl.copy(e.worldQuaternion0);else if(ju.distanceTo(Hu)>s&&o&&d)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)gl.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;noe(Vu,Hu,ju,uh,i,yo),gl.setFromRotationMatrix(Vu),Hc.setFromUnitVectors(yo.applyQuaternion(gl),uh),n.some(u=>u===!1)&&t!=="target"&&gl.premultiply(Hc).normalize()}e.currentDampingFactor>1?(c.updateWorldMatrix(!0,!1),Hc.setFromRotationMatrix(C4(c.matrixWorld)),Hc.slerp(gl,1/e.currentDampingFactor),$T(c,Vu.makeRotationFromQuaternion(Hc)),e.paused=8*(1-Hc.dot(gl))<toe):($T(c,Vu.makeRotationFromQuaternion(gl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),c.dispatchEvent(ioe),c.dispatchEvent(roe)}},Cs=new O,Vr=new O,vr=new O;function noe(e,t,i,r,a,s){let n=e.elements;vr.subVectors(t,i),vr.lengthSq()===0&&(vr.z=1),vr.normalize(),Vr.crossVectors(r,vr),Vr.lengthSq()===0&&(Math.abs(r.z)===1?vr.x+=1e-4:vr.z+=1e-4,vr.normalize(),Vr.crossVectors(r,vr)),Vr.normalize(),Cs.crossVectors(vr,Vr),a==="x"?s.z===1?[Vr,Cs,vr]=[vr,Vr,Cs]:(Vr.negate(),[Vr,vr]=[vr,Vr]):a==="y"?s.x===1?[Vr,Cs,vr]=[Cs,vr,Vr]:(Vr.negate(),[Cs,vr]=[vr,Cs]):s.x===1&&(Vr.negate(),[Vr,Cs]=[Cs,Vr]),n[0]=Vr.x,n[4]=Cs.x,n[8]=vr.x,n[1]=Vr.y,n[5]=Cs.y,n[9]=vr.y,n[2]=Vr.z,n[6]=Cs.z,n[10]=vr.z}var ooe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Lr(t,t.actions,r,a,s,i)}disconnect(){oa(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatchStart()),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()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()),this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),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())}},loe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=i=>{Ot.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onMouseUp=i=>{Ot.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=i=>{Ot.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=nf(i);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(n=>n.dispatchUserEvent(a)))}}connect(){let{page:e,sharedAssets:t}=this.eventContext,i=(a,s)=>{if(!(!a.visible||!a.data?.events.length)){for(let{id:n,data:o}of a.data.events)if(!o.disabled&&o.type==="MouseHover")try{let l=new ooe(n,o,a,e,t,this.eventManager);this.eventsPerObjects[a.uuid]?this.eventsPerObjects[a.uuid].push(l):this.eventsPerObjects[a.uuid]=[l]}catch{}this.eventsPerObjects[a.uuid]?.length&&this.objects.push(a instanceof la?s:a)}};if(e.traverseEntity(a=>{(a instanceof Ta||a instanceof ia)&&a.frame?.traverse(s=>{i(s,a)}),i(a)}),!this.objects.length)return;let{domElement:r}=this.eventContext;this.domEventsNeeded.clear(),hs&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),r.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(a=>{a.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),hs&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:a,pointerScreen:s}=this.eventContext,n=!1;if(a.uiCanvas&&(n=Co(a,[s.x,s.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=gg(r,a,this.objects);t=Hb(o),o.forEach(l=>{l.object instanceof Ta&&Co(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)})})}else this.objects.forEach(o=>{let l=Sv(r,o);l&&(t.push(o),o instanceof Ta&&Co(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},hoe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Lr(t,t.actions,r,a,s,i)}connect(){this.scrollCounter=0}disconnect(){oa(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.TimelineAnimation.forEach(r=>r.seek(i)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch()),this.actions.ClearLocalStorage.forEach(r=>r.dispatch()),this.actions.UserAPI.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()}),this.actions.TimelineAnimation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},coe=class{constructor(e,t,i,r,a,s,n){this.id=e,this.data=t,this.object=i,this.domElement=s,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Lr(t,t.actions,r,a,n,i)}getStickyParentElement(){let e=this.domElement;for(;e;){if(window.getComputedStyle(e).position==="sticky")return e;e=e.parentElement}return null}computeScrollBounds(){let e=this.getStickyParentElement(),t=e?.parentElement,i=this.domElement.getBoundingClientRect(),r={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(t){let h=t.getBoundingClientRect(),c=window.getComputedStyle(e),d=parseFloat(c.marginTop)+parseFloat(c.marginBottom),u=parseFloat(c.top),p=parseFloat(c.bottom),f=h.height-d;if(!isNaN(u))i.top===u?(r.top+=h.top-u,r.bottom+=h.top-u):i.top<0&&(r.top-=f-i.height,r.bottom-=f-i.height);else if(!isNaN(p)){let m=document.body.clientHeight??window.innerHeight,g=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===m-p?(r.top+=h.top-i.height+p+g,r.bottom+=h.top-i.height+p+g):i.bottom<m-p&&(r.top-=f-i.height,r.bottom-=f-i.height)}}let a=document.body,s=document.documentElement,n=window.pageYOffset||s.scrollTop||a.scrollTop,o=s.clientTop||a.clientTop||0,l=Math.round(r.top+n-o);if(this.data.startFrom==="enter"){let h=window.innerHeight,c=r.height,d=this.data.enterAnchor,u=d==="top"?h:d==="bottom"?h-c:h-c*.5;this.scrollStart=l-u}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=r,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){oa(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(a=>{a.object.currentTransitionEvent!==this&&(a.object.currentTransitionEvent=this,a.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(a=>a.seek(r)),this.actions.Animation.forEach(a=>a.seek(r)),this.actions.TimelineAnimation.forEach(a=>a.seek(r)),this.actions.Create.forEach(a=>a.dispatchThrottled()),this.actions.SetVariable.forEach(a=>a.checkConditions()),this.actions.SetVariable.forEach(a=>a.dispatch()),this.actions.DynamicVariablePlay.forEach(a=>a.dispatch()),this.actions.ClearLocalStorage.forEach(a=>a.dispatch()),this.actions.UserAPI.forEach(a=>a.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()}),this.actions.TimelineAnimation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},doe=class extends Ia{constructor(e,t){super(e),this.managers=t,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([i,r])=>{r.forEach(a=>a.handleResize())})},this.onScroll=i=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([a,s])=>{a.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(n=>n.dispatch(r))})},this.onWheel=i=>{!this.isInview||i.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,a])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:i.deltaY}),a.forEach(s=>s.dispatch(i.deltaY))})},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=nf(i);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}))}}connect(){let{page:e,sharedAssets:t,domElement:i,isExport:r}=this.eventContext,a=s=>{if(s.data?.events.length){for(let{id:n,data:o}of s.data.events)if(!o.disabled&&o.type==="Scroll")if(o.trigger==="load"||!r){let l=new hoe(n,o,s,e,t,this.managers);this.wheelEventsPerObject.has(s)?this.wheelEventsPerObject.get(s)?.push(l):this.wheelEventsPerObject.set(s,[l])}else{let l=new coe(n,o,s,e,t,i,this.managers);this.scrollEventsPerObject.has(s)?this.scrollEventsPerObject.get(s)?.push(l):this.scrollEventsPerObject.set(s,[l])}}};e.traverseEntity(s=>{(s instanceof Ta||s instanceof ia)&&s.frame?.traverse(n=>{a(n)}),a(s)}),this.intersectionObserver=new IntersectionObserver(s=>{let n=s[0];n&&(this.isInview=n.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([s,n])=>{n.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([s,n])=>{n.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},uoe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}disconnect(){oa(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.TimelineAnimation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),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.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Th?t.interaction.audioPlayer?.play():t.interaction instanceof Fb&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Bl?t.interaction.play(i==="autoplay"):t.interaction instanceof Vb&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}async seekVideos(e){let t=[];this.actions.Video.forEach(i=>{(i.interaction.data.triggerAfter??"autoplay")==="autoplay"&&i.interaction instanceof Bl&&t.push(i.interaction.seek(e))}),await Promise.all(t)}pauseVideos(){this.actions.Video.forEach(e=>{e.interaction instanceof Bl&&e.interaction.pause()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),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.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Th?t.interaction.audioPlayer?.play():t.interaction instanceof Fb&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Bl?t.interaction.play():t.interaction instanceof Vb&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},poe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,a=r?document:i;a.removeEventListener("pointerdown",this.onAny),a.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.actions.Audio.forEach(s=>{s.interaction instanceof Th&&s.interaction.audioPlayer?.play()}),a.actions.Video.forEach(s=>{let n=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Bl&&s.interaction.play(n==="autoplay")}),a.actions.Particles.forEach(s=>{s.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("autoplay")})})},this.seekVideos=async i=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([a,s])=>{!a.data.visible||s.forEach(n=>{r.push(n.seekVideos(i))})}),await Promise.all(r)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{r.forEach(a=>{a.pauseVideos()})})},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=nf(i);s&&s==="Start"&&(r instanceof la||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:a,data:s}of r.data.events){if(s.disabled||s.type!=="Start")continue;let n=new uoe(a,s,r,t,e,this.eventManager);(n.actions.Transition.length||n.actions.TimelineAnimation.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length||n.actions.Reset.length||n.actions.SetVariable.length||n.actions.DynamicVariablePlay.length||n.actions.ClearLocalStorage.length||n.actions.UserAPI.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}};if(t.traverseEntity(r=>{(r instanceof Ta||r instanceof ia)&&r.frame?.traverse(a=>{i(a)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:a}=this.eventContext,s=a?document:r;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,o])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,a])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(s=>s.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,a])=>{r.removeEventListener("userEvent",this.onUserEvent),a.forEach(s=>s.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},foe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=Lr(t,t.actions,r,a,s,i),this.target=t.target}disconnect(){oa(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},moe=class extends Ia{constructor(e,t,i,r,a){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=a,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.isOutOfFocus=!1,this.events=[],this.onFrame=s=>{let n=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let o=new Date,l=[],h=[];for(let u=0;u<this.propertiesToWatch.length;u++){let{objectId:p,property:f,prevValue:m}=this.propertiesToWatch[u],g=this.eventContext.scene.find(p),y=yx.propertyPaths[f];if(y[0]==="width"||y[0]==="height"||y[0]==="depth")g=g.geometry.userData.parameters[y[0]];else for(let x=0;x<y.length;x++)g=g[y[x]];m===null?this.propertiesToWatch[u].prevValue=g instanceof O?g.clone():g:(g instanceof O?!g.equals(m):m!==g)&&(h.push({objId:p,property:f}),g instanceof O?this.propertiesToWatch[u].prevValue.copy(g):this.propertiesToWatch[u].prevValue=g)}for(let u=0;u<this.variablesToWatch.length;u++){let{id:p,prevValue:f}=this.variablesToWatch[u],m=n.getVariable(p);m!==f&&(l.push(p),this.variablesToWatch[u].prevValue=m)}for(let u=0;u<this.dynamicVars.length;u++){let{id:p,expectedTime:f,last:m,data:g,timerSeconds:y,startValue:x}=this.dynamicVars[u],b=1e3;if((g.dynamicVariableType==="timer"||g.dynamicVariableType==="stopwatch")&&g.format==="number3decimal"?b=1:g.dynamicVariableType==="counter"?b=g.updateInterval:g.dynamicVariableType==="random"&&(b=g.isStatic?1/0:g.updateInterval),f===-1){this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+b;continue}if(!((n.getDynamicVariablePlayState(p)==="Stopped"||n.getDynamicVariablePlayState(p)==="Restarted")&&(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+b,g.dynamicVariableType==="counter"&&n.getVariable(p)!==x&&(n.updateVariable(p,x),this.eventManager.requestRender()),(g.dynamicVariableType==="timer"||g.dynamicVariableType==="stopwatch")&&this.dynamicVars[u].timerSeconds!==x&&(this.dynamicVars[u].timerSeconds=x,n.updateVariable(p,Is.getFormattedTimerTime(x,g)),this.eventManager.requestRender()),n.getDynamicVariablePlayState(p)==="Restarted"&&n.setDynamicVariablePlayState(p,"Playing"),n.getDynamicVariablePlayState(p)==="Stopped"))){if(n.getDynamicVariablePlayState(p)==="Paused"){this.dynamicVars[u].deltaToExpectedTime===void 0&&(this.dynamicVars[u].deltaToExpectedTime=Math.max(this.dynamicVars[u].expectedTime-s,0)),this.dynamicVars[u].last=s-(b-this.dynamicVars[u].deltaToExpectedTime),this.dynamicVars[u].expectedTime=s+this.dynamicVars[u].deltaToExpectedTime;continue}else this.dynamicVars[u].deltaToExpectedTime=void 0;if(s>=f)if(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime+=b,g.dynamicVariableType==="random"){let _=g.min+Math.random()*(g.max-g.min),S=g.decimals;_=Math.round(_*Math.pow(10,S))/Math.pow(10,S),n.updateVariable(p,_),l.push(p),this.eventManager.requestRender()}else if(g.dynamicVariableType==="counter"){let _=n.getVariable(p),S=n.getDynamicVariableToggleIsForward(p)??!0,A=n.getVariable(p)+g.increment*(S?1:-1);g.hasEnd&&(A=g.increment>0?tt.clamp(A,x,g.endValue):tt.clamp(A,g.endValue,x),A===x&&n.setDynamicVariableToggleIsForward(p,void 0),g.repeat?A===g.endValue&&(A=x):(A===x||A===g.endValue)&&n.setDynamicVariablePlayState(p,"Paused")),A!==_&&(l.push(p),n.updateVariable(p,A),this.eventManager.requestRender())}else if(g.dynamicVariableType==="time"){let _=n.getVariable(p),S=CC(o,g);if(typeof _=="object"&&"textValue"in _&&typeof S=="object"&&"textValue"in S){if(Array.isArray(_.textValue)&&Array.isArray(S.textValue)){if(_.textValue.every((A,E)=>A===S.textValue[E]))continue}else if(_.textValue===S.textValue)continue}else if(_===S)continue;n.updateVariable(p,S),l.push(p),this.eventManager.requestRender()}else{let _=ba.isTextValue(g.endValue)?e3(g.endValue.textValue):g.endValue,S=n.getDynamicVariableToggleIsForward(p)??!0,A=y+(s-m)/1e3*(g.dynamicVariableType==="timer"?-1:1)*(S?1:-1);A=Math.max(A,0),g.hasEnd&&(A=g.dynamicVariableType==="stopwatch"?tt.clamp(A,x,_):tt.clamp(A,_,x),A===x&&n.setDynamicVariableToggleIsForward(p,void 0),g.repeat?Math.abs(A-_)<(g.format==="number3decimal"?1e-4:.1)&&(A=x):(Math.abs(A-x)<(g.format==="number3decimal"?1e-4:.1)||Math.abs(A-_)<(g.format==="number3decimal"?1e-4:.1))&&n.setDynamicVariablePlayState(p,"Paused")),A!==y&&(l.push(p),this.dynamicVars[u].timerSeconds=A,n.updateVariable(p,Is.getFormattedTimerTime(A,g)),this.eventManager.requestRender())}}}let c=!1;n.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=n.mouseProperty,c=!0);let d=!1;n.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=n.raycastProperty,d=!0),this.events.forEach(u=>{(l.includes(u.data.variableId)||h.find(p=>p.objId===u.data.objectId&&p.property===u.data.property)||u.data.variableId==="mouseProperty"&&c||u.data.variableId==="raycastProperty"&&d)&&(u.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 t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new goe(i.id,i.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(t=>t.data.variableId==="objectProperty"&&t.data.objectId!==null).map(t=>({objectId:t.data.objectId,property:t.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:t,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(a=>a.data.variableId===t)&&this.variablesToWatch.push({id:t,prevValue:e.getVariable(t)});return}let r;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let a;if(ba.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let s=i.value.textValue;s.length===3?a=s[2]+s[1]*60+s[0]*3600:a=s[1]+s[0]*60}else a=i.value;r=a,this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,timerSeconds:a,startValue:r})}else i.dynamicVariableType==="time"&&e.updateVariable(t,CC(new Date,i)),i.dynamicVariableType==="counter"&&(r=ba.isTextValue(i.value)?e3(i.value.textValue):i.value),this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,startValue:r})}),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())}},goe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispose(){oa(this.actions)}};function e3(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var voe="https://unpkg.com/@splinetool/runtime@1.12.54/build/",yoe="https://unpkg.com/@splinetool/navmesh-wasm@1.12.54/build/",xoe=`
8142
+ )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:a,velocity:s}=e;t=`spring( ${i}, ${r}, ${a}, ${s} )`}else{let i;switch(e.easing){case 0:i=yl.linear;break;case 1:i=yl.ease;break;case 2:i=yl.easeIn;break;case 3:i=yl.easeOut;break;case 4:i=yl.easeInOut;break;default:i=yl.linear}let[r,a,s,n]=i;t=`cubicBezier( ${r}, ${a}, ${s}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function _v(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var u4={type:"beginState"},p4={type:"completeState",isfromEntity:!1},Ub=class{constructor(e,t,i,r,a,s,n){if(this.object=e,this.data=r,this.sharedAssets=a,this.allowSlerp=s,this.page=n,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 o=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=o,this.object.dispatchEvent({type:"beginState",state:o}),this.object instanceof la||this.object.traverseEntity(l=>{l!==this.object&&l instanceof Xr&&l.dispatchEvent(u4)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let o=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=o,this.object.dispatchEvent({type:"completeState",state:o}),this.object instanceof la||this.object.traverseEntity(l=>{l!==this.object&&l instanceof Xr&&l.dispatchEvent(p4)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=BT(this.object,this.from.data,this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp))},t===void 0){let o=mg(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!o)throw new Error("Missing property");this.from=o}else{let o=mg(this.object,t);if(!o)throw new Error("Missing property");this.from=o}if(i===void 0)throw new Error("Missing property");{let o=mg(this.object,i);if(!o)throw new Error("Missing property");this.to=o}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,..._v(r),...d4(r),change:this.onChange},this.callback=BT(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Nb=class extends ha{constructor(e,t,i,r,a){if(super(),this.eventType=e,this.data=t,this.page=i,this.shared=r,this.condition=a,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.hasPlayedOnce=!1,this.pauseOnNextLoopEnd=!1,this.onTimelineChangeComplete=()=>{if(this.pauseOnNextLoopEnd){this.pauseOnNextLoopEnd=!1,this.timeline?.pause();return}this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!t.object)throw new Error("Missing property");let s=this.page.scene.find(t.object)??this.page.uiCanvas?.find(t.object)??this.page.scene.find2DInUIObjects(t.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,t.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=t.tweens[0].data.delayDirection==="start-once"?t.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=mg(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&px(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=_v(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=Uo.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let a=this.tweens.findIndex(s=>s?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let s=a===-1?0:a;for(let n=s;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Xr&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new Ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1,this.page);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.delay:0))}this.timeline.duration+=r.endDelay}else{let s=a===-1?this.data.tweens.length-1:a+1;for(let n=s;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Xr&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new Ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1,this.page);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n-1]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Hi(this.shared,this.condition)===!1||px(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;this.startTimeout?.pause();let e=_v(this.data.tweens[0].data).pingPongDelayCorrection;this.startTimeout=Uo({targets:{},duration:this.startOnceDelay+e,easing:"linear",complete:()=>{this.startTimeout=void 0;try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}}})}pause(){this.timeline?.pause(),this.startTimeout?.pause(),this.tweens=Array(this.data.tweens.length-1),delete this.startTimeout}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof la?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(Hi(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(Hi(this.shared,this.condition)===!1)return!1;this.startTimeout?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.pauseOnNextLoopEnd=!0,this.timeline.play()):this.startTimeout=Uo({targets:{},duration:this.startOnceDelay,easing:"linear",complete:()=>{this.startTimeout=void 0,this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()}})}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function mg(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var dne={type:"beginState"},UT={type:"completeState",isfromEntity:!1},NT={type:"requestRender"},f4=class extends ha{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.posStart=new O,this.posEnd=new O,this.qStart=new Rt,this.qEnd=new Rt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=Uo({targets:i,t:1,...d4(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(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(dne));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(NT),i.t===1&&r.dispatchEvent(UT)}})}switchCamera(e){let t=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),t.dispatchEvent({type:"cameraChange",camera:i})}play(){if(Hi(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(Hi(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(UT),this.page.activeCamera.dispatchEvent(NT))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},m4=class extends ha{constructor(e,t,i,r,a){super(),this.id=e,this.data=t,this.scene=i,this.sharedAssets=r,this.eventType=a,this.toggleIsForward=!1,this._finished=!1,this.hasPlayedOnce=!1,this._shouldForwardLoop=!1,this._shouldPauseOnNextLoopComplete=!1,this._onLoopComplete=()=>{this._shouldPauseOnNextLoopComplete&&(this.timeline.pause(),this._shouldPauseOnNextLoopComplete=!1)};try{let s=_v(this.data);typeof s.loop=="number"&&s.loop--,this.timeline=Uo.timeline({...s,autoplay:!1}),this._shouldForwardLoop=s.loop===!0||typeof s.loop=="number"&&s.loop>1;let n=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.entries(n).forEach(([o,l])=>{let h=this.scene.find(o);if(!h)return;let c=h.data.timelineAnimations[l];if(!c)return;let d=eb.addKeyframesToTimeline(h,{...c},cne(h,{scene:i,shared:r}),this.sharedAssets),u=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay:0)+(this.data.delayDirection==="start-once"?this.data.delay:0);d.forEach(p=>{this.timeline.add(p,u)}),this.timeline.duration=c.to*1e3+u}),this.timeline.delay=0,this.timeline.duration+=(this.data.delayDirection==="start"?this.data.delay:0)+(this.data.delayDirection==="end"?this.data.delay:0)+(this.data.delayDirection==="start-end"?this.data.delay*2:0)+(this.data.delayDirection==="start-once"?this.data.delay*2:0),this.timeline.finished.then(()=>{Object.keys(n).forEach(o=>{let l=this.scene.find(o);l instanceof Xr&&l.dispatchEvent(p4)}),this._finished=!0}),this.timeline.loopComplete=this._onLoopComplete}catch{throw new Error("Missing property")}}get playing(){return this.timeline.paused===!1}get finished(){return this._finished}get paused(){return this.timeline.paused}play(){if(this.eventType!==void 0&&px(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0;let e=this.sharedAssets.data.timelineAnimations[this.data.timeline].mapping;Object.keys(e).forEach(t=>{let i=this.scene.find(t);i instanceof Xr&&i.dispatchEvent(u4)}),this.timeline.restart()}pause(){this.timeline.pause()}stop(){this.pause(),this.seek(0),this.timeline.reset(),this._finished=!1}seek(e){this.timeline.seek(e*this.timeline.duration,!0)}toggle(e){if(this.toggleIsForward=e??!this.toggleIsForward,this.playing){if(!this.toggleIsForward&&this.timeline.reversed&&this._shouldForwardLoop&&this.timeline.remaining%2===1){this._shouldPauseOnNextLoopComplete=!0;return}this.timeline.reverse(this.timeline.duration-this.timeline.currentTime),this._shouldForwardLoop&&this.timeline.loop&&this.timeline.reversed&&(this._shouldPauseOnNextLoopComplete=!0)}else(!this.toggleIsForward!==this.timeline.reversed||!this.toggleIsForward&&this.timeline.reversed&&this.timeline.direction==="alternate")&&this.timeline.reverse(),typeof this.timeline.loop=="number"&&typeof this.timeline.remaining=="number"&&this.timeline.remaining<this.timeline.loop&&this.toggleIsForward&&(this.timeline.remaining=this.timeline.loop),this.timeline.play()}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function g4(e){let t=e?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(t?.length){let i=bX(t);return i&&i>2?i:2}return 2}var v4=class extends ha{constructor(e,t,i,r,a){super(),this.data=e,this.page=t,this.animationControls=i,this.shared=r,this.condition=a,this.startOnceDelay=0,this.toggleIsForward=!1;let s=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(s=n.identity[0]),this.data={...e,object:s};let o=this.animationControls.clipIdToAction[e.clipId+"/"+s];if(this.duration=o?.getClip()?.duration??1,this.data.crop2){let l=g4(o?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=o?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Hi(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let a=i.split("/")[1];this.threeAnimAction!==r&&a===t&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=tt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(Hi(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,a])=>{let s=r.split("/")[1];this.threeAnimAction!==a&&s===i&&a.isRunning()&&(t?a.fadeOut(.2):a.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},y4=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=a,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(Hi(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target||t.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{t.type==="ParticleSystem"&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),L_(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},x4=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Hi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=TI(this.data.expression,this.shared,ba.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},b4=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(Hi(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}},une=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Hi(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 t=this.shared.data.variables.data(e)?.value;t!==void 0&&this.shared.updateVariable(e,t),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(bb(e))})}dispose(){}},pne=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Hi(this.shared,this.condition)===!1)return!1;if(this.data.userAPIId){let e=this.shared.getUserAPI(this.data.userAPIId);e&&"callUserAPI"in e&&e.callUserAPI(this.shared)}}dispose(){}};function Hi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=TI(t.expression,e,"boolean");return t.negate?!i:!!i}function Lr(e,t,i,r,a,s){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},o=l=>({id:h,data:c})=>{try{c.type==="Audio"?ua[e.type].includes("Audio")&&n.Audio.push(new $O(h,c,s,r,l)):c.type==="Video"&&!(s instanceof la)?ua[e.type].includes("Video")&&n.Video.push(new _4(h,c,s,r,l)):c.type==="Particles"?ua[e.type].includes("Particles")&&n.Particles.push(new e4(c,i,r,l)):c.type==="Link"?ua[e.type].includes("Link")&&n.Link.push(new Wse(c,a.controlsManager,r,l)):c.type==="Create"?ua[e.type].includes("Create")&&n.Create.push(new S4(c,i,a.controlsManager,r,l)):c.type==="Destroy"?ua[e.type].includes("Destroy")&&n.Destroy.push(new t4(c,i,a.controlsManager,r,l)):c.type==="Reset"?ua[e.type].includes("Reset")&&n.Reset.push(new i4(c,i,r,a,l)):c.type==="Transition"?ua[e.type].includes("Transition")&&n.Transition.push(new Nb(e.type,c,i,r,l)):c.type==="SwitchCamera"?ua[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new f4(c,i,r,l)):c.type==="SceneTransition"?ua[e.type].includes("SceneTransition")&&n.SceneTransition.push(new y4(c,i,a,r,l)):c.type==="Animation"?ua[e.type].includes("Animation")&&n.Animation.push(new v4(c,i,a.animationControls,r,l)):c.type==="SetVariable"?ua[e.type].includes("SetVariable")&&n.SetVariable.push(new x4(c,i,r,l)):c.type==="DynamicVariablePlay"?ua[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new b4(c,i,r,l)):c.type==="Conditional"?ua[e.type].includes("Conditional")&&(c.ifActions.forEach(o({expression:c.condition,negate:!1})),c.elseActions.forEach(o({expression:c.condition,negate:!0}))):c.type==="ClearLocalStorage"?ua[e.type].includes("ClearLocalStorage")&&n.ClearLocalStorage.push(new une(c,i,r,l)):c.type==="UserAPI"?ua[e.type].includes("UserAPI")&&n.UserAPI.push(new pne(c,i,r,l)):c.type==="TimelineAnimation"&&ua[e.type].includes("TimelineAnimation")&&n.TimelineAnimation.push(new m4(h,c,i.scene,r,e.type))}catch{}};return t.forEach(o()),n}function oa(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof $O||i instanceof _4||i instanceof Nb||i instanceof m4||i instanceof e4||i instanceof v4||i instanceof Nb||i instanceof S4||i instanceof t4||i instanceof f4||i instanceof y4||i instanceof i4||i instanceof x4||i instanceof b4)&&i.dispose()})})}function fne(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(a=>a.uuid===t):i=e.material.layers.find(a=>a.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var w4=new Map,xp=new Map,Bl=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:a,volume:s,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=fne(i,r);o&&(this.videoElement=o,this.videoElement.loop=a===1/0,Qd&&(this.videoElement.autoplay=!0),s!==void 0&&(this.videoElement.volume=s)),n!==void 0&&(this.delay=n),xp.has(i.uuid)?xp.get(i.uuid).push(this):xp.set(i.uuid,[this]),w4.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(e){return new Promise(t=>{if(!this.videoElement)return t();let i=this.videoElement.duration;if(i>0){let r=e%i;this.videoElement.currentTime=r}this.videoElement.addEventListener("seeked",()=>t(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Vb=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=w4.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=xp.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...xp.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},_4=class{constructor(e,t,i,r,a){if(this.data=t,this.shared=r,this.condition=a,t.interaction==="play")this.interaction=new Bl(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Vb(t);else throw new Error("Missing property")}dispatchBasic(){if(Hi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Bl?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Hi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Bl?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},vy=(()=>{let e,t,i,r,a=!1;function s(h){!e&&!VT()&&(t?.sharedGameControlGlobals.createdObjects.length??0)>0&&(e=requestAnimationFrame(n)),h&&(t=h,r=h.requestRender,!a&&typeof document<"u"&&(document.addEventListener("visibilitychange",o),a=!0))}function n(h){if(!t||!r){e=void 0,i=void 0;return}let c=i?h-i:0,d=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,p=d.length,f=0;for(;f<p;){let m=d[f];m.userData.createdTime===void 0&&(m.userData.createdTime=h),m.userData.lifetime===void 0&&m.userData.quantity===void 0||m.userData.lifetime&&h-m.userData.createdTime<m.userData.lifetime||m.userData.quantity&&u[m.userData.actionId]<=m.userData.quantity?(m.userData.velocity&&(m.position.addScaledVector(m.userData.velocity,c/1e3),m.updateMatrix(),r()),f++):(u[m.userData.actionId]>m.userData.quantity&&u[m.userData.actionId]--,d.splice(f,1),m.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&m.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(m.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(m.rigidBody)):(m.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(g=>g.bvhGeometry!==void 0)),p--,r())}e=f>0?requestAnimationFrame(n):void 0,i=f>0?h:void 0}function o(){VT()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}function l(){e&&(cancelAnimationFrame(e),e=void 0),a&&typeof document<"u"&&(document.removeEventListener("visibilitychange",o),a=!1),t=void 0,r=void 0,i=void 0}return{play:s,dispose:l}})();function VT(){return!!document&&document.hidden}var jT=new Rt,mne=new O,gne=new O,S4=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=a,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=tt.generateUUID(),this.dispatch=()=>{if(Hi(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(Hi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=FX(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new wa(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.scale.copy(this.object.scale),n.position.fromArray(this.data.position.map(l=>typeof l=="number"?l:0)),n.rotation.fromArray(this.data.rotation.map(l=>typeof l=="number"?l:0)),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),vy.play(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Ls)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof wa)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Ls)return;n instanceof wa?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new O().fromArray(this.data.velocity.map(c=>typeof c=="number"?c:0)),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(mne,jT,gne),l.applyQuaternion(jT),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let s=this.page.scene.find(this.data.object);if(!s)throw new Error("Missing Property");if(this.object=s,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");vy.play(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],vy.dispose()}},A4=200,yy=.02,xy=.3,vne=65,HT=new O,GT=new O,yne=new O,ka=new O,Ya=new O,fl=new O,by=new je,WT=new je,xne=new je,Ks=new Rt,mo=new Rt,An=new xr(0,0,0,"YXZ"),bne=new O(1,0,0),Zs=new O(0,1,0),wne=new O(0,0,1),qT=new O(1,1,1),_ne=1,Sne=.025,Ane=16e-6,XT=12,Mne=20,ea=new zs,Es=new wr,Ene={type:"requestRender"},Cne={type:"updateMatrix"},YT=Math.PI/6,jb=class extends ha{constructor(e,t,i,r,a,s,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=a,this.cameraFollow=s,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new je,this.target0=new O,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=A4,this.euler0=new xr(0,0,0,"YXZ"),this.position0Cam=new O,this.quat0Cam=new Rt,this.scale0Cam=new O,this.hiddenMatrix0Cam=new je,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new zs(new O(0,-40,0),new O(0,40,0)),matrix:new je,position:new O,rotation:new Rt},this.euler=new xr(0,0,0,"YXZ"),this.eulerDelta=new O,this.lastPosition=new O,this.lastCameraQuaternion=new Rt,this.lastCameraPosition=new O,this.PI_2=Math.PI/2,this.prevMouse=new ae,this.velocityTarget=new O,this.velocity=new O,this.directionXZ=new O,this.rotVelocityStick=new O,this.rotVelocityTarget=new O,this.rotVelocity=new O,this.rotDirection=new O,this.nonColliderRotOffset=new je,this.nonColliderPosOffset=new je,this.firstPointerId=-1,this.rot=new O,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 je,this.objectToTarget=new O,this.objectToTarget0=new O,this.objectToCamXZ=new O,this.objectToCamXZ0=new O,this.targetToCamera=new O,this.targetToCamera0=new O,this.cameraPolarAxis0=new O,this.targetPos=new O,this.targetQuat=new Rt,this.lerpFactorPos=new O().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Rt,this.objXZQuatInv=new Rt,this.objXZRotMat=new je,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new O,this.pushedVelocity=new O,this.groundYRotation=0,this.objectRealQuat=new Rt,this.colliderWorldQuat=new Rt,this.groundNormal=new O,this.groundTilt=new Rt,this.groundTiltInv=new Rt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new O,this.quaternion=new Rt,this.scale=new O,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!hs&&!wM&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(wM&&JX<15.5&&!hs?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?jb.isLocked=!0:jb.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let y=f.axes[g];m===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(y)>=.3&&(this.vrEulerYOffset+=y<0?1:-1),this.movementState.rotPosY=y):this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),c=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,c,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new O(0,0,-1).applyQuaternion(this.camera.quaternion),m=new O().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,y;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,y=m.projectOnVector(f)):m.y/f.y>0?y=f.multiplyScalar(m.y/f.y):y=f.multiplyScalar(m.length()),this.targetToCamera0.copy(y).negate(),g=this.camera.position.clone().add(y),this.objectToTarget0.subVectors(g,this.position);let x=new xr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-x.x,x.x=0,x.z=0,x.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(x)}if(this.object instanceof Xr&&(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)*_ne,this.speedOrbit=(i.speedRotate??100)*Sne,this.mouseOrbitSensitivity=(i.speedRotate??100)*Ane,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Dd.defaultData.gravity)*XT,this.usePhysics=this.gloabalPhysics.usePhysics??Dd.defaultData.usePhysics,this.jumpPower=i.jumpPower*Mne,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??iv.defaultDataThirdPerson.orientWith,this.slopeThresh=vne*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*yy/this.pixelsPerMeter,this.stepThresh=i.collider.height*xy/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*yy/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*xy/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*yy/this.pixelsPerMeter,this.stepThresh=i.collider.height*xy/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new O().fromArray(i.collider.position.map(f=>typeof f=="number"?f:0)),u=new Rt().setFromEuler(new xr().fromArray([...i.collider.rotation.map(f=>typeof f=="number"?f:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(u),this.collider.matrix.compose(d,u,qT),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new pt;f.push({fi:0,data:{...yr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...yr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new m_({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Fi(oI.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new xr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Xr?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},tv.list.forEach(i=>{this.actions[i]=Lr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),oa(this.actions.idle),oa(this.actions.move),oa(this.actions.run),oa(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(t=>{t.play()}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(t=>{t.stop()}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return ka.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let a=r*60,s=!1;if(this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let o=Ya.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*XT),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(s=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(c.rigidBody===h&&c.userData.isFollowingObj!==this.object.uuid){(c.hasNonUniformScale?c.matrixWorldRigid:c.matrixWorld).decompose(ka,mo,Ya),this.groundVelocity.subVectors(ka,c.prevT),this.object.getWorldPosition(Ya).add(this.collider.position).sub(ka),this.groundYRotation=An.setFromQuaternion(mo).y-c.prevR.y,fl.copy(Ya).applyAxisAngle(Zs,this.groundYRotation),this.groundVelocity.add(fl.sub(Ya)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*a),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=ka.subVectors(this.path[1],this.position),h=Ya.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**a),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**a),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**a)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=yne.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Ya.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let o=ka;this.camera.getWorldDirection(o);let l=fl.copy(Zs).multiplyScalar(o.dot(Zs));o.sub(l);let h=Ya.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(An.setFromVector3(this.rot),this.moveMode==="walk"&&(An.x=0),n.applyEuler(An),s&&(mo.setFromUnitVectors(Zs,this.groundNormal),n.applyQuaternion(mo)),i){let o=An.set(0,this.vrEulerYOffset*YT,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0&&this.object.rigidBody){let o=Ya;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=fl.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),c=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),ka.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let d=oi.is(l)?l:l.object;if(c!==null&&this.lastHitObj!==d){let u;l instanceof wa&&(u=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[d.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(u),d.dispatchEvent(Gb));this.lastHitObj=d}if(c!==null){this.pushedVelocity.copy(h),o.copy(c.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**a):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**a),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Zs,this.euler.y-this.euler0.y);let o=Ya.copy(this.objectToCamXZ).normalize(),l=fl.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(ka.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=tt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=tt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=tt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(An.copy(t),An.y=0):(An.copy(this.euler),An.y=0),this.nonColliderRotOffset.makeRotationFromEuler(An)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*YT),Ks.setFromAxisAngle(bne,this.rot.x),mo.setFromAxisAngle(Zs,this.rot.y),mo.multiply(Ks),Ks.setFromAxisAngle(wne,this.rot.z),mo.multiply(Ks),this.quaternion.copy(mo),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let o=Ya.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new O;for(let c=0;c<5;c++){let d=o.length(),u=fl.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,u,this.object.rigidBody.collider(0).shape,d,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&c===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let x of y)if(x.data.target==="character"){let b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,_;if(p.cloner){for(let S of p.cloner.children)if(S.rigidBody===b){_=S;break}}x.dispatch(_),p.dispatchEvent(Gb)}}}let f=HT.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=GT.copy(u).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(u,g)),o.copy(u).multiplyScalar(d-g),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=fl.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);x.y=0;let b=y.add(x);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{c===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(ka.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Ks.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);by.lookAt(l,o,Zs).setPosition(l),by.decompose(this.targetPos,this.targetQuat,ka),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**a),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**a),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=tt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=tt.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(Cne),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(Ene),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ks.setFromAxisAngle(Zs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?tt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=tt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=tt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=ka.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=mo.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Zs.angleTo(e)*180/Math.PI<15||Zs.angleTo(e)*180/Math.PI>85?Ks.identity():Ks.setFromUnitVectors(Zs,e),this.groundTilt.slerp(Ks,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=GT.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=by.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(ka,Ks,Ya).compose(ka,Ks,qT);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Es.makeEmpty(),a.updateMatrixWorldSVD();let s=a.matrixWorldRigid,n=WT.copy(s).invert(),o=xne.copy(WT).multiply(i);ea.copy(this.collider.segment),ea.start.applyMatrix4(o),ea.end.applyMatrix4(o);let l=HT.copy(this.position).applyMatrix4(n);Es.expandByPoint(ea.start),Es.expandByPoint(ea.end),Es.min.addScalar(-this.collider.radius),Es.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(ea.end)},intersectsBounds:h=>h.intersectsBox(Es),intersectsTriangle:h=>{let c=ka,d=Ya,u=h.closestPointToSegment(ea,c,d);if(u<this.collider.radius){let p=this.collider.radius-u,f=d.sub(c).normalize(),m=fl.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),ea.start.addScaledVector(f,p),ea.end.addScaledVector(f,p)}}})}),Es.makeEmpty(),ea.copy(this.collider.segment),ea.start.applyMatrix4(i),ea.end.applyMatrix4(i),Es.expandByPoint(ea.start),Es.expandByPoint(ea.end),Es.min.addScalar(-this.collider.radius),Es.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(a){return a.distanceToPoint(ea.end)},intersectsBounds:a=>a.intersectsBox(Es),intersectsTriangle:a=>{let s=ka,n=Ya,o=a.closestPointToSegment(ea,s,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),ea.start.addScaledVector(h,l),ea.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},M4=jb;M4.isLocked=!1;var Tne=Xl(v3());function E4(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,a=t[8]**2+t[9]**2+t[10]**2,s=t[0]**2+t[4]**2+t[8]**2,n=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||a<l||s<l||n<l||o<l}function Eo(e,t){let i=new vt;if(t&&E4(t))return i.setAttribute("position",new nt([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new nt([],3)),i.setIndex([]),i;let{positions:r,triIndices:a}=Yv(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new nt(r,3)),i.setIndex(a),t&&i.applyMatrix4(t),i}var Pne=new je,Dne=new je,Mn=[[0,0,0],[0,0,0],[0,0,0]];function C4(e){let t=e.elements;Mn[0][0]=t[0],Mn[0][1]=t[4],Mn[0][2]=t[8],Mn[1][0]=t[1],Mn[1][1]=t[5],Mn[1][2]=t[9],Mn[2][0]=t[2],Mn[2][1]=t[6],Mn[2][2]=t[10];let{u:i,v:r}=(0,Tne.SVD)(Mn),a=Pne.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),s=Dne.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 a.multiply(s.transpose())}var Ine=class extends cP{constructor(){super(),this.layers.enable(3),this.layers.enable(8),this.layers.enable(9)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new Ql({color:65280,linewidth:10}),t=new O(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new O(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,a=new O().addVectors(t,i.multiplyScalar(r)),s=new vt;return s.setFromPoints([t,a]),new Sg(s,e)}},T4=e=>e instanceof yd||e instanceof xd;function One(e,t){return e.distance-t.distance}function P4(e,t,i){if(!(!Mo(t)||!t.visible)){zn(t)&&t.raycast(e,i);for(let r of t.children)P4(e,r,i)}}function gg(e,t,i,r=!1){if(!r&&!i.some(s=>Sv(e,s)!==void 0))return[];let a=[];return t.children.forEach(s=>P4(e,s,a)),a.sort(One),a}function Hb(e){let t=[];if(e.length){let i=e[0].object;Mo(i)&&t.push(i);let r=i.parent;for(;r;)T4(r)&&t.push(r),r=r.parent}return t}function Co(e,t,i,r){let a=e.frame;if(a){let s=t[0]*a.width,n=(1-t[1])*a.height;for(let o of i){let l=o===a.uuid?a:a.find(o);if(l?.intersects(s,n))return r(l),!0}}return!1}function Sv(e,t){if(zn(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(T4(t))return D4(e,t)}function D4(e,t){if(!(!Mo(t)||!t.visible)){if(zn(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=D4(e,i);if(r)return r}}}function Rne(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}function Lne(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var Bne=class{constructor(e,t,i,r,a,s,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=a,this.requestRender=s,this.isExport=n,this.frame=o,this.raycaster=new Ine,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.pointerWorld=Rne(t,i,this._domRect),this.pointerScreen=Lne(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}dispose(){this.scene=void 0,this.sharedAssets=void 0,this.publish=void 0,this.getCamera=void 0,this.requestRender=void 0,this.frame=void 0,this.isExport=void 0}},Ia=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}dispose(){this.disconnect(),this.eventContext=void 0}},B_=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],I4=e=>B_.find(([t,i])=>i===e)?.[0],nf=e=>B_.find(([t])=>t===e)?.[1],zne=(e,t)=>{let i=I4(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},kne=class extends Ia{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let t=this.splineEvents[I4(e.eventName)]?.[e.target.uuid];if(!t)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(t,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(t)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(t=>{if(t.data?.events.length){for(let[i,r]of B_)if(t.data.events.some(a=>a.data.type===r&&!a.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(t):this.objectsPerEvents.set(i,[t]);let a={id:t.uuid,name:t.name},s=zne(r,a),n=this.splineEvents[i];n?n[t.uuid]=s:this.splineEvents[i]={[t.uuid]:s}}}}),this.objectsPerEvents.forEach(t=>{t.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Fne=class{constructor(e,t,i,r,a,s){if(this.id=e,this.data=t,this.object=i,this.entered=!1,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Lr(t,t.actions,r,a,s,i)}disconnect(){oa(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.SwitchCamera.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,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.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},Une=class extends Ia{constructor(e,t,i){super(e),this.eventManager=t,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=r=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(r);let{raycaster:a,page:s}=this.eventContext,n=gg(a,s,[],!0);this.sceneInterects=n,n.length&&(this.eventContext.sharedAssets.raycastProperty={x:n[0].point.x,y:n[0].point.y,z:n[0].point.z,objX:n[0].object.matrixWorld.elements[12],objY:n[0].object.matrixWorld.elements[13],objZ:n[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(a=>{(a.data.type==="MouseDown"||a.data.type==="MousePress")&&(this.onCanvasRaycast(r),a.dispatch())})},this.onCanvasMouseUp=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(a=>{a.data.type==="MouseUp"?(this.onCanvasRaycast(r),a.dispatch()):a.data.type==="MousePress"&&a.dispatchRelease()})},this.onMouseDown=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseDown"))},this.onMouseUp=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent())},this.onMousePressRelease=r=>{Ot.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent(!0))},this.onKeyDown=r=>{this.heldKeys[r.key]||(this.handleKeyEvent(r,"KeyDown"),this.handleKeyEventHeld(r,"KeyDown",!0)),this.heldKeys[r.key]=!0},this.onKeyUp=r=>{this.handleKeyEvent(r,"KeyUp"),this.handleKeyEventHeld(r,"KeyUp",!0)},this.onKeyPressDown=r=>{this.heldKeysPress[r.key]?this.handleKeyEventHeld(r,"KeyPress"):(this.handleKeyEvent(r,"KeyPress"),this.handleKeyEventHeld(r,"KeyPress",!0)),this.heldKeysPress[r.key]=!0},this.onKeyPressUp=r=>{this.handleKeyEvent(r,"KeyPress",!0)},this.releaseHeldKey=r=>{delete this.heldKeys[r.key]},this.releaseHeldKeyPress=r=>{delete this.heldKeysPress[r.key]},this._onUserEvent=({eventName:r,target:a,reverse:s})=>{if(!r||!a)return;let n=nf(r);n&&(n==="MouseDown"||n==="MouseUp"||n==="MousePress"?(a.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[a.uuid]?.forEach(o=>{o.dispatchUserEvent(s)}),this.canvasMouseEvents.forEach(o=>{o.dispatchUserEvent(s)})):(n==="KeyDown"||n==="KeyUp"||n==="KeyPress")&&(a.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[a.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext,r=(a,s)=>{if(!a.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];if(a.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:c})=>{try{let d=new Fne(h,c,a,e,t,this.eventManager);d.actions.Video.length&&(this.hasVideoAction=!0),(c.type==="MouseDown"||c.type==="MouseUp"||c.type==="MousePress")&&(c.mode==="Canvas"||c.mode==="Window")?this.canvasMouseEvents.push(d):(l[a.uuid]?l[a.uuid].some(u=>u.id===d.id)||l[a.uuid].push(d):l[a.uuid]=[d],a instanceof Wh&&a.traverseChildren(u=>{if(!u.visible)return!0;u instanceof Xi&&"shapeBlendNode"in u.data.geometry&&u.data.geometry.shapeBlendNode?.operation!==2&&(l[u.uuid]?l[u.uuid].push(d):l[u.uuid]=[d])}))}catch{}}),l[a.uuid]?.length&&(this.objectsPerTypes[o].push(a instanceof la&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress")?s:a),a instanceof Wh)){let h=this.objectsPerTypes[o];a.traverseChildren(c=>{if(!c.visible)return!0;c instanceof Xi&&h.indexOf(c)===-1&&h.push(c)})}}};e.traverseEntity(a=>{(a instanceof Ta||a instanceof ia)&&a.frame?.traverse(s=>{r(s,a)}),r(a)}),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(([a,s])=>{s.forEach(n=>{n.addEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(a=>{a.object.addEventListener("userEvent",this._onUserEvent)})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(t=>{t.object.removeEventListener("userEvent",this._onUserEvent)})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r,pointerScreen:a}=this.eventContext,s=this.objectsPerTypes[e],n=s.filter(o=>!(o instanceof la));if(!(!s.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&Co(r,[a.x,a.y],Object.keys(this.eventsPerObjects[e]),o=>{this.handleObjectMouseEventDispatch(o,e)}))){if(t||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=gg(i,r,n,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),t){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];Hb(o).forEach(h=>{h instanceof Ta&&Co(h,l,Object.keys(this.eventsPerObjects[e]),c=>{this.handleObjectMouseEventDispatch(c,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=Sv(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof Ta&&Co(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(s=>!(s instanceof la)),a=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=Co(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),c=>{a.push(c)})),s&&!h){let c=gg(n,o,r);a=Hb(c),c.forEach(d=>{d.object instanceof Ta&&Co(d.object,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),u=>{a.push(u)})})}else r.forEach(c=>{let d=Sv(n,c);d&&(a.push(c),c instanceof Ta&&Co(c,[d?.uv?.x??0,d?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),u=>{a.push(u)}))})}this._prevObjects.length&&this._prevObjects.forEach(s=>{a.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),a.length&&a.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=a}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let a=this.eventsPerObjects[t][r.uuid];a.some(({data:s})=>"key"in s&&s.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),a.forEach(s=>{"key"in s.data&&s.data.key===e.key&&(i?s.dispatchRelease():s.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}},Nne=new O,Vne=new O,O4=class{constructor(e,t,i,r,a){this.actionsIn=Lr(e,e.inActions,i,r,a,t),this.actionsOut=Lr(e,e.outActions,i,r,a,t)}disconnect(){oa(this.actionsIn),oa(this.actionsOut)}},jne=class extends O4{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let u of this.objects)if(!u.visible)return;let h=Nne.setFromMatrixPosition(this.objects[0].matrixWorld),c=Vne.setFromMatrixPosition(this.objects[1].matrixWorld),d=h.distanceTo(c)<=this.distance?"in":"out";if(this.stage!==d){this.stage=d;let u=d==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Particles.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Link.forEach(p=>p.dispatch()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.Animation.forEach(p=>p.play()),u.TimelineAnimation.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),u.SceneTransition.forEach(p=>p.dispatch()),u.SetVariable.forEach(p=>p.checkConditions()),u.SetVariable.forEach(p=>p.dispatch()),u.DynamicVariablePlay.forEach(p=>p.dispatch()),u.ClearLocalStorage.forEach(p=>p.dispatch()),u.UserAPI.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let c=r.find(h);if(!c)throw new Error("Missing property");this.objects.push(c)}}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)})}},Hne=class extends O4{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(c=>c.dispatchConditional()),this.actionsOut.Particles.forEach(c=>c.dispatchConditional()),this.actionsOut.Video.forEach(c=>c.dispatchConditional()),this.actionsOut.Link.forEach(c=>c.dispatch()),this.actionsOut.Create.forEach(c=>c.dispatch()),this.actionsOut.Destroy.forEach(c=>c.dispatch()),this.actionsOut.Reset.forEach(c=>c.dispatch()),this.actionsIn.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(c=>c.play()),this.actionsOut.Animation.forEach(c=>c.play()),this.actionsOut.TimelineAnimation.forEach(c=>c.play()),this.actionsIn.SwitchCamera.forEach(c=>c.pause()),this.actionsOut.SwitchCamera.forEach(c=>c.play()),this.actionsOut.SceneTransition.forEach(c=>c.dispatch()),this.actionsOut.SetVariable.forEach(c=>c.checkConditions()),this.actionsOut.SetVariable.forEach(c=>c.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(c=>c.dispatchConditional()),this.actionsIn.Particles.forEach(c=>c.dispatchConditional()),this.actionsIn.Video.forEach(c=>c.dispatchConditional()),this.actionsIn.Link.forEach(c=>c.dispatch()),this.actionsIn.Create.forEach(c=>c.dispatch()),this.actionsIn.Destroy.forEach(c=>c.dispatch()),this.actionsIn.Reset.forEach(c=>c.dispatch()),this.actionsOut.Transition.forEach(c=>c.pause()),this.actionsOut.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(c=>c.play()),this.actionsIn.Animation.forEach(c=>c.play()),this.actionsIn.TimelineAnimation.forEach(c=>c.play()),this.actionsOut.SwitchCamera.forEach(c=>c.pause()),this.actionsIn.SwitchCamera.forEach(c=>c.play()),this.actionsIn.SceneTransition.forEach(c=>c.dispatch()),this.actionsIn.SetVariable.forEach(c=>c.checkConditions()),this.actionsIn.SetVariable.forEach(c=>c.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object)??r.scene.find2D(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){Sh(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),Sh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),Sh(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),Sh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Gne=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:t}=this.eventContext;e.traverseEntity(i=>{if(i.data?.events.length){for(let{id:r,data:a}of i.data.events)if(!a.disabled&&a.type==="Conditional")try{let s;a.condition.type==="Comparison"||(a.condition.type==="Distance"?s=new jne(r,a,i,e,t,this.eventManager):a.condition.type==="State"&&(s=new Hne(r,a,i,e,t,this.eventManager))),s&&(this.eventsPerConditions[a.condition.type].push(s),(s.actionsIn.Video.length||s.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Uu=new O,ml=new O,dh=new O,QT=new Ka,Wne=.01,bi=new O,jr=new O,KT=new O,Ph=new Rt,wy=new xr,qne=new je,_y=new Dr,Nc=new O,En=new O,Vc=.2;function Sy(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Xne=function(){let e=new je;return(t,i,r)=>{let a=t.obj;e.copy(a.hiddenMatrix),a.parent!==null&&e.premultiply(a.parent.matrixWorld),e.invert(),a.position.copy(i),t.reference==="global"&&Sy(a.position,t.limits),a.position.applyMatrix4(e),t.reference==="parent"?Sy(a.position,t.limits):t.reference==="local"&&(Ph.copy(t.quat0).invert(),a.position.sub(t.position0),a.position.applyQuaternion(Ph),Sy(a.position,t.limits),Ph.invert(),a.position.applyQuaternion(Ph),a.position.add(t.position0)),e.multiply(r??a.matrixWorld).decompose(bi,a.quaternion,jr),a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldSVD()),a instanceof Sa&&zo(a.parent)&&a.invalidateDownstreamBooleanData(!0)}}(),Yne=class{constructor(e,t,i,r,a,s,n){this.object=e,this.id=t,this.data=i,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=Lr(i,i.dragDropActions.drag,r,a,s,this.object),this.actionsDrop=Lr(i,i.dragDropActions.drop,r,a,s,this.object);let o=[];this.data.objects.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(o.push(h),n[h.uuid]&&n[h.uuid].forEach(c=>{let d=r.find(c);!d||d.data.visible!==!1&&o.push(d)}))}),this.data.dropDestinations.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(this.dropDestIds.push(h.uuid),n[h.uuid]&&n[h.uuid].forEach(c=>{let d=r.find(c);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=o.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new O().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new O().setFromMatrixPosition(l.matrixWorld),pointStart:new O,pointEnd:new O,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new O().copy(l.position),quat0:new Rt().copy(l.quaternion),snapped:!1,orientationMatrix:new je,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){oa(this.actionsDrag),oa(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},Qne=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=i=>{if(Ot.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:a}=this.eventContext,s=a.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let n of this.events){let o=0;for(let{obj:l,pointEnd:h,pointStart:c}of n.dragItems){if(l===s[0].object||l===s[0].object.object||oi.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(n.activeIdx=o,n.activeDragItem.reset=!1,n.activeDragItem.currentDampingFactor=n.data.dampingFactor,n.activeDragItem.snapped=!1,n.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){n.activeDragItem.obj.rigidBody&&n.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=n.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(bi,Ph,jr),wy.setFromQuaternion(Ph),d.prevR===void 0?(d.prevR=wy.clone(),d.prevT=bi.clone()):(d.prevR.copy(wy),d.prevT.copy(bi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(n.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,n.data.plane,n.data.referenceFrame),h.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||n.data.drop===!1||n.data.resetOnSnapFail===!1)&&n.activeDragItem.fromPosition.setFromMatrixPosition(n.activeDragItem.obj.matrixWorld),this.activeEvent=n,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}o++}}this.activeEvent=null},this.onPointerMove=i=>{if(Ot.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:a}=this.eventContext,s=a.raycastWithClones(r);if(Ot.length===0){let n=!1;for(let o of this.events){for(let{obj:l}of o.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||oi.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(n=!0,o.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(n)break}n||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let n=this.activeEvent.activeDragItem;n.snapped=!1;let o;if(this.activeEvent.data.drop&&(o=s.filter(l=>n.obj!==l.object&&!n.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof yd)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(h=>h===l.object.uuid||a.scene.find(h).isAncestorOf(l.object.uuid))))[0]),o){let l=KT.copy(o.face.normal).applyMatrix3(_y.getNormalMatrix(o.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")n.fromPosition.setFromMatrixPosition(o.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(n.fromPosition.copy(o.point),this.activeEvent.data.snapSurfaceMode==="bbox"){bi.copy(l).applyMatrix3(_y.setFromMatrix4(n.obj.matrixWorld).transpose());let h=n.obj;bi.x>Vc?jr.x=-h.recursiveBBox.min.x:bi.x<-Vc&&(jr.x=-h.recursiveBBox.max.x),bi.y>Vc?jr.y=-h.recursiveBBox.min.y:bi.y<-Vc&&(jr.y=-h.recursiveBBox.max.y),bi.z>Vc?jr.z=-h.recursiveBBox.min.z:bi.z<-Vc&&(jr.z=-h.recursiveBBox.max.z),jr.applyMatrix3(_y.invert())}else jr.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);n.fromPosition.add(jr)}this.activeEvent.data.autoOrient&&(bi.set(0,1,0).cross(l),bi.length()<1e-4&&bi.set(-1,0,0).cross(l),jr.crossVectors(KT,bi),n.orientationMatrix.makeBasis(bi,jr,l)),n.pointStart.copy(n.fromPosition),n.pointEnd.copy(n.pointStart),n.currentDampingFactor=this.activeEvent.snapDampingFactor,n.snapped=!0,this.lastDropDestination!==o.object&&(this.lastDropDestination=o.object,this.activeEvent.actionsDrop.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(h=>{h.dispatchThrottled()}))}else n.orientationMatrix.makeRotationFromQuaternion(n.quat0),this.lastDropDestination=null,n.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(n.obj,n.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(n),n.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=i=>{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(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(a=>a.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(r=>r.data.type==="DragDrop"&&!r.data.disabled).forEach(r=>{this.events.push(new Yne(i,r.id,r.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let t=this.eventContext.domElement;t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:a,raycaster:s}=this.eventContext;a().getWorldDirection(ml),ml.negate();let n=Ph.identity();switch(r==="parent"?qne.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(bi,n,jr):r==="local"&&e.matrixWorld.decompose(bi,n,jr),i){case"x":bi.set(1,0,0).applyQuaternion(n),Nc.copy(ml).cross(bi),En.copy(bi).cross(Nc);break;case"y":bi.set(0,1,0).applyQuaternion(n),Nc.copy(ml).cross(bi),En.copy(bi).cross(Nc);break;case"z":bi.set(0,0,1).applyQuaternion(n),Nc.copy(ml).cross(bi),En.copy(bi).cross(Nc);break;case"xy":En.set(0,0,1).applyQuaternion(n);break;case"yz":En.set(1,0,0).applyQuaternion(n);break;case"xz":En.set(0,1,0).applyQuaternion(n);break;case"adaptive":ml.angleTo(jr.set(0,1,0))>Math.PI/6?(bi.crossVectors(jr.set(0,1,0),ml),En.crossVectors(bi,jr)):En.set(0,1,0);break;default:En.copy(ml);break}dh.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:dh;if(QT.setFromNormalAndCoplanarPoint(En,o),!!s.ray.intersectPlane(QT,t)&&(i==="x"||i==="y"||i==="z")){let l=jr.subVectors(t,o).dot(bi);t.copy(o).addScaledVector(bi,l)}}updateDragItem(e,t=!1){dh.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Uu.subVectors(e.fromPosition,dh).divideScalar(e.currentDampingFactor):e.reset==="original"?(Uu.subVectors(e.obj.userData.worldPosition0,dh).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Uu.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(dh).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Uu.length()<Wne:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Xne(e,Uu.add(dh),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},jc=new O,Ay=new O,go=new O,vo=new O,ZT=new Ka,Kne=.01,Zne={type:"requestRender"},Jne=function(){let e=new O,t=new O;return(i,r,a)=>a>0?(e.subVectors(i,r),e.length()<=a?i:t.copy(r).add(e.normalize().multiplyScalar(a))):r}(),JT=function(){let e=new je;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Sa&&zo(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),$ne=class{constructor(e,t,i,r,a,s){this.data=e,this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new O,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...mx.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Lr(e,e.actions,r,a,s,i)}},eoe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(Ot.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let a=r.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);a&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new $ne(a.data,a.id,r,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),hs&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let a=r.target,s=this.onTargetChange(r);this.pairOfEventListeners.push([a,s]),a.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),hs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,oa(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:a}=e.data;if(e.object.getWorldPosition(go),e.isReset)vo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(vo);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(Ay),Ay.negate(),jc.copy(Ay)):i==="xy"?jc.set(0,0,1):i==="xz"?jc.set(0,1,0):i==="yz"&&jc.set(1,0,0),ZT.setFromNormalAndCoplanarPoint(jc,go),!o.ray.intersectPlane(ZT,vo))return}if(!e.isReset){if(vo.distanceTo(e.worldPosition0)>r&&a&&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)vo.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&&(vo.x=go.x),e.data.enabledTranslation[1]===!1&&(vo.y=go.y),e.data.enabledTranslation[2]===!1&&(vo.z=go.z);let s=Jne(go,vo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=jc.subVectors(s,go).divideScalar(e.currentDampingFactor);go.add(n),t&&JT(e.object,go),e.paused=n.length()<Kne}else JT(e.object,s),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(Zne)}},Nu=new O,Ym=new O,Vu=new je,Hc=new Rt,gl=new Rt,ju=new O,Hu=new O,uh=new O,yo=new O,My=new Ka,toe=1e-6,ioe={type:"requestRender"},roe={type:"changeRotation"},$T=function(){let e=new je;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(C4(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Sa&&zo(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),aoe=class{constructor(e,t,i,r){this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new Rt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...gx.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),isNaN(this.worldQuaternion0.x)&&(this.worldQuaternion0.x=0),isNaN(this.worldQuaternion0.y)&&(this.worldQuaternion0.y=0),isNaN(this.worldQuaternion0.z)&&(this.worldQuaternion0.z=0),isNaN(this.worldQuaternion0.w)&&(this.worldQuaternion0.w=1),this.resetDampingFactor=80/this.data.resetSpeed+1}},soe=class extends Ia{constructor(){super(...arguments),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=e=>{if(!(Ot.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let t of this.events)t.target===void 0&&this.updateSingleEvent(t)}},this.onMouseEnter=e=>{for(let t of this.events)t.target===void 0&&(t.isReset=!1,t.currentDampingFactor=t.data.dampingFactor)},this.onMouseLeave=e=>{for(let t of this.events)t.target===void 0&&(t.data.resetOnPointerLeave&&(t.isReset=!0,t.currentDampingFactor=t.resetDampingFactor),this.updateSingleEvent(t))},this.onScroll=e=>{if(this._lastMouseEvent){let t=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(t)}},this.onTargetChange=e=>()=>{this.updateSingleEvent(e)},this.createUserEventListener=e=>({eventName:t,target:i})=>{if(!t||!i)return;let r=nf(t);r&&r==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let a=r.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);a&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new aoe(a.data,a.id,r,e))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),hs&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let n=this.onTargetChange(r),o=r.target;this.pairOfEventListeners.push([o,n]),o.addEventListener("requestRender",n)}let a=this.createUserEventListener(r),s=r.object;this.pairOfUserEventListeners.push([s,a]),s.addEventListener("userEvent",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),hs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:a,limitDistance:s,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:c,target:d}=e;if(c.getWorldPosition(ju),!e.isReset)if(e.target)e.target.getWorldPosition(Hu);else{if(a==="custom"?(l().getWorldDirection(Ym),Ym.negate(),My.setFromNormalAndCoplanarPoint(Ym,ju)):(a==="xy"?Nu.set(0,0,1):a==="xz"?Nu.set(0,1,0):a==="yz"&&Nu.set(1,0,0),My.setFromNormalAndCoplanarPoint(Nu,ju)),!h.ray.intersectPlane(My,Hu))return;r>0&&(a==="custom"||a===void 0)&&Hu.addScaledVector(Ym,r)}if(e.isReset||(d?t==="target"?uh.copy(d.up).applyMatrix4(Vu.extractRotation(d.matrixWorld)).normalize():n.some(u=>u===!1)?(i==="x"?(yo.set(0,0,1),n[2]===!1&&yo.set(0,1,0)):i==="y"?(yo.set(1,0,0),n[0]===!1&&yo.set(0,0,1)):(yo.set(0,1,0),n[1]===!1&&yo.set(1,0,0)),uh.copy(yo).applyQuaternion(e.worldQuaternion0).normalize()):uh.set(0,1,0):a==="custom"?uh.set(0,1,0):uh.copy(Nu)),e.isReset)gl.copy(e.worldQuaternion0);else if(ju.distanceTo(Hu)>s&&o&&d)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)gl.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;noe(Vu,Hu,ju,uh,i,yo),gl.setFromRotationMatrix(Vu),Hc.setFromUnitVectors(yo.applyQuaternion(gl),uh),n.some(u=>u===!1)&&t!=="target"&&gl.premultiply(Hc).normalize()}e.currentDampingFactor>1?(c.updateWorldMatrix(!0,!1),Hc.setFromRotationMatrix(C4(c.matrixWorld)),Hc.slerp(gl,1/e.currentDampingFactor),$T(c,Vu.makeRotationFromQuaternion(Hc)),e.paused=8*(1-Hc.dot(gl))<toe):($T(c,Vu.makeRotationFromQuaternion(gl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),c.dispatchEvent(ioe),c.dispatchEvent(roe)}},Cs=new O,Vr=new O,vr=new O;function noe(e,t,i,r,a,s){let n=e.elements;vr.subVectors(t,i),vr.lengthSq()===0&&(vr.z=1),vr.normalize(),Vr.crossVectors(r,vr),Vr.lengthSq()===0&&(Math.abs(r.z)===1?vr.x+=1e-4:vr.z+=1e-4,vr.normalize(),Vr.crossVectors(r,vr)),Vr.normalize(),Cs.crossVectors(vr,Vr),a==="x"?s.z===1?[Vr,Cs,vr]=[vr,Vr,Cs]:(Vr.negate(),[Vr,vr]=[vr,Vr]):a==="y"?s.x===1?[Vr,Cs,vr]=[Cs,vr,Vr]:(Vr.negate(),[Cs,vr]=[vr,Cs]):s.x===1&&(Vr.negate(),[Vr,Cs]=[Cs,Vr]),n[0]=Vr.x,n[4]=Cs.x,n[8]=vr.x,n[1]=Vr.y,n[5]=Cs.y,n[9]=vr.y,n[2]=Vr.z,n[6]=Cs.z,n[10]=vr.z}var ooe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Lr(t,t.actions,r,a,s,i)}disconnect(){oa(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatchStart()),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()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()),this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),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())}},loe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=i=>{Ot.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onMouseUp=i=>{Ot.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=i=>{Ot.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=nf(i);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(n=>n.dispatchUserEvent(a)))}}connect(){let{page:e,sharedAssets:t}=this.eventContext,i=(a,s)=>{if(!(!a.visible||!a.data?.events.length)){for(let{id:n,data:o}of a.data.events)if(!o.disabled&&o.type==="MouseHover")try{let l=new ooe(n,o,a,e,t,this.eventManager);this.eventsPerObjects[a.uuid]?this.eventsPerObjects[a.uuid].push(l):this.eventsPerObjects[a.uuid]=[l]}catch{}this.eventsPerObjects[a.uuid]?.length&&this.objects.push(a instanceof la?s:a)}};if(e.traverseEntity(a=>{(a instanceof Ta||a instanceof ia)&&a.frame?.traverse(s=>{i(s,a)}),i(a)}),!this.objects.length)return;let{domElement:r}=this.eventContext;this.domEventsNeeded.clear(),hs&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),r.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(a=>{a.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),hs&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:a,pointerScreen:s}=this.eventContext,n=!1;if(a.uiCanvas&&(n=Co(a,[s.x,s.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=gg(r,a,this.objects);t=Hb(o),o.forEach(l=>{l.object instanceof Ta&&Co(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)})})}else this.objects.forEach(o=>{let l=Sv(r,o);l&&(t.push(o),o instanceof Ta&&Co(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},hoe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Lr(t,t.actions,r,a,s,i)}connect(){this.scrollCounter=0}disconnect(){oa(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.TimelineAnimation.forEach(r=>r.seek(i)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch()),this.actions.ClearLocalStorage.forEach(r=>r.dispatch()),this.actions.UserAPI.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()}),this.actions.TimelineAnimation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},coe=class{constructor(e,t,i,r,a,s,n){this.id=e,this.data=t,this.object=i,this.domElement=s,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Lr(t,t.actions,r,a,n,i)}getStickyParentElement(){let e=this.domElement;for(;e;){if(window.getComputedStyle(e).position==="sticky")return e;e=e.parentElement}return null}computeScrollBounds(){let e=this.getStickyParentElement(),t=e?.parentElement,i=this.domElement.getBoundingClientRect(),r={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(t){let h=t.getBoundingClientRect(),c=window.getComputedStyle(e),d=parseFloat(c.marginTop)+parseFloat(c.marginBottom),u=parseFloat(c.top),p=parseFloat(c.bottom),f=h.height-d;if(!isNaN(u))i.top===u?(r.top+=h.top-u,r.bottom+=h.top-u):i.top<0&&(r.top-=f-i.height,r.bottom-=f-i.height);else if(!isNaN(p)){let m=document.body.clientHeight??window.innerHeight,g=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===m-p?(r.top+=h.top-i.height+p+g,r.bottom+=h.top-i.height+p+g):i.bottom<m-p&&(r.top-=f-i.height,r.bottom-=f-i.height)}}let a=document.body,s=document.documentElement,n=window.pageYOffset||s.scrollTop||a.scrollTop,o=s.clientTop||a.clientTop||0,l=Math.round(r.top+n-o);if(this.data.startFrom==="enter"){let h=window.innerHeight,c=r.height,d=this.data.enterAnchor,u=d==="top"?h:d==="bottom"?h-c:h-c*.5;this.scrollStart=l-u}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=r,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){oa(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(a=>{a.object.currentTransitionEvent!==this&&(a.object.currentTransitionEvent=this,a.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(a=>a.seek(r)),this.actions.Animation.forEach(a=>a.seek(r)),this.actions.TimelineAnimation.forEach(a=>a.seek(r)),this.actions.Create.forEach(a=>a.dispatchThrottled()),this.actions.SetVariable.forEach(a=>a.checkConditions()),this.actions.SetVariable.forEach(a=>a.dispatch()),this.actions.DynamicVariablePlay.forEach(a=>a.dispatch()),this.actions.ClearLocalStorage.forEach(a=>a.dispatch()),this.actions.UserAPI.forEach(a=>a.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()}),this.actions.TimelineAnimation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},doe=class extends Ia{constructor(e,t){super(e),this.managers=t,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([i,r])=>{r.forEach(a=>a.handleResize())})},this.onScroll=i=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([a,s])=>{a.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(n=>n.dispatch(r))})},this.onWheel=i=>{!this.isInview||i.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,a])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:i.deltaY}),a.forEach(s=>s.dispatch(i.deltaY))})},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=nf(i);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}))}}connect(){let{page:e,sharedAssets:t,domElement:i,isExport:r}=this.eventContext,a=s=>{if(s.data?.events.length){for(let{id:n,data:o}of s.data.events)if(!o.disabled&&o.type==="Scroll")if(o.trigger==="load"||!r){let l=new hoe(n,o,s,e,t,this.managers);this.wheelEventsPerObject.has(s)?this.wheelEventsPerObject.get(s)?.push(l):this.wheelEventsPerObject.set(s,[l])}else{let l=new coe(n,o,s,e,t,i,this.managers);this.scrollEventsPerObject.has(s)?this.scrollEventsPerObject.get(s)?.push(l):this.scrollEventsPerObject.set(s,[l])}}};e.traverseEntity(s=>{(s instanceof Ta||s instanceof ia)&&s.frame?.traverse(n=>{a(n)}),a(s)}),this.intersectionObserver=new IntersectionObserver(s=>{let n=s[0];n&&(this.isInview=n.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([s,n])=>{n.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([s,n])=>{n.forEach(o=>o.connect()),s.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(s=>s.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},uoe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}disconnect(){oa(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.TimelineAnimation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),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.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Th?t.interaction.audioPlayer?.play():t.interaction instanceof Fb&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Bl?t.interaction.play(i==="autoplay"):t.interaction instanceof Vb&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}async seekVideos(e){let t=[];this.actions.Video.forEach(i=>{(i.interaction.data.triggerAfter??"autoplay")==="autoplay"&&i.interaction instanceof Bl&&t.push(i.interaction.seek(e))}),await Promise.all(t)}pauseVideos(){this.actions.Video.forEach(e=>{e.interaction instanceof Bl&&e.interaction.pause()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),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.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Th?t.interaction.audioPlayer?.play():t.interaction instanceof Fb&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Bl?t.interaction.play():t.interaction instanceof Vb&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},poe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,a=r?document:i;a.removeEventListener("pointerdown",this.onAny),a.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.actions.Audio.forEach(s=>{s.interaction instanceof Th&&s.interaction.audioPlayer?.play()}),a.actions.Video.forEach(s=>{let n=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Bl&&s.interaction.play(n==="autoplay")}),a.actions.Particles.forEach(s=>{s.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("autoplay")})})},this.seekVideos=async i=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([a,s])=>{!a.data.visible||s.forEach(n=>{r.push(n.seekVideos(i))})}),await Promise.all(r)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{r.forEach(a=>{a.pauseVideos()})})},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=nf(i);s&&s==="Start"&&(r instanceof la||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:a,data:s}of r.data.events){if(s.disabled||s.type!=="Start")continue;let n=new uoe(a,s,r,t,e,this.eventManager);(n.actions.Transition.length||n.actions.TimelineAnimation.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length||n.actions.Reset.length||n.actions.SetVariable.length||n.actions.DynamicVariablePlay.length||n.actions.ClearLocalStorage.length||n.actions.UserAPI.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}};if(t.traverseEntity(r=>{(r instanceof Ta||r instanceof ia)&&r.frame?.traverse(a=>{i(a)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:a}=this.eventContext,s=a?document:r;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,o])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,a])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(s=>s.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,a])=>{r.removeEventListener("userEvent",this.onUserEvent),a.forEach(s=>s.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},foe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=Lr(t,t.actions,r,a,s,i),this.target=t.target}disconnect(){oa(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},moe=class extends Ia{constructor(e,t,i,r,a){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=a,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.isOutOfFocus=!1,this.events=[],this.onFrame=s=>{let n=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let o=new Date,l=[],h=[];for(let u=0;u<this.propertiesToWatch.length;u++){let{objectId:p,property:f,prevValue:m}=this.propertiesToWatch[u],g=this.eventContext.scene.find(p),y=yx.propertyPaths[f];if(y[0]==="width"||y[0]==="height"||y[0]==="depth")g=g.geometry.userData.parameters[y[0]];else for(let x=0;x<y.length;x++)g=g[y[x]];m===null?this.propertiesToWatch[u].prevValue=g instanceof O?g.clone():g:(g instanceof O?!g.equals(m):m!==g)&&(h.push({objId:p,property:f}),g instanceof O?this.propertiesToWatch[u].prevValue.copy(g):this.propertiesToWatch[u].prevValue=g)}for(let u=0;u<this.variablesToWatch.length;u++){let{id:p,prevValue:f}=this.variablesToWatch[u],m=n.getVariable(p);m!==f&&(l.push(p),this.variablesToWatch[u].prevValue=m)}for(let u=0;u<this.dynamicVars.length;u++){let{id:p,expectedTime:f,last:m,data:g,timerSeconds:y,startValue:x}=this.dynamicVars[u],b=1e3;if((g.dynamicVariableType==="timer"||g.dynamicVariableType==="stopwatch")&&g.format==="number3decimal"?b=1:g.dynamicVariableType==="counter"?b=g.updateInterval:g.dynamicVariableType==="random"&&(b=g.isStatic?1/0:g.updateInterval),f===-1){this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+b;continue}if(!((n.getDynamicVariablePlayState(p)==="Stopped"||n.getDynamicVariablePlayState(p)==="Restarted")&&(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+b,g.dynamicVariableType==="counter"&&n.getVariable(p)!==x&&(n.updateVariable(p,x),this.eventManager.requestRender()),(g.dynamicVariableType==="timer"||g.dynamicVariableType==="stopwatch")&&this.dynamicVars[u].timerSeconds!==x&&(this.dynamicVars[u].timerSeconds=x,n.updateVariable(p,Is.getFormattedTimerTime(x,g)),this.eventManager.requestRender()),n.getDynamicVariablePlayState(p)==="Restarted"&&n.setDynamicVariablePlayState(p,"Playing"),n.getDynamicVariablePlayState(p)==="Stopped"))){if(n.getDynamicVariablePlayState(p)==="Paused"){this.dynamicVars[u].deltaToExpectedTime===void 0&&(this.dynamicVars[u].deltaToExpectedTime=Math.max(this.dynamicVars[u].expectedTime-s,0)),this.dynamicVars[u].last=s-(b-this.dynamicVars[u].deltaToExpectedTime),this.dynamicVars[u].expectedTime=s+this.dynamicVars[u].deltaToExpectedTime;continue}else this.dynamicVars[u].deltaToExpectedTime=void 0;if(s>=f)if(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime+=b,g.dynamicVariableType==="random"){let _=g.min+Math.random()*(g.max-g.min),S=g.decimals;_=Math.round(_*Math.pow(10,S))/Math.pow(10,S),n.updateVariable(p,_),l.push(p),this.eventManager.requestRender()}else if(g.dynamicVariableType==="counter"){let _=n.getVariable(p),S=n.getDynamicVariableToggleIsForward(p)??!0,A=n.getVariable(p)+g.increment*(S?1:-1);g.hasEnd&&(A=g.increment>0?tt.clamp(A,x,g.endValue):tt.clamp(A,g.endValue,x),A===x&&n.setDynamicVariableToggleIsForward(p,void 0),g.repeat?A===g.endValue&&(A=x):(A===x||A===g.endValue)&&n.setDynamicVariablePlayState(p,"Paused")),A!==_&&(l.push(p),n.updateVariable(p,A),this.eventManager.requestRender())}else if(g.dynamicVariableType==="time"){let _=n.getVariable(p),S=CC(o,g);if(typeof _=="object"&&"textValue"in _&&typeof S=="object"&&"textValue"in S){if(Array.isArray(_.textValue)&&Array.isArray(S.textValue)){if(_.textValue.every((A,E)=>A===S.textValue[E]))continue}else if(_.textValue===S.textValue)continue}else if(_===S)continue;n.updateVariable(p,S),l.push(p),this.eventManager.requestRender()}else{let _=ba.isTextValue(g.endValue)?e3(g.endValue.textValue):g.endValue,S=n.getDynamicVariableToggleIsForward(p)??!0,A=y+(s-m)/1e3*(g.dynamicVariableType==="timer"?-1:1)*(S?1:-1);A=Math.max(A,0),g.hasEnd&&(A=g.dynamicVariableType==="stopwatch"?tt.clamp(A,x,_):tt.clamp(A,_,x),A===x&&n.setDynamicVariableToggleIsForward(p,void 0),g.repeat?Math.abs(A-_)<(g.format==="number3decimal"?1e-4:.1)&&(A=x):(Math.abs(A-x)<(g.format==="number3decimal"?1e-4:.1)||Math.abs(A-_)<(g.format==="number3decimal"?1e-4:.1))&&n.setDynamicVariablePlayState(p,"Paused")),A!==y&&(l.push(p),this.dynamicVars[u].timerSeconds=A,n.updateVariable(p,Is.getFormattedTimerTime(A,g)),this.eventManager.requestRender())}}}let c=!1;n.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=n.mouseProperty,c=!0);let d=!1;n.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=n.raycastProperty,d=!0),this.events.forEach(u=>{(l.includes(u.data.variableId)||h.find(p=>p.objId===u.data.objectId&&p.property===u.data.property)||u.data.variableId==="mouseProperty"&&c||u.data.variableId==="raycastProperty"&&d)&&(u.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 t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new goe(i.id,i.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(t=>t.data.variableId==="objectProperty"&&t.data.objectId!==null).map(t=>({objectId:t.data.objectId,property:t.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:t,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(a=>a.data.variableId===t)&&this.variablesToWatch.push({id:t,prevValue:e.getVariable(t)});return}let r;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let a;if(ba.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let s=i.value.textValue;s.length===3?a=s[2]+s[1]*60+s[0]*3600:a=s[1]+s[0]*60}else a=i.value;r=a,this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,timerSeconds:a,startValue:r})}else i.dynamicVariableType==="time"&&e.updateVariable(t,CC(new Date,i)),i.dynamicVariableType==="counter"&&(r=ba.isTextValue(i.value)?e3(i.value.textValue):i.value),this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,startValue:r})}),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())}},goe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispose(){oa(this.actions)}};function e3(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var voe="https://unpkg.com/@splinetool/runtime@1.12.56/build/",yoe="https://unpkg.com/@splinetool/navmesh-wasm@1.12.56/build/",xoe=`
8143
8143
  (async function() {
8144
8144
  const [wasmImport, wasmBinary] = await Promise.all([
8145
8145
  import('${voe}' + 'navmesh.js'),
@@ -8207,7 +8207,7 @@ onmessage = function(messageEvent) {
8207
8207
  `),M.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),M.addEventListener("touchend",P=>P.preventDefault()),this.joysticks[p]=[void 0,f];return}let A={zone:f,mode:"static",position:b,size:m};y==="hide"&&(A.restOpacity=0);let E=Nse.create(A);E.on("move",(M,T)=>{let P=this.gameControl;u==="pos"?T.force<.2?P.moveForce=0:(P.movementState.movePosZ=Math.sin(-T.angle.radian),P.movementState.movePosX=Math.cos(-T.angle.radian),T.force>1.2?P.movementState.run=1:P.movementState.run=0,T.force<.3?P.moveForce=(T.force-.2)/.1:P.moveForce=1):u==="rot"&&(T.force<.2?P.rotForce=0:(P.movementState.rotPosX=T.vector.y,P.movementState.rotPosY=-T.vector.x,T.force<.3?P.rotForce=(T.force-.2)/.1:P.rotForce=1)),this.requestRender()}),E.on("end",(M,T)=>{let P=this.gameControl;u==="pos"?(P.movementState.movePosZ=0,P.movementState.movePosX=0,P.moveForce=1):u==="rot"&&(P.movementState.rotPosX=0,P.movementState.rotPosY=0,P.rotForce=1)}),this.joysticks[p]=[E,f]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(u=>u.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new pi.World(new pi.Vector3(0,this.gravity,0)),this.events=new pi.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(n=>{let o;if(n instanceof Ls)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof wa)o=n.object;else{if(n instanceof gp||n instanceof mp)return;if(o=n,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l=o.dataPatched,h;for(let g of l.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(h=g.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;n.updateMatrixWorldSVD();let c=Av(l),d=!1,u=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of l.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new foe(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(x=>x.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(g.data.type==="Follow"){f=!0;let y=g.data.target;n.traverseVisible(x=>{x.userData.isFollowingObj=y})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(n.matrixWorldFusedFalse=n.matrixWorld.clone());let m=n.geometry;if(h!==void 0){let g=pi.RigidBodyDesc.kinematicPositionBased();(n.hasNonUniformScale?n.matrixWorldRigid:n.matrixWorld).decompose(Er,Js,vl),n.position0=Er.clone().divideScalar(this.pixelsPerMeter),n.rotation0=Js.clone(),Er.divideScalar(this.pixelsPerMeter),g.setTranslation(Er.x,Er.y,Er.z).setRotation(Js);let y=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);n.rigidBody=y;let x;h.collider.type==="sphere"?x=pi.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?x=pi.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):x=pi.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(pi.CoefficientCombineRule.Average).setRestitutionCombineRule(pi.CoefficientCombineRule.Average).setDensity(l.physics.density).setFriction(l.physics.friction).setRestitution(l.physics.restitution);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(x,y);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),Er.fromArray(h.collider.position.map(S=>typeof S=="number"?S:0)).multiply(vl.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(Er);let _=new Rt().setFromEuler(new xr().setFromVector3(new O().fromArray(h.collider.rotation.map(S=>typeof S=="number"?S:0))));b.setRotationWrtParent(_),b.setActiveEvents(pi.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||c||f||u||p||d?(this.addRigidBody(n,o,{hasFollow:f,hasTransformAnim:c,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(m&&e.push(Eo(m,n.matrixWorld)),l.physics.fusedBody&&n.traverseObject((g,y)=>{if(y===0)return;let x;if(g instanceof Ls)if(g.objectForSample){if(g.objectForSample.dataPatched.physics.fusedBody)return;x=g.object}else return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(g instanceof gp||g instanceof mp)return;if(g instanceof wa)x=g.object;else if(x=g,x.dataPatched.cloner?.hideBase)return!0}let b=x.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;_?.getAttribute("position")!==void 0&&e.push(Eo(_,g.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=Ch(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=pi.RigidBodyDesc.fixed(),a=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),s=pi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(pi.CoefficientCombineRule.Multiply).setRestitutionCombineRule(pi.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(s,a);for(let[n,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(n,a);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new s3(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new je().compose($s.fromArray(t.data.position.map(a=>typeof a=="number"?a:0)),Wc.setFromEuler(n3.fromArray(t.data.rotation.map(a=>typeof a=="number"?a:0))),Oy);if(t.data.triggerZone==="box"){let a=new wr;a.min.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(-.5),a.max.fromArray(t.data.size.map(s=>typeof s=="number"?s:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([a,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e,t,i){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),r=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let a=.016666666666666666;if(e===0)r=this.stepPhysics()&&r;else{let s=e/1e3;s<a&&s>a*.55&&(s=a),this.accumulator+=s;let n=performance.now(),o=0,l=6;for(;this.accumulator>=a&&o<l&&(r=this.stepPhysics()&&r,this.accumulator-=a,o++,!(performance.now()-n>a*1e3)););this.accumulator=this.accumulator%a}}this.skipRender=r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Er,Js,vl),Dy.setFromQuaternion(Js);let t=e;t.prevR===void 0?(t.prevR=Dy.clone(),t.prevT=Er.clone()):(t.prevR.copy(Dy),t.prevT.copy(Er)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(Er.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(Js))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent,a;if(t.cloner){for(let s of t.cloner.children)if(s.rigidBody===r){a=s;break}}e.dispatch(a),t.dispatchEvent(Gb)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=o3.copy(e.matrixWorld).invert();e.traverseEntity((a,s)=>{if(t===!1&&s===1)return!0;for(let n of a.dataPatched.events)if(n.data.type==="Trigger"&&n.data.disabled!==!0){let o=new s3(n.id,n.data,a,this.page,this.sharedAssets,this.eventManager),l;if(n.data.triggerZone==="box"?l=pi.ColliderDesc.cuboid(...n.data.size.map(h=>(typeof h=="number"?h:1)/(2*this.pixelsPerMeter))):l=pi.ColliderDesc.ball(n.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(pi.ActiveEvents.COLLISION_EVENTS),$s.fromArray(n.data.position.map(h=>typeof h=="number"?h:0)),Wc.setFromEuler(n3.fromArray(n.data.rotation.map(h=>typeof h=="number"?h:0))),Jm.compose($s,Wc,Oy).premultiply(a.matrixWorld),i?(Jm.decompose($s,Wc,Iy),l.setActiveCollisionTypes(pi.ActiveCollisionTypes.KINEMATIC_FIXED|pi.ActiveCollisionTypes.DYNAMIC_FIXED)):(Jm.premultiply(r).decompose($s,Wc,Iy),e.rigidBody.bodyType()===pi.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===pi.RigidBodyType.Fixed?l.setActiveCollisionTypes(pi.ActiveCollisionTypes.KINEMATIC_FIXED|pi.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(pi.ActiveCollisionTypes.KINEMATIC_KINEMATIC|pi.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),$s.divideScalar(this.pixelsPerMeter),l.setTranslation($s.x,$s.y,$s.z),l.setRotation(Wc),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,a,s]=this.sharedGameControlGlobals.triggers[t];for(let n=0;n<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;n++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[n];if(a===o||s.isValidTriggeringObject(oi.is(o)?o:o.object)===!1)continue;let l=o3.copy(a.matrixWorld).decompose($s,l3,Iy).compose($s,l3,Oy).multiply(r),h=Jm.copy(o.matrixWorld).invert().multiply(l);i instanceof wr?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(Ry.radius=i,Ry.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(Ry)),e?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),a.dispatchEvent(Boe)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(c=>c!==o)}}}};function Foe(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,a=this.time+e,s=this._loopCount,n=r===qb;if(e===0)return s===-1?a:n&&(s&1)===1?t-(a-i):a;if(r===M3){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(a>=t)a=t;else if(a<0)a=0;else{this.time=a;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),a>=t||a<i){let o=Math.floor((a-i)/(t-i));a-=(t-i)*o,s+=Math.abs(o);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n||(a=e>0?t:i,this.repetitions===1&&(a=t)),this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,n)}else this._setEndings(!1,!1,n);this._loopCount=s,this.time=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=a;if(n&&(s&1)===1)return t-(a-i)}return a}var h3=!1,Uoe=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=a=>{a.data.type==="Empty"&&a.data.animations&&a.data.animations.forEach((s,n)=>{let o=s[0]+"/";if(Array.isArray(a.identity)?o+=a.identity[0]:o+=a.uuid,this.clipIdToAction[o])return;let l=Xy.parse(JSON.parse(s[2]));a.animations[n]=l;let h=this.mixer.clipAction(l,a);h3===!1&&(Object.getPrototypeOf(h)._updateTime=Foe,h3=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new R8(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(s=>s.uuid===e);if(!r)return;let a=this.clipIdToAction[e];!a||(a.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(s=>s.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=E3}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=qb)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return g4(this.activeClip??void 0)}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(e/(this.maxFrames-1),.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},Ly=new WeakMap,Noe=class extends Yp{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let a=new Yy(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,s=>{this.decodeDracoFile(s,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(Ly.has(e)){let o=Ly.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,a=this.workerNextTaskID++,s=e.byteLength,n=this._getWorker(a,s).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[a]={resolve:l,reject:h},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return n.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),Ly.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new vt;e.index&&t.setIndex(new Pt(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],a=r.name,s=r.array,n=r.itemSize;t.setAttribute(a,new Pt(s,n))}return t}_loadLibrary(e,t){let i=new Yy(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,a)=>{i.load(e,r,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let a=Voe.toString(),s=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
8208
8208
  `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(a){let s=a.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,a){return r._taskLoad>a._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function Voe(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(c){e.onModuleLoaded=function(d){c({draco:d})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(c=>{let d=c.draco,u=new d.Decoder,p=new d.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(d,u,p,h),m=f.attributes.map(g=>g.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{d.destroy(p),d.destroy(u)}});break}};function i(n,o,l,h){let c=h.attributeIDs,d=h.attributeTypes,u,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)u=new n.Mesh,p=o.DecodeBufferToMesh(l,u);else if(f===n.POINT_CLOUD)u=new n.PointCloud,p=o.DecodeBufferToPointCloud(l,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let m={index:null,attributes:[]};for(let g in c){let y=self[d[g]],x,b;if(h.useUniqueIDs)b=c[g],x=o.GetAttributeByUniqueId(u,b);else{if(b=o.GetAttributeId(u,n[c[g]]),b===-1)continue;x=o.GetAttribute(u,b)}m.attributes.push(a(n,o,u,g,y,x))}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,u)),n.destroy(u),m}function r(n,o,l){let h=l.num_faces()*3,c=h*4,d=n._malloc(c);o.GetTrianglesUInt32Array(l,c,d);let u=new Uint32Array(n.HEAPF32.buffer,d,h).slice();return n._free(d),{array:u,itemSize:1}}function a(n,o,l,h,c,d){let u=d.num_components(),p=l.num_points()*u,f=p*c.BYTES_PER_ELEMENT,m=s(n,c),g=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,d,m,f,g);let y=new c(n.HEAPF32.buffer,g,p).slice();return n._free(g),{name:h,array:y,itemSize:u}}function s(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var zl;function c3(e){return zl||(zl=new Noe,zl.setDecoderPath(e?`${e}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),zl.decoderPending}async function joe(e){if(zl){let t={attributeIDs:zl.defaultAttributeIDs,attributeTypes:zl.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await zl.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,a])=>({name:r,itemSize:a.itemSize,array:a.array}))}}return null}async function Hoe(e,t){let[i,r]=xD(Hg.deserialize(new Uint8Array(e)));return FD(i),t&&t(i),r.result().data}function Goe(e){let t=[];return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function d3(e){for(let t of e){let i=await joe(t.geometry.data.draco);if(i){let r=t.geometry.data;i.index&&(r.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};i.attributes.forEach(({name:s,array:n,itemSize:o})=>{a[s]={array:n,itemSize:o,type:"Float32Array",normalized:!1}}),r.attributes=a,r.draco=void 0}}}var Woe=class{constructor(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0],this._delay=500,this._distance=2,this._onMouseDown=e=>{let t=[e.clientX,e.clientY],i=new Date().getTime();if(this._clickCount>0){let r=t[0]-this._lastPosition[0],a=t[1]-this._lastPosition[1];Math.sqrt(r*r+a*a)>this._distance&&(this._clickCount=0)}this._lastPosition=t,this._clickCount=i-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=i},this._onMouseUp=e=>{}}start(e,t=500,i=2){this._target&&this.stop(),this.reset(),this._delay=t,this._distance=i,this._target=e,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]}},qoe=class{constructor(e,t,i,r,a,s,n,o){this.eventId=e,this.id=t,this.data=i,this.dataEvent=r,this.object=a,this.stage=!1,this.actions=Lr(r,i.actions,s,n,o,a)}disconnect(){oa(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},Xoe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(a=>{let s=vx.deviceToSize(a.data.size),n=a.dataEvent.orientation==="horizontal"?i:r,o;switch(a.data.operator){case"<":o=n<s[0];break;case">":o=n>s[0];break;case"<>":o=n>s[0]&&n<s[1];break}a.stage!==o&&(a.stage=o,a.stage?a.dispatchIn():a.dispatchOut())})},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:a,height:s}=r.contentRect;this.resize(a,s)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let r=a=>{if(!(!a.visible||!a.data?.events.length))for(let{data:s,id:n}of a.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:o,id:l})=>{try{let h=new qoe(n,l,o,s,a,e,t,this.eventManager);this.breakpoints.push(h)}catch{}})};e.traverseEntity(a=>{(a instanceof Ta||a instanceof ia)&&a.frame?.traverse(s=>{r(s)}),r(a)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},Yoe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.userAPIs={},this.events=[],this.onSuccess=({userAPIId:i})=>{this.events.forEach(r=>{r.data.userAPIId===i&&r.dispatchSuccess()})},this.onError=({userAPIId:i})=>{this.events.forEach(r=>{r.data.userAPIId===i&&r.dispatchError()})},this.userAPIs=e.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="API"&&!t.data.disabled).forEach(t=>{this.events.push(new Qoe(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([e,t])=>{t.on("success",this.onSuccess),t.on("error",this.onError),t.autostart&&t.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([e,t])=>{t.off("success",this.onSuccess),t.off("error",this.onError)})}},Qoe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.successActions=Lr(t,t.successActions,r,a,s,i),this.errorActions=Lr(t,t.errorActions,r,a,s,i)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},Koe=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.userWebhooks={},this.events=[],this.onMessage=({userWebhookId:i})=>{this.events.forEach(r=>{r.data.userWebhookId===i&&r.dispatch()})},this.userWebhooks=e.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="WEBHOOK"&&!t.data.disabled).forEach(t=>{this.events.push(new Zoe(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([e,t])=>{t.connect(),t.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([e,t])=>{t.off("message",this.onMessage),t.disconnect()})}},Zoe=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}};function Joe(){let e=document.createElement("textarea");return e.style.position="fixed",e.style.top="200px",e.style.left="400px",e.style.zIndex="-1",e.style.border="1px solid rgba(255,0,0,0.5)",e.style.width="10px",e.style.height="500px",e.style.color="white",e.style.opacity="0.5",e.style.background="transparent",e.style.display="none",e.style.margin="0px",e.style.padding="0px",e.style.boxSizing="content-box",e.style.pointerEvents="none",e}var $oe=new O(0,0,1),u3=new O,p3=new O,f3=new Dr,ele=class{constructor(e,t,i,r,a){this.containerScene=e,this.raycaster=t,this.sharedAssets=i,this.requestRender=r,this.onExit=a,this.htmlInput=null,this.virtualInput=null,this.helper=new PO,this.doubleClickHandler=new Woe,this.isDragging=!1,this.plane=new Ka,this.caretInterval=0,this.planeIntersection=new O,this.projected=new ae,this._lastIndex=0,this._isFirstDragMove=!1,this.selectionOnDragStart=0,this.onTextMaterialChanged=()=>{let s=this.virtualInput?.data;if(this.virtualInput!==void 0&&s){let n=s.material,o=typeof n=="string"?this.sharedAssets.data.materials[n]:n,l=iae(o,this.sharedAssets);this.helper.setCaretColor(l)}},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=s=>{if(!this.htmlInput||!this.virtualInput)return;let n=this.helper,o=s?.key==="ArrowLeft"||s?.key==="ArrowRight",l=s?.key==="ArrowUp"||s?.key==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(n.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:o,verticalKeyMove:l}),this.startAnimateTextCursor()):n.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()},this.containerScene.add(this.helper)}createInput(){return this.htmlInput=Joe(),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 e=this.doubleClickHandler.clickCount,{index:t,lineIndex:i,characterIndex:r}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,e>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0};this.virtualInput?.wrappedText?.length&&this.virtualInput.wrappedText[i][Math.max(0,r-1)]===`
8209
8209
  `&&(t--,r--),this._lastIndex=t,this._isFirstDragMove=!0;let a=this.checkClickedObject();if(e===1){if(a===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=t,this.isDragging=!0,this.setInputSelection(t)}else a===this.virtualInput&&(e===2?this.selectClosestWord(i,r):e>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(e){if(this.virtualInput=e,this.updateTextInputStyles(),this.htmlInput)if(e){let t=this.data?.geometry.text;this.htmlInput.value=typeof t=="string"?"":t?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:e}=this;if(e)return e.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let e=this.selectionOnDragStart,{index:t,lineIndex:i,characterIndex:r}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0};i!==void 0&&r!==void 0&&this.virtualInput?.wrappedText[i][r-1]===`
8210
- `&&t--,this.htmlInput.setSelectionRange(Math.min(e,t),Math.max(e,t))}checkClickedObject(){if(this.virtualInput){let e=this.raycaster.intersectObject(this.virtualInput,!1);if(e.length>0){let t=e[0];if(t.object instanceof T_)return t.object}}return null}selectClosestWord(e,t){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,r=i[e],a=t+1,s=t;r[t]!==" "&&(a=this.findNextCharOccurence(r,t,"forward"," "),s=this.findNextCharOccurence(r,t,"backward"," "),s>0&&s++,a>=r.length-1&&e===i.length-1&&a++);let n=this.helper,o=n.getGlobalIndexFromLineAndCharIndexes(i,e,s),l=n.getGlobalIndexFromLineAndCharIndexes(i,e,a);this.setInputSelection(o,l)}findNextCharOccurence(e,t,i,r=" "){let a=Math.max(0,e.length-1),s=i==="forward"?a:0,n=i==="forward"?1:-1,o=Math.max(Math.min(t,a),0);for(;o!==s;)if(o+=n,e.charAt(o)===r)return o;return s}getPointOnPlane(){let e=this.virtualInput?.data;if(!(!this.virtualInput||!e)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new O);let t=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(t){this.planeIntersection.copy(this.virtualInput.worldToLocal(t));let i=typeof e.geometry.width=="number"?e.geometry.width:1,r=typeof e.geometry.height=="number"?e.geometry.height:1;this.projected.set(t.x+i*.5,t.y-r*.5)}}}updatePlane(){let e=this.virtualInput?.data;this.virtualInput&&e&&(f3.getNormalMatrix(this.virtualInput.matrixWorld),u3.copy($oe).applyMatrix3(f3).normalize(),this.virtualInput.localToWorld(p3.set(0,0,e.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(u3,p3))}setInputSelection(e,t=e){this.htmlInput?.setSelectionRange(e,t),Qd&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let e=this.virtualInput?.data;this.virtualInput&&e&&this.htmlInput&&(this.htmlInput.style.fontSize=e.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=e.geometry.letterSpacing*e.geometry.fontSize+"px",this.htmlInput.style.lineHeight=e.geometry.fontSize*e.geometry.lineHeight+"px",this.htmlInput.style.width=e.geometry.width+"px",this.htmlInput.style.height=e.geometry.height+"px",this.htmlInput.style.textAlign=tle(e.geometry.horizontalAlign))}};function tle(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}var B4=(e,t)=>{if(typeof e=="string"){let i=t.data(e);if(i)return B4(i.value,t)}return ba.getDisplayedValue(e)};function m3(e,t){let i=e.text,r="";if(typeof i=="string"){let a=t.variables.data(r);a&&(r=B4(a.value,t.variables))}else r=i.textValue.toString();return r}var ile=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this._textInputs=[],this.sceneHelpers=new is,this.helper=new PO,this._onMouseDownFocusIn=i=>{if(Ot.length>1)return;this.eventContext.updateRaycaster(i);let r=null;if(this.eventContext.raycaster){for(let a of this._textInputs)if(this.eventContext.raycaster.intersectObject(a,!0).length>0){r=a;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===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:a}=this.eventContext;a.removeEventListener("pointerdown",this._onMouseDown,!1),a.removeEventListener("pointerup",this._onMouseUp,!1),a.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),a.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),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=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:r,virtualInput:a,helper:s}=this.textInputManager;if(!r||!a)return;let n=r.value;a.textGeometry.setText(n,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=a.data;s.update();let l=o.geometry.text;if(typeof l=="string"){let h=l;this.eventContext.sharedAssets.updateVariable(h,{textValue:n})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new ele(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(r=>{r instanceof T_&&e.push(r)}),this._textInputs=e,e.length===0)return;let{domElement:t}=this.eventContext;t.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:t,sharedAssets:i}=this.eventContext;t.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(r=>{let a=m3(r.data.geometry,this.eventContext.sharedAssets.data);r.textGeometry.setText(a,i)}),t.removeEventListener("pointerdown",this._onMouseDown,!1),t.removeEventListener("pointerup",this._onMouseUp,!1),t.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("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 t=this.textInputManager.htmlInput;if(!t||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=m3(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);t.value=i,t.setSelectionRange(0,0),this.textInputManager.helper.show(e),t.style.display="block",t.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),r.addEventListener("pointerdown",this._onMouseDown,!1),r.addEventListener("pointerup",this._onMouseUp,!1),r.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}},rle=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onVoice=({value:i,frequencies:r})=>{this.events.forEach(a=>{a.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantListener"&&!t.data.disabled).forEach(t=>{this.events.push(new ale(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},ale=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},sle=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onTriggerEvent=({description:i,direction:r})=>{let a=this.events.find(s=>s.data.description===i);a&&(r==="backward"?a.dispatchReverse():a.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantTrigger"&&!t.data.disabled).forEach(t=>{this.events.push(new nle(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},nle=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispatchReverse(){let e=this.actions;e.Transition.forEach(t=>t.reverseFromCurrent()),e.Particles.forEach(t=>t.reverseFromCurrent()),e.Animation.forEach(t=>t.reverseFromCurrent()),e.SwitchCamera.forEach(t=>t.reverseFromCurrent()),e.Create.forEach(t=>t.dispatchStop())}},ole=class{constructor(e,t,i,r,a){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=a,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=s=>{let n=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(s.touches.length>1||this.preventTouchScroll||n===!1&&o===!1)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.onMouseMove=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:s.buttons>0}},this.onMouseDown=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!0}},this.onMouseUp=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!1}},this.getMousePosition=s=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=s.touches?.length>0?s.touches[0]:s;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(e=!1){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new kne(this.eventContext),VariableChange:new moe(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),API:new Yoe(this.eventContext,this),WEBHOOK:new Koe(this.eventContext,this),AIAssistantListener:new rle(this.eventContext,this),AIAssistantTrigger:new sle(this.eventContext,this),Conditional:new Gne(this.eventContext,this),Start:new poe(this.eventContext,this),Basic:new Une(this.eventContext,this,this.needsRaycast),MouseHover:new loe(this.eventContext,this),Scroll:new doe(this.eventContext,this),Follow:new eoe(this.eventContext,this),DragDrop:new Qne(this.eventContext,this),LookAt:new soe(this.eventContext),Resize:new Xoe(this.eventContext,this),Textfields:new ile(this.eventContext,this)};let{page:t,domElement:i}=this.eventContext;this.hideCursor&&(i.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),i.addEventListener("wheel",this.onMouseWheelPreventScroll),i.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,e||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(e=!1){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:i}=this.eventContext;i.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}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),e||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}dispose(){this.deactivate(),Object.values(this.handlers).forEach(e=>e.dispose())}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length)for(let r of i.data.events)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let a of["inActions","outActions"])r.data[a].forEach(t);else if(r.data.type==="DragDrop")for(let a of["drag","drop"])r.data.dragDropActions[a].forEach(t);else if(r.data.type==="GameControl")for(let a of["idle","move","jump","run"])r.data.gameActions[a].forEach(t);else if(r.data.type==="Resize")for(let a of r.data.breakpoints)a.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.type==="API"||r.data.actions.forEach(t)})}},lle=class{constructor(e,t,i,r,a){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new ae().copy(i),this._editorSize=new ae().copy(r),this._aspect=t.aspect,this._fov=a??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let a=hle(t,1080,2160,1,15)/100;r*=t/i,r*=1-a}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function hle(e,t,i,r,a){return(e-t)/(i-t)*(a-r)+r}var cle=class{get sharedAssets(){return this.shared}constructor(e,t={},i=!0){this.shared=new v_(e.shared,t,!0,i),this.scene=new I_(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof ia&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Xi&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},dle=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function ule(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function bp(e){return e instanceof jp?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function ple(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Sa)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let a=r.parent;for(;a;){if(a instanceof Sa&&r.states&&Object.keys(r.states).length)return;a=a.parent}let s=r.material.uuid,n=t.shared.materials[s];if(n){if(!sa.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!sa.isMergable(l.material))return;s=sa.getHash(l.material)}}i[s]||(i[s]={});let o=i[s][bp(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[s][bp(r)]=[r],r.cloner)for(let l of r.cloner.children)i[s][bp(r)].push(l)}),i}function fle(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let a=r.length;a>t&&(t=a)})}),t}function mle(e,t){let i=ple(t,e),r=fle(i),a=new Array(r),s=0,n=new Array(r),o=0,l=new Array(r),h=0,c=new Array(r),d=0;for(let[u,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof Sa&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&ule(n[g]);let m=Ch(n.slice(0,o),!1);if(m){let g;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Fi(m,l[0].material);break}default:{g=new Fi(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=x=>{d=0;for(let b of x)b.children&&y(b.children),b instanceof Sa&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][bp(b)]&&i[b.material.uuid][bp(b)].length>1||(c[d++]=b));for(let b=0;b<d;b++)t.attach(c[b])};for(let x=0;x<h;x++){let b=l[x];y(b.children),a[s++]=b}}}for(let u=0;u<s;u++)a[u].removeFromParent()}var gle=Xl(vz(),1);function vle(e){let t=Array.isArray(e)?e[0]:e,i=t.layers.map(yle),r=t.layers.find(a=>a.type==="light");return{layers:i,alpha:r.node.alphaOverride?.value??1}}function yle(e){return e.type==="texture"||e.type==="video"||e.type==="matcap"?{...e.data,updateTexture(t){return e.color.texture.image.updateSrc(t)}}:{...e.data}}function xle(e,t,i){let r=Array.isArray(i)?i[0]:i;if(e[0]==="layers"){let a=parseInt(e[1]),s=r.layers[a],n=e[2];s&&n&&ble(e.slice(2),t,s)}else e[0]==="alpha"&&r.layers.forEach(a=>{a.type==="light"&&a.node.alphaOverride!==void 0&&(a.node.alphaOverride.value=t,t<1&&(r.transparent=!0))})}var Wu=new qr(0,0,0,1);function ble(e,t,i){let r=e[0];try{if(Sle(r,i.type,e.slice(1)))if(r==="colors"){if(e.length<2)throw new Error("You cannot mutate the colors array, only its items");let a=parseInt(e[1]),s=i.getValue(r)?.[a];if(s)Wu.setStyle(t),s.set(Wu.r,Wu.g,Wu.b,Wu.a);else throw new Error("Color index out of range")}else i.getValue(r)?.setStyle(t);else if(r==="texture"||r==="video"){let a=i.color;wle(e.slice(1),t,a,i)}else{let a=e[1],s=i.getValue(r);s?.isVector3&&a!==void 0||s?.isVector2&&a!==void 0?s.setComponent(parseInt(a),t):i.setValue(r,t)}}catch(a){console.error("Error setting material value",a)}}function wle(e,t,i,r){let a=e[0];if(a==="repeat"||a==="offset"){let s=e[1];if(s===void 0)t instanceof Array&&t.length===2&&Object.assign(i.mat,{[a]:t});else{let n=i.mat[a],o=parseInt(s)===0?[parseFloat(t),n[1]]:[n[0],parseFloat(t)];Object.assign(i.mat,{[a]:o})}i.mat.updateMatrix()}else a==="rotation"?(i.mat.rotation=parseFloat(t),i.mat.updateMatrix()):a==="wrapping"||a==="minFilter"||a==="magFilter"?a==="wrapping"?i.texture.wrap=t:i.texture[a]=t:a==="image"&&e[1]==="data"&&i.texture.image.updateSrc(t)}var _le={color:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],matcap:[],pattern:["colorA","colorB"],light:[],displace:[],rainbow:[],particle:[]};function Sle(e,t,i){return!!_le[t]?.includes(e)}var Ale=new ae;function Mle(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}function g3(e){let t=new qr(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}finally{return t}}var z_=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r}={}){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=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(s=>{s.type==="ParticleSystem"&&(s.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 s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Ale.set(this._viewportWidth,this._viewportHeight)),a){let s=this._viewportWidth,n=this._viewportHeight;this._renderer.setSize(s-1,n-1,!1),this._renderer.setSize(s,n,!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 s=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(s!=="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=Dp(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,r&&(this._wasmPath=jX(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 dle({x:10,y:10})),tY(e)}async load(e,t,i){Mle(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;Uo.init();let r=await Hoe(e);this._data=r;let a=Goe(r);r.version&&(0,gle.default)(r.version,"1.12.54")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath&&this.setUIWasmUrl(`${this._wasmPath}/ui.wasm`),await Promise.all([a.length&&c3(this._wasmPath),ZC(r)&&f$(this._wasmPath),xte(r)&&c$(this._wasmPath),zp.physicsEnabled(r.scene.objects)&&nY(),XC(r)&&Kee(),ET(r)&&Ese(),Yee(r)&&Xee(),vT(r)&&fae(),Eoe(r)&&aY(this._wasmPath)].filter(Boolean)),a.length&&await d3(a),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new cle(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let l=performance.now();mle(r,s.scene);let h=performance.now();console.log("Merged geometries in ",h-l," ms")}ZC(r)&&this._scene.traverse(l=>{zo(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Ls&&l.pendingMediaLoad&&l.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(l=>{l.type==="ParticleSystem"&&(l.wakeUp(),l.data.autoPlay?l.start():l.stop())});let n=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);if(Promise.all(n).then(()=>{this.disposed||(s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),XC(r)&&zoe(r)&&await Promise.all(n),vT(r)){let l=[];this._scene.traverseEntity(h=>{(h instanceof Ta||h instanceof ia)&&h.uiCanvas&&l.push(h.uiCanvas)}),await Promise.all(l.map(h=>h.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),L_(this._scene.activePage,this._sharedAssetsManager),!this._renderer){this._renderer=new eae({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let l=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),h=this._getPixelRatio(l()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(h),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let c=this._sharedAssetsManager.getImage("SplineWatermark");await c.loadPromise;let d=c.getTexture(1001);this._renderer.pipeline.setWatermark(d)}}ET(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let o=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.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=o.size[0],this._viewportHeight=o.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 lle(this._renderer,this._camera,new ae(this._viewportWidth,this._viewportHeight),new ae(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),t){let l=new Bne(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new koe(l),this._animationControls=new Uoe(this._scene,this._requestRenderAutoMode),this._eventManager=new ole(r.scene.publish,this._controls,this._animationControls,l,r.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.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let a=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,a),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&ba.isTextValue(e)?ba.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Zd&&!this._scene.isInvisibleObjects(t)&&!(t instanceof ia)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof L4&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=g3(e);this._scene?.activePage.setBackgroundColor(t),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,$$(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(e=>{jA.unsubscribe(e)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,iY(this.canvas),document.removeEventListener("scroll",this._onScroll),Uo.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene)return;let t=this._scene;if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let i;e.traverseAncestors(h=>{h instanceof ia&&(i=h.name)});let r=this._sharedAssetsManager,a={shared:r,scene:this._scene},s=h=>{if(h===null||h==="Base State")return null;if(h&&e.data.states){let c=e.data.states.find(d=>d.data.name===h);return c?c.id:void 0}},n="material"in e?e.material:void 0,o={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:i,material:n?vle(n):void 0,parentUuid:e.parent instanceof ia||e instanceof I_?void 0:e.parent?.uuid,emitEvent(h){e.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){e.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){e.visible&&(e.visible=!1,a.shared.requestRender())},show(){e.visible||(e.visible=!0,a.shared.requestRender())},get state(){let h=e.stateSelection;if(h!==null)return e.data.states.find(({id:c})=>c===h)?.data.name},set state(h){let c;if(h!==void 0){let d=typeof h=="string"?e.data.states.find(({id:u})=>u===h):e.data.states[h];if(d)c=d.id;else{let u=typeof h=="string"?s(h):void 0;u&&(c=u)}}e.changeSelectedState(c??null,a),e.currentState=c??null,e.dispatchEvent({type:"completeState",state:c??null}),a.shared.requestRender()},transition(h){let c=this,d,u=Uo.timeline({autoplay:h.autoPlay??!0}),p={transition({from:f,to:m,duration:g,delay:y,...x}){let b=s(f);b===void 0&&(b=d);let _=s(m);d=_;let S=new Ub(e,b,_,{state:_,repeat:0,delay:y??0,delayDirection:"start-once",direction:"normal",duration:g??1e3,...x,...x.easing===6?Wg.defaultData:x.easing===5?qg.defaultData:{}},r,!1,t.activePage);return u.add({...S.params,begin:()=>{(f&&b||f==="Base State"&&!b)&&(c.state=b??void 0)},complete:()=>{c.state=_??void 0}},u.duration),this},play(){return u.play(),this},pause(){return u.pause(),this},reset(){return u.reset(),this},seek(f){return u.seek(f),this}};return p.transition(h),p},set color(h){let c=g3(h);if(gv.is(e)){e.color=c;return}else if(e.type!=="Mesh"||!("material"in e)||!(e instanceof Wl))return;let d={r:c.r,g:c.g,b:c.b,a:c.a},u=Array.isArray(e.material)?e.material[0]:e.material,p=u.data.layers.find(f=>f.data.type==="color")?.id;if(p)u.updateByOp({type:0,path:["layers",p],props:{color:{...d}}},u.data,a);else{let f=u.data,m=f.layers.find(A=>A.data.type==="light");if(!m)return;let g=f.layers.indexOf(m)===0?m:null,y=f.layers.at(g?f.layers.indexOf(g)+1:0),x=g?g.fi+(y?(y.fi-g.fi)/2:1):y?y.fi/2:1,b={type:4,fi:x,id:tt.generateUUID(),data:{...yr.defaultData("color"),color:d},localIndex:0},_=f.layers.insertAfterHelper(g?.id??null,1),S=f.layers.runOp({...b,fi:_[0]}).data;Object.assign(u.data,{layers:S}),u.updateByOp({...b,path:["layers"]},u.data,a)}}},l=jA(o,(h,c)=>{let d=e[h],u=Ele(h);u[0]==="material"&&n&&xle(u.slice(1),c,n),typeof d!="object"&&Object.getOwnPropertyDescriptor(e,h)?.writable&&(e[h]=c),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,l),l}setUIWasmUrl(e){lO.skiaWasmUrl=e}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(e,t){let i;if(typeof t=="string")if(t.endsWith(".splinegeometry")){let l=await(await fetch(t)).arrayBuffer();i=new Uint8Array(l)}else throw new Error("Only .splinegeometry format is supported");else i=t;let r=Hg.deserialize(i),a="data"in r&&r.data.draco!==void 0;a&&await c3(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e);if(!s){console.warn(`Object ${e} not found`);return}if(s.data.type!=="Mesh"||!(s instanceof Wl)){console.warn(`Object ${e} is not a mesh`);return}let n=s,o={...n.data,geometry:r};a&&await d3([o]),n.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of n.data.states){let h={...l.data};n.states||(n.states={}),n.states[l.id]=Il.patch(o,h)}return i}};function Ele(e){return e.split(".")}var t0=window,i0=t0.ShadowRoot&&(t0.ShadyCSS===void 0||t0.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,k_=Symbol(),z4=new WeakMap,of=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==k_)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(i0&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=z4.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&z4.set(i,t))}return t}toString(){return this.cssText}},k4=e=>new of(typeof e=="string"?e:e+"",void 0,k_),F_=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,a,s)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(a)+e[s+1],e[0]);return new of(i,e,k_)},U_=(e,t)=>{i0?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),a=t0.litNonce;a!==void 0&&r.setAttribute("nonce",a),r.textContent=i.cssText,e.appendChild(r)})},r0=i0?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return k4(i)})(e):e;var N_,a0=window,F4=a0.trustedTypes,Cle=F4?F4.emptyScript:"",U4=a0.reactiveElementPolyfillSupport,j_={toAttribute(e,t){switch(t){case Boolean:e=e?Cle:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},N4=(e,t)=>t!==e&&(t==t||e==e),V_={attribute:!0,type:String,converter:j_,reflect:!1,hasChanged:N4},H_="finalized",Yo=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let a=this._$Ep(r,i);a!==void 0&&(this._$Ev.set(a,r),t.push(a))}),t}static createProperty(t,i=V_){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,a=this.getPropertyDescriptor(t,r,i);a!==void 0&&Object.defineProperty(this.prototype,t,a)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(a){let s=this[t];this[i]=a,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||V_}static finalize(){if(this.hasOwnProperty(H_))return!1;this[H_]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let a of r)this.createProperty(a,i[a])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let a of r)i.unshift(r0(a))}else t!==void 0&&i.push(r0(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return U_(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=V_){var a;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let n=(((a=r.converter)===null||a===void 0?void 0:a.toAttribute)!==void 0?r.converter:j_).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$El=null}}_$AK(t,i){var r;let a=this.constructor,s=a._$Ev.get(t);if(s!==void 0&&this._$El!==s){let n=a.getPropertyOptions(s),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:j_;this._$El=s,this[s]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let a=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||N4)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):a=!1),!this.isUpdatePending&&a&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((a,s)=>this[s]=a),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(a=>{var s;return(s=a.hostUpdate)===null||s===void 0?void 0:s.call(a)}),this.update(r)):this._$Ek()}catch(a){throw i=!1,this._$Ek(),a}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var a;return(a=r.hostUpdated)===null||a===void 0?void 0:a.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Yo[H_]=!0,Yo.elementProperties=new Map,Yo.elementStyles=[],Yo.shadowRootOptions={mode:"open"},U4?.({ReactiveElement:Yo}),((N_=a0.reactiveElementVersions)!==null&&N_!==void 0?N_:a0.reactiveElementVersions=[]).push("1.6.3");var G_,s0=window,tu=s0.trustedTypes,V4=tu?tu.createPolicy("lit-html",{createHTML:e=>e}):void 0,q_="$lit$",Zl=`lit$${(Math.random()+"").slice(9)}$`,Y4="?"+Zl,Tle=`<${Y4}>`,ec=document,hf=()=>ec.createComment(""),cf=e=>e===null||typeof e!="object"&&typeof e!="function",Q4=Array.isArray,Ple=e=>Q4(e)||typeof e?.[Symbol.iterator]=="function",W_=`[
8210
+ `&&t--,this.htmlInput.setSelectionRange(Math.min(e,t),Math.max(e,t))}checkClickedObject(){if(this.virtualInput){let e=this.raycaster.intersectObject(this.virtualInput,!1);if(e.length>0){let t=e[0];if(t.object instanceof T_)return t.object}}return null}selectClosestWord(e,t){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,r=i[e],a=t+1,s=t;r[t]!==" "&&(a=this.findNextCharOccurence(r,t,"forward"," "),s=this.findNextCharOccurence(r,t,"backward"," "),s>0&&s++,a>=r.length-1&&e===i.length-1&&a++);let n=this.helper,o=n.getGlobalIndexFromLineAndCharIndexes(i,e,s),l=n.getGlobalIndexFromLineAndCharIndexes(i,e,a);this.setInputSelection(o,l)}findNextCharOccurence(e,t,i,r=" "){let a=Math.max(0,e.length-1),s=i==="forward"?a:0,n=i==="forward"?1:-1,o=Math.max(Math.min(t,a),0);for(;o!==s;)if(o+=n,e.charAt(o)===r)return o;return s}getPointOnPlane(){let e=this.virtualInput?.data;if(!(!this.virtualInput||!e)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new O);let t=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(t){this.planeIntersection.copy(this.virtualInput.worldToLocal(t));let i=typeof e.geometry.width=="number"?e.geometry.width:1,r=typeof e.geometry.height=="number"?e.geometry.height:1;this.projected.set(t.x+i*.5,t.y-r*.5)}}}updatePlane(){let e=this.virtualInput?.data;this.virtualInput&&e&&(f3.getNormalMatrix(this.virtualInput.matrixWorld),u3.copy($oe).applyMatrix3(f3).normalize(),this.virtualInput.localToWorld(p3.set(0,0,e.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(u3,p3))}setInputSelection(e,t=e){this.htmlInput?.setSelectionRange(e,t),Qd&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let e=this.virtualInput?.data;this.virtualInput&&e&&this.htmlInput&&(this.htmlInput.style.fontSize=e.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=e.geometry.letterSpacing*e.geometry.fontSize+"px",this.htmlInput.style.lineHeight=e.geometry.fontSize*e.geometry.lineHeight+"px",this.htmlInput.style.width=e.geometry.width+"px",this.htmlInput.style.height=e.geometry.height+"px",this.htmlInput.style.textAlign=tle(e.geometry.horizontalAlign))}};function tle(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}var B4=(e,t)=>{if(typeof e=="string"){let i=t.data(e);if(i)return B4(i.value,t)}return ba.getDisplayedValue(e)};function m3(e,t){let i=e.text,r="";if(typeof i=="string"){let a=t.variables.data(r);a&&(r=B4(a.value,t.variables))}else r=i.textValue.toString();return r}var ile=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this._textInputs=[],this.sceneHelpers=new is,this.helper=new PO,this._onMouseDownFocusIn=i=>{if(Ot.length>1)return;this.eventContext.updateRaycaster(i);let r=null;if(this.eventContext.raycaster){for(let a of this._textInputs)if(this.eventContext.raycaster.intersectObject(a,!0).length>0){r=a;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===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:a}=this.eventContext;a.removeEventListener("pointerdown",this._onMouseDown,!1),a.removeEventListener("pointerup",this._onMouseUp,!1),a.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),a.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),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=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:r,virtualInput:a,helper:s}=this.textInputManager;if(!r||!a)return;let n=r.value;a.textGeometry.setText(n,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=a.data;s.update();let l=o.geometry.text;if(typeof l=="string"){let h=l;this.eventContext.sharedAssets.updateVariable(h,{textValue:n})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new ele(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(r=>{r instanceof T_&&e.push(r)}),this._textInputs=e,e.length===0)return;let{domElement:t}=this.eventContext;t.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:t,sharedAssets:i}=this.eventContext;t.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(r=>{let a=m3(r.data.geometry,this.eventContext.sharedAssets.data);r.textGeometry.setText(a,i)}),t.removeEventListener("pointerdown",this._onMouseDown,!1),t.removeEventListener("pointerup",this._onMouseUp,!1),t.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("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 t=this.textInputManager.htmlInput;if(!t||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=m3(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);t.value=i,t.setSelectionRange(0,0),this.textInputManager.helper.show(e),t.style.display="block",t.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),r.addEventListener("pointerdown",this._onMouseDown,!1),r.addEventListener("pointerup",this._onMouseUp,!1),r.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}},rle=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onVoice=({value:i,frequencies:r})=>{this.events.forEach(a=>{a.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantListener"&&!t.data.disabled).forEach(t=>{this.events.push(new ale(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},ale=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},sle=class extends Ia{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onTriggerEvent=({description:i,direction:r})=>{let a=this.events.find(s=>s.data.description===i);a&&(r==="backward"?a.dispatchReverse():a.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantTrigger"&&!t.data.disabled).forEach(t=>{this.events.push(new nle(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},nle=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Lr(t,t.actions,r,a,s,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispatchReverse(){let e=this.actions;e.Transition.forEach(t=>t.reverseFromCurrent()),e.Particles.forEach(t=>t.reverseFromCurrent()),e.Animation.forEach(t=>t.reverseFromCurrent()),e.SwitchCamera.forEach(t=>t.reverseFromCurrent()),e.Create.forEach(t=>t.dispatchStop())}},ole=class{constructor(e,t,i,r,a){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=a,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=s=>{let n=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(s.touches.length>1||this.preventTouchScroll||n===!1&&o===!1)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.onMouseMove=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:s.buttons>0}},this.onMouseDown=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!0}},this.onMouseUp=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!1}},this.getMousePosition=s=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=s.touches?.length>0?s.touches[0]:s;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(e=!1){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new kne(this.eventContext),VariableChange:new moe(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),API:new Yoe(this.eventContext,this),WEBHOOK:new Koe(this.eventContext,this),AIAssistantListener:new rle(this.eventContext,this),AIAssistantTrigger:new sle(this.eventContext,this),Conditional:new Gne(this.eventContext,this),Start:new poe(this.eventContext,this),Basic:new Une(this.eventContext,this,this.needsRaycast),MouseHover:new loe(this.eventContext,this),Scroll:new doe(this.eventContext,this),Follow:new eoe(this.eventContext,this),DragDrop:new Qne(this.eventContext,this),LookAt:new soe(this.eventContext),Resize:new Xoe(this.eventContext,this),Textfields:new ile(this.eventContext,this)};let{page:t,domElement:i}=this.eventContext;this.hideCursor&&(i.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),i.addEventListener("wheel",this.onMouseWheelPreventScroll),i.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,e||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(e=!1){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:i}=this.eventContext;i.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}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),e||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}dispose(){this.deactivate(),Object.values(this.handlers).forEach(e=>e.dispose())}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length)for(let r of i.data.events)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let a of["inActions","outActions"])r.data[a].forEach(t);else if(r.data.type==="DragDrop")for(let a of["drag","drop"])r.data.dragDropActions[a].forEach(t);else if(r.data.type==="GameControl")for(let a of["idle","move","jump","run"])r.data.gameActions[a].forEach(t);else if(r.data.type==="Resize")for(let a of r.data.breakpoints)a.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.type==="API"||r.data.actions.forEach(t)})}},lle=class{constructor(e,t,i,r,a){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new ae().copy(i),this._editorSize=new ae().copy(r),this._aspect=t.aspect,this._fov=a??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let a=hle(t,1080,2160,1,15)/100;r*=t/i,r*=1-a}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function hle(e,t,i,r,a){return(e-t)/(i-t)*(a-r)+r}var cle=class{get sharedAssets(){return this.shared}constructor(e,t={},i=!0){this.shared=new v_(e.shared,t,!0,i),this.scene=new I_(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof ia&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Xi&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},dle=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function ule(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function bp(e){return e instanceof jp?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function ple(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Sa)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let a=r.parent;for(;a;){if(a instanceof Sa&&r.states&&Object.keys(r.states).length)return;a=a.parent}let s=r.material.uuid,n=t.shared.materials[s];if(n){if(!sa.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!sa.isMergable(l.material))return;s=sa.getHash(l.material)}}i[s]||(i[s]={});let o=i[s][bp(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[s][bp(r)]=[r],r.cloner)for(let l of r.cloner.children)i[s][bp(r)].push(l)}),i}function fle(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let a=r.length;a>t&&(t=a)})}),t}function mle(e,t){let i=ple(t,e),r=fle(i),a=new Array(r),s=0,n=new Array(r),o=0,l=new Array(r),h=0,c=new Array(r),d=0;for(let[u,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof Sa&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&ule(n[g]);let m=Ch(n.slice(0,o),!1);if(m){let g;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Fi(m,l[0].material);break}default:{g=new Fi(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=x=>{d=0;for(let b of x)b.children&&y(b.children),b instanceof Sa&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][bp(b)]&&i[b.material.uuid][bp(b)].length>1||(c[d++]=b));for(let b=0;b<d;b++)t.attach(c[b])};for(let x=0;x<h;x++){let b=l[x];y(b.children),a[s++]=b}}}for(let u=0;u<s;u++)a[u].removeFromParent()}var gle=Xl(vz(),1);function vle(e){let t=Array.isArray(e)?e[0]:e,i=t.layers.map(yle),r=t.layers.find(a=>a.type==="light");return{layers:i,alpha:r.node.alphaOverride?.value??1}}function yle(e){return e.type==="texture"||e.type==="video"||e.type==="matcap"?{...e.data,updateTexture(t){return e.color.texture.image.updateSrc(t)}}:{...e.data}}function xle(e,t,i){let r=Array.isArray(i)?i[0]:i;if(e[0]==="layers"){let a=parseInt(e[1]),s=r.layers[a],n=e[2];s&&n&&ble(e.slice(2),t,s)}else e[0]==="alpha"&&r.layers.forEach(a=>{a.type==="light"&&a.node.alphaOverride!==void 0&&(a.node.alphaOverride.value=t,t<1&&(r.transparent=!0))})}var Wu=new qr(0,0,0,1);function ble(e,t,i){let r=e[0];try{if(Sle(r,i.type,e.slice(1)))if(r==="colors"){if(e.length<2)throw new Error("You cannot mutate the colors array, only its items");let a=parseInt(e[1]),s=i.getValue(r)?.[a];if(s)Wu.setStyle(t),s.set(Wu.r,Wu.g,Wu.b,Wu.a);else throw new Error("Color index out of range")}else i.getValue(r)?.setStyle(t);else if(r==="texture"||r==="video"){let a=i.color;wle(e.slice(1),t,a,i)}else{let a=e[1],s=i.getValue(r);s?.isVector3&&a!==void 0||s?.isVector2&&a!==void 0?s.setComponent(parseInt(a),t):i.setValue(r,t)}}catch(a){console.error("Error setting material value",a)}}function wle(e,t,i,r){let a=e[0];if(a==="repeat"||a==="offset"){let s=e[1];if(s===void 0)t instanceof Array&&t.length===2&&Object.assign(i.mat,{[a]:t});else{let n=i.mat[a],o=parseInt(s)===0?[parseFloat(t),n[1]]:[n[0],parseFloat(t)];Object.assign(i.mat,{[a]:o})}i.mat.updateMatrix()}else a==="rotation"?(i.mat.rotation=parseFloat(t),i.mat.updateMatrix()):a==="wrapping"||a==="minFilter"||a==="magFilter"?a==="wrapping"?i.texture.wrap=t:i.texture[a]=t:a==="image"&&e[1]==="data"&&i.texture.image.updateSrc(t)}var _le={color:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],matcap:[],pattern:["colorA","colorB"],light:[],displace:[],rainbow:[],particle:[]};function Sle(e,t,i){return!!_le[t]?.includes(e)}var Ale=new ae;function Mle(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}function g3(e){let t=new qr(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}finally{return t}}var z_=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r}={}){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=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(s=>{s.type==="ParticleSystem"&&(s.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 s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Ale.set(this._viewportWidth,this._viewportHeight)),a){let s=this._viewportWidth,n=this._viewportHeight;this._renderer.setSize(s-1,n-1,!1),this._renderer.setSize(s,n,!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 s=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(s!=="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=Dp(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,r&&(this._wasmPath=jX(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 dle({x:10,y:10})),tY(e)}async load(e,t,i){Mle(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;Uo.init();let r=await Hoe(e);this._data=r;let a=Goe(r);r.version&&(0,gle.default)(r.version,"1.12.56")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath&&this.setUIWasmUrl(`${this._wasmPath}/ui.wasm`),await Promise.all([a.length&&c3(this._wasmPath),ZC(r)&&f$(this._wasmPath),xte(r)&&c$(this._wasmPath),zp.physicsEnabled(r.scene.objects)&&nY(),XC(r)&&Kee(),ET(r)&&Ese(),Yee(r)&&Xee(),vT(r)&&fae(),Eoe(r)&&aY(this._wasmPath)].filter(Boolean)),a.length&&await d3(a),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new cle(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let l=performance.now();mle(r,s.scene);let h=performance.now();console.log("Merged geometries in ",h-l," ms")}ZC(r)&&this._scene.traverse(l=>{zo(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Ls&&l.pendingMediaLoad&&l.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(l=>{l.type==="ParticleSystem"&&(l.wakeUp(),l.data.autoPlay?l.start():l.stop())});let n=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);if(Promise.all(n).then(()=>{this.disposed||(s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),XC(r)&&zoe(r)&&await Promise.all(n),vT(r)){let l=[];this._scene.traverseEntity(h=>{(h instanceof Ta||h instanceof ia)&&h.uiCanvas&&l.push(h.uiCanvas)}),await Promise.all(l.map(h=>h.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),L_(this._scene.activePage,this._sharedAssetsManager),!this._renderer){this._renderer=new eae({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let l=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),h=this._getPixelRatio(l()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(h),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let c=this._sharedAssetsManager.getImage("SplineWatermark");await c.loadPromise;let d=c.getTexture(1001);this._renderer.pipeline.setWatermark(d)}}ET(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let o=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.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=o.size[0],this._viewportHeight=o.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 lle(this._renderer,this._camera,new ae(this._viewportWidth,this._viewportHeight),new ae(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),t){let l=new Bne(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new koe(l),this._animationControls=new Uoe(this._scene,this._requestRenderAutoMode),this._eventManager=new ole(r.scene.publish,this._controls,this._animationControls,l,r.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.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let a=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,a),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&ba.isTextValue(e)?ba.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Zd&&!this._scene.isInvisibleObjects(t)&&!(t instanceof ia)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof L4&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=g3(e);this._scene?.activePage.setBackgroundColor(t),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,$$(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(e=>{jA.unsubscribe(e)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,iY(this.canvas),document.removeEventListener("scroll",this._onScroll),Uo.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene)return;let t=this._scene;if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let i;e.traverseAncestors(h=>{h instanceof ia&&(i=h.name)});let r=this._sharedAssetsManager,a={shared:r,scene:this._scene},s=h=>{if(h===null||h==="Base State")return null;if(h&&e.data.states){let c=e.data.states.find(d=>d.data.name===h);return c?c.id:void 0}},n="material"in e?e.material:void 0,o={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:i,material:n?vle(n):void 0,parentUuid:e.parent instanceof ia||e instanceof I_?void 0:e.parent?.uuid,emitEvent(h){e.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){e.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){e.visible&&(e.visible=!1,a.shared.requestRender())},show(){e.visible||(e.visible=!0,a.shared.requestRender())},get state(){let h=e.stateSelection;if(h!==null)return e.data.states.find(({id:c})=>c===h)?.data.name},set state(h){let c;if(h!==void 0){let d=typeof h=="string"?e.data.states.find(({id:u})=>u===h):e.data.states[h];if(d)c=d.id;else{let u=typeof h=="string"?s(h):void 0;u&&(c=u)}}e.changeSelectedState(c??null,a),e.currentState=c??null,e.dispatchEvent({type:"completeState",state:c??null}),a.shared.requestRender()},transition(h){let c=this,d,u=Uo.timeline({autoplay:h.autoPlay??!0}),p={transition({from:f,to:m,duration:g,delay:y,...x}){let b=s(f);b===void 0&&(b=d);let _=s(m);d=_;let S=new Ub(e,b,_,{state:_,repeat:0,delay:y??0,delayDirection:"start-once",direction:"normal",duration:g??1e3,...x,...x.easing===6?Wg.defaultData:x.easing===5?qg.defaultData:{}},r,!1,t.activePage);return u.add({...S.params,begin:()=>{(f&&b||f==="Base State"&&!b)&&(c.state=b??void 0)},complete:()=>{c.state=_??void 0}},u.duration),this},play(){return u.play(),this},pause(){return u.pause(),this},reset(){return u.reset(),this},seek(f){return u.seek(f),this}};return p.transition(h),p},set color(h){let c=g3(h);if(gv.is(e)){e.color=c;return}else if(e.type!=="Mesh"||!("material"in e)||!(e instanceof Wl))return;let d={r:c.r,g:c.g,b:c.b,a:c.a},u=Array.isArray(e.material)?e.material[0]:e.material,p=u.data.layers.find(f=>f.data.type==="color")?.id;if(p)u.updateByOp({type:0,path:["layers",p],props:{color:{...d}}},u.data,a);else{let f=u.data,m=f.layers.find(A=>A.data.type==="light");if(!m)return;let g=f.layers.indexOf(m)===0?m:null,y=f.layers.at(g?f.layers.indexOf(g)+1:0),x=g?g.fi+(y?(y.fi-g.fi)/2:1):y?y.fi/2:1,b={type:4,fi:x,id:tt.generateUUID(),data:{...yr.defaultData("color"),color:d},localIndex:0},_=f.layers.insertAfterHelper(g?.id??null,1),S=f.layers.runOp({...b,fi:_[0]}).data;Object.assign(u.data,{layers:S}),u.updateByOp({...b,path:["layers"]},u.data,a)}}},l=jA(o,(h,c)=>{let d=e[h],u=Ele(h);u[0]==="material"&&n&&xle(u.slice(1),c,n),typeof d!="object"&&Object.getOwnPropertyDescriptor(e,h)?.writable&&(e[h]=c),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,l),l}setUIWasmUrl(e){lO.skiaWasmUrl=e}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(e,t){let i;if(typeof t=="string")if(t.endsWith(".splinegeometry")){let l=await(await fetch(t)).arrayBuffer();i=new Uint8Array(l)}else throw new Error("Only .splinegeometry format is supported");else i=t;let r=Hg.deserialize(i),a="data"in r&&r.data.draco!==void 0;a&&await c3(this._wasmPath);let s=this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e);if(!s){console.warn(`Object ${e} not found`);return}if(s.data.type!=="Mesh"||!(s instanceof Wl)){console.warn(`Object ${e} is not a mesh`);return}let n=s,o={...n.data,geometry:r};a&&await d3([o]),n.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of n.data.states){let h={...l.data};n.states||(n.states={}),n.states[l.id]=Il.patch(o,h)}return i}};function Ele(e){return e.split(".")}var t0=window,i0=t0.ShadowRoot&&(t0.ShadyCSS===void 0||t0.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,k_=Symbol(),z4=new WeakMap,of=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==k_)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(i0&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=z4.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&z4.set(i,t))}return t}toString(){return this.cssText}},k4=e=>new of(typeof e=="string"?e:e+"",void 0,k_),F_=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,a,s)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(a)+e[s+1],e[0]);return new of(i,e,k_)},U_=(e,t)=>{i0?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),a=t0.litNonce;a!==void 0&&r.setAttribute("nonce",a),r.textContent=i.cssText,e.appendChild(r)})},r0=i0?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return k4(i)})(e):e;var N_,a0=window,F4=a0.trustedTypes,Cle=F4?F4.emptyScript:"",U4=a0.reactiveElementPolyfillSupport,j_={toAttribute(e,t){switch(t){case Boolean:e=e?Cle:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},N4=(e,t)=>t!==e&&(t==t||e==e),V_={attribute:!0,type:String,converter:j_,reflect:!1,hasChanged:N4},H_="finalized",Yo=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let a=this._$Ep(r,i);a!==void 0&&(this._$Ev.set(a,r),t.push(a))}),t}static createProperty(t,i=V_){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,a=this.getPropertyDescriptor(t,r,i);a!==void 0&&Object.defineProperty(this.prototype,t,a)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(a){let s=this[t];this[i]=a,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||V_}static finalize(){if(this.hasOwnProperty(H_))return!1;this[H_]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let a of r)this.createProperty(a,i[a])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let a of r)i.unshift(r0(a))}else t!==void 0&&i.push(r0(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return U_(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=V_){var a;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let n=(((a=r.converter)===null||a===void 0?void 0:a.toAttribute)!==void 0?r.converter:j_).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$El=null}}_$AK(t,i){var r;let a=this.constructor,s=a._$Ev.get(t);if(s!==void 0&&this._$El!==s){let n=a.getPropertyOptions(s),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:j_;this._$El=s,this[s]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let a=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||N4)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):a=!1),!this.isUpdatePending&&a&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((a,s)=>this[s]=a),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(a=>{var s;return(s=a.hostUpdate)===null||s===void 0?void 0:s.call(a)}),this.update(r)):this._$Ek()}catch(a){throw i=!1,this._$Ek(),a}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var a;return(a=r.hostUpdated)===null||a===void 0?void 0:a.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Yo[H_]=!0,Yo.elementProperties=new Map,Yo.elementStyles=[],Yo.shadowRootOptions={mode:"open"},U4?.({ReactiveElement:Yo}),((N_=a0.reactiveElementVersions)!==null&&N_!==void 0?N_:a0.reactiveElementVersions=[]).push("1.6.3");var G_,s0=window,tu=s0.trustedTypes,V4=tu?tu.createPolicy("lit-html",{createHTML:e=>e}):void 0,q_="$lit$",Zl=`lit$${(Math.random()+"").slice(9)}$`,Y4="?"+Zl,Tle=`<${Y4}>`,ec=document,hf=()=>ec.createComment(""),cf=e=>e===null||typeof e!="object"&&typeof e!="function",Q4=Array.isArray,Ple=e=>Q4(e)||typeof e?.[Symbol.iterator]=="function",W_=`[
8211
8211
  \f\r]`,lf=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j4=/-->/g,H4=/>/g,Jh=RegExp(`>|${W_}(?:([^\\s"'>=/]+)(${W_}*=${W_}*(?:[^
8212
8212
  \f\r"'\`<>=]|("|')|))|$)`,"g"),G4=/'/g,W4=/"/g,K4=/^(?:script|style|textarea|title)$/i,Z4=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),J4=Z4(1),b1e=Z4(2),tc=Symbol.for("lit-noChange"),ca=Symbol.for("lit-nothing"),q4=new WeakMap,$h=ec.createTreeWalker(ec,129,null,!1);function $4(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return V4!==void 0?V4.createHTML(t):t}var Dle=(e,t)=>{let i=e.length-1,r=[],a,s=t===2?"<svg>":"",n=lf;for(let o=0;o<i;o++){let l=e[o],h,c,d=-1,u=0;for(;u<l.length&&(n.lastIndex=u,c=n.exec(l),c!==null);)u=n.lastIndex,n===lf?c[1]==="!--"?n=j4:c[1]!==void 0?n=H4:c[2]!==void 0?(K4.test(c[2])&&(a=RegExp("</"+c[2],"g")),n=Jh):c[3]!==void 0&&(n=Jh):n===Jh?c[0]===">"?(n=a??lf,d=-1):c[1]===void 0?d=-2:(d=n.lastIndex-c[2].length,h=c[1],n=c[3]===void 0?Jh:c[3]==='"'?W4:G4):n===W4||n===G4?n=Jh:n===j4||n===H4?n=lf:(n=Jh,a=void 0);let p=n===Jh&&e[o+1].startsWith("/>")?" ":"";s+=n===lf?l+Tle:d>=0?(r.push(h),l.slice(0,d)+q_+l.slice(d)+Zl+p):l+Zl+(d===-2?(r.push(void 0),o):p)}return[$4(e,s+(e[i]||"<?>")+(t===2?"</svg>":"")),r]},ic=class{constructor({strings:t,_$litType$:i},r){let a;this.parts=[];let s=0,n=0,o=t.length-1,l=this.parts,[h,c]=Dle(t,i);if(this.el=ic.createElement(h,r),$h.currentNode=this.el.content,i===2){let d=this.el.content,u=d.firstChild;u.remove(),d.append(...u.childNodes)}for(;(a=$h.nextNode())!==null&&l.length<o;){if(a.nodeType===1){if(a.hasAttributes()){let d=[];for(let u of a.getAttributeNames())if(u.endsWith(q_)||u.startsWith(Zl)){let p=c[n++];if(d.push(u),p!==void 0){let f=a.getAttribute(p.toLowerCase()+q_).split(Zl),m=/([.?@])?(.*)/.exec(p);l.push({type:1,index:s,name:m[2],strings:f,ctor:m[1]==="."?Y_:m[1]==="?"?Q_:m[1]==="@"?K_:ru})}else l.push({type:6,index:s})}for(let u of d)a.removeAttribute(u)}if(K4.test(a.tagName)){let d=a.textContent.split(Zl),u=d.length-1;if(u>0){a.textContent=tu?tu.emptyScript:"";for(let p=0;p<u;p++)a.append(d[p],hf()),$h.nextNode(),l.push({type:2,index:++s});a.append(d[u],hf())}}}else if(a.nodeType===8)if(a.data===Y4)l.push({type:2,index:s});else{let d=-1;for(;(d=a.data.indexOf(Zl,d+1))!==-1;)l.push({type:7,index:s}),d+=Zl.length-1}s++}}static createElement(t,i){let r=ec.createElement("template");return r.innerHTML=t,r}};function iu(e,t,i=e,r){var a,s,n,o;if(t===tc)return t;let l=r!==void 0?(a=i._$Co)===null||a===void 0?void 0:a[r]:i._$Cl,h=cf(t)?void 0:t._$litDirective$;return l?.constructor!==h&&((s=l?._$AO)===null||s===void 0||s.call(l,!1),h===void 0?l=void 0:(l=new h(e),l._$AT(e,i,r)),r!==void 0?((n=(o=i)._$Co)!==null&&n!==void 0?n:o._$Co=[])[r]=l:i._$Cl=l),l!==void 0&&(t=iu(e,l._$AS(e,t.values),l,r)),t}var X_=class{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;let{el:{content:r},parts:a}=this._$AD,s=((i=t?.creationScope)!==null&&i!==void 0?i:ec).importNode(r,!0);$h.currentNode=s;let n=$h.nextNode(),o=0,l=0,h=a[0];for(;h!==void 0;){if(o===h.index){let c;h.type===2?c=new rc(n,n.nextSibling,this,t):h.type===1?c=new h.ctor(n,h.name,h.strings,this,t):h.type===6&&(c=new Z_(n,this,t)),this._$AV.push(c),h=a[++l]}o!==h?.index&&(n=$h.nextNode(),o++)}return $h.currentNode=ec,s}v(t){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,i),i+=r.strings.length-2):r._$AI(t[i])),i++}},rc=class{constructor(t,i,r,a){var s;this.type=2,this._$AH=ca,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=r,this.options=a,this._$Cp=(s=a?.isConnected)===null||s===void 0||s}get _$AU(){var t,i;return(i=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&i!==void 0?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode,i=this._$AM;return i!==void 0&&t?.nodeType===11&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=iu(this,t,i),cf(t)?t===ca||t==null||t===""?(this._$AH!==ca&&this._$AR(),this._$AH=ca):t!==this._$AH&&t!==tc&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Ple(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==ca&&cf(this._$AH)?this._$AA.nextSibling.data=t:this.$(ec.createTextNode(t)),this._$AH=t}g(t){var i;let{values:r,_$litType$:a}=t,s=typeof a=="number"?this._$AC(t):(a.el===void 0&&(a.el=ic.createElement($4(a.h,a.h[0]),this.options)),a);if(((i=this._$AH)===null||i===void 0?void 0:i._$AD)===s)this._$AH.v(r);else{let n=new X_(s,this),o=n.u(this.options);n.v(r),this.$(o),this._$AH=n}}_$AC(t){let i=q4.get(t.strings);return i===void 0&&q4.set(t.strings,i=new ic(t)),i}T(t){Q4(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,a=0;for(let s of t)a===i.length?i.push(r=new rc(this.k(hf()),this.k(hf()),this,this.options)):r=i[a],r._$AI(s),a++;a<i.length&&(this._$AR(r&&r._$AB.nextSibling,a),i.length=a)}_$AR(t=this._$AA.nextSibling,i){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,i);t&&t!==this._$AB;){let a=t.nextSibling;t.remove(),t=a}}setConnected(t){var i;this._$AM===void 0&&(this._$Cp=t,(i=this._$AP)===null||i===void 0||i.call(this,t))}},ru=class{constructor(t,i,r,a,s){this.type=1,this._$AH=ca,this._$AN=void 0,this.element=t,this.name=i,this._$AM=a,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ca}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,r,a){let s=this.strings,n=!1;if(s===void 0)t=iu(this,t,i,0),n=!cf(t)||t!==this._$AH&&t!==tc,n&&(this._$AH=t);else{let o=t,l,h;for(t=s[0],l=0;l<s.length-1;l++)h=iu(this,o[r+l],i,l),h===tc&&(h=this._$AH[l]),n||(n=!cf(h)||h!==this._$AH[l]),h===ca?t=ca:t!==ca&&(t+=(h??"")+s[l+1]),this._$AH[l]=h}n&&!a&&this.j(t)}j(t){t===ca?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Y_=class extends ru{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ca?void 0:t}},Ile=tu?tu.emptyScript:"",Q_=class extends ru{constructor(){super(...arguments),this.type=4}j(t){t&&t!==ca?this.element.setAttribute(this.name,Ile):this.element.removeAttribute(this.name)}},K_=class extends ru{constructor(t,i,r,a,s){super(t,i,r,a,s),this.type=5}_$AI(t,i=this){var r;if((t=(r=iu(this,t,i,0))!==null&&r!==void 0?r:ca)===tc)return;let a=this._$AH,s=t===ca&&a!==ca||t.capture!==a.capture||t.once!==a.once||t.passive!==a.passive,n=t!==ca&&(a===ca||s);s&&this.element.removeEventListener(this.name,this,a),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,r;typeof this._$AH=="function"?this._$AH.call((r=(i=this.options)===null||i===void 0?void 0:i.host)!==null&&r!==void 0?r:this.element,t):this._$AH.handleEvent(t)}},Z_=class{constructor(t,i,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){iu(this,t)}};var X4=s0.litHtmlPolyfillSupport;X4?.(ic,rc),((G_=s0.litHtmlVersions)!==null&&G_!==void 0?G_:s0.litHtmlVersions=[]).push("2.8.0");var df=(e,t,i)=>{var r,a;let s=(r=i?.renderBefore)!==null&&r!==void 0?r:t,n=s._$litPart$;if(n===void 0){let o=(a=i?.renderBefore)!==null&&a!==void 0?a:null;s._$litPart$=n=new rc(t.insertBefore(hf(),o),o,void 0,i??{})}return n._$AI(e),n};var J_,$_;var Jl=class extends Yo{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;let r=super.createRenderRoot();return(t=(i=this.renderOptions).renderBefore)!==null&&t!==void 0||(i.renderBefore=r.firstChild),r}update(t){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=df(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return tc}};Jl.finalized=!0,Jl._$litElement$=!0,(J_=globalThis.litElementHydrateSupport)===null||J_===void 0||J_.call(globalThis,{LitElement:Jl});var eR=globalThis.litElementPolyfillSupport;eR?.({LitElement:Jl});(($_=globalThis.litElementVersions)!==null&&$_!==void 0?$_:globalThis.litElementVersions=[]).push("3.3.3");var tR=e=>t=>typeof t=="function"?((i,r)=>(customElements.define(i,r),r))(e,t):((i,r)=>{let{kind:a,elements:s}=r;return{kind:a,elements:s,finisher(n){customElements.define(i,n)}}})(e,t);var Ole=(e,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(i){i.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}},Rle=(e,t,i)=>{t.constructor.createProperty(i,e)};function Fs(e){return(t,i)=>i!==void 0?Rle(e,t,i):Ole(e,t)}var e2,X1e=((e2=window.HTMLSlotElement)===null||e2===void 0?void 0:e2.prototype.assignedElements)!=null?(e,t)=>e.assignedElements(t):(e,t)=>e.assignedNodes(t).filter(i=>i.nodeType===Node.ELEMENT_NODE);var n0=window.IntersectionObserver!=null;var iR=(e=32,t=2)=>{let i=e/2;return J4` <style>
8213
8213
  :host {