@splinetool/runtime 0.9.400 → 0.9.402

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.js CHANGED
@@ -3135,9 +3135,9 @@ void main() {
3135
3135
  squared_mean = squared_mean / samples;
3136
3136
  float std_dev = sqrt( squared_mean - mean * mean );
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
- }`;function CF(i,t,e){let n=new Vh,r=new F,s=new F,o=new We,a=new Hh({depthPacking:Hx}),l=new vx,u={},c=e.maxTextureSize,d={[ai]:On,[On]:ai,[Lr]:Lr},h=new rt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:EF,fragmentShader:TF}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new Me;m.setAttribute("position",new Be(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Dn(m,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Nm,this.render=function(w,S,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let M=i.getRenderTarget(),b=i.getActiveCubeFace(),E=i.getActiveMipmapLevel(),T=i.state;T.setBlending(Ot),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let I=0,C=w.length;I<C;I++){let P=w[I],O=P.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);let B=O.getFrameExtents();if(r.multiply(B),s.copy(O.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/B.x),r.x=s.x*B.x,O.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/B.y),r.y=s.y*B.y,O.mapSize.y=s.y)),O.map===null){let Q=this.type!==Oh?{minFilter:Dt,magFilter:Dt}:{};O.map=new ot(r.x,r.y,Q),O.map.texture.name=P.name+".shadowMap",O.camera.updateProjectionMatrix()}i.setRenderTarget(O.map),i.clear();let j=O.getViewportCount();for(let Q=0;Q<j;Q++){let V=O.getViewport(Q);o.set(s.x*V.x,s.y*V.y,s.x*V.z,s.y*V.w),T.viewport(o),O.updateMatrices(P,Q),n=O.getFrustum(),x(S,_,O.camera,P,this.type)}O.isPointLightShadow!==!0&&this.type===Oh&&y(O,_),O.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(M,b,E)};function y(w,S){let _=t.update(p);h.defines.VSM_SAMPLES!==w.blurSamples&&(h.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ot(r.x,r.y)),h.uniforms.shadow_pass.value=w.map.texture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(S,null,_,h,p,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(S,null,_,f,p,null)}function v(w,S,_,M,b,E){let T=null,I=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(I!==void 0)T=I;else if(T=_.isPointLight===!0?l:a,i.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 C=T.uuid,P=S.uuid,O=u[C];O===void 0&&(O={},u[C]=O);let B=O[P];B===void 0&&(B=T.clone(),O[P]=B),T=B}return T.visible=S.visible,T.wireframe=S.wireframe,E===Oh?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:d[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,_.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(_.matrixWorld),T.nearDistance=M,T.farDistance=b),T}function x(w,S,_,M,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===Oh)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let I=t.update(w),C=w.material;if(Array.isArray(C)){let P=I.groups;for(let O=0,B=P.length;O<B;O++){let j=P[O],Q=C[j.materialIndex];if(Q&&Q.visible){let V=v(w,Q,M,_.near,_.far,b);i.renderBufferDirect(_,null,I,V,w,j)}}}else if(C.visible){let P=v(w,C,M,_.near,_.far,b);i.renderBufferDirect(_,null,I,P,w,null)}}let T=w.children;for(let I=0,C=T.length;I<C;I++)x(T[I],S,_,M,b)}}function PF(i,t,e){let n=e.isWebGL2;function r(){let Y=!1,oe=new We,ge=null,Ne=new We(0,0,0,0);return{setMask:function(Oe){ge!==Oe&&!Y&&(i.colorMask(Oe,Oe,Oe,Oe),ge=Oe)},setLocked:function(Oe){Y=Oe},setClear:function(Oe,bt,Tn,mn,Xa){Xa===!0&&(Oe*=mn,bt*=mn,Tn*=mn),oe.set(Oe,bt,Tn,mn),Ne.equals(oe)===!1&&(i.clearColor(Oe,bt,Tn,mn),Ne.copy(oe))},reset:function(){Y=!1,ge=null,Ne.set(-1,0,0,0)}}}function s(){let Y=!1,oe=null,ge=null,Ne=null;return{setTest:function(Oe){Oe?re(2929):K(2929)},setMask:function(Oe){oe!==Oe&&!Y&&(i.depthMask(Oe),oe=Oe)},setFunc:function(Oe){if(ge!==Oe){switch(Oe){case sR:i.depthFunc(512);break;case oR:i.depthFunc(519);break;case aR:i.depthFunc(513);break;case rx:i.depthFunc(515);break;case lR:i.depthFunc(514);break;case cR:i.depthFunc(518);break;case uR:i.depthFunc(516);break;case dR:i.depthFunc(517);break;default:i.depthFunc(515)}ge=Oe}},setLocked:function(Oe){Y=Oe},setClear:function(Oe){Ne!==Oe&&(i.clearDepth(Oe),Ne=Oe)},reset:function(){Y=!1,oe=null,ge=null,Ne=null}}}function o(){let Y=!1,oe=null,ge=null,Ne=null,Oe=null,bt=null,Tn=null,mn=null,Xa=null;return{setTest:function(Jt){Y||(Jt?re(2960):K(2960))},setMask:function(Jt){oe!==Jt&&!Y&&(i.stencilMask(Jt),oe=Jt)},setFunc:function(Jt,no,yi){(ge!==Jt||Ne!==no||Oe!==yi)&&(i.stencilFunc(Jt,no,yi),ge=Jt,Ne=no,Oe=yi)},setOp:function(Jt,no,yi){(bt!==Jt||Tn!==no||mn!==yi)&&(i.stencilOp(Jt,no,yi),bt=Jt,Tn=no,mn=yi)},setLocked:function(Jt){Y=Jt},setClear:function(Jt){Xa!==Jt&&(i.clearStencil(Jt),Xa=Jt)},reset:function(){Y=!1,oe=null,ge=null,Ne=null,Oe=null,bt=null,Tn=null,mn=null,Xa=null}}}let a=new r,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,I=null,C=null,P=null,O=null,B=i.getParameter(35661),j=!1,Q=0,V=i.getParameter(7938);V.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(V)[1]),j=Q>=1):V.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),j=Q>=2);let q=null,W={},X=i.getParameter(3088),L=i.getParameter(2978),U=new We().fromArray(X),G=new We().fromArray(L);function H(Y,oe,ge){let Ne=new Uint8Array(4),Oe=i.createTexture();i.bindTexture(Y,Oe),i.texParameteri(Y,10241,9728),i.texParameteri(Y,10240,9728);for(let bt=0;bt<ge;bt++)i.texImage2D(oe+bt,0,6408,1,1,0,6408,5121,Ne);return Oe}let z={};z[3553]=H(3553,3553,1),z[34067]=H(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(rx),ve(!1),Ee(z1),re(2884),ye(Ot);function re(Y){h[Y]!==!0&&(i.enable(Y),h[Y]=!0)}function K(Y){h[Y]!==!1&&(i.disable(Y),h[Y]=!1)}function Z(Y,oe){return f[Y]!==oe?(i.bindFramebuffer(Y,oe),f[Y]=oe,n&&(Y===36009&&(f[36160]=oe),Y===36160&&(f[36009]=oe)),!0):!1}function k(Y,oe){let ge=p,Ne=!1;if(Y)if(ge=m.get(oe),ge===void 0&&(ge=[],m.set(oe,ge)),Y.isWebGLMultipleRenderTargets){let Oe=Y.texture;if(ge.length!==Oe.length||ge[0]!==36064){for(let bt=0,Tn=Oe.length;bt<Tn;bt++)ge[bt]=36064+bt;ge.length=Oe.length,Ne=!0}}else ge[0]!==36064&&(ge[0]=36064,Ne=!0);else ge[0]!==1029&&(ge[0]=1029,Ne=!0);Ne&&(e.isWebGL2?i.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function he(Y){return g!==Y?(i.useProgram(Y),g=Y,!0):!1}let fe={[gc]:32774,[XO]:32778,[QO]:32779};if(n)fe[j1]=32775,fe[W1]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(fe[j1]=Y.MIN_EXT,fe[W1]=Y.MAX_EXT)}let ce={[KO]:0,[ZO]:1,[JO]:768,[y_]:770,[iR]:776,[nR]:774,[eR]:772,[$O]:769,[v_]:771,[rR]:775,[tR]:773};function ye(Y,oe,ge,Ne,Oe,bt,Tn,mn){if(Y===Ot){y===!0&&(K(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Y!==YO){if(Y!==v||mn!==E){if((x!==gc||_!==gc)&&(i.blendEquation(32774),x=gc,_=gc),mn)switch(Y){case wc:i.blendFuncSeparate(1,771,1,771);break;case G1:i.blendFunc(1,1);break;case V1:i.blendFuncSeparate(0,769,0,1);break;case H1:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case wc:i.blendFuncSeparate(770,771,1,771);break;case G1:i.blendFunc(770,1);break;case V1:i.blendFuncSeparate(0,769,0,1);break;case H1:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}w=null,S=null,M=null,b=null,v=Y,E=mn}return}Oe=Oe||oe,bt=bt||ge,Tn=Tn||Ne,(oe!==x||Oe!==_)&&(i.blendEquationSeparate(fe[oe],fe[Oe]),x=oe,_=Oe),(ge!==w||Ne!==S||bt!==M||Tn!==b)&&(i.blendFuncSeparate(ce[ge],ce[Ne],ce[bt],ce[Tn]),w=ge,S=Ne,M=bt,b=Tn),v=Y,E=!1}function Se(Y,oe){Y.side===Lr?K(2884):re(2884);let ge=Y.side===On;oe&&(ge=!ge),ve(ge),Y.blending===wc&&Y.transparent===!1?ye(Ot):ye(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),a.setMask(Y.colorWrite);let Ne=Y.stencilWrite;u.setTest(Ne),Ne&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),we(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?re(32926):K(32926)}function ve(Y){T!==Y&&(Y?i.frontFace(2304):i.frontFace(2305),T=Y)}function Ee(Y){Y!==jO?(re(2884),Y!==I&&(Y===z1?i.cullFace(1029):Y===WO?i.cullFace(1028):i.cullFace(1032))):K(2884),I=Y}function Te(Y){Y!==C&&(j&&i.lineWidth(Y),C=Y)}function we(Y,oe,ge){Y?(re(32823),(P!==oe||O!==ge)&&(i.polygonOffset(oe,ge),P=oe,O=ge)):K(32823)}function He(Y){Y?re(3089):K(3089)}function vt(Y){Y===void 0&&(Y=33984+B-1),q!==Y&&(i.activeTexture(Y),q=Y)}function R(Y,oe,ge){ge===void 0&&(q===null?ge=33984+B-1:ge=q);let Ne=W[ge];Ne===void 0&&(Ne={type:void 0,texture:void 0},W[ge]=Ne),(Ne.type!==Y||Ne.texture!==oe)&&(q!==ge&&(i.activeTexture(ge),q=ge),i.bindTexture(Y,oe||z[Y]),Ne.type=Y,Ne.texture=oe)}function D(){let Y=W[q];Y!==void 0&&Y.type!==void 0&&(i.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ee(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function xe(){try{i.texSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ce(){try{i.texSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Pe(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{i.texStorage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Qe(){try{i.texStorage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{i.texImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{i.texImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ue(Y){U.equals(Y)===!1&&(i.scissor(Y.x,Y.y,Y.z,Y.w),U.copy(Y))}function Ke(Y){G.equals(Y)===!1&&(i.viewport(Y.x,Y.y,Y.z,Y.w),G.copy(Y))}function xt(Y,oe){let ge=d.get(oe);ge===void 0&&(ge=new WeakMap,d.set(oe,ge));let Ne=ge.get(Y);Ne===void 0&&(Ne=i.getUniformBlockIndex(oe,Y.name),ge.set(Y,Ne))}function jt(Y,oe){let Ne=d.get(oe).get(Y);c.get(oe)!==Ne&&(i.uniformBlockBinding(oe,Ne,Y.__bindingPointIndex),c.set(oe,Ne))}function En(){i.disable(3042),i.disable(2884),i.disable(2929),i.disable(32823),i.disable(3089),i.disable(2960),i.disable(32926),i.blendEquation(32774),i.blendFunc(1,0),i.blendFuncSeparate(1,0,1,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(513),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(519,0,4294967295),i.stencilOp(7680,7680,7680),i.clearStencil(0),i.cullFace(1029),i.frontFace(2305),i.polygonOffset(0,0),i.activeTexture(33984),i.bindFramebuffer(36160,null),n===!0&&(i.bindFramebuffer(36009,null),i.bindFramebuffer(36008,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},q=null,W={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,I=null,C=null,P=null,O=null,U.set(0,0,i.canvas.width,i.canvas.height),G.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:re,disable:K,bindFramebuffer:Z,drawBuffers:k,useProgram:he,setBlending:ye,setMaterial:Se,setFlipSided:ve,setCullFace:Ee,setLineWidth:Te,setPolygonOffset:we,setScissorTest:He,activeTexture:vt,bindTexture:R,unbindTexture:D,compressedTexImage2D:ee,compressedTexImage3D:me,texImage2D:Le,texImage3D:Ie,updateUBOMapping:xt,uniformBlockBinding:jt,texStorage2D:de,texStorage3D:Qe,texSubImage2D:xe,texSubImage3D:Ce,compressedTexSubImage2D:je,compressedTexSubImage3D:Pe,scissor:Ue,viewport:Ke,reset:En}}function IF(i,t,e,n,r,s,o){let a=r.isWebGL2,l=r.maxTextures,u=r.maxCubemapSize,c=r.maxTextureSize,d=r.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,D){return y?new OffscreenCanvas(R,D):dm("canvas")}function x(R,D,ee,me){let xe=1;if((R.width>me||R.height>me)&&(xe=me/Math.max(R.width,R.height)),xe<1||D===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ce=D?um:Math.floor,je=Ce(xe*R.width),Pe=Ce(xe*R.height);p===void 0&&(p=v(je,Pe));let de=ee?v(je,Pe):p;return de.width=je,de.height=Pe,de.getContext("2d").drawImage(R,0,0,je,Pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+je+"x"+Pe+")."),de}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function w(R){return cx(R.width)&&cx(R.height)}function S(R){return a?!1:R.wrapS!==Wt||R.wrapT!==Wt||R.minFilter!==Dt&&R.minFilter!==Xe}function _(R,D){return R.generateMipmaps&&D&&R.minFilter!==Dt&&R.minFilter!==Xe}function M(R){i.generateMipmap(R)}function b(R,D,ee,me,xe=!1){if(a===!1)return D;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ce=D;return D===6403&&(ee===5126&&(Ce=33326),ee===5131&&(Ce=33325),ee===5121&&(Ce=33321)),D===33319&&(ee===5126&&(Ce=33328),ee===5131&&(Ce=33327),ee===5121&&(Ce=33323)),D===6408&&(ee===5126&&(Ce=34836),ee===5131&&(Ce=34842),ee===5121&&(Ce=me===Ze&&xe===!1?35907:32856),ee===32819&&(Ce=32854),ee===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&t.get("EXT_color_buffer_float"),Ce}function E(R,D,ee){return _(R,ee)===!0||R.isFramebufferTexture&&R.minFilter!==Dt&&R.minFilter!==Xe?Math.log2(Math.max(D.width,D.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?D.mipmaps.length:1}function T(R){return R===Dt||R===q1||R===b0?9728:9729}function I(R){let D=R.target;D.removeEventListener("dispose",I),P(D),D.isVideoTexture&&m.delete(D)}function C(R){let D=R.target;D.removeEventListener("dispose",C),B(D)}function P(R){let D=n.get(R);if(D.__webglInit===void 0)return;let ee=R.source,me=g.get(ee);if(me){let xe=me[D.__cacheKey];xe.usedTimes--,xe.usedTimes===0&&O(R),Object.keys(me).length===0&&g.delete(ee)}n.remove(R)}function O(R){let D=n.get(R);i.deleteTexture(D.__webglTexture);let ee=R.source,me=g.get(ee);delete me[D.__cacheKey],o.memory.textures--}function B(R){let D=R.texture,ee=n.get(R),me=n.get(D);if(me.__webglTexture!==void 0&&(i.deleteTexture(me.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++)i.deleteFramebuffer(ee.__webglFramebuffer[xe]),ee.__webglDepthbuffer&&i.deleteRenderbuffer(ee.__webglDepthbuffer[xe]);else{if(i.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&i.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&i.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let xe=0;xe<ee.__webglColorRenderbuffer.length;xe++)ee.__webglColorRenderbuffer[xe]&&i.deleteRenderbuffer(ee.__webglColorRenderbuffer[xe]);ee.__webglDepthRenderbuffer&&i.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let xe=0,Ce=D.length;xe<Ce;xe++){let je=n.get(D[xe]);je.__webglTexture&&(i.deleteTexture(je.__webglTexture),o.memory.textures--),n.remove(D[xe])}n.remove(D),n.remove(R)}let j=0;function Q(){j=0}function V(){let R=j;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),j+=1,R}function q(R){let D=[];return D.push(R.wrapS),D.push(R.wrapT),D.push(R.wrapR||0),D.push(R.magFilter),D.push(R.minFilter),D.push(R.anisotropy),D.push(R.internalFormat),D.push(R.format),D.push(R.type),D.push(R.generateMipmaps),D.push(R.premultiplyAlpha),D.push(R.flipY),D.push(R.unpackAlignment),D.push(R.encoding),D.join()}function W(R,D){let ee=n.get(R);if(R.isVideoTexture&&He(R),R.isRenderTargetTexture===!1&&R.version>0&&ee.__version!==R.version){let me=R.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(ee,R,D);return}}e.bindTexture(3553,ee.__webglTexture,33984+D)}function X(R,D){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,D);return}e.bindTexture(35866,ee.__webglTexture,33984+D)}function L(R,D){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,D);return}e.bindTexture(32879,ee.__webglTexture,33984+D)}function U(R,D){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){Z(ee,R,D);return}e.bindTexture(34067,ee.__webglTexture,33984+D)}let G={[Hi]:10497,[Wt]:33071,[ox]:33648},H={[Dt]:9728,[q1]:9984,[b0]:9986,[Xe]:9729,[xR]:9985,[sl]:9987};function z(R,D,ee){if(ee?(i.texParameteri(R,10242,G[D.wrapS]),i.texParameteri(R,10243,G[D.wrapT]),(R===32879||R===35866)&&i.texParameteri(R,32882,G[D.wrapR]),i.texParameteri(R,10240,H[D.magFilter]),i.texParameteri(R,10241,H[D.minFilter])):(i.texParameteri(R,10242,33071),i.texParameteri(R,10243,33071),(R===32879||R===35866)&&i.texParameteri(R,32882,33071),(D.wrapS!==Wt||D.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,10240,T(D.magFilter)),i.texParameteri(R,10241,T(D.minFilter)),D.minFilter!==Dt&&D.minFilter!==Xe&&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 me=t.get("EXT_texture_filter_anisotropic");if(D.magFilter===Dt||D.minFilter!==b0&&D.minFilter!==sl||D.type===pr&&t.has("OES_texture_float_linear")===!1||a===!1&&D.type===ol&&t.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(i.texParameterf(R,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,r.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function re(R,D){let ee=!1;R.__webglInit===void 0&&(R.__webglInit=!0,D.addEventListener("dispose",I));let me=D.source,xe=g.get(me);xe===void 0&&(xe={},g.set(me,xe));let Ce=q(D);if(Ce!==R.__cacheKey){xe[Ce]===void 0&&(xe[Ce]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),xe[Ce].usedTimes++;let je=xe[R.__cacheKey];je!==void 0&&(xe[R.__cacheKey].usedTimes--,je.usedTimes===0&&O(D)),R.__cacheKey=Ce,R.__webglTexture=xe[Ce].texture}return ee}function K(R,D,ee){let me=3553;(D.isDataArrayTexture||D.isCompressedArrayTexture)&&(me=35866),D.isData3DTexture&&(me=32879);let xe=re(R,D),Ce=D.source;e.bindTexture(me,R.__webglTexture,33984+ee);let je=n.get(Ce);if(Ce.version!==je.__version||xe===!0){e.activeTexture(33984+ee),i.pixelStorei(37440,D.flipY),i.pixelStorei(37441,D.premultiplyAlpha),i.pixelStorei(3317,D.unpackAlignment),i.pixelStorei(37443,0);let Pe=S(D)&&w(D.image)===!1,de=x(D.image,Pe,!1,c);de=vt(D,de);let Qe=w(de)||a,Le=s.convert(D.format,D.encoding),Ie=s.convert(D.type),Ue=b(D.internalFormat,Le,Ie,D.encoding,D.isVideoTexture);z(me,D,Qe);let Ke,xt=D.mipmaps,jt=a&&D.isVideoTexture!==!0,En=je.__version===void 0||xe===!0,Y=E(D,de,Qe);if(D.isDepthTexture)Ue=6402,a?D.type===pr?Ue=36012:D.type===uo?Ue=33190:D.type===$o?Ue=35056:Ue=33189:D.type===pr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===rl&&Ue===6402&&D.type!==w_&&D.type!==uo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=uo,Ie=s.convert(D.type)),D.format===na&&Ue===6402&&(Ue=34041,D.type!==$o&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=$o,Ie=s.convert(D.type))),En&&(jt?e.texStorage2D(3553,1,Ue,de.width,de.height):e.texImage2D(3553,0,Ue,de.width,de.height,0,Le,Ie,null));else if(D.isDataTexture)if(xt.length>0&&Qe){jt&&En&&e.texStorage2D(3553,Y,Ue,xt[0].width,xt[0].height);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],jt?e.texSubImage2D(3553,oe,0,0,Ke.width,Ke.height,Le,Ie,Ke.data):e.texImage2D(3553,oe,Ue,Ke.width,Ke.height,0,Le,Ie,Ke.data);D.generateMipmaps=!1}else jt?(En&&e.texStorage2D(3553,Y,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,de.width,de.height,Le,Ie,de.data)):e.texImage2D(3553,0,Ue,de.width,de.height,0,Le,Ie,de.data);else if(D.isCompressedTexture)if(D.isCompressedArrayTexture){jt&&En&&e.texStorage3D(35866,Y,Ue,xt[0].width,xt[0].height,de.depth);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],D.format!==oi?Le!==null?jt?e.compressedTexSubImage3D(35866,oe,0,0,0,Ke.width,Ke.height,de.depth,Le,Ke.data,0,0):e.compressedTexImage3D(35866,oe,Ue,Ke.width,Ke.height,de.depth,0,Ke.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):jt?e.texSubImage3D(35866,oe,0,0,0,Ke.width,Ke.height,de.depth,Le,Ie,Ke.data):e.texImage3D(35866,oe,Ue,Ke.width,Ke.height,de.depth,0,Le,Ie,Ke.data)}else{jt&&En&&e.texStorage2D(3553,Y,Ue,xt[0].width,xt[0].height);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],D.format!==oi?Le!==null?jt?e.compressedTexSubImage2D(3553,oe,0,0,Ke.width,Ke.height,Le,Ke.data):e.compressedTexImage2D(3553,oe,Ue,Ke.width,Ke.height,0,Ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):jt?e.texSubImage2D(3553,oe,0,0,Ke.width,Ke.height,Le,Ie,Ke.data):e.texImage2D(3553,oe,Ue,Ke.width,Ke.height,0,Le,Ie,Ke.data)}else if(D.isDataArrayTexture)jt?(En&&e.texStorage3D(35866,Y,Ue,de.width,de.height,de.depth),e.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Le,Ie,de.data)):e.texImage3D(35866,0,Ue,de.width,de.height,de.depth,0,Le,Ie,de.data);else if(D.isData3DTexture)jt?(En&&e.texStorage3D(32879,Y,Ue,de.width,de.height,de.depth),e.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Le,Ie,de.data)):e.texImage3D(32879,0,Ue,de.width,de.height,de.depth,0,Le,Ie,de.data);else if(D.isFramebufferTexture){if(En)if(jt)e.texStorage2D(3553,Y,Ue,de.width,de.height);else{let oe=de.width,ge=de.height;for(let Ne=0;Ne<Y;Ne++)e.texImage2D(3553,Ne,Ue,oe,ge,0,Le,Ie,null),oe>>=1,ge>>=1}}else if(xt.length>0&&Qe){jt&&En&&e.texStorage2D(3553,Y,Ue,xt[0].width,xt[0].height);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],jt?e.texSubImage2D(3553,oe,0,0,Le,Ie,Ke):e.texImage2D(3553,oe,Ue,Le,Ie,Ke);D.generateMipmaps=!1}else jt?(En&&e.texStorage2D(3553,Y,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,Le,Ie,de)):e.texImage2D(3553,0,Ue,Le,Ie,de);_(D,Qe)&&M(me),je.__version=Ce.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function Z(R,D,ee){if(D.image.length!==6)return;let me=re(R,D),xe=D.source;e.bindTexture(34067,R.__webglTexture,33984+ee);let Ce=n.get(xe);if(xe.version!==Ce.__version||me===!0){e.activeTexture(33984+ee),i.pixelStorei(37440,D.flipY),i.pixelStorei(37441,D.premultiplyAlpha),i.pixelStorei(3317,D.unpackAlignment),i.pixelStorei(37443,0);let je=D.isCompressedTexture||D.image[0].isCompressedTexture,Pe=D.image[0]&&D.image[0].isDataTexture,de=[];for(let oe=0;oe<6;oe++)!je&&!Pe?de[oe]=x(D.image[oe],!1,!0,u):de[oe]=Pe?D.image[oe].image:D.image[oe],de[oe]=vt(D,de[oe]);let Qe=de[0],Le=w(Qe)||a,Ie=s.convert(D.format,D.encoding),Ue=s.convert(D.type),Ke=b(D.internalFormat,Ie,Ue,D.encoding),xt=a&&D.isVideoTexture!==!0,jt=Ce.__version===void 0||me===!0,En=E(D,Qe,Le);z(34067,D,Le);let Y;if(je){xt&&jt&&e.texStorage2D(34067,En,Ke,Qe.width,Qe.height);for(let oe=0;oe<6;oe++){Y=de[oe].mipmaps;for(let ge=0;ge<Y.length;ge++){let Ne=Y[ge];D.format!==oi?Ie!==null?xt?e.compressedTexSubImage2D(34069+oe,ge,0,0,Ne.width,Ne.height,Ie,Ne.data):e.compressedTexImage2D(34069+oe,ge,Ke,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):xt?e.texSubImage2D(34069+oe,ge,0,0,Ne.width,Ne.height,Ie,Ue,Ne.data):e.texImage2D(34069+oe,ge,Ke,Ne.width,Ne.height,0,Ie,Ue,Ne.data)}}}else{Y=D.mipmaps,xt&&jt&&(Y.length>0&&En++,e.texStorage2D(34067,En,Ke,de[0].width,de[0].height));for(let oe=0;oe<6;oe++)if(Pe){xt?e.texSubImage2D(34069+oe,0,0,0,de[oe].width,de[oe].height,Ie,Ue,de[oe].data):e.texImage2D(34069+oe,0,Ke,de[oe].width,de[oe].height,0,Ie,Ue,de[oe].data);for(let ge=0;ge<Y.length;ge++){let Oe=Y[ge].image[oe].image;xt?e.texSubImage2D(34069+oe,ge+1,0,0,Oe.width,Oe.height,Ie,Ue,Oe.data):e.texImage2D(34069+oe,ge+1,Ke,Oe.width,Oe.height,0,Ie,Ue,Oe.data)}}else{xt?e.texSubImage2D(34069+oe,0,0,0,Ie,Ue,de[oe]):e.texImage2D(34069+oe,0,Ke,Ie,Ue,de[oe]);for(let ge=0;ge<Y.length;ge++){let Ne=Y[ge];xt?e.texSubImage2D(34069+oe,ge+1,0,0,Ie,Ue,Ne.image[oe]):e.texImage2D(34069+oe,ge+1,Ke,Ie,Ue,Ne.image[oe])}}}_(D,Le)&&M(34067),Ce.__version=xe.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function k(R,D,ee,me,xe){let Ce=s.convert(ee.format,ee.encoding),je=s.convert(ee.type),Pe=b(ee.internalFormat,Ce,je,ee.encoding);n.get(D).__hasExternalTextures||(xe===32879||xe===35866?e.texImage3D(xe,0,Pe,D.width,D.height,D.depth,0,Ce,je,null):e.texImage2D(xe,0,Pe,D.width,D.height,0,Ce,je,null)),e.bindFramebuffer(36160,R),we(D)?h.framebufferTexture2DMultisampleEXT(36160,me,xe,n.get(ee).__webglTexture,0,Te(D)):(xe===3553||xe>=34069&&xe<=34074)&&i.framebufferTexture2D(36160,me,xe,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function he(R,D,ee){if(i.bindRenderbuffer(36161,R),D.depthBuffer&&!D.stencilBuffer){let me=33189;if(ee||we(D)){let xe=D.depthTexture;xe&&xe.isDepthTexture&&(xe.type===pr?me=36012:xe.type===uo&&(me=33190));let Ce=Te(D);we(D)?h.renderbufferStorageMultisampleEXT(36161,Ce,me,D.width,D.height):i.renderbufferStorageMultisample(36161,Ce,me,D.width,D.height)}else i.renderbufferStorage(36161,me,D.width,D.height);i.framebufferRenderbuffer(36160,36096,36161,R)}else if(D.depthBuffer&&D.stencilBuffer){let me=Te(D);ee&&we(D)===!1?i.renderbufferStorageMultisample(36161,me,35056,D.width,D.height):we(D)?h.renderbufferStorageMultisampleEXT(36161,me,35056,D.width,D.height):i.renderbufferStorage(36161,34041,D.width,D.height),i.framebufferRenderbuffer(36160,33306,36161,R)}else{let me=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let xe=0;xe<me.length;xe++){let Ce=me[xe],je=s.convert(Ce.format,Ce.encoding),Pe=s.convert(Ce.type),de=b(Ce.internalFormat,je,Pe,Ce.encoding),Qe=Te(D);ee&&we(D)===!1?i.renderbufferStorageMultisample(36161,Qe,de,D.width,D.height):we(D)?h.renderbufferStorageMultisampleEXT(36161,Qe,de,D.width,D.height):i.renderbufferStorage(36161,de,D.width,D.height)}}i.bindRenderbuffer(36161,null)}function fe(R,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),W(D.depthTexture,0);let me=n.get(D.depthTexture).__webglTexture,xe=Te(D);if(D.depthTexture.format===rl)we(D)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,me,0,xe):i.framebufferTexture2D(36160,36096,3553,me,0);else if(D.depthTexture.format===na)we(D)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,me,0,xe):i.framebufferTexture2D(36160,33306,3553,me,0);else throw new Error("Unknown depthTexture format")}function ce(R){let D=n.get(R),ee=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!D.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");fe(D.__webglFramebuffer,R)}else if(ee){D.__webglDepthbuffer=[];for(let me=0;me<6;me++)e.bindFramebuffer(36160,D.__webglFramebuffer[me]),D.__webglDepthbuffer[me]=i.createRenderbuffer(),he(D.__webglDepthbuffer[me],R,!1)}else e.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=i.createRenderbuffer(),he(D.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function ye(R,D,ee){let me=n.get(R);D!==void 0&&k(me.__webglFramebuffer,R,R.texture,36064,3553),ee!==void 0&&ce(R)}function Se(R){let D=R.texture,ee=n.get(R),me=n.get(D);R.addEventListener("dispose",C),R.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=i.createTexture()),me.__version=D.version,o.memory.textures++);let xe=R.isWebGLCubeRenderTarget===!0,Ce=R.isWebGLMultipleRenderTargets===!0,je=w(R)||a;if(xe){ee.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)ee.__webglFramebuffer[Pe]=i.createFramebuffer()}else{if(ee.__webglFramebuffer=i.createFramebuffer(),Ce)if(r.drawBuffers){let Pe=R.texture;for(let de=0,Qe=Pe.length;de<Qe;de++){let Le=n.get(Pe[de]);Le.__webglTexture===void 0&&(Le.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&we(R)===!1){let Pe=Ce?D:[D];ee.__webglMultisampledFramebuffer=i.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let de=0;de<Pe.length;de++){let Qe=Pe[de];ee.__webglColorRenderbuffer[de]=i.createRenderbuffer(),i.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[de]);let Le=s.convert(Qe.format,Qe.encoding),Ie=s.convert(Qe.type),Ue=b(Qe.internalFormat,Le,Ie,Qe.encoding,R.isXRRenderTarget===!0),Ke=Te(R);i.renderbufferStorageMultisample(36161,Ke,Ue,R.width,R.height),i.framebufferRenderbuffer(36160,36064+de,36161,ee.__webglColorRenderbuffer[de])}i.bindRenderbuffer(36161,null),R.depthBuffer&&(ee.__webglDepthRenderbuffer=i.createRenderbuffer(),he(ee.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(xe){e.bindTexture(34067,me.__webglTexture),z(34067,D,je);for(let Pe=0;Pe<6;Pe++)k(ee.__webglFramebuffer[Pe],R,D,36064,34069+Pe);_(D,je)&&M(34067),e.unbindTexture()}else if(Ce){let Pe=R.texture;for(let de=0,Qe=Pe.length;de<Qe;de++){let Le=Pe[de],Ie=n.get(Le);e.bindTexture(3553,Ie.__webglTexture),z(3553,Le,je),k(ee.__webglFramebuffer,R,Le,36064+de,3553),_(Le,je)&&M(3553)}e.unbindTexture()}else{let Pe=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?Pe=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Pe,me.__webglTexture),z(Pe,D,je),k(ee.__webglFramebuffer,R,D,36064,Pe),_(D,je)&&M(Pe),e.unbindTexture()}R.depthBuffer&&ce(R)}function ve(R){let D=w(R)||a,ee=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let me=0,xe=ee.length;me<xe;me++){let Ce=ee[me];if(_(Ce,D)){let je=R.isWebGLCubeRenderTarget?34067:3553,Pe=n.get(Ce).__webglTexture;e.bindTexture(je,Pe),M(je),e.unbindTexture()}}}function Ee(R){if(a&&R.samples>0&&we(R)===!1){let D=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ee=R.width,me=R.height,xe=16384,Ce=[],je=R.stencilBuffer?33306:36096,Pe=n.get(R),de=R.isWebGLMultipleRenderTargets===!0;if(de)for(let Qe=0;Qe<D.length;Qe++)e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Qe,36161,null),e.bindFramebuffer(36160,Pe.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Qe,3553,null,0);e.bindFramebuffer(36008,Pe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Pe.__webglFramebuffer);for(let Qe=0;Qe<D.length;Qe++){Ce.push(36064+Qe),R.depthBuffer&&Ce.push(je);let Le=Pe.__ignoreDepthValues!==void 0?Pe.__ignoreDepthValues:!1;if(Le===!1&&(R.depthBuffer&&(xe|=256),R.stencilBuffer&&(xe|=1024)),de&&i.framebufferRenderbuffer(36008,36064,36161,Pe.__webglColorRenderbuffer[Qe]),Le===!0&&(i.invalidateFramebuffer(36008,[je]),i.invalidateFramebuffer(36009,[je])),de){let Ie=n.get(D[Qe]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Ie,0)}i.blitFramebuffer(0,0,ee,me,0,0,ee,me,xe,9728),f&&i.invalidateFramebuffer(36008,Ce)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),de)for(let Qe=0;Qe<D.length;Qe++){e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Qe,36161,Pe.__webglColorRenderbuffer[Qe]);let Le=n.get(D[Qe]).__webglTexture;e.bindFramebuffer(36160,Pe.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Qe,3553,Le,0)}e.bindFramebuffer(36009,Pe.__webglMultisampledFramebuffer)}}function Te(R){return Math.min(d,R.samples)}function we(R){let D=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function He(R){let D=o.render.frame;m.get(R)!==D&&(m.set(R,D),R.update())}function vt(R,D){let ee=R.encoding,me=R.format,xe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===lx||ee!==li&&(ee===Ze?a===!1?t.has("EXT_sRGB")===!0&&me===oi?(R.format=lx,R.minFilter=Xe,R.generateMipmaps=!1):D=hm.sRGBToLinear(D):(me!==oi||xe!==Qt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ee)),D}this.allocateTextureUnit=V,this.resetTextureUnits=Q,this.setTexture2D=W,this.setTexture2DArray=X,this.setTexture3D=L,this.setTextureCube=U,this.rebindTextures=ye,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=ve,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=ce,this.setupFrameBufferTexture=k,this.useMultisampledRTT=we}function DF(i,t,e){let n=e.isWebGL2;function r(s,o=null){let a;if(s===Qt)return 5121;if(s===AR)return 32819;if(s===_R)return 32820;if(s===bR)return 5120;if(s===wR)return 5122;if(s===w_)return 5123;if(s===SR)return 5124;if(s===uo)return 5125;if(s===pr)return 5126;if(s===ol)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===MR)return 6406;if(s===oi)return 6408;if(s===ER)return 6409;if(s===TR)return 6410;if(s===rl)return 6402;if(s===na)return 34041;if(s===lx)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===CR)return 6403;if(s===PR)return 36244;if(s===kx)return 33319;if(s===IR)return 33320;if(s===DR)return 36249;if(s===w0||s===S0||s===A0||s===_0)if(o===Ze)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===w0)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===S0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===A0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===_0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===w0)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===S0)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===A0)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===_0)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Y1||s===X1||s===Q1||s===K1)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Y1)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===X1)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Q1)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===K1)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===OR)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Z1||s===J1)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Z1)return o===Ze?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===J1)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===$1||s===eA||s===tA||s===nA||s===rA||s===iA||s===sA||s===oA||s===aA||s===lA||s===cA||s===uA||s===dA||s===hA)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===$1)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===eA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===tA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===nA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===rA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===iA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===sA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===oA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===aA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===lA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===cA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===uA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===dA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===hA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===M0)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===M0)return o===Ze?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===RR||s===fA||s===pA||s===mA)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===M0)return a.COMPRESSED_RED_RGTC1_EXT;if(s===fA)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===pA)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===mA)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===$o?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:r}}var xx=class extends yn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},xs=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}},OF={type:"move"},Bh=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new xs,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 xs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new xs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let p of t.hand.values()){let g=e.getJointPose(p,n),y=this._getHandJoint(u,p);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,m=.005;u.inputState.pinching&&h>f+m?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=f-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(OF)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new xs;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},bi=class extends qt{constructor(t,e,n,r,s,o,a,l,u,c){if(c=c!==void 0?c:rl,c!==rl&&c!==na)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===rl&&(n=uo),n===void 0&&c===na&&(n=$o),super(null,r,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Dt,this.minFilter=l!==void 0?l:Dt,this.flipY=!1,this.generateMipmaps=!1}},bx=class extends Ut{constructor(t,e){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,m=null,p=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,_=new yn;_.layers.enable(1),_.viewport=new We;let M=new yn;M.layers.enable(2),M.viewport=new We;let b=[_,M],E=new xx;E.layers.enable(1),E.layers.enable(2);let T=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(L){let U=v[L];return U===void 0&&(U=new Bh,v[L]=U),U.getTargetRaySpace()},this.getControllerGrip=function(L){let U=v[L];return U===void 0&&(U=new Bh,v[L]=U),U.getGripSpace()},this.getHand=function(L){let U=v[L];return U===void 0&&(U=new Bh,v[L]=U),U.getHandSpace()};function C(L){let U=x.indexOf(L.inputSource);if(U===-1)return;let G=v[U];G!==void 0&&G.dispatchEvent({type:L.type,data:L.inputSource})}function P(){r.removeEventListener("select",C),r.removeEventListener("selectstart",C),r.removeEventListener("selectend",C),r.removeEventListener("squeeze",C),r.removeEventListener("squeezestart",C),r.removeEventListener("squeezeend",C),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",O);for(let L=0;L<v.length;L++){let U=x[L];U!==null&&(x[L]=null,v[L].disconnect(U))}T=null,I=null,t.setRenderTarget(g),f=null,h=null,d=null,r=null,y=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(L){s=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(L){a=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(L){u=L},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(L){if(r=L,r!==null){if(g=t.getRenderTarget(),r.addEventListener("select",C),r.addEventListener("selectstart",C),r.addEventListener("selectend",C),r.addEventListener("squeeze",C),r.addEventListener("squeezestart",C),r.addEventListener("squeezeend",C),r.addEventListener("end",P),r.addEventListener("inputsourceschange",O),p.xrCompatible!==!0&&await e.makeXRCompatible(),r.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let U={antialias:r.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,e,U),r.updateRenderState({baseLayer:f}),y=new ot(f.framebufferWidth,f.framebufferHeight,{format:oi,type:Qt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let U=null,G=null,H=null;p.depth&&(H=p.stencil?35056:33190,U=p.stencil?na:rl,G=p.stencil?$o:uo);let z={colorFormat:32856,depthFormat:H,scaleFactor:s};d=new XRWebGLBinding(r,e),h=d.createProjectionLayer(z),r.updateRenderState({layers:[h]}),y=new ot(h.textureWidth,h.textureHeight,{format:oi,type:Qt,depthTexture:new bi(h.textureWidth,h.textureHeight,G,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let re=t.properties.get(y);re.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await r.requestReferenceSpace(a),X.setContext(r),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function O(L){for(let U=0;U<L.removed.length;U++){let G=L.removed[U],H=x.indexOf(G);H>=0&&(x[H]=null,v[H].disconnect(G))}for(let U=0;U<L.added.length;U++){let G=L.added[U],H=x.indexOf(G);if(H===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(G),H=re;break}else if(x[re]===null){x[re]=G,H=re;break}if(H===-1)break}let z=v[H];z&&z.connect(G)}}let B=new A,j=new A;function Q(L,U,G){B.setFromMatrixPosition(U.matrixWorld),j.setFromMatrixPosition(G.matrixWorld);let H=B.distanceTo(j),z=U.projectionMatrix.elements,re=G.projectionMatrix.elements,K=z[14]/(z[10]-1),Z=z[14]/(z[10]+1),k=(z[9]+1)/z[5],he=(z[9]-1)/z[5],fe=(z[8]-1)/z[0],ce=(re[8]+1)/re[0],ye=K*fe,Se=K*ce,ve=H/(-fe+ce),Ee=ve*-fe;U.matrixWorld.decompose(L.position,L.quaternion,L.scale),L.translateX(Ee),L.translateZ(ve),L.matrixWorld.compose(L.position,L.quaternion,L.scale),L.matrixWorldInverse.copy(L.matrixWorld).invert();let Te=K+ve,we=Z+ve,He=ye-Ee,vt=Se+(H-Ee),R=k*Z/we*Te,D=he*Z/we*Te;L.projectionMatrix.makePerspective(He,vt,R,D,Te,we)}function V(L,U){U===null?L.matrixWorld.copy(L.matrix):L.matrixWorld.multiplyMatrices(U.matrixWorld,L.matrix),L.matrixWorldInverse.copy(L.matrixWorld).invert()}this.updateCamera=function(L){if(r===null)return;E.near=M.near=_.near=L.near,E.far=M.far=_.far=L.far,(T!==E.near||I!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,I=E.far);let U=L.parent,G=E.cameras;V(E,U);for(let z=0;z<G.length;z++)V(G[z],U);E.matrixWorld.decompose(E.position,E.quaternion,E.scale),L.matrix.copy(E.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);let H=L.children;for(let z=0,re=H.length;z<re;z++)H[z].updateMatrixWorld(!0);G.length===2?Q(E,_,M):E.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(L){l=L,h!==null&&(h.fixedFoveation=L),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=L)},this.getPlanes=function(){return w};let q=null;function W(L,U){if(c=U.getViewerPose(u||o),m=U,c!==null){let G=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let H=!1;G.length!==E.cameras.length&&(E.cameras.length=0,H=!0);for(let z=0;z<G.length;z++){let re=G[z],K=null;if(f!==null)K=f.getViewport(re);else{let k=d.getViewSubImage(h,re);K=k.viewport,z===0&&(t.setRenderTargetTextures(y,k.colorTexture,h.ignoreDepthValues?void 0:k.depthStencilTexture),t.setRenderTarget(y))}let Z=b[z];Z===void 0&&(Z=new yn,Z.layers.enable(z),Z.viewport=new We,b[z]=Z),Z.matrix.fromArray(re.transform.matrix),Z.projectionMatrix.fromArray(re.projectionMatrix),Z.viewport.set(K.x,K.y,K.width,K.height),z===0&&E.matrix.copy(Z.matrix),H===!0&&E.cameras.push(Z)}}for(let G=0;G<v.length;G++){let H=x[G],z=v[G];H!==null&&z!==void 0&&z.update(H,U,u||o)}if(q&&q(L,U),U.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:U.detectedPlanes});let G=null;for(let H of w)U.detectedPlanes.has(H)||(G===null&&(G=[]),G.push(H));if(G!==null)for(let H of G)w.delete(H),S.delete(H),n.dispatchEvent({type:"planeremoved",data:H});for(let H of U.detectedPlanes)if(!w.has(H))w.add(H),S.set(H,U.lastChangedTime),n.dispatchEvent({type:"planeadded",data:H});else{let z=S.get(H);H.lastChangedTime>z&&(S.set(H,H.lastChangedTime),n.dispatchEvent({type:"planechanged",data:H}))}}m=null}let X=new E_;X.setAnimationLoop(W),this.setAnimationLoop=function(L){q=L},this.dispose=function(){}}};function RF(i,t){function e(p,g){g.color.getRGB(p.fogColor.value,M_(i)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(p,g):g.isMeshToonMaterial?(r(p,g),c(p,g)):g.isMeshPhongMaterial?(r(p,g),u(p,g)):g.isMeshStandardMaterial?(r(p,g),d(p,g),g.isMeshPhysicalMaterial&&h(p,g,x)):g.isMeshMatcapMaterial?(r(p,g),f(p,g)):g.isMeshDepthMaterial?r(p,g):g.isMeshDistanceMaterial?(r(p,g),m(p,g)):g.isMeshNormalMaterial?r(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,y,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===On&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===On&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let w=i.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uv2Transform.value.copy(x.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,y,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function c(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function d(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function h(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===On&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function LF(i,t,e,n){let r={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let w=x.program;n.uniformBlockBinding(v,w)}function u(v,x){let w=r[v.id];w===void 0&&(m(v),w=c(v),r[v.id]=w,v.addEventListener("dispose",g));let S=x.program;n.updateUBOMapping(v,S);let _=t.render.frame;s[v.id]!==_&&(h(v),s[v.id]=_)}function c(v){let x=d();v.__bindingPointIndex=x;let w=i.createBuffer(),S=v.__size,_=v.usage;return i.bindBuffer(35345,w),i.bufferData(35345,S,_),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,w),w}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let x=r[v.id],w=v.uniforms,S=v.__cache;i.bindBuffer(35345,x);for(let _=0,M=w.length;_<M;_++){let b=w[_];if(f(b,_,S)===!0){let E=b.__offset,T=Array.isArray(b.value)?b.value:[b.value],I=0;for(let C=0;C<T.length;C++){let P=T[C],O=p(P);typeof P=="number"?(b.__data[0]=P,i.bufferSubData(35345,E+I,b.__data)):P.isMatrix3?(b.__data[0]=P.elements[0],b.__data[1]=P.elements[1],b.__data[2]=P.elements[2],b.__data[3]=P.elements[0],b.__data[4]=P.elements[3],b.__data[5]=P.elements[4],b.__data[6]=P.elements[5],b.__data[7]=P.elements[0],b.__data[8]=P.elements[6],b.__data[9]=P.elements[7],b.__data[10]=P.elements[8],b.__data[11]=P.elements[0]):(P.toArray(b.__data,I),I+=O.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,E,b.__data)}}i.bindBuffer(35345,null)}function f(v,x,w){let S=v.value;if(w[x]===void 0){if(typeof S=="number")w[x]=S;else{let _=Array.isArray(S)?S:[S],M=[];for(let b=0;b<_.length;b++)M.push(_[b].clone());w[x]=M}return!0}else if(typeof S=="number"){if(w[x]!==S)return w[x]=S,!0}else{let _=Array.isArray(w[x])?w[x]:[w[x]],M=Array.isArray(S)?S:[S];for(let b=0;b<_.length;b++){let E=_[b];if(E.equals(M[b])===!1)return E.copy(M[b]),!0}}return!1}function m(v){let x=v.uniforms,w=0,S=16,_=0;for(let M=0,b=x.length;M<b;M++){let E=x[M],T={boundary:0,storage:0},I=Array.isArray(E.value)?E.value:[E.value];for(let C=0,P=I.length;C<P;C++){let O=I[C],B=p(O);T.boundary+=B.boundary,T.storage+=B.storage}if(E.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=w,M>0){_=w%S;let C=S-_;_!==0&&C-T.boundary<0&&(w+=S-_,E.__offset=w)}w+=T.storage}return _=w%S,_>0&&(w+=S-_),v.__size=w,v.__cache={},this}function p(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),i.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function y(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:u,dispose:y}}function NF(){let i=dm("canvas");return i.style.display="block",i}function qx(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:NF(),e=i.context!==void 0?i.context:null,n=i.depth!==void 0?i.depth:!0,r=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.alpha:!1;let d=null,h=null,f=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=li,this.physicallyCorrectLights=!1,this.toneMapping=fo,this.toneMappingExposure=1;let p=this,g=!1,y=0,v=0,x=null,w=-1,S=null,_=new We,M=new We,b=null,E=t.width,T=t.height,I=1,C=null,P=null,O=new We(0,0,E,T),B=new We(0,0,E,T),j=!1,Q=new Vh,V=!1,q=!1,W=null,X=new ie,L=new F,U=new A,G={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function H(){return x===null?I:1}let z=e;function re(N,te){for(let ae=0;ae<N.length;ae++){let $=N[ae],ue=t.getContext($,te);if(ue!==null)return ue}return null}try{let N={alpha:!0,depth:n,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${yo}`),t.addEventListener("webglcontextlost",Ue,!1),t.addEventListener("webglcontextrestored",Ke,!1),t.addEventListener("webglcontextcreationerror",xt,!1),z===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),z=re(te,N),z===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let K,Z,k,he,fe,ce,ye,Se,ve,Ee,Te,we,He,vt,R,D,ee,me,xe,Ce,je,Pe,de,Qe;function Le(){K=new nB(z),Z=new KN(z,K,i),K.init(Z),Pe=new DF(z,K,Z),k=new PF(z,K,Z),he=new sB,fe=new yF,ce=new IF(z,K,k,fe,Z,Pe,he),ye=new JN(p),Se=new tB(p),ve=new pL(z,Z),de=new XN(z,K,ve,Z),Ee=new rB(z,ve,he,de),Te=new cB(z,Ee,ve,he),xe=new lB(z,Z,ce),D=new ZN(fe),we=new gF(p,ye,Se,K,Z,de,D),He=new RF(p,fe),vt=new xF,R=new MF(K,Z),me=new YN(p,ye,Se,k,Te,c,o),ee=new CF(p,Te,Z),Qe=new LF(z,he,Z,k),Ce=new QN(z,K,he,Z),je=new iB(z,K,he,Z),he.programs=we.programs,p.capabilities=Z,p.extensions=K,p.properties=fe,p.renderLists=vt,p.shadowMap=ee,p.state=k,p.info=he}Le();let Ie=new bx(p,z);this.xr=Ie,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let N=K.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=K.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(N){N!==void 0&&(I=N,this.setSize(E,T,!1))},this.getSize=function(N){return N.set(E,T)},this.setSize=function(N,te,ae){if(Ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=N,T=te,t.width=Math.floor(N*I),t.height=Math.floor(te*I),ae!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(E*I,T*I).floor()},this.setDrawingBufferSize=function(N,te,ae){E=N,T=te,I=ae,t.width=Math.floor(N*ae),t.height=Math.floor(te*ae),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(_)},this.getViewport=function(N){return N.copy(O)},this.setViewport=function(N,te,ae,$){N.isVector4?O.set(N.x,N.y,N.z,N.w):O.set(N,te,ae,$),k.viewport(_.copy(O).multiplyScalar(I).floor())},this.getScissor=function(N){return N.copy(B)},this.setScissor=function(N,te,ae,$){N.isVector4?B.set(N.x,N.y,N.z,N.w):B.set(N,te,ae,$),k.scissor(M.copy(B).multiplyScalar(I).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(N){k.setScissorTest(j=N)},this.setOpaqueSort=function(N){C=N},this.setTransparentSort=function(N){P=N},this.getClearColor=function(N){return N.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(N=!0,te=!0,ae=!0){let $=0;N&&($|=16384),te&&($|=256),ae&&($|=1024),z.clear($)},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",Ue,!1),t.removeEventListener("webglcontextrestored",Ke,!1),t.removeEventListener("webglcontextcreationerror",xt,!1),vt.dispose(),R.dispose(),fe.dispose(),ye.dispose(),Se.dispose(),Te.dispose(),de.dispose(),Qe.dispose(),we.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",Ne),Ie.removeEventListener("sessionend",Oe),W&&(W.dispose(),W=null),bt.stop()};function Ue(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Ke(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=he.autoReset,te=ee.enabled,ae=ee.autoUpdate,$=ee.needsUpdate,ue=ee.type;Le(),he.autoReset=N,ee.enabled=te,ee.autoUpdate=ae,ee.needsUpdate=$,ee.type=ue}function xt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function jt(N){let te=N.target;te.removeEventListener("dispose",jt),En(te)}function En(N){Y(N),fe.remove(N)}function Y(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(ae){we.releaseProgram(ae)}),N.isShaderMaterial&&we.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,ae,$,ue,tt){te===null&&(te=G);let at=ue.isMesh&&ue.matrixWorld.determinant()<0,dt=RO(N,te,ae,$,ue);k.setMaterial($,at);let mt=ae.index,Ct=1;$.wireframe===!0&&(mt=Ee.getWireframeAttribute(ae),Ct=2);let wt=ae.drawRange,St=ae.attributes.position,Cn=wt.start*Ct,ni=(wt.start+wt.count)*Ct;tt!==null&&(Cn=Math.max(Cn,tt.start*Ct),ni=Math.min(ni,(tt.start+tt.count)*Ct)),mt!==null?(Cn=Math.max(Cn,0),ni=Math.min(ni,mt.count)):St!=null&&(Cn=Math.max(Cn,0),ni=Math.min(ni,St.count));let ro=ni-Cn;if(ro<0||ro===1/0)return;de.setup(ue,$,dt,ae,mt);let Qa,Pn=Ce;if(mt!==null&&(Qa=ve.get(mt),Pn=je,Pn.setIndex(Qa)),ue.isMesh)$.wireframe===!0?(k.setLineWidth($.wireframeLinewidth*H()),Pn.setMode(1)):Pn.setMode(4);else if(ue.isLine){let At=$.linewidth;At===void 0&&(At=1),k.setLineWidth(At*H()),ue.isLineSegments?Pn.setMode(1):ue.isLineLoop?Pn.setMode(2):Pn.setMode(3)}else ue.isPoints?Pn.setMode(0):ue.isSprite&&Pn.setMode(4);if(ue.isInstancedMesh)Pn.renderInstances(Cn,ro,ue.count);else if(ae.isInstancedBufferGeometry){let At=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,m0=Math.min(ae.instanceCount,At);Pn.renderInstances(Cn,ro,m0)}else Pn.render(Cn,ro)},this.compile=function(N,te){function ae($,ue,tt){$.transparent===!0&&$.side===Lr&&$.forceSinglePass===!1?($.side=On,$.needsUpdate=!0,yi($,ue,tt),$.side=ai,$.needsUpdate=!0,yi($,ue,tt),$.side=Lr):yi($,ue,tt)}h=R.get(N),h.init(),m.push(h),N.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),N.traverse(function($){let ue=$.material;if(ue)if(Array.isArray(ue))for(let tt=0;tt<ue.length;tt++){let at=ue[tt];ae(at,N,$)}else ae(ue,N,$)}),m.pop(),h=null};let oe=null;function ge(N){oe&&oe(N)}function Ne(){bt.stop()}function Oe(){bt.start()}let bt=new E_;bt.setAnimationLoop(ge),typeof self<"u"&&bt.setContext(self),this.setAnimationLoop=function(N){oe=N,Ie.setAnimationLoop(N),N===null?bt.stop():bt.start()},Ie.addEventListener("sessionstart",Ne),Ie.addEventListener("sessionend",Oe),this.render=function(N,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(te),te=Ie.getCamera()),N.isScene===!0&&N.onBeforeRender(p,N,te,x),h=R.get(N,m.length),h.init(),m.push(h),X.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),Q.setFromProjectionMatrix(X),q=this.localClippingEnabled,V=D.init(this.clippingPlanes,q),d=vt.get(N,f.length),d.init(),f.push(d),Tn(N,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(C,P),V===!0&&D.beginShadows();let ae=h.state.shadowsArray;if(ee.render(ae,N,te),V===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(d,N),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let ue=0,tt=$.length;ue<tt;ue++){let at=$[ue];mn(d,N,at,at.viewport)}}else mn(d,N,te);x!==null&&(ce.updateMultisampleRenderTarget(x),ce.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(p,N,te),de.resetDefaultState(),w=-1,S=null,m.pop(),m.length>0?h=m[m.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function Tn(N,te,ae,$){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)ae=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||Q.intersectsSprite(N)){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),dt=N.material;dt.visible&&d.push(N,at,dt,ae,U.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==he.render.frame&&(N.skeleton.update(),N.skeleton.frame=he.render.frame),!N.frustumCulled||Q.intersectsObject(N))){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),dt=N.material;if(Array.isArray(dt)){let mt=at.groups;for(let Ct=0,wt=mt.length;Ct<wt;Ct++){let St=mt[Ct],Cn=dt[St.materialIndex];Cn&&Cn.visible&&d.push(N,at,Cn,ae,U.z,St)}}else dt.visible&&d.push(N,at,dt,ae,U.z,null)}}let tt=N.children;for(let at=0,dt=tt.length;at<dt;at++)Tn(tt[at],te,ae,$)}function mn(N,te,ae,$){let ue=N.opaque,tt=N.transmissive,at=N.transparent;h.setupLightsView(ae),V===!0&&D.setGlobalState(p.clippingPlanes,ae),tt.length>0&&Xa(ue,te,ae),$&&k.viewport(_.copy($)),ue.length>0&&Jt(ue,te,ae),tt.length>0&&Jt(tt,te,ae),at.length>0&&Jt(at,te,ae),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function Xa(N,te,ae){let $=Z.isWebGL2;W===null&&(W=new ot(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?ol:Qt,minFilter:sl,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(L),$?W.setSize(L.x,L.y):W.setSize(um(L.x),um(L.y));let ue=p.getRenderTarget();p.setRenderTarget(W),p.clear();let tt=p.toneMapping;p.toneMapping=fo,Jt(N,te,ae),p.toneMapping=tt,ce.updateMultisampleRenderTarget(W),ce.updateRenderTargetMipmap(W),p.setRenderTarget(ue)}function Jt(N,te,ae){let $=te.isScene===!0?te.overrideMaterial:null;for(let ue=0,tt=N.length;ue<tt;ue++){let at=N[ue],dt=at.object,mt=at.geometry,Ct=$===null?at.material:$,wt=at.group;dt.layers.test(ae.layers)&&no(dt,te,ae,mt,Ct,wt)}}function no(N,te,ae,$,ue,tt){N.onBeforeRender(p,te,ae,$,ue,tt),N.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),ue.onBeforeRender(p,te,ae,$,N,tt),ue.transparent===!0&&ue.side===Lr&&ue.forceSinglePass===!1?(ue.side=On,ue.needsUpdate=!0,p.renderBufferDirect(ae,te,$,ue,N,tt),ue.side=ai,ue.needsUpdate=!0,p.renderBufferDirect(ae,te,$,ue,N,tt),ue.side=Lr):p.renderBufferDirect(ae,te,$,ue,N,tt),N.onAfterRender(p,te,ae,$,ue,tt)}function yi(N,te,ae){te.isScene!==!0&&(te=G);let $=fe.get(N),ue=h.state.lights,tt=h.state.shadowsArray,at=ue.state.version,dt=we.getParameters(N,ue.state,tt,te,ae),mt=we.getProgramCacheKey(dt),Ct=$.programs;$.environment=N.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(N.isMeshStandardMaterial?Se:ye).get(N.envMap||$.environment),Ct===void 0&&(N.addEventListener("dispose",jt),Ct=new Map,$.programs=Ct);let wt=Ct.get(mt);if(wt!==void 0){if($.currentProgram===wt&&$.lightsStateVersion===at)return F1(N,dt),wt}else dt.uniforms=we.getUniforms(N),N.onBuild(ae,dt,p),N.onBeforeCompile(dt,p),wt=we.acquireProgram(dt,mt),Ct.set(mt,wt),$.uniforms=dt.uniforms;let St=$.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(St.clippingPlanes=D.uniform),F1(N,dt),$.needsLights=NO(N),$.lightsStateVersion=at,$.needsLights&&(St.ambientLightColor.value=ue.state.ambient,St.lightProbe.value=ue.state.probe,St.directionalLights.value=ue.state.directional,St.directionalLightShadows.value=ue.state.directionalShadow,St.spotLights.value=ue.state.spot,St.spotLightShadows.value=ue.state.spotShadow,St.rectAreaLights.value=ue.state.rectArea,St.ltc_1.value=ue.state.rectAreaLTC1,St.ltc_2.value=ue.state.rectAreaLTC2,St.pointLights.value=ue.state.point,St.pointLightShadows.value=ue.state.pointShadow,St.hemisphereLights.value=ue.state.hemi,St.directionalShadowMap.value=ue.state.directionalShadowMap,St.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,St.spotShadowMap.value=ue.state.spotShadowMap,St.spotLightMatrix.value=ue.state.spotLightMatrix,St.spotLightMap.value=ue.state.spotLightMap,St.pointShadowMap.value=ue.state.pointShadowMap,St.pointShadowMatrix.value=ue.state.pointShadowMatrix);let Cn=wt.getUniforms(),ni=Sc.seqWithValue(Cn.seq,St);return $.currentProgram=wt,$.uniformsList=ni,wt}function F1(N,te){let ae=fe.get(N);ae.outputEncoding=te.outputEncoding,ae.instancing=te.instancing,ae.skinning=te.skinning,ae.morphTargets=te.morphTargets,ae.morphNormals=te.morphNormals,ae.morphColors=te.morphColors,ae.morphTargetsCount=te.morphTargetsCount,ae.numClippingPlanes=te.numClippingPlanes,ae.numIntersection=te.numClipIntersection,ae.vertexAlphas=te.vertexAlphas,ae.vertexTangents=te.vertexTangents,ae.toneMapping=te.toneMapping}function RO(N,te,ae,$,ue){te.isScene!==!0&&(te=G),ce.resetTextureUnits();let tt=te.fog,at=$.isMeshStandardMaterial?te.environment:null,dt=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:li,mt=($.isMeshStandardMaterial?Se:ye).get($.envMap||at),Ct=$.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,wt=!!$.normalMap&&!!ae.attributes.tangent,St=!!ae.morphAttributes.position,Cn=!!ae.morphAttributes.normal,ni=!!ae.morphAttributes.color,ro=$.toneMapped?p.toneMapping:fo,Qa=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Pn=Qa!==void 0?Qa.length:0,At=fe.get($),m0=h.state.lights;if(V===!0&&(q===!0||N!==S)){let ri=N===S&&$.id===w;D.setState($,N,ri)}let Jn=!1;$.version===At.__version?(At.needsLights&&At.lightsStateVersion!==m0.state.version||At.outputEncoding!==dt||ue.isInstancedMesh&&At.instancing===!1||!ue.isInstancedMesh&&At.instancing===!0||ue.isSkinnedMesh&&At.skinning===!1||!ue.isSkinnedMesh&&At.skinning===!0||At.envMap!==mt||$.fog===!0&&At.fog!==tt||At.numClippingPlanes!==void 0&&(At.numClippingPlanes!==D.numPlanes||At.numIntersection!==D.numIntersection)||At.vertexAlphas!==Ct||At.vertexTangents!==wt||At.morphTargets!==St||At.morphNormals!==Cn||At.morphColors!==ni||At.toneMapping!==ro||Z.isWebGL2===!0&&At.morphTargetsCount!==Pn)&&(Jn=!0):(Jn=!0,At.__version=$.version);let Ka=At.currentProgram;Jn===!0&&(Ka=yi($,te,ue));let U1=!1,Sh=!1,g0=!1,fr=Ka.getUniforms(),Za=At.uniforms;if(k.useProgram(Ka.program)&&(U1=!0,Sh=!0,g0=!0),$.id!==w&&(w=$.id,Sh=!0),U1||S!==N){if(fr.setValue(z,"projectionMatrix",N.projectionMatrix),Z.logarithmicDepthBuffer&&fr.setValue(z,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),S!==N&&(S=N,Sh=!0,g0=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let ri=fr.map.cameraPosition;ri!==void 0&&ri.setValue(z,U.setFromMatrixPosition(N.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&fr.setValue(z,"isOrthographic",N.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||ue.isSkinnedMesh)&&fr.setValue(z,"viewMatrix",N.matrixWorldInverse)}if(ue.isSkinnedMesh){fr.setOptional(z,ue,"bindMatrix"),fr.setOptional(z,ue,"bindMatrixInverse");let ri=ue.skeleton;ri&&(Z.floatVertexTextures?(ri.boneTexture===null&&ri.computeBoneTexture(),fr.setValue(z,"boneTexture",ri.boneTexture,ce),fr.setValue(z,"boneTextureSize",ri.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 y0=ae.morphAttributes;if((y0.position!==void 0||y0.normal!==void 0||y0.color!==void 0&&Z.isWebGL2===!0)&&xe.update(ue,ae,$,Ka),(Sh||At.receiveShadow!==ue.receiveShadow)&&(At.receiveShadow=ue.receiveShadow,fr.setValue(z,"receiveShadow",ue.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(Za.envMap.value=mt,Za.flipEnvMap.value=mt.isCubeTexture&&mt.isRenderTargetTexture===!1?-1:1),Sh&&(fr.setValue(z,"toneMappingExposure",p.toneMappingExposure),At.needsLights&&LO(Za,g0),tt&&$.fog===!0&&He.refreshFogUniforms(Za,tt),He.refreshMaterialUniforms(Za,$,I,T,W),Sc.upload(z,At.uniformsList,Za,ce)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Sc.upload(z,At.uniformsList,Za,ce),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&fr.setValue(z,"center",ue.center),fr.setValue(z,"modelViewMatrix",ue.modelViewMatrix),fr.setValue(z,"normalMatrix",ue.normalMatrix),fr.setValue(z,"modelMatrix",ue.matrixWorld),ue.previousModelViewMatrix&&fr.setValue(z,"previousModelViewMatrix",ue.previousModelViewMatrix),N.previousProjectionMatrix&&fr.setValue(z,"previousProjectionMatrix",N.previousProjectionMatrix),$.isShaderMaterial||$.isRawShaderMaterial){let ri=$.uniformsGroups;for(let v0=0,BO=ri.length;v0<BO;v0++)if(Z.isWebGL2){let k1=ri[v0];Qe.update(k1,Ka),Qe.bind(k1,Ka)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ka}function LO(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function NO(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,ae){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=ae;let $=fe.get(N);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=ae===void 0,$.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let ae=fe.get(N);ae.__webglFramebuffer=te,ae.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,ae=0){x=N,y=te,v=ae;let $=!0,ue=null,tt=!1,at=!1;if(N){let mt=fe.get(N);mt.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),$=!1):mt.__webglFramebuffer===void 0?ce.setupRenderTarget(N):mt.__hasExternalTextures&&ce.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let Ct=N.texture;(Ct.isData3DTexture||Ct.isDataArrayTexture||Ct.isCompressedArrayTexture)&&(at=!0);let wt=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(ue=wt[te],tt=!0):Z.isWebGL2&&N.samples>0&&ce.useMultisampledRTT(N)===!1?ue=fe.get(N).__webglMultisampledFramebuffer:ue=wt,_.copy(N.viewport),M.copy(N.scissor),b=N.scissorTest}else _.copy(O).multiplyScalar(I).floor(),M.copy(B).multiplyScalar(I).floor(),b=j;if(k.bindFramebuffer(36160,ue)&&Z.drawBuffers&&$&&k.drawBuffers(N,ue),k.viewport(_),k.scissor(M),k.setScissorTest(b),tt){let mt=fe.get(N.texture);z.framebufferTexture2D(36160,36064,34069+te,mt.__webglTexture,ae)}else if(at){let mt=fe.get(N.texture),Ct=te||0;z.framebufferTextureLayer(36160,36064,mt.__webglTexture,ae||0,Ct)}w=-1},this.readRenderTargetPixels=function(N,te,ae,$,ue,tt,at){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let dt=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&at!==void 0&&(dt=dt[at]),dt){k.bindFramebuffer(36160,dt);try{let mt=N.texture,Ct=mt.format,wt=mt.type;if(Ct!==oi&&Pe.convert(Ct)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let St=wt===ol&&(K.has("EXT_color_buffer_half_float")||Z.isWebGL2&&K.has("EXT_color_buffer_float"));if(wt!==Qt&&Pe.convert(wt)!==z.getParameter(35738)&&!(wt===pr&&(Z.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!St){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-$&&ae>=0&&ae<=N.height-ue&&z.readPixels(te,ae,$,ue,Pe.convert(Ct),Pe.convert(wt),tt)}finally{let mt=x!==null?fe.get(x).__webglFramebuffer:null;k.bindFramebuffer(36160,mt)}}},this.copyFramebufferToTexture=function(N,te,ae=0){let $=Math.pow(2,-ae),ue=Math.floor(te.image.width*$),tt=Math.floor(te.image.height*$);ce.setTexture2D(te,0),z.copyTexSubImage2D(3553,ae,0,0,N.x,N.y,ue,tt),k.unbindTexture()},this.copyTextureToTexture=function(N,te,ae,$=0){let ue=te.image.width,tt=te.image.height,at=Pe.convert(ae.format),dt=Pe.convert(ae.type);ce.setTexture2D(ae,0),z.pixelStorei(37440,ae.flipY),z.pixelStorei(37441,ae.premultiplyAlpha),z.pixelStorei(3317,ae.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,$,N.x,N.y,ue,tt,at,dt,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,$,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,at,te.mipmaps[0].data):z.texSubImage2D(3553,$,N.x,N.y,at,dt,te.image),$===0&&ae.generateMipmaps&&z.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(N,te,ae,$,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let tt=N.max.x-N.min.x+1,at=N.max.y-N.min.y+1,dt=N.max.z-N.min.z+1,mt=Pe.convert($.format),Ct=Pe.convert($.type),wt;if($.isData3DTexture)ce.setTexture3D($,0),wt=32879;else if($.isDataArrayTexture)ce.setTexture2DArray($,0),wt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,$.flipY),z.pixelStorei(37441,$.premultiplyAlpha),z.pixelStorei(3317,$.unpackAlignment);let St=z.getParameter(3314),Cn=z.getParameter(32878),ni=z.getParameter(3316),ro=z.getParameter(3315),Qa=z.getParameter(32877),Pn=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;z.pixelStorei(3314,Pn.width),z.pixelStorei(32878,Pn.height),z.pixelStorei(3316,N.min.x),z.pixelStorei(3315,N.min.y),z.pixelStorei(32877,N.min.z),ae.isDataTexture||ae.isData3DTexture?z.texSubImage3D(wt,ue,te.x,te.y,te.z,tt,at,dt,mt,Ct,Pn.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(wt,ue,te.x,te.y,te.z,tt,at,dt,mt,Pn.data)):z.texSubImage3D(wt,ue,te.x,te.y,te.z,tt,at,dt,mt,Ct,Pn),z.pixelStorei(3314,St),z.pixelStorei(32878,Cn),z.pixelStorei(3316,ni),z.pixelStorei(3315,ro),z.pixelStorei(32877,Qa),ue===0&&$.generateMipmaps&&z.generateMipmap(wt),k.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ce.setTextureCube(N,0):N.isData3DTexture?ce.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ce.setTexture2DArray(N,0):ce.setTexture2D(N,0),k.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,k.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var wx=class extends qx{};wx.prototype.isWebGL1Renderer=!0;var Ec=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Re(t),this.near=e,this.far=n}clone(){return new Ec(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},mr=class extends ht{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},xm=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=ax,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=xi()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=xi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=xi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Or=new A,ll=class{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Or.fromBufferAttribute(this,e),Or.applyMatrix4(t),this.setXYZ(e,Or.x,Or.y,Or.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Or.fromBufferAttribute(this,e),Or.applyNormalMatrix(t),this.setXYZ(e,Or.x,Or.y,Or.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Or.fromBufferAttribute(this,e),Or.transformDirection(t),this.setXYZ(e,Or.x,Or.y,Or.z);return this}setX(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=ho(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=ho(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=ho(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=ho(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=zt(e,this.array),n=zt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=zt(e,this.array),n=zt(n,this.array),r=zt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=zt(e,this.array),n=zt(n,this.array),r=zt(r,this.array),s=zt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return new Be(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new ll(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var jh=class extends ht{constructor(){super(),this.isBone=!0,this.type="Bone"}},mo=class extends qt{constructor(t=null,e=1,n=1,r,s,o,a,l,u=Dt,c=Dt,d,h){super(null,o,a,l,u,c,r,s,d,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},QA=new ie,BF=new ie,ra=class{constructor(t=[],e=[]){this.uuid=xi(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new ie)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new ie;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:BF;QA.multiplyMatrices(a,e[s]),QA.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ra(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=S_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new mo(e,t,t,oi,pr);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){let s=t.bones[n],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new jh),this.bones.push(o),this.boneInverses.push(new ie().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let r=0,s=e.length;r<s;r++){let o=e[r];t.bones.push(o.uuid);let a=n[r];t.boneInverses.push(a.toArray())}return t}},bm=class extends Be{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var wi=class extends al{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Re(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},KA=new A,ZA=new A,JA=new ie,Z0=new ji,Jp=new dn,cl=class extends ht{constructor(t=new Me,e=new wi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let r=1,s=e.count;r<s;r++)KA.fromBufferAttribute(e,r-1),ZA.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=KA.distanceTo(ZA);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,r=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Jp.copy(n.boundingSphere),Jp.applyMatrix4(r),Jp.radius+=s,t.ray.intersectsSphere(Jp)===!1)return;JA.copy(r).invert(),Z0.copy(t.ray).applyMatrix4(JA);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let y=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){let S=m.getX(x),_=m.getX(x+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,_),Z0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(h);b<t.near||b>t.far||e.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),Z0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let _=t.ray.origin.distanceTo(h);_<t.near||_>t.far||e.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},$A=new A,e_=new A,ia=class extends cl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let r=0,s=e.count;r<s;r+=2)$A.fromBufferAttribute(e,r),e_.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+$A.distanceTo(e_);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var wm=class extends qt{constructor(t,e,n,r,s,o,a,l,u){super(t,e,n,r,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Xe,this.magFilter=s!==void 0?s:Xe,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Si=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),r=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),u=n[r]-o,u<0)a=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===o)return r/(s-1);let c=n[r],h=n[r+1]-c,f=(o-c)/h;return(r+f)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),l=e||(o.isVector2?new F:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,r=[],s=[],o=[],a=new A,l=new ie;for(let f=0;f<=t;f++){let m=f/t;r[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(zn(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(r[f],s[f])}if(e===!0){let f=Math.acos(zn(s[0].dot(s[t]),-1,1));f/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],f*m)),o[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},ul=class extends Si{constructor(t=0,e=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new F,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},Sx=class extends ul{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Yx(){let i=0,t=0,e=0,n=0;function r(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){r(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+n*a}}}var $p=new A,J0=new Yx,$0=new Yx,ex=new Yx,Ax=class extends Si{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new A){let n=e,r=this.points,s=r.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=r[(a-1)%s]:($p.subVectors(r[0],r[1]).add(r[0]),u=$p);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?c=r[(a+2)%s]:($p.subVectors(r[s-1],r[s-2]).add(r[s-1]),c=$p),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(c),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),J0.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,m,p,g),$0.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,m,p,g),ex.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(J0.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),$0.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),ex.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(J0.calc(l),$0.calc(l),ex.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new A().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function t_(i,t,e,n,r){let s=(n-t)*.5,o=(r-e)*.5,a=i*i,l=i*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*i+e}function FF(i,t){let e=1-i;return e*e*t}function UF(i,t){return 2*(1-i)*i*t}function kF(i,t){return i*i*t}function Fh(i,t,e,n){return FF(i,t)+UF(i,e)+kF(i,n)}function zF(i,t){let e=1-i;return e*e*e*t}function GF(i,t){let e=1-i;return 3*e*e*i*t}function VF(i,t){return 3*(1-i)*i*i*t}function HF(i,t){return i*i*i*t}function Uh(i,t,e,n,r){return zF(i,t)+GF(i,e)+VF(i,n)+HF(i,r)}var _r=class extends Si{constructor(t=new F,e=new F,n=new F,r=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new F){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Uh(t,r.x,s.x,o.x,a.x),Uh(t,r.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},dl=class extends Si{constructor(t=new A,e=new A,n=new A,r=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Uh(t,r.x,s.x,o.x,a.x),Uh(t,r.y,s.y,o.y,a.y),Uh(t,r.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Mr=class extends Si{constructor(t=new F,e=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new F){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new F;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Wh=class extends Si{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},ci=class extends Si{constructor(t=new F,e=new F,n=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new F){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Fh(t,r.x,s.x,o.x),Fh(t,r.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},_x=class extends Si{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Fh(t,r.x,s.x,o.x),Fh(t,r.y,s.y,o.y),Fh(t,r.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Tc=class extends Si{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new F){let n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],u=r[o],c=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return n.set(t_(a,l.x,u.x,c.x,d.x),t_(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new F().fromArray(r))}return this}},jF=Object.freeze({__proto__:null,ArcCurve:Sx,CatmullRomCurve3:Ax,CubicBezierCurve:_r,CubicBezierCurve3:dl,EllipseCurve:ul,LineCurve:Mr,LineCurve3:Wh,QuadraticBezierCurve:ci,QuadraticBezierCurve3:_x,SplineCurve:Tc}),qh=class extends Si{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Mr(e,t))}getPoint(t,e){let n=t*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(e.push(c),n=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new jF[r.type]().fromJSON(r))}return this}},hl=class extends qh{constructor(t){super(),this.type="Path",this.currentPoint=new F,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Mr(this.currentPoint.clone(),new F(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){let s=new ci(this.currentPoint.clone(),new F(t,e),new F(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){let a=new _r(this.currentPoint.clone(),new F(t,e),new F(n,r),new F(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Tc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,r,s,o,a,l),this}absellipse(t,e,n,r,s,o,a,l){let u=new ul(t,e,n,r,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},Cc=class extends Me{constructor(t=[new F(0,-.5),new F(.5,0),new F(0,.5)],e=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:r},e=Math.floor(e),r=zn(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new F,f=new A,m=new A,p=new A,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let v=0;v<=e;v++){let x=n+v*c*r,w=Math.sin(x),S=Math.cos(x);for(let _=0;_<=t.length-1;_++){d.x=t[_].x*w,d.y=t[_].y,d.z=t[_].x*S,o.push(d.x,d.y,d.z),h.x=v/e,h.y=_/(t.length-1),a.push(h.x,h.y);let M=l[3*_+0]*w,b=l[3*_+1],E=l[3*_+0]*S;u.push(M,b,E)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let w=x+v*t.length,S=w,_=w+t.length,M=w+t.length+1,b=w+1;s.push(S,_,b),s.push(M,b,_)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(u,3))}static fromJSON(t){return new Cc(t.points,t.segments,t.phiStart,t.phiLength)}};var fl=class extends Me{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;r=Math.floor(r),s=Math.floor(s);let c=[],d=[],h=[],f=[],m=0,p=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function v(){let w=new A,S=new A,_=0,M=(e-t)/n;for(let b=0;b<=s;b++){let E=[],T=b/s,I=T*(e-t)+t;for(let C=0;C<=r;C++){let P=C/r,O=P*l+a,B=Math.sin(O),j=Math.cos(O);S.x=I*B,S.y=-T*n+g,S.z=I*j,d.push(S.x,S.y,S.z),w.set(B,M,j).normalize(),h.push(w.x,w.y,w.z),f.push(P,1-T),E.push(m++)}p.push(E)}for(let b=0;b<r;b++)for(let E=0;E<s;E++){let T=p[E][b],I=p[E+1][b],C=p[E+1][b+1],P=p[E][b+1];c.push(T,I,P),c.push(I,C,P),_+=6}u.addGroup(y,_,0),y+=_}function x(w){let S=m,_=new F,M=new A,b=0,E=w===!0?t:e,T=w===!0?1:-1;for(let C=1;C<=r;C++)d.push(0,g*T,0),h.push(0,T,0),f.push(.5,.5),m++;let I=m;for(let C=0;C<=r;C++){let O=C/r*l+a,B=Math.cos(O),j=Math.sin(O);M.x=E*j,M.y=g*T,M.z=E*B,d.push(M.x,M.y,M.z),h.push(0,T,0),_.x=B*.5+.5,_.y=j*.5*T+.5,f.push(_.x,_.y),m++}for(let C=0;C<r;C++){let P=S+C,O=I+C;w===!0?c.push(O,O+1,P):c.push(O+1,O,P),b+=3}u.addGroup(y,b,w===!0?1:2),y+=b}}static fromJSON(t){return new fl(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Pc=class extends fl{constructor(t=1,e=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Pc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Ic=class extends Me{constructor(t=[],e=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};let s=[],o=[];a(r),u(n),c(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,w=new A,S=new A;for(let _=0;_<e.length;_+=3)f(e[_+0],x),f(e[_+1],w),f(e[_+2],S),l(x,w,S,v)}function l(v,x,w,S){let _=S+1,M=[];for(let b=0;b<=_;b++){M[b]=[];let E=v.clone().lerp(w,b/_),T=x.clone().lerp(w,b/_),I=_-b;for(let C=0;C<=I;C++)C===0&&b===_?M[b][C]=E:M[b][C]=E.clone().lerp(T,C/I)}for(let b=0;b<_;b++)for(let E=0;E<2*(_-b)-1;E++){let T=Math.floor(E/2);E%2===0?(h(M[b][T+1]),h(M[b+1][T]),h(M[b][T])):(h(M[b][T+1]),h(M[b+1][T+1]),h(M[b+1][T]))}}function u(v){let x=new A;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,S=y(v)/Math.PI+.5;o.push(w,1-S)}m(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],S=o[v+4],_=Math.max(x,w,S),M=Math.min(x,w,S);_>.9&&M<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function m(){let v=new A,x=new A,w=new A,S=new A,_=new F,M=new F,b=new F;for(let E=0,T=0;E<s.length;E+=9,T+=6){v.set(s[E+0],s[E+1],s[E+2]),x.set(s[E+3],s[E+4],s[E+5]),w.set(s[E+6],s[E+7],s[E+8]),_.set(o[T+0],o[T+1]),M.set(o[T+2],o[T+3]),b.set(o[T+4],o[T+5]),S.copy(v).add(x).add(w).divideScalar(3);let I=g(S);p(_,T+0,v,I),p(M,T+2,x,I),p(b,T+4,w,I)}}function p(v,x,w,S){S<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new Ic(t.vertices,t.indices,t.radius,t.details)}},Dc=class extends Ic{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Dc(t.radius,t.detail)}};var go=class extends hl{constructor(t){super(t),this.uuid=xi(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new hl().fromJSON(r))}return this}},WF={triangulate:function(i,t,e=2){let n=t&&t.length,r=n?t[0]*e:i.length,s=D_(i,0,r,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=KF(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let m=e;m<r;m+=e)d=i[m],h=i[m+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return Yh(s,o,e,a,l,f,0),o}};function D_(i,t,e,n,r){let s,o;if(r===aU(i,t,e,n)>0)for(s=t;s<e;s+=n)o=n_(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=n_(s,i[s],i[s+1],o);return o&&Fm(o,o.next)&&(Qh(o),o=o.next),o}function pl(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(Fm(e,e.next)||on(e.prev,e,e.next)===0)){if(Qh(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Yh(i,t,e,n,r,s,o){if(!i)return;!o&&s&&tU(i,n,r,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?YF(i,n,r,s):qF(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),Qh(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=XF(pl(i),t,e),Yh(i,t,e,n,r,s,2)):o===2&&QF(i,t,e,n,r,s):Yh(pl(i),t,e,n,r,s,1);break}}}function qF(i){let t=i.prev,e=i,n=i.next;if(on(t,e,n)>=0)return!1;let r=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=r<s?r<o?r:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=r>s?r>o?r:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,m=n.next;for(;m!==t;){if(m.x>=c&&m.x<=h&&m.y>=d&&m.y<=f&&bc(r,a,s,l,o,u,m.x,m.y)&&on(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function YF(i,t,e,n){let r=i.prev,s=i,o=i.next;if(on(r,s,o)>=0)return!1;let a=r.x,l=s.x,u=o.x,c=r.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,m=c<d?c<h?c:h:d<h?d:h,p=a>l?a>u?a:u:l>u?l:u,g=c>d?c>h?c:h:d>h?d:h,y=Mx(f,m,t,e,n),v=Mx(p,g,t,e,n),x=i.prevZ,w=i.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&bc(a,c,l,d,u,h,x.x,x.y)&&on(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==r&&w!==o&&bc(a,c,l,d,u,h,w.x,w.y)&&on(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&bc(a,c,l,d,u,h,x.x,x.y)&&on(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==r&&w!==o&&bc(a,c,l,d,u,h,w.x,w.y)&&on(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function XF(i,t,e){let n=i;do{let r=n.prev,s=n.next.next;!Fm(r,s)&&O_(r,n,n.next,s)&&Xh(r,s)&&Xh(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Qh(n),Qh(n.next),n=i=s),n=n.next}while(n!==i);return pl(n)}function QF(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&iU(o,a)){let l=R_(o,a);o=pl(o,o.next),l=pl(l,l.next),Yh(o,t,e,n,r,s,0),Yh(l,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function KF(i,t,e,n){let r=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:i.length,u=D_(i,a,l,n,!1),u===u.next&&(u.steiner=!0),r.push(rU(u));for(r.sort(ZF),s=0;s<r.length;s++)e=JF(r[s],e);return e}function ZF(i,t){return i.x-t.x}function JF(i,t){let e=$F(i,t);if(!e)return t;let n=R_(e,i);return pl(n,n.next),pl(e,e.next)}function $F(i,t){let e=t,n=-1/0,r,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,r=e.x<e.next.x?e:e.next,h===s))return r}e=e.next}while(e!==t);if(!r)return null;let a=r,l=r.x,u=r.y,c=1/0,d;e=r;do s>=e.x&&e.x>=l&&s!==e.x&&bc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),Xh(e,i)&&(d<c||d===c&&(e.x>r.x||e.x===r.x&&eU(r,e)))&&(r=e,c=d)),e=e.next;while(e!==a);return r}function eU(i,t){return on(i.prev,i,t.prev)<0&&on(t.next,i,i.next)<0}function tU(i,t,e,n){let r=i;do r.z===0&&(r.z=Mx(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,nU(r)}function nU(i){let t,e,n,r,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,u*=2}while(o>1);return i}function Mx(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function rU(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function bc(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function iU(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!sU(i,t)&&(Xh(i,t)&&Xh(t,i)&&oU(i,t)&&(on(i.prev,i,t.prev)||on(i,t.prev,t))||Fm(i,t)&&on(i.prev,i,i.next)>0&&on(t.prev,t,t.next)>0)}function on(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Fm(i,t){return i.x===t.x&&i.y===t.y}function O_(i,t,e,n){let r=tm(on(i,t,e)),s=tm(on(i,t,n)),o=tm(on(e,n,i)),a=tm(on(e,n,t));return!!(r!==s&&o!==a||r===0&&em(i,e,t)||s===0&&em(i,n,t)||o===0&&em(e,i,n)||a===0&&em(e,t,n))}function em(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function tm(i){return i>0?1:i<0?-1:0}function sU(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&O_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Xh(i,t){return on(i.prev,i,i.next)<0?on(i,t,i.next)>=0&&on(i,i.prev,t)>=0:on(i,t,i.prev)<0||on(i,i.next,t)<0}function oU(i,t){let e=i,n=!1,r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function R_(i,t){let e=new Ex(i.i,i.x,i.y),n=new Ex(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function n_(i,t,e,n){let r=new Ex(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Qh(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ex(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function aU(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var Oc=class{static area(t){let e=t.length,n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return Oc.area(t)<0}static triangulateShape(t,e){let n=[],r=[],s=[];r_(t),i_(n,t);let o=t.length;e.forEach(r_);for(let l=0;l<e.length;l++)r.push(o),o+=e[l].length,i_(n,e[l]);let a=WF.triangulate(n,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function r_(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function i_(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var Rc=class extends Ic{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Rc(t.radius,t.detail)}};var ml=class extends Me{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],d=new A,h=new A,f=[],m=[],p=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,w=0;y==0&&o==0?w=.5/e:y==n&&l==Math.PI&&(w=-.5/e);for(let S=0;S<=e;S++){let _=S/e;d.x=-t*Math.cos(r+_*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(r+_*s)*Math.sin(o+x*a),m.push(d.x,d.y,d.z),h.copy(d).normalize(),p.push(h.x,h.y,h.z),g.push(_+w,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],w=c[y][v],S=c[y+1][v],_=c[y+1][v+1];(y!==0||o>0)&&f.push(x,w,_),(y!==n-1||l<Math.PI)&&f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(t){return new ml(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var Lc=class extends Me{constructor(t=1,e=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],l=[],u=[],c=[],d=new A,h=new A,f=new A,m=new A,p=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let w=x/n*s*Math.PI*2;v(w,s,o,t,f),v(w+.01,s,o,t,m),g.subVectors(m,f),y.addVectors(m,f),p.crossVectors(g,y),y.crossVectors(p,g),p.normalize(),y.normalize();for(let S=0;S<=r;++S){let _=S/r*Math.PI*2,M=-e*Math.cos(_),b=e*Math.sin(_);d.x=f.x+(M*y.x+b*p.x),d.y=f.y+(M*y.y+b*p.y),d.z=f.z+(M*y.z+b*p.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(S/r)}}for(let x=1;x<=n;x++)for(let w=1;w<=r;w++){let S=(r+1)*(x-1)+(w-1),_=(r+1)*x+(w-1),M=(r+1)*x+w,b=(r+1)*(x-1)+w;a.push(S,_,b),a.push(_,M,b)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(c,2));function v(x,w,S,_,M){let b=Math.cos(x),E=Math.sin(x),T=S/w*x,I=Math.cos(T);M.x=_*(2+I)*.5*b,M.y=_*(2+I)*E*.5,M.z=_*Math.sin(T)*.5}}static fromJSON(t){return new Lc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Jo(i,t,e){return L_(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function nm(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function L_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function lU(i){function t(r,s){return i[r]-i[s]}let e=i.length,n=new Array(e);for(let r=0;r!==e;++r)n[r]=r;return n.sort(t),n}function s_(i,t,e){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=e[s]*t;for(let l=0;l!==t;++l)r[o++]=i[a+l]}return r}function N_(i,t,e,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=i[r++];while(s!==void 0)}var Nc=class{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],s=e[n-1];e:{t:{let o;n:{r:if(!(t<r)){for(let a=n+2;;){if(r===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=e[++n],t<r)break t}o=e.length;break n}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=e[--n-1],t>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(r=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r;for(let o=0;o!==r;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Tx=class extends Nc{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yc,endingEnd:yc}}intervalChanged_(t,e,n){let r=this.parameterPositions,s=t-2,o=t+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case vc:s=t,a=2*e-n;break;case cm:s=r.length-2,a=e+r[s]-r[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case vc:o=t,l=2*n-e;break;case cm:o=1,l=n+r[1]-r[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(n-e)/(r-e),p=m*m,g=p*m,y=-h*g+2*h*p-h*m,v=(1+h)*g+(-1.5-2*h)*p+(-.5+h)*m+1,x=(-1-f)*g+(1.5+f)*p+.5*m,w=f*g-f*p;for(let S=0;S!==a;++S)s[S]=y*o[c+S]+v*o[u+S]+x*o[l+S]+w*o[d+S];return s}},Sm=class extends Nc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(r-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},Cx=class extends Nc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}},Ai=class{constructor(t,e,n,r){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=nm(e,this.TimeBufferType),this.values=nm(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:nm(t.times,Array),values:nm(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Cx(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Sm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Tx(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case am:e=this.InterpolantFactoryMethodDiscrete;break;case lm:e=this.InterpolantFactoryMethodLinear;break;case E0:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return am;case this.InterpolantFactoryMethodLinear:return lm;case this.InterpolantFactoryMethodSmooth:return E0}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Jo(n,s,o),this.values=Jo(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(r!==void 0&&L_(r))for(let a=0,l=r.length;a!==l;++a){let u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Jo(this.times),e=Jo(this.values),n=this.getValueSize(),r=this.getInterpolation()===E0,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(r)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let m=0;m!==n;++m){let p=e[d+m];if(p!==e[h+m]||p!==e[f+m]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Jo(t,0,o),this.values=Jo(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=Jo(this.times,0),e=Jo(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}};Ai.prototype.TimeBufferType=Float32Array;Ai.prototype.ValueBufferType=Float32Array;Ai.prototype.DefaultInterpolation=lm;var sa=class extends Ai{};sa.prototype.ValueTypeName="bool";sa.prototype.ValueBufferType=Array;sa.prototype.DefaultInterpolation=am;sa.prototype.InterpolantFactoryMethodLinear=void 0;sa.prototype.InterpolantFactoryMethodSmooth=void 0;var Am=class extends Ai{};Am.prototype.ValueTypeName="color";var Bc=class extends Ai{};Bc.prototype.ValueTypeName="number";var Px=class extends Nc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(r-e),u=t*a;for(let c=u+a;u!==c;u+=4)qe.slerpFlat(s,0,o,u-a,o,u,l);return s}},gl=class extends Ai{InterpolantFactoryMethodLinear(t){return new Px(this.times,this.values,this.getValueSize(),t)}};gl.prototype.ValueTypeName="quaternion";gl.prototype.DefaultInterpolation=lm;gl.prototype.InterpolantFactoryMethodSmooth=void 0;var oa=class extends Ai{};oa.prototype.ValueTypeName="string";oa.prototype.ValueBufferType=Array;oa.prototype.DefaultInterpolation=am;oa.prototype.InterpolantFactoryMethodLinear=void 0;oa.prototype.InterpolantFactoryMethodSmooth=void 0;var Fc=class extends Ai{};Fc.prototype.ValueTypeName="vector";var Uc=class{constructor(t,e=-1,n,r=Vx){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=xi(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(uU(n[o]).scale(r));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=n.length;s!==o;++s)e.push(Ai.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(t,e,n,r){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],u=[];l.push((a+s-1)%s,a,(a+1)%s),u.push(0,1,0);let c=lU(l);l=s_(l,1,c),u=s_(u,1,c),!r&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new Bc(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let u=t[a],c=u.name.match(s);if(c&&c.length>1){let d=c[1],h=r[d];h||(r[d]=h=[]),h.push(u)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(d,h,f,m,p){if(f.length!==0){let g=[],y=[];N_(f,g,y,m),g.length!==0&&p.push(new d(h,g,y))}},r=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let d=0;d<u.length;d++){let h=u[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},m;for(m=0;m<h.length;m++)if(h[m].morphTargets)for(let p=0;p<h[m].morphTargets.length;p++)f[h[m].morphTargets[p]]=-1;for(let p in f){let g=[],y=[];for(let v=0;v!==h[m].morphTargets.length;++v){let x=h[m];g.push(x.time),y.push(x.morphTarget===p?1:0)}r.push(new Bc(".morphTargetInfluence["+p+"]",g,y))}l=f.length*o}else{let f=".bones["+e[d].name+"]";n(Fc,f+".position",h,"pos",r),n(gl,f+".quaternion",h,"rot",r),n(Fc,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function cU(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bc;case"vector":case"vector2":case"vector3":case"vector4":return Fc;case"color":return Am;case"quaternion":return gl;case"bool":case"boolean":return sa;case"string":return oa}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function uU(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=cU(i.type);if(i.times===void 0){let e=[],n=[];N_(i.keys,e,n,"value"),i.times=e,i.values=n}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var o_={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},Kh=class{constructor(t,e,n){let r=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&r.onStart!==void 0&&r.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,r.onProgress!==void 0&&r.onProgress(c,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],m=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return m}return null}}},dU=new Kh,kc=class{constructor(t){this.manager=t!==void 0?t:dU,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},co={},Ix=class extends Error{constructor(t,e){super(t),this.response=e}},zc=class extends kc{constructor(t){super(t)}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=o_.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(co[t]!==void 0){co[t].push({onLoad:e,onProgress:n,onError:r});return}co[t]=[],co[t].push({onLoad:e,onProgress:n,onError:r});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=co[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,m=f!==0,p=0,g=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:w})=>{if(x)y.close();else{p+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let _=0,M=c.length;_<M;_++){let b=c[_];b.onProgress&&b.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw new Ix(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(m=>f.decode(m))}}}).then(u=>{o_.add(t,u);let c=co[t];delete co[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=co[t];if(c===void 0)throw this.manager.itemError(t),u;delete co[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var aa=class extends ht{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},_m=class extends aa{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Re(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},tx=new ie,a_=new A,l_=new A,Zh=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Vh,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new We(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;a_.setFromMatrixPosition(t.matrixWorld),e.position.copy(a_),l_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(l_),e.updateMatrixWorld(),tx.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tx),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(tx)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},Dx=class extends Zh{constructor(){super(new yn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=zh*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||r!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=r,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Mm=class extends aa{constructor(t,e,n=0,r=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Dx}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},c_=new ie,Dh=new A,nx=new A,Ox=class extends Zh{constructor(){super(new yn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new We(2,1,1,1),new We(0,1,1,1),new We(3,1,1,1),new We(1,1,1,1),new We(3,0,1,1),new We(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Dh.setFromMatrixPosition(t.matrixWorld),n.position.copy(Dh),nx.copy(n.position),nx.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(nx),n.updateMatrixWorld(),r.makeTranslation(-Dh.x,-Dh.y,-Dh.z),c_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(c_)}},Em=class extends aa{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Ox}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},Rx=class extends Zh{constructor(){super(new Mc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Tm=class extends aa{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.shadow=new Rx}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Lx=class extends Me{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Gc=class extends kc{constructor(t){super(t)}load(t,e,n,r){let s=this,o=new zc(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(t)}},n,r)}parse(t){let e={},n={};function r(f,m){if(e[m]!==void 0)return e[m];let g=f.interleavedBuffers[m],y=s(f,g.buffer),v=Rp(g.type,y),x=new xm(v,g.stride);return x.uuid=g.uuid,e[m]=x,x}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],y=new Uint32Array(g).buffer;return n[m]=y,y}let o=t.isInstancedBufferGeometry?new Lx:new Me,a=t.data.index;if(a!==void 0){let f=Rp(a.type,a.array);o.setIndex(new Be(f,1))}let l=t.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=r(t.data,m.data);p=new ll(g,m.itemSize,m.offset,m.normalized)}else{let g=Rp(m.type,m.array),y=m.isInstancedBufferAttribute?bm:Be;p=new y(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let u=t.data.morphAttributes;if(u)for(let f in u){let m=u[f],p=[];for(let g=0,y=m.length;g<y;g++){let v=m[g],x;if(v.isInterleavedBufferAttribute){let w=r(t.data,v.data);x=new ll(w,v.itemSize,v.offset,v.normalized)}else{let w=Rp(v.type,v.array);x=new Be(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),p.push(x)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,m=d.length;f!==m;++f){let p=d[f];o.addGroup(p.start,p.count,p.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new dn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Cm=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=u_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=u_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function u_(){return(typeof performance>"u"?Date:performance).now()}var Nx=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let r,s,o;switch(e){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let n=this.buffer,r=this.valueSize,s=t*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,r=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(n,r,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){a.setValue(n,r);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let s=n,o=r;s!==o;++s)e[s]=e[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,r){qe.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,s){let o=this._workIndex*s;qe.multiplyQuaternionsFlat(t,o,t,e,t,n),qe.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[n+o]*r}}},Xx="\\[\\]\\.:\\/",hU=new RegExp("["+Xx+"]","g"),Qx="[^"+Xx+"]",fU="[^"+Xx.replace("\\.","")+"]",pU=/((?:WC+[\/:])*)/.source.replace("WC",Qx),mU=/(WCOD+)?/.source.replace("WCOD",fU),gU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qx),yU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qx),vU=new RegExp("^"+pU+mU+gU+yU+"$"),xU=["material","materials","bones","map"],Bx=class{constructor(t,e,n){let r=n||It.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},It=class{constructor(t,e,n){this.path=e,this.parsedPath=n||It.parseTrackName(e),this.node=It.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new It.Composite(t,e,n):new It(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(hU,"")}static parseTrackName(t){let e=vU.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);xU.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)t[e++]=n[r]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,r=e.propertyName,s=e.propertyIndex;if(t||(t=It.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[r];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};It.Composite=Bx;It.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};It.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};It.prototype.GetterByBindingType=[It.prototype._getValue_direct,It.prototype._getValue_array,It.prototype._getValue_arrayElement,It.prototype._getValue_toArray];It.prototype.SetterByBindingTypeAndVersioning=[[It.prototype._setValue_direct,It.prototype._setValue_direct_setNeedsUpdate,It.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[It.prototype._setValue_array,It.prototype._setValue_array_setNeedsUpdate,It.prototype._setValue_array_setMatrixWorldNeedsUpdate],[It.prototype._setValue_arrayElement,It.prototype._setValue_arrayElement_setNeedsUpdate,It.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[It.prototype._setValue_fromArray,It.prototype._setValue_fromArray_setNeedsUpdate,It.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Fx=class{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:yc,endingEnd:yc};for(let u=0;u!==o;++u){let c=s[u].createInterpolant(null);a[u]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Gx,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){let r=this._clip.duration,s=t._clip.duration,o=s/r,a=r/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+n,u[0]=t/o,u[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,r){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case LR:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case Vx:default:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulate(r,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,r=this.time+t,s=this._loopCount,o=n===$h;if(t===0)return s===-1?r:o&&(s&1)===1?e-r:r;if(n===zx){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=e)r=e;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:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=e||r<0){let a=Math.floor(r/e);r-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return e-r}return r}_setEndings(t,e,n){let r=this._interpolantSettings;n?(r.endingStart=vc,r.endingEnd=vc):(t?r.endingStart=this.zeroSlopeAtStart?vc:yc:r.endingStart=cm,e?r.endingEnd=this.zeroSlopeAtEnd?vc:yc:r.endingEnd=cm)}_scheduleFading(t,e,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}},bU=new Float32Array(1),Pm=class extends Ut{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,s=r.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let d=0;d!==s;++d){let h=r[d],f=h.name,m=c[f];if(m!==void 0)++m.referenceCount,o[d]=m;else{if(m=o[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}let p=e&&e._propertyBindings[d].binding.parsedPath;m=new Nx(It.create(n,f,p),h.ValueTypeName,h.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),o[d]=m}a[d].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,s=this._actionsByClip[r];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){let r=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,u=l[l.length-1],c=t._byClipCacheIndex;u._byClipCacheIndex=c,l[c]=u,l.pop(),t._byClipCacheIndex=null;let d=a.actionByRoot,h=(t._localRoot||this._root).uuid;delete d[h],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[e];o===void 0&&(o={},r[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new Sm(new Float32Array(2),new Float32Array(2),1,bU),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,s=e[r];t.__cacheIndex=r,e[r]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){let r=e||this._root,s=r.uuid,o=typeof t=="string"?Uc.findByName(r,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Vx),l!==void 0){let d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===n)return d;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new Fx(this,o,e,n);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let n=e||this._root,r=n.uuid,s=typeof t=="string"?Uc.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,n=t.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let u=o[a];this._deactivateAction(u);let c=u._cacheIndex,d=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,d._cacheIndex=c,e[c]=d,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},se=class{constructor(t){this.value=t}clone(){return new se(this.value.clone===void 0?this.value:this.value.clone())}};var Vc=class{constructor(t,e,n=0,r=1/0){this.ray=new ji(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new Gh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return Ux(t,this,n,e),n.sort(d_),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)Ux(t[r],this,n,e);return n.sort(d_),n}};function d_(i,t){return i.distance-t.distance}function Ux(i,t,e,n){if(i.layers.test(t.layers)&&i.raycast(t,e),n===!0){let r=i.children;for(let s=0,o=r.length;s<o;s++)Ux(r[s],t,e,!0)}}var Jh=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(zn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var h_=new F,Im=class{constructor(t=new F(1/0,1/0),e=new F(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=h_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return h_.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},f_=new A,rm=new A,Hn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){f_.subVectors(t,this.start),rm.subVectors(this.end,this.start);let n=rm.dot(rm),s=rm.dot(f_)/n;return e&&(s=zn(s,0,1)),s}closestPointToPoint(t,e,n){let r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},p_=new A,Dm=class extends ht{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Me,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 o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;r.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Ae(r,3));let s=new wi({fog:!1,toneMapped:!1});this.cone=new ia(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),p_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(p_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Om=class extends Dn{constructor(t,e,n){let r=new ml(e,4,2),s=new Wi({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var m_=new A,im=new A,g_=new A,Rm=class extends ht{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let r=new Me;r.setAttribute("position",new Ae([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new wi({fog:!1,toneMapped:!1});this.lightPlane=new cl(r,s),this.add(this.lightPlane),r=new Me,r.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new cl(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),m_.setFromMatrixPosition(this.light.matrixWorld),im.setFromMatrixPosition(this.light.target.matrixWorld),g_.subVectors(im,m_),this.lightPlane.lookAt(im),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(im),this.targetLine.scale.z=g_.length()}},sm=new A,un=new qi,la=class extends ia{constructor(t){let e=new Me,n=new wi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){r.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(r.length/3-1)}e.setAttribute("position",new Ae(r,3)),e.setAttribute("color",new Ae(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Re(16755200),c=new Re(16711680),d=new Re(43775),h=new Re(16777215),f=new Re(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,r=1;un.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),gn("c",e,t,un,0,0,-1),gn("t",e,t,un,0,0,1),gn("n1",e,t,un,-n,-r,-1),gn("n2",e,t,un,n,-r,-1),gn("n3",e,t,un,-n,r,-1),gn("n4",e,t,un,n,r,-1),gn("f1",e,t,un,-n,-r,1),gn("f2",e,t,un,n,-r,1),gn("f3",e,t,un,-n,r,1),gn("f4",e,t,un,n,r,1),gn("u1",e,t,un,n*.7,r*1.1,-1),gn("u2",e,t,un,-n*.7,r*1.1,-1),gn("u3",e,t,un,0,r*2,-1),gn("cf1",e,t,un,-n,0,1),gn("cf2",e,t,un,n,0,1),gn("cf3",e,t,un,0,-r,1),gn("cf4",e,t,un,0,r,1),gn("cn1",e,t,un,-n,0,-1),gn("cn2",e,t,un,n,0,-1),gn("cn3",e,t,un,0,-r,-1),gn("cn4",e,t,un,0,r,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function gn(i,t,e,n,r,s,o){sm.set(r,s,o).unproject(n);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],sm.x,sm.y,sm.z)}}var ca=class extends ia{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Me;s.setIndex(new Be(n,1)),s.setAttribute("position",new Ae(r,3)),super(s,new wi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var Lm=class extends ia{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Me;r.setAttribute("position",new Ae(e,3)),r.setAttribute("color",new Ae(n,3));let s=new wi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(t,e,n){let r=new Re,s=this.geometry.attributes.color.array;return r.set(t),r.toArray(s,0),r.toArray(s,3),r.set(e),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=yo);var Wc=".",ef=Symbol("target"),Kx=Symbol("unsubscribe");function tf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function B_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var di=Array.isArray;function yl(i){return typeof i=="symbol"}var wU={after:(i,t)=>di(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>di(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=Wc),yl(t)?i+t.toString():i+t):i,initial:i=>{if(di(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(Wc);return t===-1?"":i.slice(0,t)},last:i=>{if(di(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(Wc);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(di(i))for(let e of i)t(e);else if(i!==""){let e=0,n=i.indexOf(Wc);if(n===-1)t(i);else for(;e<i.length;)n===-1&&(n=i.length),t(i.slice(e,n)),e=n+1,n=i.indexOf(Wc,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},Nr=wU;function Zx(i){return typeof i=="object"&&typeof i.next=="function"}function Jx(i,t,e,n,r){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=r(o.value[0],t,o.value[0],n),o.value[1]=r(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[ef].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=r(a.value,t,o.next().value,n)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=r(o.value,t,o.value,n)),o};return i}function Um(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&yl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var nf=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),r=n[e];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(t,e),n[e]=r),r}getProxy(t,e,n,r){if(this.isUnsubscribed)return t;let s=t[r],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,n):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Nr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,r,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,r):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(t);r&&(delete r[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let r=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&r!==void 0&&Object.is(t.value,r.value)&&(t.writable||!1)===(r.writable||!1)&&(t.enumerable||!1)===(r.enumerable||!1)&&(t.configurable||!1)===(r.configurable||!1)&&t.get===r.get&&t.set===r.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function qc(i){return toString.call(i)==="[object Object]"}function Yc(){return!0}function ua(i,t){return i.length!==t.length||i.some((e,n)=>t[n]!==e)}var km=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var SU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),$x={push:Yc,pop:Yc,shift:Yc,unshift:Yc,copyWithin:ua,reverse:ua,sort:ua,splice:ua,flat:ua,fill:ua},F_=new Set([...km,...SU,...Object.keys($x)]);function Xc(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var eb=["keys","values","entries"],tb=new Set(["has","toString"]),nb={add:Xc,clear:Xc,delete:Xc,forEach:Xc},U_=new Set([...tb,...Object.keys(nb),...eb]);function Qc(i,t){if(i.size!==t.size)return!0;let e;for(let[n,r]of i)if(e=t.get(n),e!==r||e===void 0&&!t.has(n))return!0;return!1}var AU=new Set([...tb,"get"]),rb={set:Qc,clear:Qc,delete:Qc,forEach:Qc},k_=new Set([...AU,...Object.keys(rb),...eb]);var nr=class{constructor(t,e,n,r){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return km.has(t)}_shallowClone(t){let e=t;if(qc(t))e={...t};else if(di(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,r]of t.entries())e.set(n,this._shallowClone(r))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,r){return t?(di(r)?this._onIsChanged=$x[e]:r instanceof Set?this._onIsChanged=nb[e]:r instanceof Map&&(this._onIsChanged=rb[e]),r):n}update(t,e,n){let r=Nr.after(t,this._path);if(e!=="length"){let s=this.clone;Nr.walk(r,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:r,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],Nr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Kc=class extends nr{static isHandledMethod(t){return F_.has(t)}};var rf=class extends nr{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Zc=class extends nr{static isHandledMethod(t){return U_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var Jc=class extends nr{static isHandledMethod(t){return k_.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var sf=class extends nr{constructor(t,e,n,r){super(void 0,e,n,r),this._arg1=n[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var of=class extends nr{constructor(t,e,n,r){super(void 0,e,n,r),this._weakKey=n[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Xi=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return qc(t)||di(t)||tf(t)}static isHandledMethod(t,e){return qc(t)?nr.isHandledMethod(e):di(t)?Kc.isHandledMethod(e):t instanceof Set?Zc.isHandledMethod(e):t instanceof Map?Jc.isHandledMethod(e):tf(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let r=nr;di(t)?r=Kc:t instanceof Date?r=rf:t instanceof Set?r=Zc:t instanceof Map?r=Jc:t instanceof WeakSet?r=sf:t instanceof WeakMap&&(r=of),this._stack.push(new r(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:r}=t,s=Xi.isHandledMethod(n,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var _U={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},ib=(i,t,e={})=>{e={..._U,...e};let n=Symbol("ProxyTarget"),{equals:r,isShallow:s,ignoreDetached:o,details:a}=e,l=new nf(r),u=typeof e.onValidate=="function",c=new Xi(u),d=(v,x,w,S,_)=>!u||c.isCloning||e.onValidate(Nr.concat(l.getPath(v),x),w,S,_)===!0,h=(v,x,w,S)=>{!Um(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,_)=>{c.isCloning?c.update(v,x,S):t(Nr.concat(v,x),w,S,_)},m=v=>v&&(v[n]||v),p=(v,x,w,S)=>B_(v)||w==="constructor"||s&&!Xi.isHandledMethod(x,w)||Um(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,Nr.concat(S,w),g,n)),g={get(v,x,w){if(yl(x)){if(x===n||x===ef)return v;if(x===Kx&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=tf(v)?Reflect.get(v,x):Reflect.get(v,x,w);return p(S,v,x)},set(v,x,w,S){w=m(w);let _=v[n]||v,M=_[x];if(r(M,w)&&x in v)return!0;let b=d(v,x,w,M);return b&&l.setProperty(_,x,w,S,M)?(h(v,x,v[x],M),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];d(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&h(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=d(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(h(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&Xi.isHandledType(S)){let _=Nr.initial(l.getPath(v)),M=Xi.isHandledMethod(S,v.name);c.start(S,_,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),M?w.map(I=>m(I)):w),E=c.isChanged(S,r),T=c.stop();if(Xi.isHandledType(b)&&M&&(x instanceof Map&&v.name==="get"&&(_=Nr.concat(_,w[0])),b=l.getProxy(b,_,g)),E){let I={name:v.name,args:w,result:b},C=c.isCloning?Nr.initial(_):_,P=c.isCloning?Nr.last(_):"";d(Nr.get(i,C),P,S,T,I)?f(C,P,S,T,I):c.undo(S)}return(x instanceof Map||x instanceof Set)&&Zx(b)?Jx(b,v,x,_,p):b}return Reflect.apply(v,x,w)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};ib.target=i=>i&&i[ef]||i;ib.unsubscribe=i=>i[Kx]||i;var sb=ib;var MU=typeof global=="object"&&global&&global.Object===Object&&global,zm=MU;var EU=typeof self=="object"&&self&&self.Object===Object&&self,TU=zm||EU||Function("return this")(),hn=TU;var CU=hn.Symbol,rr=CU;var z_=Object.prototype,PU=z_.hasOwnProperty,IU=z_.toString,af=rr?rr.toStringTag:void 0;function DU(i){var t=PU.call(i,af),e=i[af];try{i[af]=void 0;var n=!0}catch{}var r=IU.call(i);return n&&(t?i[af]=e:delete i[af]),r}var G_=DU;var OU=Object.prototype,RU=OU.toString;function LU(i){return RU.call(i)}var V_=LU;var NU="[object Null]",BU="[object Undefined]",H_=rr?rr.toStringTag:void 0;function FU(i){return i==null?i===void 0?BU:NU:H_&&H_ in Object(i)?G_(i):V_(i)}var hi=FU;function UU(i){return i!=null&&typeof i=="object"}var gr=UU;var kU="[object Symbol]";function zU(i){return typeof i=="symbol"||gr(i)&&hi(i)==kU}var da=zU;function GU(i,t){for(var e=-1,n=i==null?0:i.length,r=Array(n);++e<n;)r[e]=t(i[e],e,i);return r}var Gm=GU;var VU=Array.isArray,jn=VU;var HU=1/0,j_=rr?rr.prototype:void 0,W_=j_?j_.toString:void 0;function q_(i){if(typeof i=="string")return i;if(jn(i))return Gm(i,q_)+"";if(da(i))return W_?W_.call(i):"";var t=i+"";return t=="0"&&1/i==-HU?"-0":t}var Y_=q_;var jU=/\s/;function WU(i){for(var t=i.length;t--&&jU.test(i.charAt(t)););return t}var X_=WU;var qU=/^\s+/;function YU(i){return i&&i.slice(0,X_(i)+1).replace(qU,"")}var Q_=YU;function XU(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Rn=XU;var K_=0/0,QU=/^[-+]0x[0-9a-f]+$/i,KU=/^0b[01]+$/i,ZU=/^0o[0-7]+$/i,JU=parseInt;function $U(i){if(typeof i=="number")return i;if(da(i))return K_;if(Rn(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Rn(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Q_(i);var e=KU.test(i);return e||ZU.test(i)?JU(i.slice(2),e?2:8):QU.test(i)?K_:+i}var ob=$U;function ek(i){return i}var Z_=ek;var tk="[object AsyncFunction]",nk="[object Function]",rk="[object GeneratorFunction]",ik="[object Proxy]";function sk(i){if(!Rn(i))return!1;var t=hi(i);return t==nk||t==rk||t==tk||t==ik}var Vm=sk;var ok=hn["__core-js_shared__"],Hm=ok;var J_=function(){var i=/[^.]+$/.exec(Hm&&Hm.keys&&Hm.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function ak(i){return!!J_&&J_ in i}var $_=ak;var lk=Function.prototype,ck=lk.toString;function uk(i){if(i!=null){try{return ck.call(i)}catch{}try{return i+""}catch{}}return""}var vo=uk;var dk=/[\\^$.*+?()[\]{}|]/g,hk=/^\[object .+?Constructor\]$/,fk=Function.prototype,pk=Object.prototype,mk=fk.toString,gk=pk.hasOwnProperty,yk=RegExp("^"+mk.call(gk).replace(dk,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function vk(i){if(!Rn(i)||$_(i))return!1;var t=Vm(i)?yk:hk;return t.test(vo(i))}var eM=vk;function xk(i,t){return i?.[t]}var tM=xk;function bk(i,t){var e=tM(i,t);return eM(e)?e:void 0}var Wr=bk;var wk=Wr(hn,"WeakMap"),jm=wk;var nM=Object.create,Sk=function(){function i(){}return function(t){if(!Rn(t))return{};if(nM)return nM(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),rM=Sk;function Ak(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var iM=Ak;function _k(i,t){var e=-1,n=i.length;for(t||(t=Array(n));++e<n;)t[e]=i[e];return t}var sM=_k;var Mk=800,Ek=16,Tk=Date.now;function Ck(i){var t=0,e=0;return function(){var n=Tk(),r=Ek-(n-e);if(e=n,r>0){if(++t>=Mk)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var oM=Ck;function Pk(i){return function(){return i}}var aM=Pk;var Ik=function(){try{var i=Wr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),$c=Ik;var Dk=$c?function(i,t){return $c(i,"toString",{configurable:!0,enumerable:!1,value:aM(t),writable:!0})}:Z_,lM=Dk;var Ok=oM(lM),cM=Ok;function Rk(i,t){for(var e=-1,n=i==null?0:i.length;++e<n&&t(i[e],e,i)!==!1;);return i}var uM=Rk;var Lk=9007199254740991,Nk=/^(?:0|[1-9]\d*)$/;function Bk(i,t){var e=typeof i;return t=t??Lk,!!t&&(e=="number"||e!="symbol"&&Nk.test(i))&&i>-1&&i%1==0&&i<t}var eu=Bk;function Fk(i,t,e){t=="__proto__"&&$c?$c(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Wm=Fk;function Uk(i,t){return i===t||i!==i&&t!==t}var tu=Uk;var kk=Object.prototype,zk=kk.hasOwnProperty;function Gk(i,t,e){var n=i[t];(!(zk.call(i,t)&&tu(n,e))||e===void 0&&!(t in i))&&Wm(i,t,e)}var nu=Gk;function Vk(i,t,e,n){var r=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),r?Wm(e,a,l):nu(e,a,l)}return e}var ws=Vk;var dM=Math.max;function Hk(i,t,e){return t=dM(t===void 0?i.length-1:t,0),function(){for(var n=arguments,r=-1,s=dM(n.length-t,0),o=Array(s);++r<s;)o[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=e(o),iM(i,this,a)}}var hM=Hk;var jk=9007199254740991;function Wk(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=jk}var ru=Wk;function qk(i){return i!=null&&ru(i.length)&&!Vm(i)}var qm=qk;var Yk=Object.prototype;function Xk(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Yk;return i===e}var iu=Xk;function Qk(i,t){for(var e=-1,n=Array(i);++e<i;)n[e]=t(e);return n}var fM=Qk;var Kk="[object Arguments]";function Zk(i){return gr(i)&&hi(i)==Kk}var ab=Zk;var pM=Object.prototype,Jk=pM.hasOwnProperty,$k=pM.propertyIsEnumerable,ez=ab(function(){return arguments}())?ab:function(i){return gr(i)&&Jk.call(i,"callee")&&!$k.call(i,"callee")},su=ez;function tz(){return!1}var mM=tz;var vM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,gM=vM&&typeof module=="object"&&module&&!module.nodeType&&module,nz=gM&&gM.exports===vM,yM=nz?hn.Buffer:void 0,rz=yM?yM.isBuffer:void 0,iz=rz||mM,vl=iz;var sz="[object Arguments]",oz="[object Array]",az="[object Boolean]",lz="[object Date]",cz="[object Error]",uz="[object Function]",dz="[object Map]",hz="[object Number]",fz="[object Object]",pz="[object RegExp]",mz="[object Set]",gz="[object String]",yz="[object WeakMap]",vz="[object ArrayBuffer]",xz="[object DataView]",bz="[object Float32Array]",wz="[object Float64Array]",Sz="[object Int8Array]",Az="[object Int16Array]",_z="[object Int32Array]",Mz="[object Uint8Array]",Ez="[object Uint8ClampedArray]",Tz="[object Uint16Array]",Cz="[object Uint32Array]",Kt={};Kt[bz]=Kt[wz]=Kt[Sz]=Kt[Az]=Kt[_z]=Kt[Mz]=Kt[Ez]=Kt[Tz]=Kt[Cz]=!0;Kt[sz]=Kt[oz]=Kt[vz]=Kt[az]=Kt[xz]=Kt[lz]=Kt[cz]=Kt[uz]=Kt[dz]=Kt[hz]=Kt[fz]=Kt[pz]=Kt[mz]=Kt[gz]=Kt[yz]=!1;function Pz(i){return gr(i)&&ru(i.length)&&!!Kt[hi(i)]}var xM=Pz;function Iz(i){return function(t){return i(t)}}var ou=Iz;var bM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lf=bM&&typeof module=="object"&&module&&!module.nodeType&&module,Dz=lf&&lf.exports===bM,lb=Dz&&zm.process,Oz=function(){try{var i=lf&&lf.require&&lf.require("util").types;return i||lb&&lb.binding&&lb.binding("util")}catch{}}(),xo=Oz;var wM=xo&&xo.isTypedArray,Rz=wM?ou(wM):xM,Ym=Rz;var Lz=Object.prototype,Nz=Lz.hasOwnProperty;function Bz(i,t){var e=jn(i),n=!e&&su(i),r=!e&&!n&&vl(i),s=!e&&!n&&!r&&Ym(i),o=e||n||r||s,a=o?fM(i.length,String):[],l=a.length;for(var u in i)(t||Nz.call(i,u))&&!(o&&(u=="length"||r&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||eu(u,l)))&&a.push(u);return a}var Xm=Bz;function Fz(i,t){return function(e){return i(t(e))}}var Qm=Fz;var Uz=Qm(Object.keys,Object),SM=Uz;var kz=Object.prototype,zz=kz.hasOwnProperty;function Gz(i){if(!iu(i))return SM(i);var t=[];for(var e in Object(i))zz.call(i,e)&&e!="constructor"&&t.push(e);return t}var AM=Gz;function Vz(i){return qm(i)?Xm(i):AM(i)}var au=Vz;function Hz(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var _M=Hz;var jz=Object.prototype,Wz=jz.hasOwnProperty;function qz(i){if(!Rn(i))return _M(i);var t=iu(i),e=[];for(var n in i)n=="constructor"&&(t||!Wz.call(i,n))||e.push(n);return e}var MM=qz;function Yz(i){return qm(i)?Xm(i,!0):MM(i)}var lu=Yz;var Xz=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qz=/^\w*$/;function Kz(i,t){if(jn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||da(i)?!0:Qz.test(i)||!Xz.test(i)||t!=null&&i in Object(t)}var EM=Kz;var Zz=Wr(Object,"create"),bo=Zz;function Jz(){this.__data__=bo?bo(null):{},this.size=0}var TM=Jz;function $z(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var CM=$z;var eG="__lodash_hash_undefined__",tG=Object.prototype,nG=tG.hasOwnProperty;function rG(i){var t=this.__data__;if(bo){var e=t[i];return e===eG?void 0:e}return nG.call(t,i)?t[i]:void 0}var PM=rG;var iG=Object.prototype,sG=iG.hasOwnProperty;function oG(i){var t=this.__data__;return bo?t[i]!==void 0:sG.call(t,i)}var IM=oG;var aG="__lodash_hash_undefined__";function lG(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=bo&&t===void 0?aG:t,this}var DM=lG;function cu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}cu.prototype.clear=TM;cu.prototype.delete=CM;cu.prototype.get=PM;cu.prototype.has=IM;cu.prototype.set=DM;var cb=cu;function cG(){this.__data__=[],this.size=0}var OM=cG;function uG(i,t){for(var e=i.length;e--;)if(tu(i[e][0],t))return e;return-1}var ha=uG;var dG=Array.prototype,hG=dG.splice;function fG(i){var t=this.__data__,e=ha(t,i);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():hG.call(t,e,1),--this.size,!0}var RM=fG;function pG(i){var t=this.__data__,e=ha(t,i);return e<0?void 0:t[e][1]}var LM=pG;function mG(i){return ha(this.__data__,i)>-1}var NM=mG;function gG(i,t){var e=this.__data__,n=ha(e,i);return n<0?(++this.size,e.push([i,t])):e[n][1]=t,this}var BM=gG;function uu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}uu.prototype.clear=OM;uu.prototype.delete=RM;uu.prototype.get=LM;uu.prototype.has=NM;uu.prototype.set=BM;var fa=uu;var yG=Wr(hn,"Map"),pa=yG;function vG(){this.size=0,this.__data__={hash:new cb,map:new(pa||fa),string:new cb}}var FM=vG;function xG(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var UM=xG;function bG(i,t){var e=i.__data__;return UM(t)?e[typeof t=="string"?"string":"hash"]:e.map}var ma=bG;function wG(i){var t=ma(this,i).delete(i);return this.size-=t?1:0,t}var kM=wG;function SG(i){return ma(this,i).get(i)}var zM=SG;function AG(i){return ma(this,i).has(i)}var GM=AG;function _G(i,t){var e=ma(this,i),n=e.size;return e.set(i,t),this.size+=e.size==n?0:1,this}var VM=_G;function du(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}du.prototype.clear=FM;du.prototype.delete=kM;du.prototype.get=zM;du.prototype.has=GM;du.prototype.set=VM;var xl=du;var MG="Expected a function";function ub(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(MG);var e=function(){var n=arguments,r=t?t.apply(this,n):n[0],s=e.cache;if(s.has(r))return s.get(r);var o=i.apply(this,n);return e.cache=s.set(r,o)||s,o};return e.cache=new(ub.Cache||xl),e}ub.Cache=xl;var HM=ub;var EG=500;function TG(i){var t=HM(i,function(n){return e.size===EG&&e.clear(),n}),e=t.cache;return t}var jM=TG;var CG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,PG=/\\(\\)?/g,IG=jM(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(CG,function(e,n,r,s){t.push(r?s.replace(PG,"$1"):n||e)}),t}),WM=IG;function DG(i){return i==null?"":Y_(i)}var qM=DG;function OG(i,t){return jn(i)?i:EM(i,t)?[i]:WM(qM(i))}var _i=OG;var RG=1/0;function LG(i){if(typeof i=="string"||da(i))return i;var t=i+"";return t=="0"&&1/i==-RG?"-0":t}var ga=LG;function NG(i,t){t=_i(t,i);for(var e=0,n=t.length;i!=null&&e<n;)i=i[ga(t[e++])];return e&&e==n?i:void 0}var Km=NG;function BG(i,t){for(var e=-1,n=t.length,r=i.length;++e<n;)i[r+e]=t[e];return i}var hu=BG;var YM=rr?rr.isConcatSpreadable:void 0;function FG(i){return jn(i)||su(i)||!!(YM&&i&&i[YM])}var XM=FG;function QM(i,t,e,n,r){var s=-1,o=i.length;for(e||(e=XM),r||(r=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?QM(a,t-1,e,n,r):hu(r,a):n||(r[r.length]=a)}return r}var KM=QM;function UG(i){var t=i==null?0:i.length;return t?KM(i,1):[]}var ZM=UG;function kG(i){return cM(hM(i,void 0,ZM),i+"")}var Zm=kG;var zG=Qm(Object.getPrototypeOf,Object),fu=zG;var GG="[object Object]",VG=Function.prototype,HG=Object.prototype,JM=VG.toString,jG=HG.hasOwnProperty,WG=JM.call(Object);function qG(i){if(!gr(i)||hi(i)!=GG)return!1;var t=fu(i);if(t===null)return!0;var e=jG.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&JM.call(e)==WG}var $M=qG;function YG(i,t,e){var n=-1,r=i.length;t<0&&(t=-t>r?0:r+t),e=e>r?r:e,e<0&&(e+=r),r=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(r);++n<r;)s[n]=i[n+t];return s}var eE=YG;function XG(){this.__data__=new fa,this.size=0}var tE=XG;function QG(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var nE=QG;function KG(i){return this.__data__.get(i)}var rE=KG;function ZG(i){return this.__data__.has(i)}var iE=ZG;var JG=200;function $G(i,t){var e=this.__data__;if(e instanceof fa){var n=e.__data__;if(!pa||n.length<JG-1)return n.push([i,t]),this.size=++e.size,this;e=this.__data__=new xl(n)}return e.set(i,t),this.size=e.size,this}var sE=$G;function pu(i){var t=this.__data__=new fa(i);this.size=t.size}pu.prototype.clear=tE;pu.prototype.delete=nE;pu.prototype.get=rE;pu.prototype.has=iE;pu.prototype.set=sE;var mu=pu;function eV(i,t){return i&&ws(t,au(t),i)}var oE=eV;function tV(i,t){return i&&ws(t,lu(t),i)}var aE=tV;var dE=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lE=dE&&typeof module=="object"&&module&&!module.nodeType&&module,nV=lE&&lE.exports===dE,cE=nV?hn.Buffer:void 0,uE=cE?cE.allocUnsafe:void 0;function rV(i,t){if(t)return i.slice();var e=i.length,n=uE?uE(e):new i.constructor(e);return i.copy(n),n}var hE=rV;function iV(i,t){for(var e=-1,n=i==null?0:i.length,r=0,s=[];++e<n;){var o=i[e];t(o,e,i)&&(s[r++]=o)}return s}var fE=iV;function sV(){return[]}var Jm=sV;var oV=Object.prototype,aV=oV.propertyIsEnumerable,pE=Object.getOwnPropertySymbols,lV=pE?function(i){return i==null?[]:(i=Object(i),fE(pE(i),function(t){return aV.call(i,t)}))}:Jm,gu=lV;function cV(i,t){return ws(i,gu(i),t)}var mE=cV;var uV=Object.getOwnPropertySymbols,dV=uV?function(i){for(var t=[];i;)hu(t,gu(i)),i=fu(i);return t}:Jm,$m=dV;function hV(i,t){return ws(i,$m(i),t)}var gE=hV;function fV(i,t,e){var n=t(i);return jn(i)?n:hu(n,e(i))}var eg=fV;function pV(i){return eg(i,au,gu)}var cf=pV;function mV(i){return eg(i,lu,$m)}var tg=mV;var gV=Wr(hn,"DataView"),ng=gV;var yV=Wr(hn,"Promise"),rg=yV;var vV=Wr(hn,"Set"),ig=vV;var yE="[object Map]",xV="[object Object]",vE="[object Promise]",xE="[object Set]",bE="[object WeakMap]",wE="[object DataView]",bV=vo(ng),wV=vo(pa),SV=vo(rg),AV=vo(ig),_V=vo(jm),bl=hi;(ng&&bl(new ng(new ArrayBuffer(1)))!=wE||pa&&bl(new pa)!=yE||rg&&bl(rg.resolve())!=vE||ig&&bl(new ig)!=xE||jm&&bl(new jm)!=bE)&&(bl=function(i){var t=hi(i),e=t==xV?i.constructor:void 0,n=e?vo(e):"";if(n)switch(n){case bV:return wE;case wV:return yE;case SV:return vE;case AV:return xE;case _V:return bE}return t});var wo=bl;var MV=Object.prototype,EV=MV.hasOwnProperty;function TV(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&EV.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var SE=TV;var CV=hn.Uint8Array,yu=CV;function PV(i){var t=new i.constructor(i.byteLength);return new yu(t).set(new yu(i)),t}var vu=PV;function IV(i,t){var e=t?vu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var AE=IV;var DV=/\w*$/;function OV(i){var t=new i.constructor(i.source,DV.exec(i));return t.lastIndex=i.lastIndex,t}var _E=OV;var ME=rr?rr.prototype:void 0,EE=ME?ME.valueOf:void 0;function RV(i){return EE?Object(EE.call(i)):{}}var TE=RV;function LV(i,t){var e=t?vu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var CE=LV;var NV="[object Boolean]",BV="[object Date]",FV="[object Map]",UV="[object Number]",kV="[object RegExp]",zV="[object Set]",GV="[object String]",VV="[object Symbol]",HV="[object ArrayBuffer]",jV="[object DataView]",WV="[object Float32Array]",qV="[object Float64Array]",YV="[object Int8Array]",XV="[object Int16Array]",QV="[object Int32Array]",KV="[object Uint8Array]",ZV="[object Uint8ClampedArray]",JV="[object Uint16Array]",$V="[object Uint32Array]";function e4(i,t,e){var n=i.constructor;switch(t){case HV:return vu(i);case NV:case BV:return new n(+i);case jV:return AE(i,e);case WV:case qV:case YV:case XV:case QV:case KV:case ZV:case JV:case $V:return CE(i,e);case FV:return new n;case UV:case GV:return new n(i);case kV:return _E(i);case zV:return new n;case VV:return TE(i)}}var PE=e4;function t4(i){return typeof i.constructor=="function"&&!iu(i)?rM(fu(i)):{}}var IE=t4;var n4="[object Map]";function r4(i){return gr(i)&&wo(i)==n4}var DE=r4;var OE=xo&&xo.isMap,i4=OE?ou(OE):DE,RE=i4;var s4="[object Set]";function o4(i){return gr(i)&&wo(i)==s4}var LE=o4;var NE=xo&&xo.isSet,a4=NE?ou(NE):LE,BE=a4;var l4=1,c4=2,u4=4,FE="[object Arguments]",d4="[object Array]",h4="[object Boolean]",f4="[object Date]",p4="[object Error]",UE="[object Function]",m4="[object GeneratorFunction]",g4="[object Map]",y4="[object Number]",kE="[object Object]",v4="[object RegExp]",x4="[object Set]",b4="[object String]",w4="[object Symbol]",S4="[object WeakMap]",A4="[object ArrayBuffer]",_4="[object DataView]",M4="[object Float32Array]",E4="[object Float64Array]",T4="[object Int8Array]",C4="[object Int16Array]",P4="[object Int32Array]",I4="[object Uint8Array]",D4="[object Uint8ClampedArray]",O4="[object Uint16Array]",R4="[object Uint32Array]",Yt={};Yt[FE]=Yt[d4]=Yt[A4]=Yt[_4]=Yt[h4]=Yt[f4]=Yt[M4]=Yt[E4]=Yt[T4]=Yt[C4]=Yt[P4]=Yt[g4]=Yt[y4]=Yt[kE]=Yt[v4]=Yt[x4]=Yt[b4]=Yt[w4]=Yt[I4]=Yt[D4]=Yt[O4]=Yt[R4]=!0;Yt[p4]=Yt[UE]=Yt[S4]=!1;function sg(i,t,e,n,r,s){var o,a=t&l4,l=t&c4,u=t&u4;if(e&&(o=r?e(i,n,r,s):e(i)),o!==void 0)return o;if(!Rn(i))return i;var c=jn(i);if(c){if(o=SE(i),!a)return sM(i,o)}else{var d=wo(i),h=d==UE||d==m4;if(vl(i))return hE(i,a);if(d==kE||d==FE||h&&!r){if(o=l||h?{}:IE(i),!a)return l?gE(i,aE(o,i)):mE(i,oE(o,i))}else{if(!Yt[d])return r?i:{};o=PE(i,d,a)}}s||(s=new mu);var f=s.get(i);if(f)return f;s.set(i,o),BE(i)?i.forEach(function(g){o.add(sg(g,t,e,g,i,s))}):RE(i)&&i.forEach(function(g,y){o.set(y,sg(g,t,e,y,i,s))});var m=u?l?tg:cf:l?lu:au,p=c?void 0:m(i);return uM(p||i,function(g,y){p&&(y=g,g=i[y]),nu(o,y,sg(g,t,e,y,i,s))}),o}var og=sg;var L4=1,N4=4;function B4(i){return og(i,L4|N4)}var So=B4;var F4="__lodash_hash_undefined__";function U4(i){return this.__data__.set(i,F4),this}var zE=U4;function k4(i){return this.__data__.has(i)}var GE=k4;function ag(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new xl;++t<e;)this.add(i[t])}ag.prototype.add=ag.prototype.push=zE;ag.prototype.has=GE;var VE=ag;function z4(i,t){for(var e=-1,n=i==null?0:i.length;++e<n;)if(t(i[e],e,i))return!0;return!1}var HE=z4;function G4(i,t){return i.has(t)}var jE=G4;var V4=1,H4=2;function j4(i,t,e,n,r,s){var o=e&V4,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var d=-1,h=!0,f=e&H4?new VE:void 0;for(s.set(i,t),s.set(t,i);++d<a;){var m=i[d],p=t[d];if(n)var g=o?n(p,m,d,t,i,s):n(m,p,d,i,t,s);if(g!==void 0){if(g)continue;h=!1;break}if(f){if(!HE(t,function(y,v){if(!jE(f,v)&&(m===y||r(m,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(m===p||r(m,p,e,n,s))){h=!1;break}}return s.delete(i),s.delete(t),h}var lg=j4;function W4(i){var t=-1,e=Array(i.size);return i.forEach(function(n,r){e[++t]=[r,n]}),e}var WE=W4;function q4(i){var t=-1,e=Array(i.size);return i.forEach(function(n){e[++t]=n}),e}var qE=q4;var Y4=1,X4=2,Q4="[object Boolean]",K4="[object Date]",Z4="[object Error]",J4="[object Map]",$4="[object Number]",eH="[object RegExp]",tH="[object Set]",nH="[object String]",rH="[object Symbol]",iH="[object ArrayBuffer]",sH="[object DataView]",YE=rr?rr.prototype:void 0,db=YE?YE.valueOf:void 0;function oH(i,t,e,n,r,s,o){switch(e){case sH:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case iH:return!(i.byteLength!=t.byteLength||!s(new yu(i),new yu(t)));case Q4:case K4:case $4:return tu(+i,+t);case Z4:return i.name==t.name&&i.message==t.message;case eH:case nH:return i==t+"";case J4:var a=WE;case tH:var l=n&Y4;if(a||(a=qE),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;n|=X4,o.set(i,t);var c=lg(a(i),a(t),n,r,s,o);return o.delete(i),c;case rH:if(db)return db.call(i)==db.call(t)}return!1}var XE=oH;var aH=1,lH=Object.prototype,cH=lH.hasOwnProperty;function uH(i,t,e,n,r,s){var o=e&aH,a=cf(i),l=a.length,u=cf(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:cH.call(t,h)))return!1}var f=s.get(i),m=s.get(t);if(f&&m)return f==t&&m==i;var p=!0;s.set(i,t),s.set(t,i);for(var g=o;++d<l;){h=a[d];var y=i[h],v=t[h];if(n)var x=o?n(v,y,h,t,i,s):n(y,v,h,i,t,s);if(!(x===void 0?y===v||r(y,v,e,n,s):x)){p=!1;break}g||(g=h=="constructor")}if(p&&!g){var w=i.constructor,S=t.constructor;w!=S&&"constructor"in i&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(p=!1)}return s.delete(i),s.delete(t),p}var QE=uH;var dH=1,KE="[object Arguments]",ZE="[object Array]",cg="[object Object]",hH=Object.prototype,JE=hH.hasOwnProperty;function fH(i,t,e,n,r,s){var o=jn(i),a=jn(t),l=o?ZE:wo(i),u=a?ZE:wo(t);l=l==KE?cg:l,u=u==KE?cg:u;var c=l==cg,d=u==cg,h=l==u;if(h&&vl(i)){if(!vl(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new mu),o||Ym(i)?lg(i,t,e,n,r,s):XE(i,t,l,e,n,r,s);if(!(e&dH)){var f=c&&JE.call(i,"__wrapped__"),m=d&&JE.call(t,"__wrapped__");if(f||m){var p=f?i.value():i,g=m?t.value():t;return s||(s=new mu),r(p,g,e,n,s)}}return h?(s||(s=new mu),QE(i,t,e,n,r,s)):!1}var $E=fH;function eT(i,t,e,n,r){return i===t?!0:i==null||t==null||!gr(i)&&!gr(t)?i!==i&&t!==t:$E(i,t,e,n,eT,r)}var tT=eT;function pH(i,t){return i!=null&&t in Object(i)}var nT=pH;function mH(i,t,e){t=_i(t,i);for(var n=-1,r=t.length,s=!1;++n<r;){var o=ga(t[n]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++n!=r?s:(r=i==null?0:i.length,!!r&&ru(r)&&eu(o,r)&&(jn(i)||su(i)))}var rT=mH;function gH(i,t){return i!=null&&rT(i,t,nT)}var iT=gH;var yH=function(){return hn.Date.now()},ug=yH;var vH="Expected a function",xH=Math.max,bH=Math.min;function wH(i,t,e){var n,r,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof i!="function")throw new TypeError(vH);t=ob(t)||0,Rn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?xH(ob(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(_){var M=n,b=r;return n=r=void 0,u=_,o=i.apply(b,M),o}function m(_){return u=_,a=setTimeout(y,t),c?f(_):o}function p(_){var M=_-l,b=_-u,E=t-M;return d?bH(E,s-b):E}function g(_){var M=_-l,b=_-u;return l===void 0||M>=t||M<0||d&&b>=s}function y(){var _=ug();if(g(_))return v(_);a=setTimeout(y,p(_))}function v(_){return a=void 0,h&&n?f(_):(n=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0}function w(){return a===void 0?o:v(ug())}function S(){var _=ug(),M=g(_);if(n=arguments,r=this,l=_,M){if(a===void 0)return m(l);if(d)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return S.cancel=x,S.flush=w,S}var wl=wH;function SH(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var sT=SH;function AH(i,t){return t.length<2?i:Km(i,eE(t,0,-1))}var oT=AH;function _H(i,t){return tT(i,t)}var Sl=_H;function MH(i,t){return t=_i(t,i),i=oT(i,t),i==null||delete i[ga(sT(t))]}var aT=MH;function EH(i){return $M(i)?void 0:i}var lT=EH;var TH=1,CH=2,PH=4,IH=Zm(function(i,t){var e={};if(i==null)return e;var n=!1;t=Gm(t,function(s){return s=_i(s,i),n||(n=s.length>1),s}),ws(i,tg(i),e),n&&(e=og(e,TH|CH|PH,lT));for(var r=t.length;r--;)aT(e,t[r]);return e}),xu=IH;function DH(i,t,e,n){if(!Rn(i))return i;t=_i(t,i);for(var r=-1,s=t.length,o=s-1,a=i;a!=null&&++r<s;){var l=ga(t[r]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(r!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Rn(c)?c:eu(t[r+1])?[]:{})}nu(a,l,u),a=a[l]}return i}var cT=DH;function OH(i,t,e){for(var n=-1,r=t.length,s={};++n<r;){var o=t[n],a=Km(i,o);e(a,o)&&cT(s,_i(o,i),a)}return s}var uT=OH;function RH(i,t){return uT(i,t,function(e,n){return iT(i,n)})}var dT=RH;var LH=Zm(function(i,t){return i==null?{}:dT(i,t)}),Qi=LH;var NH="Expected a function";function BH(i,t,e){var n=!0,r=!0;if(typeof i!="function")throw new TypeError(NH);return Rn(e)&&(n="leading"in e?!!e.leading:n,r="trailing"in e?!!e.trailing:r),wl(i,t,{leading:n,maxWait:t,trailing:r})}var hb=BH;function hT(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ki(i,t){return Object.setPrototypeOf(i,t),i}var FH=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),UH=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),kH=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Al&&"ontouchend"in document,zH=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,GH=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,VH=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},HH=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},jte=FH(),Al=UH(),dg=kH(),fT=zH(),Wn=GH(),fb=VH(),pb=Number(HH());function hg(i){return Array.isArray(i)?i:[i]}function pT(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function uf(i){return Al?i.metaKey:i.ctrlKey}var ke=[],pg={},df={},fg={};function mT(i){ke.includes(i)||ke.push(i)}function bu(i){delete pg[i.pointerId];for(let t=0;t<ke.length;t++)if(ke[t].pointerId===i.pointerId){ke.splice(t,1);break}}function gT(){ke.splice(0,ke.length)}function mg(i){if(i.pointerType!=="touch")return;let t=pg[i.pointerId];t===void 0&&(t={x:0,y:0},pg[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function gg(i){let t=i.pointerId===ke[0].pointerId?ke[1]:ke[0];return pg[t.pointerId]}function yT(i){df[i.key]=!0,fg[i.key]=fg[i.key]===void 0?1:fg[i.key]+1}function vT(i){if(Al&&df.Meta)for(let t in df)df[t]=!1;else df[i.key]=!1;fg={}}function xT(i){i.addEventListener("pointerdown",mT,!0),i.addEventListener("pointerdown",mg,!0),i.addEventListener("pointermove",mg,!0),i.addEventListener("pointerup",bu,!0),i.addEventListener("pointercancel",bu,!0),i.addEventListener("pointerleave",bu,!0),window.addEventListener("keydown",yT,!0),window.addEventListener("keyup",vT,!0)}function bT(i){i.removeEventListener("pointerdown",mT,!0),i.removeEventListener("pointerdown",mg,!0),i.removeEventListener("pointermove",mg,!0),i.removeEventListener("pointerup",bu,!0),i.removeEventListener("pointercancel",bu,!0),i.removeEventListener("pointerleave",bu,!0),window.removeEventListener("keydown",yT,!0),window.removeEventListener("keyup",vT,!0)}var wT,ST=new Promise(i=>{wT=i});var yg;function AT(){if(yg)return yg;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.400/build",[n,r]=await Promise.all([import("./navmesh.js"),fetch(`${e}/navmesh.wasm`).then(a=>a.arrayBuffer())]),s=n.default,o=await s({wasmBinary:r});wT(o)}return yg=i(),yg}var _T,MT=new Promise(i=>{_T=i});var vg;function ET(){if(vg)return vg;async function i(){let t=await import("./physics.js");await t.init(),_T(t)}return vg=i(),vg}var kt=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,kt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let n=e[t.id],r;n===void 0?r={type:2,id:t.id}:r={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,kt.prototype),{data:a,actual:t,reverse:r}}else if(t.type===2){let{id:n}=t,r=e[n];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,kt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:r}}}}return null}};function hf(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let n=i[e];n&&typeof n=="object"&&hf(n)}return Object.freeze(i)}function TT(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var wu=class extends Error{};function xg(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ss(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let n=[],r=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*r;n.push(o)}return n}function Su(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function CT(){return typeof process<"u"}function PT(i,t){for(let e of i)t(e.id,e.data)!==!0&&PT(e.children,t)}function IT(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)IT(e,t)}var tn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,tn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hf(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let r of e.children)this.fillCaches0(r,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,n){if(!this.has(e))return!0;for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}rootAcestor(e){for(;e;){let n=this.parent(e);if(n)e=n;else return e}return e}isDescendantOf(e,n){for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}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,n){if(e===null)this.traverse(n);else{let r=this.get(e);r&&IT(r,n)}}traverse(e){PT(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,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let r=e,s=n;for(;r!==null;){let a=s,l=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,tn.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:n}){if(this.get(e)!==void 0)return!0;for(let r of n)if(this.checkDuplicatedIdRec(r))return!0;return!1}addOp(e){let{parent:n,fi:r,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:r,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let r=this.parent(n);if(r===void 0)return null;let s=this.childrenArray(r),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(r,s),actual:e,reverse:{type:7,...a,parent:r}}}}moveOp(e){let{parent:n,fi:r,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new wu("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:r},l=[...l,c],l.sort((f,m)=>f.fi-m.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let r=null;for(let s of this.childrenArray(e)){if(s.id===n)return r;r=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)+1;if(s<r.length)return r[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(r[s].id):n}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push({...r,...s})}n.sort((r,s)=>TT(r.sortKey,s.sortKey));for(let r of n)delete r.sortKey;return n}getWithSortKey(e){var n=e;let r=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)r.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:r}}}insertBeforeHelper(e,n,r){return this.insertAfterHelper(e,this.previous(e,n),r)}insertAfterHelper(e,n,r){let s=this.childrenArray(e);if(n===null){if(s.length===0)return Ss(0,r,r);{let o=s[0].fi;return Ss(o-r,o,r)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ss(l,l+r,r)}else return Ss(o.fi,a.fi,r)}}};var Au;(t=>{function i(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let r=n.props,s={},o=[...e],a=!1;if(r)for(let l of Object.keys(r)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=r[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let r=n.props,s={},o={...e},a=!1;if(r)for(let l of Object.keys(r)){s[l]=o[l];let u=r[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=i})(Au||(Au={}));var ze=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ze.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hf(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,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,ze.prototype);let n=e;return CT()||n.fillCaches(),n}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:n,id:r,data:s}=e,o=this,a={fi:n,id:r,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:r}}}deleteOp(e){let{id:n}=e,r=this,s=r.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,r=[...r];let o=r.splice(s,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:r}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===r);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let r of this){if(r.id===e)return n;n=r.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let r=this;if(e===null){if(r.length===0)return Ss(0,n,n);{let s=r[0].fi;return Ss(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=r.find(a=>a.fi>s.fi);if(o===void 0){let a=r[r.length-1].fi;return Ss(a,a+n,n)}else return Ss(s.fi,o.fi,n)}}};function _u(i){return i&&typeof i=="object"&&i instanceof nn}var nn=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,r=0,s={};for(;r<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[r]],n!==void 0&&!_u(n))return null;r+=1}n=n?xg(n):new nn;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;r>0;){if(Object.keys(n).length===0){let l=e[r-1];l&&(n=xg(l),delete n[t.path[r-1]])}else{let l=e[r-1];if(l){let u=xg(l);u[t.path[r-1]]=n,n=u}else{let u=new nn;u[t.path[r-1]]=n,n=u}}r-=1}let o=Object.setPrototypeOf(n,nn.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},As;(n=>{function i(r,s){return ff(r,s)??r}n.apply=i;function t(r,s){return gb(r,s)}n.merge=t;function e(r,s){let o=0,a=s.path,l=r;for(;o<a.length&&l!==void 0;){if(l=Br.zoomOnce(l,a[o]),l===void 0)return s;if(!_u(l))return;o+=1}if(l===void 0)return s;if(!!_u(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=mb([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(As||(As={}));function mb(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=ff(r.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=r.data),r.children){let a=mb(r.children,t);return a!==void 0?e=!0:a=r.children,{...r,id:s,data:o,children:a}}else return{...r,id:s,data:o}});if(e)return n}function jH(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=ff(r.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=r.data),{...r,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function ff(i,t){if(!_u(t))return t;if(i instanceof tn){let e=mb(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof ze)return jH(i,t);if(Array.isArray(i)){let e=!1,n=i.map((r,s)=>{let o=ff(r,t[s]);return e=e||o!==void 0,o===void 0&&(o=r),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else{if(i instanceof nn)return gb(i,t);if(i&&typeof i=="object"){let e={},n=!1;for(let[r,s]of Object.entries(i)){let o=ff(s,t[r]);n=n||o!==void 0,o===void 0&&(o=s),e[r]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function gb(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!_u(t))return t;if(!_u(i))return As.apply(i,t);let e=new Set;for(let r of Object.keys(i))e.add(r);for(let r of Object.keys(t))e.add(r);let n=new nn;for(let r of e){let s=gb(i===void 0?void 0:i[r],t===void 0?void 0:t[r]);n[r]=s}return n}function DT(i,t){let e={cur:[],result:[],len:0};return i=pf(i,t,e)??i,[i,e.result]}function bg(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function wg(i){i&&(i.len-=1)}function WH(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function OT(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=pf(s.data,t,bg(e,o));wg(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=OT(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return r}function qH(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=pf(s.data,t,bg(e,o));return wg(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function pf(i,t,e){if(i instanceof tn){let n=OT(i,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}else{if(i instanceof ze)return qH(i,t,e);if(Array.isArray(i)){let n=!1,r=i.map((s,o)=>{let a=pf(s,t,bg(e,o));return wg(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(i&&typeof i=="object"&&!Su(i)){let n={},r=!1;for(let[s,o]of Object.entries(i))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");r=!0,s=a}let l=pf(o,t,bg(e,s));wg(e),r=r||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(typeof i=="string"){let n=t[i];if(n!==void 0){if(i.length!==36)throw new Error("for now you should only call this method when the key is a uuid");WH(e)}return n}else return}}var Sg;(t=>{function i(e,n){let r=Br.zoom(n,e.path);if(typeof r=="object"){let s={};for(let o of Object.keys(e.props))s[o]=r[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(Sg||(Sg={}));var yr;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof nn&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof tn||l instanceof ze||l instanceof kt?h=l.runOp(u):h=Au.runOp(l,u)),h!==void 0)if(h!==null){let p=h.data;for(let g=d.length-1;g>=0;g--){let y=c[g],v=d[g];if(v instanceof tn){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof ze){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof kt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof nn){let x={...v,[y]:p};p=Object.setPrototypeOf(x,nn.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=p;p=[...v],p[y]=x}else p={...v,[y]:p};else return null}return{data:p,actual:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],m;if(l instanceof tn){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof ze){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)d.push(l),l=m;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function r(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=r;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&r(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(yr||(yr={}));var yb;(l=>{function i(){return[]}l.empty=i;function t(u,c){let d=[];for(let h of u){let[f,...m]=h.path;f===c&&d.push({...h,path:m})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function r(u,c){return[...u.filter(h=>!c.some(f=>yr.subsumed(h,f))),...c]}l.compress=r;function s(u,c){return u.every(d=>c.every(h=>yr.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],f=[];for(let m of c)try{if(m.type===3){let p=Br.zoom(d,[...m.path,m.id]),g=yr.apply(d,{...m,type:2});if(g!==null){d=g.data;let[y,v]=DT(d,{[m.id]:p});d=y;for(let x of v){let w=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[w]:p}}),f.push({type:0,path:x,props:{[w]:m.id}})}f.push(g.reverse),h.push(g.actual)}}else{let p=yr.apply(d,m);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof wu)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(yb||(yb={}));var RT=Symbol(),YH=Symbol(),_g=Symbol(),_l=class{reportOp(t,e,n=[]){let r=this;if(e===null)return;r._current=e.data;let s=n;for(;!(r instanceof Ag);){let o=r._path,a=r._current;if(o!==""&&s.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[_g];n&&n(),delete this._children[t]}}}},xb=class extends _l{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Au.runOp(this._current,t),t.path)}},bb=class extends _l{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,kt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},LT={get(i,t){if(t===_g)return()=>{i._parent=null};if(t===RT)return i._current;if(t===YH)return i;let{_current:e,_children:n}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e[t],o=Mg(i,t,s);return o!==s?(n===void 0&&(n={},i._children=n),n[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},XH={...LT,set(i,t,e){let n={type:0,props:{[t]:Ln(e)??e}};return i.deleteChildren(t),i.runOp(n),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},QH={...LT,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},Mu=class extends _l{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[_g]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Mg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,r,s){this.runOp({type:7,parent:t,fi:e,id:n,data:r,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}moveBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Eu=class extends _l{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[_g]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),r,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Mg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function vb(i,t,e){if(i.length>0){let n=i[i.length-1];if(n.type===0&&t.type===0&&Br.equal(n.path,e)){Object.assign(n.props,t.props);return}}i.push({...t,path:e})}var Ag=class extends _l{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,n,r){vb(this.ts,e,t),vb(this.actual,n,t),vb(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Mg(i,t,e){return e instanceof tn?new Mu(i,t,e):e instanceof ze?new Eu(i,t,e):e instanceof kt?new Proxy(new bb(i,t,e),QH):e!==null&&typeof e=="object"?Su(e)?e:new Proxy(new xb(i,t,e),XH):e}function wb(i){let t=new Ag(i);return[Mg(t,"",i),t]}function Tu(i,t){let[e,n]=wb(i);return t(e),n.result()}function Ln(i){return i instanceof Mu||i instanceof Eu?i._current:i!==null&&typeof i=="object"?i[RT]:i}var Br;(r=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}r.equal=i;function t(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}r.removeOverridden=t;function e(s,o){if((s instanceof tn||s instanceof Mu)&&typeof o=="string")return s.data(o);if((s instanceof ze||s instanceof Eu)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}r.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}r.zoom=n})(Br||(Br={}));function NT(i,t){let e=[];if(t.length===i.length)for(var n=0;n<i.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}function Tr(i,t){let e=[];if(t.length<=i.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}var Eg=class{},mf=class extends Eg{constructor(e){super();this.id=e}},gf=class extends Eg{constructor(e){super();this.data=e}};var Ab;try{Ab=new TextDecoder}catch{}var De,va,J=0;var HT=[],_b=HT,Mb=0,qr={},Pt,ya,Mi=0,_s=0,fi,Ao,Fr=[],Nt,BT={useRecords:!1,mapsAsObjects:!0},yf=class{},Tb=new yf;Tb.name="MessagePack 0xC1";var Cu=!1,Ms=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(De)return XT(()=>(Cg(),this?this.unpack(t,e):Ms.prototype.unpack.call(BT,t,e)));va=e>-1?e:t.length,J=0,Mb=0,_s=0,ya=null,_b=HT,fi=null,De=t;try{Nt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw De=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ms){if(qr=this,this.structures)return Pt=this.structures,Tg();(!Pt||Pt.length>0)&&(Pt=[])}else qr=BT,(!Pt||Pt.length>0)&&(Pt=[]);return Tg()}unpackMultiple(t,e){let n,r=0;try{Cu=!0;let s=t.length,o=this?this.unpack(t,s):Dg.unpack(t,s);if(e){for(e(o);J<s;)if(r=J,e(Tg())===!1)return}else{for(n=[o];J<s;)r=J,n.push(Tg());return n}}catch(s){throw s.lastPosition=r,s.values=n,s}finally{Cu=!1,Cg()}}_mergeStructures(t,e){t=t||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let r=t[n],s=e[n];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[n]=r),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Tg(){try{if(!qr.trusted&&!Cu){let t=Pt.sharedLength||0;t<Pt.length&&(Pt.length=t)}let i=fn();if(J==va)Pt.restoreStructures&&FT(),Pt=null,De=null,Ao&&(Ao=null);else if(J>va){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Cu)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Pt.restoreStructures&&FT(),Cg(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function FT(){for(let i in Pt.restoreStructures)Pt[i]=Pt.restoreStructures[i];Pt.restoreStructures=null}function fn(){let i=De[J++];if(i<160)if(i<128){if(i<64)return i;{let t=Pt[i&63]||qr.getStructures&&jT()[i&63];return t?(t.read||(t.read=Cb(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,qr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[qT()]=fn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(fn(),fn());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=fn();return t}else if(i<192){let t=i-160;if(_s>=J)return ya.slice(J-Mi,(J+=t)-Mi);if(_s==0&&va<140){let e=t<16?Pb(t):WT(t);if(e!=null)return e}return Eb(t)}else{let t;switch(i){case 192:return null;case 193:return fi?(t=fn(),t>0?fi[1].slice(fi.position1,fi.position1+=t):fi[0].slice(fi.position0,fi.position0-=t)):Tb;case 194:return!1;case 195:return!0;case 196:return Sb(De[J++]);case 197:return t=Nt.getUint16(J),J+=2,Sb(t);case 198:return t=Nt.getUint32(J),J+=4,Sb(t);case 199:return Ml(De[J++]);case 200:return t=Nt.getUint16(J),J+=2,Ml(t);case 201:return t=Nt.getUint32(J),J+=4,Ml(t);case 202:if(t=Nt.getFloat32(J),qr.useFloat32>2){let e=Ig[(De[J]&127)<<1|De[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=Nt.getFloat64(J),J+=8,t;case 204:return De[J++];case 205:return t=Nt.getUint16(J),J+=2,t;case 206:return t=Nt.getUint32(J),J+=4,t;case 207:return qr.int64AsNumber?(t=Nt.getUint32(J)*4294967296,t+=Nt.getUint32(J+4)):t=Nt.getBigUint64(J),J+=8,t;case 208:return Nt.getInt8(J++);case 209:return t=Nt.getInt16(J),J+=2,t;case 210:return t=Nt.getInt32(J),J+=4,t;case 211:return qr.int64AsNumber?(t=Nt.getInt32(J)*4294967296,t+=Nt.getUint32(J+4)):t=Nt.getBigInt64(J),J+=8,t;case 212:if(t=De[J++],t==114)return VT(De[J++]&63);{let e=Fr[t];if(e)return e.read?(J++,e.read(fn())):e.noBuffer?(J++,e()):e(De.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=De[J],t==114?(J++,VT(De[J++]&63,De[J++])):Ml(2);case 214:return Ml(4);case 215:return Ml(8);case 216:return Ml(16);case 217:return t=De[J++],_s>=J?ya.slice(J-Mi,(J+=t)-Mi):ZH(t);case 218:return t=Nt.getUint16(J),J+=2,_s>=J?ya.slice(J-Mi,(J+=t)-Mi):JH(t);case 219:return t=Nt.getUint32(J),J+=4,_s>=J?ya.slice(J-Mi,(J+=t)-Mi):$H(t);case 220:return t=Nt.getUint16(J),J+=2,kT(t);case 221:return t=Nt.getUint32(J),J+=4,kT(t);case 222:return t=Nt.getUint16(J),J+=2,zT(t);case 223:return t=Nt.getUint32(J),J+=4,zT(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var KH=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Cb(i,t){function e(){if(e.count++>2){let r=i.read=new Function("r","return function(){return {"+i.map(s=>KH.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(fn);return i.highByte===0&&(i.read=UT(t,i.read)),r()}let n={};for(let r=0,s=i.length;r<s;r++){let o=i[r];n[o]=fn()}return n}return e.count=0,i.highByte===0?UT(t,e):e}var UT=(i,t)=>function(){let e=De[J++];if(e===0)return t();let n=i<32?-(i+(e<<5)):i+(e<<5),r=Pt[n]||jT()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=Cb(r,i)),r.read()};function jT(){let i=XT(()=>(De=null,qr.getStructures()));return Pt=qr._mergeStructures(i,Pt)}var Eb=Pg,ZH=Pg,JH=Pg,$H=Pg;function Pg(i){let t;if(i<16&&(t=Pb(i)))return t;if(i>64&&Ab)return Ab.decode(De.subarray(J,J+=i));let e=J+i,n=[];for(t="";J<e;){let r=De[J++];if((r&128)===0)n.push(r);else if((r&224)===192){let s=De[J++]&63;n.push((r&31)<<6|s)}else if((r&240)===224){let s=De[J++]&63,o=De[J++]&63;n.push((r&31)<<12|s<<6|o)}else if((r&248)===240){let s=De[J++]&63,o=De[J++]&63,a=De[J++]&63,l=(r&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(r);n.length>=4096&&(t+=ir.apply(String,n),n.length=0)}return n.length>0&&(t+=ir.apply(String,n)),t}function kT(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=fn();return t}function zT(i){if(qr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[qT()]=fn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(fn(),fn());return t}}var ir=String.fromCharCode;function WT(i){let t=J,e=new Array(i);for(let n=0;n<i;n++){let r=De[J++];if((r&128)>0){J=t;return}e[n]=r}return ir.apply(String,e)}function Pb(i){if(i<4)if(i<2){if(i===0)return"";{let t=De[J++];if((t&128)>1){J-=1;return}return ir(t)}}else{let t=De[J++],e=De[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(i<3)return ir(t,e);let n=De[J++];if((n&128)>0){J-=3;return}return ir(t,e,n)}else{let t=De[J++],e=De[J++],n=De[J++],r=De[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(r&128)>0){J-=4;return}if(i<6){if(i===4)return ir(t,e,n,r);{let s=De[J++];if((s&128)>0){J-=5;return}return ir(t,e,n,r,s)}}else if(i<8){let s=De[J++],o=De[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(i<7)return ir(t,e,n,r,s,o);let a=De[J++];if((a&128)>0){J-=7;return}return ir(t,e,n,r,s,o,a)}else{let s=De[J++],o=De[J++],a=De[J++],l=De[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(i<10){if(i===8)return ir(t,e,n,r,s,o,a,l);{let u=De[J++];if((u&128)>0){J-=9;return}return ir(t,e,n,r,s,o,a,l,u)}}else if(i<12){let u=De[J++],c=De[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(i<11)return ir(t,e,n,r,s,o,a,l,u,c);let d=De[J++];if((d&128)>0){J-=11;return}return ir(t,e,n,r,s,o,a,l,u,c,d)}else{let u=De[J++],c=De[J++],d=De[J++],h=De[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(i<14){if(i===12)return ir(t,e,n,r,s,o,a,l,u,c,d,h);{let f=De[J++];if((f&128)>0){J-=13;return}return ir(t,e,n,r,s,o,a,l,u,c,d,h,f)}}else{let f=De[J++],m=De[J++];if((f&128)>0||(m&128)>0){J-=14;return}if(i<15)return ir(t,e,n,r,s,o,a,l,u,c,d,h,f,m);let p=De[J++];if((p&128)>0){J-=15;return}return ir(t,e,n,r,s,o,a,l,u,c,d,h,f,m,p)}}}}}function Sb(i){return qr.copyBuffers?Uint8Array.prototype.slice.call(De,J,J+=i):De.subarray(J,J+=i)}function Ml(i){let t=De[J++];if(Fr[t])return Fr[t](De.subarray(J,J+=i));throw new Error("Unknown extension type "+t)}var GT=new Array(4096);function qT(){let i=De[J++];if(i>=160&&i<192){if(i=i-160,_s>=J)return ya.slice(J-Mi,(J+=i)-Mi);if(!(_s==0&&va<180))return Eb(i)}else return J--,fn();let t=(i<<5^(i>1?Nt.getUint16(J):i>0?De[J]:0))&4095,e=GT[t],n=J,r=J+i-3,s,o=0;if(e&&e.bytes==i){for(;n<r;){if(s=Nt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(r+=3;n<r;)if(s=De[n++],s!=e[o++]){n=1879048192;break}if(n===r)return J=n,e.string;r-=3,n=J}for(e=[],GT[t]=e,e.bytes=i;n<r;)s=Nt.getUint32(n),e.push(s),n+=4;for(r+=3;n<r;)s=De[n++],e.push(s);let a=i<16?Pb(i):WT(i);return a!=null?e.string=a:e.string=Eb(i)}var VT=(i,t)=>{var e=fn();let n=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let r=Pt[i];return r&&r.isShared&&((Pt.restoreStructures||(Pt.restoreStructures=[]))[i]=r),Pt[i]=e,e.read=Cb(e,n),e.read()},YT=typeof self=="object"?self:global;Fr[0]=()=>{};Fr[0].noBuffer=!0;Fr[101]=()=>{let i=fn();return(YT[i[0]]||Error)(i[1])};Fr[105]=i=>{let t=Nt.getUint32(J-4);Ao||(Ao=new Map);let e=De[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let r={target:n};Ao.set(t,r);let s=fn();return r.used?Object.assign(n,s):(r.target=s,s)};Fr[112]=i=>{let t=Nt.getUint32(J-4),e=Ao.get(t);return e.used=!0,e.target};Fr[115]=()=>new Set(fn());var Ib=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Fr[116]=i=>{let t=i[0],e=Ib[t];if(!e)throw new Error("Could not find typed array for code "+t);return new YT[e](Uint8Array.prototype.slice.call(i,1).buffer)};Fr[120]=()=>{let i=fn();return new RegExp(i[0],i[1])};Fr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=J;J+=t-4,fi=[fn(),fn()],fi.position0=0,fi.position1=0;let n=J;J=e;try{return fn()}finally{J=n}};Fr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function XT(i){let t=va,e=J,n=Mb,r=Mi,s=_s,o=ya,a=_b,l=Ao,u=fi,c=new Uint8Array(De.slice(0,va)),d=Pt,h=Pt.slice(0,Pt.length),f=qr,m=Cu,p=i();return va=t,J=e,Mb=n,Mi=r,_s=s,ya=o,_b=a,Ao=l,fi=u,De=c,Cu=m,Pt=d,Pt.splice(0,Pt.length,...h),qr=f,Nt=new DataView(De.buffer,De.byteOffset,De.byteLength),p}function Cg(){De=null,Ao=null,Pt=null}function QT(i){i.unpack?Fr[i.type]=i.unpack:Fr[i.type]=i}var Ig=new Array(147);for(let i=0;i<256;i++)Ig[i]=+("1e"+Math.floor(45.15-i*.30103));var Dg=new Ms({useRecords:!1}),e5=Dg.unpack,t5=Dg.unpackMultiple,n5=Dg.unpack,Og={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},r5=new Float32Array(1),tre=new Uint8Array(r5.buffer,0,4);var Rg;try{Rg=new TextEncoder}catch{}var Lg,Ob,Ng=typeof Buffer<"u",Db=Ng?Buffer.allocUnsafeSlow:Uint8Array,$T=Ng?Buffer:Uint8Array,KT=Ng?4294967296:2144337920,le,xn,ne=0,Es,Ts=null,i5=/[\u0080-\uFFFF]/,vf=Symbol("record-id"),El=class extends Ms{constructor(t){super(t),this.offset=0;let e,n,r,s,o,a,l=0,u=$T.prototype.utf8Write?function(b,E,T){return le.utf8Write(b,E,T)}:Rg&&Rg.encodeInto?function(b,E){return Rg.encodeInto(b,le.subarray(E)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=t.maxOwnStructures;m==null&&(m=h?32:64),d&&!t.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,y=f+m+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,w=0;this.pack=this.encode=function(b,E){if(le||(le=new Db(8192),xn=new DataView(le.buffer,0,8192),ne=0),Es=le.length-10,Es-ne<2048?(le=new Db(le.length),xn=new DataView(le.buffer,0,le.length),Es=le.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(Ts=["",""],le[ne++]=214,le[ne++]=98,Ts.position=ne-n,ne+=4):Ts=null,r=c.structures,r){r.uninitialized&&(r=c._mergeStructures(c.getStructures()));let T=r.sharedLength||0;if(T>f)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 I=0;I<T;I++){let C=r[I];if(!C)continue;let P,O=r.transitions;for(let B=0,j=C.length;B<j;B++){let Q=C[B];P=O[Q],P||(P=O[Q]=Object.create(null)),O=P}O[vf]=I+64}l=T}d||(r.nextId=T+64)}s&&(s=!1),o=r||[];try{if(S(b),Ts){xn.setUint32(Ts.position+n,ne-Ts.position-n);let T=Ts;Ts=null,S(T[0]),S(T[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>Es&&M(ne),c.offset=ne;let T=o5(le.subarray(n,ne),a.idsToInsert);return a=null,T}return E&tC?(le.start=n,le.end=ne,le):le.subarray(n,ne)}finally{if(r){if(w<10&&w++,x>1e4)r.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let T=0,I=v.length;T<I;T++)v[T][vf]=0;v=[]}if(s&&c.saveStructures){let T=r.sharedLength||f;r.length>T&&(r=r.slice(0,T));let I=le.subarray(n,ne);return c.saveStructures(r,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,I)}}E&f5&&(ne=n)}};let S=b=>{ne>Es&&(le=M(ne));var E=typeof b,T;if(E==="string"){let I=b.length;if(Ts&&I>=8&&I<4096){let O=i5.test(b);Ts[O?0:1]+=b,le[ne++]=193,S(O?-I:I);return}let C;I<32?C=1:I<256?C=2:I<65536?C=3:C=5;let P=I*3;if(ne+P>Es&&(le=M(ne+P)),I<64||!u){let O,B,j,Q=ne+C;for(O=0;O<I;O++)B=b.charCodeAt(O),B<128?le[Q++]=B:B<2048?(le[Q++]=B>>6|192,le[Q++]=B&63|128):(B&64512)===55296&&((j=b.charCodeAt(O+1))&64512)===56320?(B=65536+((B&1023)<<10)+(j&1023),O++,le[Q++]=B>>18|240,le[Q++]=B>>12&63|128,le[Q++]=B>>6&63|128,le[Q++]=B&63|128):(le[Q++]=B>>12|224,le[Q++]=B>>6&63|128,le[Q++]=B&63|128);T=Q-ne-C}else T=u(b,ne+C,P);T<32?le[ne++]=160|T:T<256?(C<2&&le.copyWithin(ne+2,ne+1,ne+1+T),le[ne++]=217,le[ne++]=T):T<65536?(C<3&&le.copyWithin(ne+3,ne+2,ne+2+T),le[ne++]=218,le[ne++]=T>>8,le[ne++]=T&255):(C<5&&le.copyWithin(ne+5,ne+3,ne+3+T),le[ne++]=219,xn.setUint32(ne,T),ne+=4),ne+=T}else if(E==="number")if(b>>>0===b)b<64?le[ne++]=b:b<256?(le[ne++]=204,le[ne++]=b):b<65536?(le[ne++]=205,le[ne++]=b>>8,le[ne++]=b&255):(le[ne++]=206,xn.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?le[ne++]=256+b:b>=-128?(le[ne++]=208,le[ne++]=b+256):b>=-32768?(le[ne++]=209,xn.setInt16(ne,b),ne+=2):(le[ne++]=210,xn.setInt32(ne,b),ne+=4);else{let I;if((I=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){le[ne++]=202,xn.setFloat32(ne,b);let C;if(I<4||(C=b*Ig[(le[ne]&127)<<1|le[ne+1]>>7])>>0===C){ne+=4;return}else ne--}le[ne++]=203,xn.setFloat64(ne,b),ne+=8}else if(E==="object")if(!b)le[ne++]=192;else{if(a){let C=a.get(b);if(C){if(!C.id){let P=a.idsToInsert||(a.idsToInsert=[]);C.id=P.push(C)}le[ne++]=214,le[ne++]=112,xn.setUint32(ne,C.id),ne+=4;return}else a.set(b,{offset:ne-n})}let I=b.constructor;if(I===Object)_(b,!0);else if(I===Array){T=b.length,T<16?le[ne++]=144|T:T<65536?(le[ne++]=220,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=221,xn.setUint32(ne,T),ne+=4);for(let C=0;C<T;C++)S(b[C])}else if(I===Map){T=b.size,T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,xn.setUint32(ne,T),ne+=4);for(let[C,P]of b)S(C),S(P)}else{for(let C=0,P=Lg.length;C<P;C++){let O=Ob[C];if(b instanceof O){let B=Lg[C];if(B.write){B.type&&(le[ne++]=212,le[ne++]=B.type,le[ne++]=0),S(B.write.call(this,b));return}let j=le,Q=xn,V=ne;le=null;let q;try{q=B.pack.call(this,b,W=>(le=j,j=null,ne+=W,ne>Es&&M(ne),{target:le,targetView:xn,position:ne-W}),S)}finally{j&&(le=j,xn=Q,ne=V,Es=le.length-10)}q&&(q.length+ne>Es&&M(q.length+ne),ne=s5(q,le,ne,B.type));return}}_(b,!b.hasOwnProperty)}}else if(E==="boolean")le[ne++]=b?195:194;else if(E==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))le[ne++]=211,xn.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)le[ne++]=207,xn.setBigUint64(ne,b);else if(this.largeBigIntToFloat)le[ne++]=203,xn.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(E==="undefined")this.encodeUndefinedAsNil?le[ne++]=192:(le[ne++]=212,le[ne++]=0,le[ne++]=0);else if(E==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+E)},_=this.useRecords===!1?this.variableMapSize?b=>{let E=Object.keys(b),T=E.length;T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,xn.setUint32(ne,T),ne+=4);let I;for(let C=0;C<T;C++)S(I=E[C]),S(b[I])}:(b,E)=>{le[ne++]=222;let T=ne-n;ne+=2;let I=0;for(let C in b)(E||b.hasOwnProperty(C))&&(S(C),S(b[C]),I++);le[T+++n]=I>>8,le[T+n]=I&255}:b=>{let E=Object.keys(b),T,I=o.transitions||(o.transitions=Object.create(null)),C=0;for(let O=0,B=E.length;O<B;O++){let j=E[O];T=I[j],T||(T=I[j]=Object.create(null),C++),I=T}let P=I[vf];if(P)P>=96&&p?(le[ne++]=((P-=96)&31)+96,le[ne++]=P>>5):le[ne++]=P;else{P=o.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(E)?(P=o.nextOwnId,P<y||(P=g),o.nextOwnId=P+1):(P>=y&&(P=g),o.nextId=P+1);let O=E.highByte=P>=96&&p?P-96>>5:-1;I[vf]=P,o[P-64]=E,P<g?(E.isShared=!0,o.sharedLength=P-63,s=!0,O>=0?(le[ne++]=(P&31)+96,le[ne++]=O):le[ne++]=P):(O>=0?(le[ne++]=213,le[ne++]=114,le[ne++]=(P&31)+96,le[ne++]=O):(le[ne++]=212,le[ne++]=114,le[ne++]=P),C&&(x+=w*C),v.length>=m&&(v.shift()[vf]=0),v.push(I),S(E))}for(let O=0,B=E.length;O<B;O++)S(b[E[O]])},M=b=>{let E;if(b>16777216){if(b-n>KT)throw new Error("Packed buffer would be larger than maximum buffer size");E=Math.min(KT,Math.round(Math.max((b-n)*(b>67108864?1.25:2),4194304)/4096)*4096)}else E=(Math.max(b-n<<2,le.length-1)>>12)+1<<12;let T=new Db(E);return xn=new DataView(T.buffer,0,E),le.copy?le.copy(T,0,n,b):T.set(le.slice(n,b)),ne-=n,n=0,Es=T.length-10,le=T}}useBuffer(t){le=t,xn=new DataView(le.buffer,le.byteOffset,le.byteLength),ne=0}};Ob=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,yf];Lg=[{pack(i,t,e){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:s,position:o}=t(6);r[o++]=214,r[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:r,targetView:s,position:o}=t(10);r[o++]=215,r[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:r,targetView:s,position:o}=t(3);r[o++]=212,r[o++]=255,r[o++]=255}else{let{target:r,targetView:s,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(i,t,e){let n=Array.from(i),{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=115,r[s++]=0),e(n)}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=101,n[r++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=120,n[r++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?ZT(i,16,t):JT(Ng?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==$T&&this.structuredClone?ZT(i,Ib.indexOf(e.name),t):JT(i,t)}},{pack(i,t){let{target:e,position:n}=t(1);e[n]=193}}];function ZT(i,t,e,n){let r=i.byteLength;if(r+1<256){var{target:s,position:o}=e(4+r);s[o++]=199,s[o++]=r+1}else if(r+1<65536){var{target:s,position:o}=e(5+r);s[o++]=200,s[o++]=r+1>>8,s[o++]=r+1&255}else{var{target:s,position:o,targetView:a}=e(7+r);s[o++]=201,a.setUint32(o,r+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function JT(i,t){let e=i.byteLength;var n,r;if(e<256){var{target:n,position:r}=t(e+2);n[r++]=196,n[r++]=e}else if(e<65536){var{target:n,position:r}=t(e+3);n[r++]=197,n[r++]=e>>8,n[r++]=e&255}else{var{target:n,position:r,targetView:s}=t(e+5);n[r++]=198,s.setUint32(r,e),r+=4}n.set(i,r)}function s5(i,t,e,n){let r=i.length;switch(r){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:r<256?(t[e++]=199,t[e++]=r):r<65536?(t[e++]=200,t[e++]=r>>8,t[e++]=r&255):(t[e++]=201,t[e++]=r>>24,t[e++]=r>>16&255,t[e++]=r>>8&255,t[e++]=r&255)}return t[e++]=n,t.set(i,e),e+=r,e}function o5(i,t){let e,n=t.length*6,r=i.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+n,s,r),n-=6;let a=s+n;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,r=s}return i}function xa(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ob.unshift(i.Class),Lg.unshift(i)}QT(i)}var eC=new El({useRecords:!1}),a5=eC.pack,l5=eC.pack;var{NEVER:c5,ALWAYS:u5,DECIMAL_ROUND:d5,DECIMAL_FIT:h5}=Og,tC=512,f5=1024;var nC=new El({structuredClone:!0});xa({Class:kt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,kt.prototype),i}});xa({Class:ze.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ze.prototype),i}});xa({Class:tn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,tn.prototype),i}});xa({Class:mf.prototype.constructor,type:4,write(i){return i.id},read(i){return new mf(i)}});xa({Class:gf.prototype.constructor,type:5,write(i){return i.data},read(i){return new gf(i)}});xa({Class:nn.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,nn.prototype),i}});function p5(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let n=i[e];t=(t<<5)-t+n,t=t&t}return t}function Rb(i){if(Su(i))return i;if(Array.isArray(i))return i.map(Rb);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Rb(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var Bg;(n=>{function i(r){return nC.pack(r)}n.serialize=i;function t(r){return nC.unpack(r)}n.deserialize=t;function e(r){return p5(i(Rb(r))).toString()}n.checksum=e})(Bg||(Bg={}));var Zi={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition"],["Scroll"]:["Transition","Animation","Create"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset"],["GameControl"]:["Transition","Animation","Audio","Video","Create"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"]},rC;(e=>{function i(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=i;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,toggle:!1,actions:new ze}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new ze}}e.defaultData=t})(rC||(rC={}));var Fg;(e=>{function i(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(Fg||(Fg={}));var Lb;(n=>{function i(r){return{type:"Comparison",operator:"==",lOperand:Fg.propertyDefaultData(r),rOperand:{...Fg.valueDefaultData}}}n.comparisonDefaultData=i;function t(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}}n.distanceDefaultData=t;function e(r,s){return{type:"State",object:r??null,state:s??null}}n.stateDefaultData=e})(Lb||(Lb={}));var iC;(e=>{function i(n){return n.type==="Conditional"}e.is=i;function t(n){return{type:"Conditional",disabled:!1,inActions:new ze,outActions:new ze,condition:Lb.distanceDefaultData(n)}}e.defaultData=t})(iC||(iC={}));var sC;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ze,drop:new ze}})(sC||(sC={}));var Ug;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ze})(Ug||(Ug={}));var kg;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(kg||(kg={}));var oC;(e=>{function i(n){return n.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new ze}}e.defaultData=t})(oC||(oC={}));var aC;(e=>{function i(n){return n.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ze}}e.defaultData=t})(aC||(aC={}));var lC;(e=>{function i(n){return n.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new ze}}e.defaultData=t})(lC||(lC={}));var cC;(e=>{function i(n){return n.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new ze}}e.defaultData=t})(cC||(cC={}));var uC;(e=>{function i(n){return n.type==="Trigger"}e.is=i;function t(n,r){return{type:"Trigger",disabled:!1,toggle:!1,target:"all",triggeringObjects:[],actions:new ze,triggerZone:"box",position:r.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}e.defaultData=t})(uC||(uC={}));var Ei="personal camera",wa="a218fcc3-276b-49b9-b485-49037fd14f5f",fC=2960946,qn=5526619;var Tl;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s]}e.lerp=t})(Tl||(Tl={}));var Cs;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function r(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=r;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(Cs||(Cs={}));var xf;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s,n[2]+(r[2]-n[2])*s,n[3]+(r[3]-n[3])*s]}e.lerp=t})(xf||(xf={}));var ba;(r=>{r.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}r.isEqual=t;function e(s){return s??r.identity}r.simplify=e;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}r.applyMatrix4=n})(ba||(ba={}));var Nn;(c=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function r(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=r;function s(d){return{r:d.r,g:d.g,b:d.b}}c.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=a;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}c.equals=l;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}c.lerp=u})(Nn||(Nn={}));var Ur;(a=>{a.white={...Nn.white,a:1},a.transparent={...Nn.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...Nn.fromHex(l),a:u}}a.fromHexAndA=n;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=r;function s(l,u){return Nn.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Ur||(Ur={}));var zg;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(zg||(zg={}));var dC;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(dC||(dC={}));var hC;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(hC||(hC={}));var _o;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(_o||(_o={}));var Ji;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(Ji||(Ji={}));var Sa;(r=>{r.DefaultUp=[0,1,0],r.DefaultTargetOffset=1e3,r.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:r.DefaultUp,isUpVectorFlipped:!1,targetOffset:r.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}r.getZoom=n})(Sa||(Sa={}));var Ps;(e=>{function i(n,r=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*r,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+r)),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=i;function t(n,r){let s={...n};if(Nb.forEach(o=>{Object.assign(s,{[o]:r[o]??n[o]})}),s.radial={...n.radial},r.radial){let o=n.radial,a=r.radial;Bb.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},r.linear){let o=n.linear,a=r.linear;Fb.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},r.grid){let o=n.grid,a=r.grid;Ub.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},r.toObject){let o=n.toObject,a=r.toObject;kb.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},r.randomnessObject){let o=n.randomnessObject,a=r.randomnessObject;zb.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Ps||(Ps={}));var Gg;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(r,s){let o=[];r.count!==void 0&&o.push({type:0,path:s,props:{count:r.count}});for(let a of t){let l=r[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(Gg||(Gg={}));var Nb=["count"],Bb=["radius","start","end","position","scale","rotation"],Fb=["position","scale","rotation"],Ub=["count","size"],kb=["count","position","scale","rotation"],zb=["strength","scale","rotation","position","movement","seed","freqScale"];var Vg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(Vg||(Vg={}));var Hg;(e=>{function i(n){return t(n)}e.defaultData=i;function t(n){if(n==="PointLight")return{type:n,color:Ur.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(n==="SpotLight")return{type:n,color:Ur.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(n==="DirectionalLight")return{type:n,color:Ur.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Hg||(Hg={}));var Aa;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Aa||(Aa={}));var Gb;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,r){return n.castShadow===r.castShadow&&n.receiveShadow===r.receiveShadow}e.equals=t})(Gb||(Gb={}));var Vb;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe}e.equals=t})(Vb||(Vb={}));var jg;(t=>t.defaultData={...Vb.defaultData,...Gb.defaultData})(jg||(jg={}));var Pu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Pu||(Pu={}));var pC;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(pC||(pC={}));function gC(i){return i.type!=="displace"}var mC;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(mC||(mC={}));var Wg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],yC=["wrapping","image","video","name"],kr;(r=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}r.patch=i;function t(s,o){return s==="light"&&o?e(o):n(s)}r.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function n(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Pu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:Nn.fromHex(qn)};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:{...Nn.fromHex(6710886),a:1},colorB:{...Nn.fromHex(6710886),a:1},colorC:{...Nn.fromHex(16777215),a:1},colorD:{...Nn.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:Ur.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:Ur.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Ur.fromHexAndA(0,1),contourColor:Ur.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]}};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:{...Nn.fromHex(0),a:1},colorB:{...Nn.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}}}})(kr||(kr={}));var sr;(l=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${f}`,Array.isArray(f)?f.forEach(m=>c+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new ze}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function r(u,c){return{...u,name:c}}l.withName=r;function s(u,c="layer1",d="layer2"){let h=new ze;return h.push({fi:0,data:kr.defaultData("light",u),id:c}),h.push({fi:1,data:kr.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=kr.defaultData("texture");Object.assign(f.texture,{image:u});let m=new ze;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:kr.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=kr.defaultData("video");Object.assign(f.texture,{video:u});let m=new ze;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:kr.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerVideoTextureData=a})(sr||(sr={}));var Iu;(t=>{function i(){return{points:new ze,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Iu||(Iu={}));var Du;(t=>{function i(){return{points:new ze,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Du||(Du={}));var Hb={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var qg;(t=>{function i(e,n){let r={...e};return jb.forEach(s=>{Object.assign(r,{[s]:n[s]??e[s]})}),r}t.merge=i})(qg||(qg={}));var Yg={shape:Hb,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},jb=["depth","offset","angle","twist","startScale","endScale"];var bf;(e=>{function i(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=i;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(bf||(bf={}));var Xg;(t=>{function i(e,n){let r={...e};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...e.extrusion},Object.assign(r.extrusion,qg.merge(r.extrusion,n.extrusion))),r}t.merge=i})(Xg||(Xg={}));var _a;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Du.defaultData(),extrusion:Yg};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Iu.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}t.defaultData=i})(_a||(_a={}));var Wb=["width","height","depth"];var Qg;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Nn.white,near:.1,far:2e3})(Qg||(Qg={}));var Ou;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(Ou||(Ou={}));var qb;(t=>t.defaultData={softShadowQuality:"low"})(qb||(qb={}));var Yb;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Yb||(Yb={}));var Xb;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Xb||(Xb={}));var Ma;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ma||(Ma={}));var Qb;(t=>t.defaultData={playCamera:Ei,gameControlObject:null})(Qb||(Qb={}));var Kg;(t=>t.defaultData={backgroundColor:Ur.fromHexAndA(fC,1),postprocessing:Ou.defaultData,fog:Qg.defaultData,globalPhysics:Ma.defaultData,ambient:Yb.defaultData,ao:Xb.defaultData,shadow:qb.defaultData,publish:Qb.defaultData})(Kg||(Kg={}));var vC;(e=>{function i(n){return n==="Component"||n==="Instance"}e.isComponentRelated=i;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(vC||(vC={}));var Ru;(r=>{r.identity={...zg.identity,hiddenMatrix:ba.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}r.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}r.merge=e;function n(s,o){return hT({position:Cs.isEqual(s.position,o.position)?void 0:o.position,rotation:Cs.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Cs.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:ba.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}r.diff=n})(Ru||(Ru={}));var Cr;(t=>t.defaultData={states:new ze,events:new ze,visible:!0,raycastLock:!1,physics:Aa.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ru.identity,cloner:null})(Cr||(Cr={}));var xC;(t=>t.defaultData={type:"Empty",...Cr.defaultData})(xC||(xC={}));var bC;(t=>t.defaultData={type:"Component",...Cr.defaultData})(bC||(bC={}));var Cl;(t=>t.defaultData={type:"Mesh",...Cr.defaultData,...jg.defaultData})(Cl||(Cl={}));var Pl;(t=>t.defaultData={...Cr.defaultData,...Ru.identity,position:[0,0,Sa.DefaultTargetOffset],...Sa.defaultData})(Pl||(Pl={}));var Zg;(e=>{function i(n){return{...Cr.defaultData,...Hg.defaultData(n)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Zg||(Zg={}));var Lu;(e=>{function i(n,r,s=0){for(;s<r.length;){let o=n?n[r[s]]:void 0;if(r.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(n,r,s=0){let o=i(n,r,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(Lu||(Lu={}));var Mo;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...Cr.defaultData,...a,component:o,overrides:new nn,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=n;function r(o){let a=Ru.fromObject(o.data);return n(o.id,a)}s.fromComponentData=r})(Mo||(Mo={}));var Eo;(t=>t.defaultData={type:"Page",...Cr.defaultData,physics:{...Aa.defaultData,fusedBody:!1},...Kg.defaultData,camera:Pl.defaultData})(Eo||(Eo={}));var Jg;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:ba.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Aa.defaultData,states:new ze,events:new ze,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Sa.defaultData},s.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"]},s.defaultMeshObject={name:"Rectangle",...Cr.defaultData,...Cl.defaultData,geometry:_a.defaultData("RectangleGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Cr.defaultData,...Cl.defaultData,geometry:_a.defaultData("BooleanGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Cr.defaultData,...Cl.defaultData,geometry:_a.defaultData("TextGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")}))(Jg||(Jg={}));var To;(r=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new nn}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new nn})))):Ji.is(s.type)&&(a.perspective={},a.orthographic={}),a}r.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Tu(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&kr.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Tu(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&kr.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,m]of Object.entries(h.layers)){let{texture:p,...g}=m;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...d,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",f],props:g,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...Gg.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,m]of Object.entries(h))c(["materials",f],m);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}r.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Ru.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Ji.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Xg.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Ps.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Ps.merge(a.cloner,o.cloner)});else if(Vg.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Nn.clone(l.color))}return a}r.patch=n})(To||(To={}));var Nu;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Nu||(Nu={}));var Is;(t=>t.defaultData={orbitControls:Nu.defaultData,playPage:wa,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let r=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?r=30:(n===4||n===11||n===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Is||(Is={}));var Kb;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Kb||(Kb={}));var Zb;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Zb||(Zb={}));var Ea;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Kb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Zb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ea||(Ea={}));var Ta;(e=>{function i(n){return n.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(n,r,s){n.traverseFrom(r,(o,a)=>{if(a.type==="Instance"){let l=n.data(a.component);l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Ta||(Ta={}));var $g;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=Jg.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:Zg.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let d=new tn;return d.push({fi:1,id:wa,data:{...Eo.defaultData,name:"Scene 1"},children:u}),d}a.defaultData={objects:t(),publish:Is.defaultData,styles:Ea.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new tn,publish:Is.defaultData,styles:Ea.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:Is.defaultData,styles:Ea.defaultData()}};function s(l){return{...a.defaultData,objects:Ki(l,tn.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})($g||($g={}));var Bu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Bu||(Bu={}));var ey;(n=>{function i(){let r={};return r["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ki(r,kt.prototype)}n.defaultColors=i;function t(r){let s={};return r?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Bu.emptyImage,name:"AI generated image"}),Ki(s,kt.prototype)}n.defaultImages=t;function e(){return{materials:new kt,images:new kt,videos:new kt,colors:new kt,audios:new kt,fonts:new kt}}n.emptyData=e})(ey||(ey={}));var ty;(t=>t.list=["idle","move","jump","run"])(ty||(ty={}));var Fu;(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 ze,move:new ze,jump:new ze,run:new ze},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ur.fromHexAndA(3728051,1)}}))(Fu||(Fu={}));function wC(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,r=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)r.push(r[1]),s.push(1);let o={...Qi(Ln(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:r,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Ln(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Co(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Po(i,t){i.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach(r=>{typeof r!="string"&&t(r)}):"material"in n&&typeof n.material!="string"&&t(n.material),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&t(r.material)})})}function g5(i){Object.assign(i.scene.publish,{orbitControls:{...Nu.defaultData,...Ln(i.scene.publish.orbitControls)}})}function y5(i){Object.assign(i.scene.publish.settings,{video:{...Is.defaultData.settings.video,...Ln(i.scene.publish.settings.video)}})}function v5(i){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[r,s]of Object.entries(n))if((Wg.includes(r)||typeof s=="boolean")&&delete n[r],r==="texture")for(let[o,a]of Object.entries(s))(yC.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,n)=>{n.states.forEach(r=>{let s=r;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function x5(i){i.scene.publish.withBackground=!0}function b5(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function w5(i){i.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(r=>r+1),n.linear.scale=n.linear.scale.map(r=>r+1))})}function S5(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function A5(i){i.scene.objects.traverse((t,e)=>{let n=i.scene.objects.unproxy().parent(t);if(n){let r=Ln(i.scene.objects.data(n));r&&r.type==="Mesh"&&r.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Ln(e).booleanExclude!==!0)}})}function _5(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function M5(i){function t(n){Object.setPrototypeOf(n,nn.prototype),n.texture&&Object.setPrototypeOf(n.texture,nn.prototype)}function e(n){Object.setPrototypeOf(n,nn.prototype);for(let r in n)t(n[r])}i.scene.objects.traverse((n,r)=>{r.states.forEach(s=>{let o=s;if(o.material){let a=Ln(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=Ln(l).layers;e(u),l.layers=u}})})}function SC(i){i.layers===void 0&&Object.assign(i,sr.defaultTwoLayerData("lambert"))}function Jb(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let n=[...t.steps];n.push(t.steps[9]);let r={...Ln(t),colors:e,steps:n};Object.assign(t,r)}})}function E5(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function AC(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&Jb(n)}):"material"in e&&typeof e.material!="string"&&Jb(e.material)}),Object.values(i.shared.materials).forEach(t=>Jb(t))}function T5(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function C5(i){i.shared.audios=Ki({},kt.prototype)}function P5(i){i.shared.videos=Ki({},kt.prototype)}function I5(i){let t=i.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let r={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:r})}})}function D5(i){Object.entries(Ln(i.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.images[n]}),Object.entries(Ln(i.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.audios[n]})}function O5(i){i.scene.publish.settings.web.preload=!1}function _C(i){i.layers&&i.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 MC(i){i.layers&&i.layers.forEach(t=>{gC(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 R5(i){i.shared.fonts=Ki({},kt.prototype)}function L5(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function N5(i){let t=[];i.scene.objects.traverse((e,n)=>{let r=n;if(r.type==="TextFrame"){let s=sr.defaultTwoLayerData("phong"),o=typeof r.color=="string"?i.shared.colors[r.color]:r.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=r.alpha;let a=L5(r.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:r.name,...Cr.defaultData,...Cl.defaultData,flatShading:!1,wireframe:!1,geometry:{..._a.defaultData("TextGeometry"),width:r.width,height:r.height,font:a,depth:0,horizontalAlign:r.horizontalAlign,verticalAlign:r.verticalAlign,fontSize:r.fontSize*1.40625,lineHeight:r.lineHeight/1.40625,letterSpacing:r.letterSpacing-1,text:r.text,textTransform:r.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Ln(r.states),events:Ln(r.events),visible:r.visible,raycastLock:r.raycastLock,position:r.position,rotation:r.rotation,scale:r.scale,hiddenMatrix:r.hiddenMatrix},u=Ln(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function B5(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,n)=>{n.events.forEach(r=>{if(!!t[Number(r.type)])if(Object.assign(r,{type:t[Number(r.type)]}),r.type==="Audio"&&"audioEvent"in r&&(Object.assign(r,{playAudio:r.audioEvent}),delete r.audioEvent),r.type==="GameControl")Object.assign(r,{gameActions:{idle:new ze,move:new ze,jump:new ze}});else{let s=new ze;Object.assign(r,{actions:s}),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp")&&"url"in r&&s.push({fi:0,id:Ve.generateUUID(),data:{type:"Link",url:r.url,delay:0}}),"targets"in r&&(r.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Qi(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ze({fi:0,id:Ve.generateUUID(),data:u},{fi:1,id:Ve.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete r.targets)}})})}function F5(i){i.scene.objects.traverse((t,e)=>{function n(r,s){let o=new ze,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Qi(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={...Qi(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===r)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Ve.generateUUID(),data:{type:r,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function EC(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=kr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function TC(i){Co(i,EC),Po(i,EC)}function U5(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function k5(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function z5(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=sr.defaultTwoLayerData("phong"))})}function G5(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function V5(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function H5(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function j5(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function W5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function q5(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function Y5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=Fu.defaultDataThirdPerson.navmesh)})})}function X5(i){i.scene.styles||(i.scene.styles=Ea.defaultData())}function CC(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Q5(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Po(i,CC),Co(i,CC)}function K5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&Object.assign(n.gameActions,{run:new ze})})})}function Z5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.keyAssignments=[...n.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function PC(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function IC(i,t){if(t<1&&(Po(i,wC),Co(i,wC),i.schema=1),t<2&&(g5(i),i.schema=2),t<3&&(v5(i),i.schema=3),t<4&&(x5(i),i.schema=4),t<5&&(b5(i),i.schema=5),t<6&&(w5(i),i.schema=6),t<7&&(S5(i),i.schema=7),t<8&&(i.schema=8),t<9&&(AC(i),i.schema=9),t<10&&(E5(i),i.schema=10),t<11&&(T5(i),i.schema=11),t<12&&(AC(i),i.schema=12),t<13&&(C5(i),i.schema=13),t<14&&(I5(i),i.schema=14),t<15&&(D5(i),i.schema=15),t<16&&(O5(i),i.schema=16),t<17&&(Po(i,_C),Co(i,_C),i.schema=17),t<18&&(Po(i,SC),Co(i,SC),i.schema=18),t<19&&(y5(i),i.schema=19),t<20&&(R5(i),N5(i),i.schema=20),t<21&&(B5(i),F5(i),i.schema=21),t<22&&(TC(i),i.schema=22),t<23&&(U5(i),i.schema=23),t<24&&(k5(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(P5(i),t<25&&(i.schema=25)),t<26&&(A5(i),i.schema=26),t<27&&(_5(i),i.schema=27),t<28&&(TC(i),i.schema=28),t<29&&(M5(i),i.schema=29),t<30&&(z5(i),i.schema=30),t<31&&(G5(i),i.schema=31),t<33&&(V5(i),i.schema=33),t<34&&(H5(i),i.schema=34),t<35&&(j5(i),i.schema=35),t<36&&(W5(i),i.schema=36),t<37&&(q5(i),i.schema=37),t<38&&(Po(i,MC),Co(i,MC),i.schema=38),t<39&&(Y5(i),i.schema=39),t<40&&(X5(i),i.schema=40),t<41&&(Q5(i),i.schema=41),t<42&&(K5(i),i.schema=42),t<43&&(Z5(i),i.schema=43),t<99){Po(i,PC),Co(i,PC),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Ei);let e=Ln(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=wa,n.insertBefore(null,null,[{id:wa,data:{...Eo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Qi(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Qi(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ma.defaultData,...Qi(i.scene.environment,"usePhysics","gravity")},camera:Ln(i.scene.ownerCamera)??Eo.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==$g.TRASH_CAN_ID&&n.move(wa,o.fi,o.id);let r=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(r,2)],r+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Aa.defaultData)),a.physics!==void 0&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function DC(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}var OC=101;function RC(i){let t=i.schema??0;t!==OC&&(console.warn("updating from ",t,"to ",OC),IC(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Is.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Po(i,DC),Co(i,DC),i.schema=101))}function $i(i,t=!1){let e=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Me,u=0;for(let c=0;c<i.length;++c){let d=i[c],h=0;if(e!==(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 f in d.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(d.attributes[f]),h++}if(h!==n.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(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in d.morphAttributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=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(u,f,c),u+=f}}if(e){let c=0,d=[];for(let h=0;h<i.length;++h){let f=i[h].index;for(let m=0;m<f.count;++m)d.push(f.getX(m)+c);c+=i[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=LC(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 o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][h]);let m=LC(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(m)}}return l}function LC(i){let t,e,n,r=0;for(let a=0;a<i.length;++a){let l=i[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=l.array.length}let s=new t(r),o=0;for(let a=0;a<i.length;++a)s.set(i[a].array,o),o+=i[a].array.length;return new Be(s,e,n)}var NC=Math.pow(2,-24);var Il=class{constructor(){}};function Ti(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function $b(i){let t=-1,e=-1/0;for(let n=0;n<3;n++){let r=i[n+3]-i[n];r>e&&(e=r,t=n)}return t}function ew(i,t){t.set(i)}function tw(i,t,e){let n,r;for(let s=0;s<3;s++){let o=s+3;n=i[s],r=t[s],e[s]=n<r?n:r,n=i[o],r=t[o],e[o]=n>r?n:r}}function Sf(i,t,e){for(let n=0;n<3;n++){let r=t[i+2*n],s=t[i+2*n+1],o=r-s,a=r+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Uu(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function ej(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r;e>65535?r=new Uint32Array(new n(4*e)):r=new Uint16Array(new n(2*e)),i.setIndex(new Be(r,1));for(let s=0;s<e;s++)r[s]=s}}function tj(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let r of i.groups)e.add(r.start),e.add(r.start+r.count);let n=Array.from(e.values()).sort((r,s)=>r-s);for(let r=0;r<n.length-1;r++){let s=n[r],o=n[r+1];t.push({offset:s/3,count:(o-s)/3})}return t}function rw(i,t,e,n,r=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,y=r!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let w=i[v+0],S=i[v+1],_=w-S,M=w+S;_<s&&(s=_),M>l&&(l=M),y&&w<d&&(d=w),y&&w>m&&(m=w);let b=i[v+2],E=i[v+3],T=b-E,I=b+E;T<o&&(o=T),I>u&&(u=I),y&&b<h&&(h=b),y&&b>p&&(p=b);let C=i[v+4],P=i[v+5],O=C-P,B=C+P;O<a&&(a=O),B>c&&(c=B),y&&C<f&&(f=C),y&&C>g&&(g=C)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(r[0]=d,r[1]=h,r[2]=f,r[3]=m,r[4]=p,r[5]=g)}function nj(i,t,e,n){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=i[c+0];h<r&&(r=h),h>a&&(a=h);let f=i[c+2];f<s&&(s=f),f>l&&(l=f);let m=i[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=r,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function rj(i,t,e,n,r){let s=e,o=e+n-1,a=r.pos,l=r.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=i[s*3+u];i[s*3+u]=i[o*3+u],i[o*3+u]=c;let d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var Io=32,ij=(i,t)=>i.candidate-t.candidate,Ca=new Array(Io).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ny=new Float32Array(6);function sj(i,t,e,n,r,s){let o=-1,a=0;if(s===0)o=$b(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=$b(i),o!==-1&&(a=oj(e,n,r,o));else if(s===2){let l=Uu(i),u=1.25*r,c=n*6,d=(n+r)*6;for(let h=0;h<3;h++){let f=t[h],g=(t[h+3]-f)/Io;if(r<Io/4){let y=[...Ca];y.length=r;let v=0;for(let w=c;w<d;w+=6,v++){let S=y[v];S.candidate=e[w+2*h],S.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:b}=S;for(let E=0;E<3;E++)b[E]=1/0,b[E+3]=-1/0,M[E]=1/0,M[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;Sf(w,e,_)}y.sort(ij);let x=r;for(let w=0;w<x;w++){let S=y[w];for(;w+1<x&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),x--}for(let w=c;w<d;w+=6){let S=e[w+2*h];for(let _=0;_<x;_++){let M=y[_];S>=M.candidate?Sf(w,e,M.rightCacheBounds):(Sf(w,e,M.leftCacheBounds),M.count++)}}for(let w=0;w<x;w++){let S=y[w],_=S.count,M=r-S.count,b=S.leftCacheBounds,E=S.rightCacheBounds,T=0;_!==0&&(T=Uu(b)/l);let I=0;M!==0&&(I=Uu(E)/l);let C=1+1.25*(T*_+I*M);C<u&&(o=h,u=C,a=S.candidate)}}else{for(let x=0;x<Io;x++){let w=Ca[x];w.count=0,w.candidate=f+g+x*g;let S=w.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let x=c;x<d;x+=6){let _=~~((e[x+2*h]-f)/g);_>=Io&&(_=Io-1);let M=Ca[_];M.count++,Sf(x,e,M.bounds)}let y=Ca[Io-1];ew(y.bounds,y.rightCacheBounds);for(let x=Io-2;x>=0;x--){let w=Ca[x],S=Ca[x+1];tw(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;x<Io-1;x++){let w=Ca[x],S=w.count,_=w.bounds,b=Ca[x+1].rightCacheBounds;S!==0&&(v===0?ew(_,ny):tw(_,ny,ny)),v+=S;let E=0,T=0;v!==0&&(E=Uu(ny)/l);let I=r-v;I!==0&&(T=Uu(b)/l);let C=1+1.25*(E*v+T*I);C<u&&(o=h,u=C,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function oj(i,t,e,n){let r=0;for(let s=t,o=t+e;s<o;s++)r+=i[s*6+n*2];return r/e}function aj(i,t){let e=i.attributes.position,n=i.index.array,r=n.length/3,s=new Float32Array(r*6),o=e.normalized,a=e.array,l=e.offset||0,u=3;e.isInterleavedBufferAttribute&&(u=e.data.stride);let c=["getX","getY","getZ"];for(let d=0;d<r;d++){let h=d*3,f=d*6,m,p,g;o?(m=n[h+0],p=n[h+1],g=n[h+2]):(m=n[h+0]*u+l,p=n[h+1]*u+l,g=n[h+2]*u+l);for(let y=0;y<3;y++){let v,x,w;o?(v=e[c[y]](m),x=e[c[y]](p),w=e[c[y]](g)):(v=a[m+y],x=a[p+y],w=a[g+y]);let S=v;x<S&&(S=x),w<S&&(S=w);let _=v;x>_&&(_=x),w>_&&(_=w);let M=(_-S)/2,b=y*2;s[f+b+0]=S+M,s[f+b+1]=M+(Math.abs(S)+M)*NC,S<t[y]&&(t[y]=S),_>t[y+3]&&(t[y+3]=_)}}return s}function lj(i,t){function e(y){h&&h(y/f)}function n(y,v,x,w=null,S=0){if(!m&&S>=l&&(m=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let _=sj(y.boundingData,w,o,v,x,d);if(_.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=rj(a,o,v,x,_);if(M===v||M===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=_.axis;let b=new Il,E=v,T=M-v;y.left=b,b.boundingData=new Float32Array(6),rw(o,E,T,b.boundingData,s),n(b,E,T,s,S+1);let I=new Il,C=M,P=x-T;y.right=I,I.boundingData=new Float32Array(6),rw(o,C,P,I.boundingData,s),n(I,C,P,s,S+1)}return y}ej(i,t);let r=new Float32Array(6),s=new Float32Array(6),o=aj(i,r),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=i.index.count/3,m=!1,p=[],g=tj(i);if(g.length===1){let y=g[0],v=new Il;v.boundingData=r,nj(o,y.offset,y.count,s),n(v,y.offset,y.count,s),p.push(v)}else for(let y of g){let v=new Il;v.boundingData=new Float32Array(6),rw(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function UC(i,t){let e=lj(i,t),n,r,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),r=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,m=!!d.count,p=d.boundingData;for(let g=0;g<6;g++)n[h+g]=p[g];if(m){let g=d.offset,y=d.count;return r[h+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=d.left,y=d.right,v=d.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[h+6]=x/4,x=u(x,y),r[h+7]=v,x}}}var Yr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,r=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}setFromPoints(t,e){let n=1/0,r=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}};Yr.prototype.setFromBox=function(){let i=new A;return function(e,n){let r=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=r.x*l+s.x*(1-l),i.y=r.y*u+s.y*(1-u),i.z=r.z*c+s.z*(1-c);let d=e.dot(i);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var Poe=function(){let i=new Yr;return function(e,n){let r=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let d=o[c],h=s[c];if(i.setFromPoints(h,a),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(i.setFromPoints(h,r),d.isSeparated(i))return!1}}}();var cj=function(){let i=new A,t=new A,e=new A;return function(r,s,o){let a=r.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),m=e.dot(l),g=l.dot(l)*f-h*h,y,v;g!==0?y=(d*h-m*f)/g:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),Af=function(){let i=new F,t=new A,e=new A;return function(r,s,o,a){cj(r,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){r.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=r.start:c=r.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),kC=function(){let i=new A,t=new A,e=new vn,n=new Hn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var uj=1e-15;function ku(i){return Math.abs(i)<uj}var Xr=class extends $t{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Yr),this.points=[this.a,this.b,this.c],this.sphere=new dn,this.plane=new vn,this.needsUpdate=!0}intersectsSphere(t){return kC(t,this)}update(){let t=this.a,e=this.b,n=this.c,r=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,r);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,r);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,r);let f=s[3],m=o[3];f.subVectors(n,t),m.setFromPoints(f,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Xr.prototype.closestPointToSegment=function(){let i=new A,t=new A,e=new Hn;return function(r,s=null,o=null){let{start:a,end:l}=r,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),Af(e,r,i,t),c=i.distanceToSquared(t),c<d&&(d=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(d)}}();Xr.prototype.intersectsTriangle=function(){let i=new Xr,t=new Array(3),e=new Array(3),n=new Yr,r=new Yr,s=new A,o=new A,a=new A,l=new A,u=new Hn,c=new Hn,d=new Hn;return function(f,m=null,p=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let _=0;_<4;_++){let M=v[_],b=x[_];if(n.setFromPoints(b,e),M.isSeparated(n))return!1}let w=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let M=w[_],b=S[_];if(n.setFromPoints(b,t),M.isSeparated(n))return!1}for(let _=0;_<4;_++){let M=x[_];for(let b=0;b<4;b++){let E=S[b];if(s.crossVectors(M,E),n.setFromPoints(s,t),r.setFromPoints(s,e),n.isSeparated(r))return!1}}return m&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let v=this.points,x=!1,w=0;for(let O=0;O<3;O++){let B=v[O],j=v[(O+1)%3];u.start.copy(B),u.end.copy(j),u.delta(o);let Q=x?c.start:c.end,V=ku(y.distanceToPoint(B));if(ku(y.normal.dot(o))&&V){c.copy(u),w=2;break}if((y.intersectLine(u,Q)||V)&&!ku(Q.distanceTo(j))){if(w++,x)break;x=!0}}if(w===1&&f.containsPoint(c.end))return m&&(m.start.copy(c.end),m.end.copy(c.end)),!0;if(w!==2)return!1;let S=f.points,_=!1,M=0;for(let O=0;O<3;O++){let B=S[O],j=S[(O+1)%3];u.start.copy(B),u.end.copy(j),u.delta(a);let Q=_?d.start:d.end,V=ku(g.distanceToPoint(B));if(ku(g.normal.dot(a))&&V){d.copy(u),M=2;break}if((g.intersectLine(u,Q)||V)&&!ku(Q.distanceTo(j))){if(M++,_)break;_=!0}}if(M===1&&this.containsPoint(d.end))return m&&(m.start.copy(d.end),m.end.copy(d.end)),!0;if(M!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let O=d.start;d.start=d.end,d.end=O}let b=c.start.dot(o),E=c.end.dot(o),T=d.start.dot(o),I=d.end.dot(o),C=E<T,P=b<I;return b!==I&&T!==E&&C===P?!1:(m&&(l.subVectors(c.start,d.start),l.dot(o)>0?m.start.copy(c.start):m.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?m.end.copy(c.end):m.end.copy(d.end)),!0)}}}();Xr.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Xr.prototype.distanceToTriangle=function(){let i=new A,t=new A,e=["a","b","c"],n=new Hn,r=new Hn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],m=o[f];this.closestPointToPoint(m,i),h=m.distanceToSquared(i),h<c&&(c=h,a&&a.copy(i),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,i),h=p.distanceToSquared(i),h<c&&(c=h,a&&a.copy(p),l&&l.copy(i))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let m=0;m<3;m++){let p=e[m],g=e[(m+1)%3];r.set(o[p],o[g]),Af(n,r,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var Qr=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new A,this.max=new A,this.matrix=new ie,this.invMatrix=new ie,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Yr),this.alignedSatBounds=new Array(3).fill().map(()=>new Yr),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Qr.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,r=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=r[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=r[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=r[h];c.subVectors(a,f),d.setFromPoints(c,r)}let l=this.alignedSatBounds;l[0].setFromPointsField(r,"x"),l[1].setFromPointsField(r,"y"),l[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Qr.prototype.intersectsBox=function(){let i=new Yr;return function(e){this.needsUpdate&&this.update();let n=e.min,r=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=n.x,i.max=r.x,a[0].isSeparated(i)||(i.min=n.y,i.max=r.y,a[1].isSeparated(i))||(i.min=n.z,i.max=r.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(i.setFromBox(u,e),c.isSeparated(i))return!1}return!0}}();Qr.prototype.intersectsTriangle=function(){let i=new Xr,t=new Array(3),e=new Yr,n=new Yr,r=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let h=0;h<3;h++){let f=a[h],m=l[h];if(e.setFromPoints(m,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],m=c[h];if(e.setFromPoints(m,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let m=0;m<4;m++){let p=c[m];if(r.crossVectors(f,p),e.setFromPoints(r,t),n.setFromPoints(r,d),e.isSeparated(n))return!1}}return!0}}();Qr.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Qr.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Qr.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Hn),e=new Array(12).fill().map(()=>new Hn),n=new A,r=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(r),this.closestPointToPoint(r,n),o.closestPointToPoint(n,r),l&&l.copy(n),u&&u.copy(r)),0;let c=a*a,d=o.min,h=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let y=f[g];r.copy(y).clamp(d,h);let v=y.distanceToSquared(r);if(v<m&&(m=v,l&&l.copy(y),u&&u.copy(r),v<c))return Math.sqrt(v)}let p=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,w=(g+2)%3,S=y<<x|v<<w,_=1<<g|y<<x|v<<w,M=f[S],b=f[_];t[p].set(M,b);let T=i[g],I=i[x],C=i[w],P=e[p],O=P.start,B=P.end;O[T]=d[T],O[I]=y?d[I]:h[I],O[C]=v?d[C]:h[I],B[T]=h[T],B[I]=y?d[I]:h[I],B[C]=v?d[C]:h[I],p++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){r.x=g?h.x:d.x,r.y=y?h.y:d.y,r.z=v?h.z:d.z,this.closestPointToPoint(r,n);let x=r.distanceToSquared(n);if(x<m&&(m=x,l&&l.copy(n),u&&u.copy(r),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Af(y,x,n,r);let w=n.distanceToSquared(r);if(w<m&&(m=w,l&&l.copy(n),u&&u.copy(r),w<c))return Math.sqrt(w)}}return Math.sqrt(m)}}();var zu=new A,Gu=new A,Vu=new A,iy=new F,sy=new F,oy=new F,zC=new A,GC=new A,VC=new A,ay=new A;function dj(i,t,e,n,r,s){let o;return s===On?o=i.intersectTriangle(n,e,t,!0,r):o=i.intersectTriangle(t,e,n,s!==Lr,r),o===null?null:{distance:i.origin.distanceTo(r),point:r.clone()}}function hj(i,t,e,n,r,s,o,a,l){zu.fromBufferAttribute(t,s),Gu.fromBufferAttribute(t,o),Vu.fromBufferAttribute(t,a);let u=dj(i,zu,Gu,Vu,ay,l);if(u){n&&(iy.fromBufferAttribute(n,s),sy.fromBufferAttribute(n,o),oy.fromBufferAttribute(n,a),u.uv=$t.getInterpolation(ay,zu,Gu,Vu,iy,sy,oy,new F)),r&&(iy.fromBufferAttribute(r,s),sy.fromBufferAttribute(r,o),oy.fromBufferAttribute(r,a),u.uv1=$t.getInterpolation(ay,zu,Gu,Vu,iy,sy,oy,new F)),e&&(zC.fromBufferAttribute(e,s),GC.fromBufferAttribute(e,o),VC.fromBufferAttribute(e,a),u.normal=$t.getInterpolation(ay,zu,Gu,Vu,zC,GC,VC,new A),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new A,materialIndex:0};$t.getNormal(zu,Gu,Vu,c.normal),u.face=c,u.faceIndex=s}return u}function sw(i,t,e,n,r){let s=n*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:d,uv1:h}=i.attributes,f=hj(e,u,c,d,h,o,a,l,t);return f?(f.faceIndex=n,r&&r.push(f),f):null}function HC(i,t,e,n,r,s){for(let o=n,a=n+r;o<a;o++)sw(i,t,e,o,s)}function jC(i,t,e,n,r){let s=1/0,o=null;for(let a=n,l=n+r;a<l;a++){let u=sw(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Ci(i,t,e,n){let r=i.a,s=i.b,o=i.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),r.x=n.getX(a),r.y=n.getY(a),r.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function ow(i,t,e,n,r,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Ci(o,u*3,a,l),o.needsUpdate=!0,n(o,u,r,s))return!0;return!1}var Hu=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function Do(i,t){return t[i+15]===65535}function Dl(i,t){return t[i+6]}function ju(i,t){return t[i+14]}function Wu(i){return i+8}function qu(i,t){return t[i+6]}function WC(i,t){return t[i+7]}var Yu=new _t,cy=new A,pj=["x","y","z"];function uy(i,t,e,n,r){let s=i*2,o=Xu,a=Pa,l=Ia;if(Do(s,a)){let c=Dl(i,l),d=ju(s,a);HC(t,e,n,c,d,r)}else{let c=Wu(i);hy(c,o,n,cy)&&uy(c,t,e,n,r);let d=qu(i,l);hy(d,o,n,cy)&&uy(d,t,e,n,r)}}function dy(i,t,e,n){let r=i*2,s=Xu,o=Pa,a=Ia;if(Do(r,o)){let u=Dl(i,a),c=ju(r,o);return jC(t,e,n,u,c)}else{let u=WC(i,a),c=pj[u],h=n.direction[c]>=0,f,m;h?(f=Wu(i),m=qu(i,a)):(f=qu(i,a),m=Wu(i));let g=hy(f,s,n,cy)?dy(f,t,e,n):null;if(g){let x=g.point[c];if(h?x<=s[m+u]:x>=s[m+u+3])return g}let v=hy(m,s,n,cy)?dy(m,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var qC=function(){let i,t,e=[],n=new Hu(()=>new _t);return function(...o){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let a=r(...o);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function r(s,o,a,l,u=null,c=0,d=0){function h(x){let w=x*2,S=Pa,_=Ia;for(;!Do(w,S);)x=Wu(x),w=x*2;return Dl(x,_)}function f(x){let w=x*2,S=Pa,_=Ia;for(;!Do(w,S);)x=qu(x,_),w=x*2;return Dl(x,_)+ju(w,S)}let m=s*2,p=Xu,g=Pa,y=Ia;if(Do(m,g)){let x=Dl(s,y),w=ju(m,g);return Ti(s,p,i),l(x,w,!1,d,c+s,i)}else{let x=Wu(s),w=qu(s,y),S=x,_=w,M,b,E,T;if(u&&(E=i,T=t,Ti(S,p,E),Ti(_,p,T),M=u(E),b=u(T),b<M)){S=w,_=x;let Q=M;M=b,b=Q,E=T}E||(E=i,Ti(S,p,E));let I=Do(S*2,g),C=a(E,I,M,d+1,c+S),P;if(C===2){let Q=h(S),q=f(S)-Q;P=l(Q,q,!0,d+1,c+S,E)}else P=C&&r(S,o,a,l,u,c,d+1);if(P)return!0;T=t,Ti(_,p,T);let O=Do(_*2,g),B=a(T,O,b,d+1,c+_),j;if(B===2){let Q=h(_),q=f(_)-Q;j=l(Q,q,!0,d+1,c+_,T)}else j=B&&r(_,o,a,l,u,c,d+1);return!!j}}}(),YC=function(){let i=new Xr,t=new Xr,e=new ie,n=new Qr,r=new Qr;return function s(o,a,l,u,c=null){let d=o*2,h=Xu,f=Pa,m=Ia;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),Do(d,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,w=l.attributes.position,S=Dl(o,m),_=ju(d,f);if(e.copy(u).invert(),l.boundsTree)return Ti(o,h,r),r.matrix.copy(e),r.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>r.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let E=S*3,T=(_+S)*3;E<T;E+=3)if(Ci(t,E,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let M=S*3,b=_+S*3;M<b;M+=3){Ci(i,M,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let E=0,T=x.count;E<T;E+=3)if(Ci(t,E,x,w),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=m[o+6];return Ti(g,h,Yu),!!(c.intersectsBox(Yu)&&s(g,a,l,u,c)||(Ti(y,h,Yu),c.intersectsBox(Yu)&&s(y,a,l,u,c)))}}}();function hy(i,t,e,n){return Ti(i,t,Yu),e.intersectBox(Yu,n)}var aw=[],ly,Xu,Pa,Ia;function Qu(i){ly&&aw.push(ly),ly=i,Xu=new Float32Array(i),Pa=new Uint16Array(i),Ia=new Uint32Array(i)}function _f(){ly=null,Xu=null,Pa=null,Ia=null,aw.length&&Qu(aw.pop())}var lw=Symbol("skip tree generation"),cw=new _t,uw=new _t,Ku=new ie,Ol=new Qr,Mf=new Qr,Ef=new A,fy=new A,mj=new A,gj=new A,yj=new A,XC=new _t,Ds=new Hu(()=>new Xr),Os=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Os.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,r=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:r.map(a=>a.slice()),index:s.array.slice()}:o={roots:r,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Os.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:r,roots:s}=t,o=new Os(e,{...n,[lw]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Be(t.index,1,!1);e.setIndex(l)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[lw]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[lw]||(this._roots=UC(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new _t))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,r=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let h=0,f=c.length;h<f;h++)s=c[h],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,u),u+=s.byteLength;function d(h,f,m=!1){let p=h*2;if(a[p+15]===65535){let y=o[h+6],v=a[p+14],x=1/0,w=1/0,S=1/0,_=-1/0,M=-1/0,b=-1/0;for(let E=3*y,T=3*(y+v);E<T;E++){let I=n[E],C=r.getX(I),P=r.getY(I),O=r.getZ(I);C<x&&(x=C),C>_&&(_=C),P<w&&(w=P),P>M&&(M=P),O<S&&(S=O),O>b&&(b=O)}return l[h+0]!==x||l[h+1]!==w||l[h+2]!==S||l[h+3]!==_||l[h+4]!==M||l[h+5]!==b?(l[h+0]=x,l[h+1]=w,l[h+2]=S,l[h+3]=_,l[h+4]=M,l[h+5]=b,!0):!1}else{let y=h+8,v=o[h+6],x=y+f,w=v+f,S=m,_=!1,M=!1;t?S||(_=t.has(x),M=t.has(w),S=!_&&!M):(_=!0,M=!0);let b=S||_,E=S||M,T=!1;b&&(T=d(y,f,S));let I=!1;E&&(I=d(v,f,S));let C=T||I;if(C)for(let P=0;P<3;P++){let O=y+P,B=v+P,j=l[O],Q=l[O+3],V=l[B],q=l[B+3];l[h+P]=j<V?j:V,l[h+P+3]=Q>q?Q:q}return C}}}traverse(t,e=0){let n=this._roots[e],r=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=r[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=r[a+6],f=r[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=ai){let n=this._roots,r=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=r.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(Qu(n[c]),uy(0,r,h,t,s),_f(),a){let m=l[c].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(t,e=ai){let n=this._roots,r=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=r.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;Qu(n[c]);let f=dy(0,r,h,t);_f(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,r=!1;for(let s of this._roots)if(Qu(s),r=YC(0,n,t,e),_f(),r)break;return r}shapecast(t,e,n){let r=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,m,p,g)=>{let y=m*3;return h(f,y,y+1,y+2,p,g)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Ds.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,m,p,g,y)=>h(f,m,p,g,y)?!0:ow(f,m,r,u,p,g,s)}else l||(u?l=(h,f,m,p)=>ow(h,f,r,u,m,p,s):l=(h,f,m)=>m);let c=!1,d=0;for(let h of this._roots){if(Qu(h),c=qC(0,r,a,l,o,d),_f(),c)break;d+=h.byteLength}return Ds.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:r,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;Ku.copy(e).invert();let c=Ds.getPrimitive(),d=Ds.getPrimitive();if(s){let f=function(m,p,g,y,v,x,w,S){for(let _=g,M=g+y;_<M;_++){Ci(d,_*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let b=m,E=m+p;b<E;b++)if(Ci(c,b*3,o,a),c.needsUpdate=!0,s(c,d,b,_,v,x,w,S))return!0}return!1};if(r){let m=r;r=function(p,g,y,v,x,w,S,_){return m(p,g,y,v,x,w,S,_)?!0:f(p,g,y,v,x,w,S,_)}}else r=f}t.getBoundingBox(uw),uw.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>uw.intersectsBox(f),intersectsRange:(f,m,p,g,y,v)=>(cw.copy(v),cw.applyMatrix4(Ku),t.shapecast({intersectsBounds:x=>cw.intersectsBox(x),intersectsRange:(x,w,S,_,M)=>r(f,m,x,w,g,y,_,M)}))});return Ds.releasePrimitive(c),Ds.releasePrimitive(d),h}intersectsBox(t,e){return Ol.set(t.min,t.max,e),Ol.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Ol.intersectsBox(n),intersectsTriangle:n=>Ol.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Ol.set(t.boundingBox.min,t.boundingBox.max,e),Ol.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=Ds.getPrimitive(),f=Ds.getPrimitive(),m=fy,p=mj,g=null,y=null;r&&(g=gj,y=yj);let v=1/0,x=null,w=null;return Ku.copy(e).invert(),Mf.matrix.copy(Ku),this.shapecast({boundsTraverseOrder:S=>Ol.distanceToBox(S),intersectsBounds:(S,_,M)=>M<v&&M<o?(_&&(Mf.min.copy(S.min),Mf.max.copy(S.max),Mf.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>Mf.distanceToBox(M),intersectsBounds:(M,b,E)=>E<v&&E<o,intersectsRange:(M,b)=>{for(let E=M*3,T=(M+b)*3;E<T;E+=3){Ci(f,E,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let I=S*3,C=(S+_)*3;I<C;I+=3){Ci(h,I,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,m,g);if(P<v&&(p.copy(m),y&&y.copy(g),v=P,x=I/3,w=E/3),P<s)return!0}}}});{let M=d?d.count:c.count;for(let b=0,E=M;b<E;b+=3){Ci(f,b,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let T=S*3,I=(S+_)*3;T<I;T+=3){Ci(h,T,u,l),h.needsUpdate=!0;let C=h.distanceToTriangle(f,m,g);if(C<v&&(p.copy(m),y&&y.copy(g),v=C,x=T/3,w=b/3),C<s)return!0}}}}}),Ds.releasePrimitive(h),Ds.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=x,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(Ku),p.applyMatrix4(Ku),r.distance=p.sub(r.point).length(),r.faceIndex=w),n)}closestPointToPoint(t,e={},n=0,r=1/0){let s=n*n,o=r*r,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(Ef.copy(t).clamp(c.min,c.max),Ef.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,Ef);let h=t.distanceToSquared(Ef);return h<a&&(fy.copy(Ef),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(fy):e.point=fy.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ti(0,new Float32Array(n),XC),t.union(XC)}),t}};var Gd=Ah(KC());var vj=.5*(Math.sqrt(3)-1),Tf=(3-Math.sqrt(3))/6,xj=1/3,Rs=1/6,Sae=(Math.sqrt(5)-1)/4,Aae=(5-Math.sqrt(5))/20,Cf=i=>Math.floor(i)|0,ZC=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]),hw=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 py(i=Math.random){let t=$C(i),e=new Float64Array(t).map(r=>ZC[r%12*2]),n=new Float64Array(t).map(r=>ZC[r%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*vj,d=Cf(s+c),h=Cf(o+c),f=(d+h)*Tf,m=d-f,p=h-f,g=s-m,y=o-p,v,x;g>y?(v=1,x=0):(v=0,x=1);let w=g-v+Tf,S=y-x+Tf,_=g-1+2*Tf,M=y-1+2*Tf,b=d&255,E=h&255,T=.5-g*g-y*y;if(T>=0){let P=b+t[E],O=e[P],B=n[P];T*=T,a=T*T*(O*g+B*y)}let I=.5-w*w-S*S;if(I>=0){let P=b+v+t[E+x],O=e[P],B=n[P];I*=I,l=I*I*(O*w+B*S)}let C=.5-_*_-M*M;if(C>=0){let P=b+1+t[E+1],O=e[P],B=n[P];C*=C,u=C*C*(O*_+B*M)}return 70*(a+l+u)}}function JC(i=Math.random){let t=$C(i),e=new Float64Array(t).map(s=>hw[s%12*3]),n=new Float64Array(t).map(s=>hw[s%12*3+1]),r=new Float64Array(t).map(s=>hw[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*xj,m=Cf(o+f),p=Cf(a+f),g=Cf(l+f),y=(m+p+g)*Rs,v=m-y,x=p-y,w=g-y,S=o-v,_=a-x,M=l-w,b,E,T,I,C,P;S>=_?_>=M?(b=1,E=0,T=0,I=1,C=1,P=0):S>=M?(b=1,E=0,T=0,I=1,C=0,P=1):(b=0,E=0,T=1,I=1,C=0,P=1):_<M?(b=0,E=0,T=1,I=0,C=1,P=1):S<M?(b=0,E=1,T=0,I=0,C=1,P=1):(b=0,E=1,T=0,I=1,C=1,P=0);let O=S-b+Rs,B=_-E+Rs,j=M-T+Rs,Q=S-I+2*Rs,V=_-C+2*Rs,q=M-P+2*Rs,W=S-1+3*Rs,X=_-1+3*Rs,L=M-1+3*Rs,U=m&255,G=p&255,H=g&255,z=.6-S*S-_*_-M*M;if(z<0)u=0;else{let k=U+t[G+t[H]];z*=z,u=z*z*(e[k]*S+n[k]*_+r[k]*M)}let re=.6-O*O-B*B-j*j;if(re<0)c=0;else{let k=U+b+t[G+E+t[H+T]];re*=re,c=re*re*(e[k]*O+n[k]*B+r[k]*j)}let K=.6-Q*Q-V*V-q*q;if(K<0)d=0;else{let k=U+I+t[G+C+t[H+P]];K*=K,d=K*K*(e[k]*Q+n[k]*V+r[k]*q)}let Z=.6-W*W-X*X-L*L;if(Z<0)h=0;else{let k=U+1+t[G+1+t[H+1]];Z*=Z,h=Z*Z*(e[k]*W+n[k]*X+r[k]*L)}return 32*(u+c+d+h)}}function $C(i){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let r=n+~~(i()*(256-n)),s=e[n];e[n]=e[r],e[r]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var es=new $t,my=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let r=0;r<t.count;r+=3){let s=1;es.a.fromBufferAttribute(t,r),es.b.fromBufferAttribute(t,r+1),es.c.fromBufferAttribute(t,r+2),s*=es.getArea(),e[r/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let r=0;r<e.length;r++)n+=e[r],this.distribution[r]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*n);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,r=e.length-1,s=-1;for(;n<=r;){let o=Math.ceil((n+r)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?r=o-1:n=o+1}return s}sampleFace(t,e,n){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),es.a.fromBufferAttribute(this.positionAttribute,t*3),es.b.fromBufferAttribute(this.positionAttribute,t*3+1),es.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(es.a,r).addScaledVector(es.b,s).addScaledVector(es.c,1-(r+s)),es.getNormal(n),this}};var tP=Ah(fw()),bj=new ie,wj=new ie,Sj=new ie,Zu;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(Zu||(Zu={}));var Ju=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ie;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ie;this.matrixWorldRigid=new ie;this.shearScale=new ie;this.shearScaleInv=new ie}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof ht&&(n=n.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===n)return!0;r=r.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let r of this.children)r.updateMatrixWorld(n)}updateWorldMatrix(n,r){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(n,r=0){for(let s of this.children)Zu.is(s)&&s.traverseObject(n,r+1)}traverseObject(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Zu.is(o)&&o.traverseObject(n,r+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,r=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,tP.SVD)(r),l=bj.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=wj.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=Sj.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,r){this.updateWorldMatrix(!0,!1);let s=new ie().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof ie?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),r!==void 0&&(this.children.pop(),this.children.splice(r,0,n)),this}copy(n,r=!1){return super.copy(n,r),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,r,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var pw=class extends Ju(ht){},Aj=i=>i.type==="Mesh",rn=class extends pw{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let r=this.children[e];r?.object!==n&&(r&&this.remove(r),r=new rn(n),this.add(r),this.children.splice(e,0,this.children.pop()),r.matrixWorldNeedsUpdate=!0,r.matrixAutoUpdate=!1,r.matrix=n.matrix,r.hiddenMatrix=n.hiddenMatrix),r.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return Aj(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Rl=new A,Ll=new A,$u=new ie,rP=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],_j=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Mj=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],nP=(i,t,e)=>{i.updateEntityBoxSize(Rl,Ll),$u.copy(t).multiply(i.matrixWorld),Ll.x===0&&Ll.y===0&&Ll.z===0?e.push(new A(Rl.x,Rl.y,Rl.z).applyMatrix4($u)):rP.forEach(n=>{e.push(n.clone().multiply(Ll).add(Rl).applyMatrix4($u))})},Pf=class extends _t{constructor(){super(...arguments);this.matrix=new ie;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new ie().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,n)}expandByObjectSize(e,n,r=!1){let s=[];return r===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}nP(o,n,s)}}):nP(e,n,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4($u.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ll).multiplyScalar(.5),this.getCenter(Rl),$u.copy(this.matrix).setPosition(Rl),this.vertices=rP.map(e=>e.clone().multiply(Ll).applyMatrix4($u))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=_j.map(([e,n])=>new Hn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Mj.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var ts={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var gw=class extends qh{constructor(){super()}getPoints(t=12){let e=[],n,r=this.getCurveLengths(),o=r[r.length-1]/r.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?r[a]:r[a]-r[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let m=h[f];n&&n.equals(m)||(e.push(m),n=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var yw=.001;function vw(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=yw}function mw(i,t){let e=new A(...i.position),n=new A(...i.controlNext.position),r=new A(...t.controlPrevious.position),s=new A(...t.position);return vw(e,n,s)&&vw(e,r,s)}function yy(i){let t=i.points.map(c=>new A(...c.data.position)),e=[i.points[0]],n=new A(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)vw(n,t[c],t[c+1])||(e.push(i.points[c]),n=t[c]);e.push(i.points[i.points.length-1]);let r=i.isClosed,s=e.length-(r?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new A(...d.position),f=new A(...d.controlPrevious.position),m=new A(...d.controlNext.position),p={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...p,removedLength:0};continue}let g=r&&c==0?o-1:c-1,y=r&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,w=new A(...v.position),S=new A(...x.position),_=w.clone().sub(h).normalize(),M=S.clone().sub(h).normalize();Object.assign(p,{prevDir:_,nextDir:M});let b=mw(v,d),E=mw(d,x);if(!b||!E)a[c]={...p,removedLength:0};else{let T=_.clone().add(M).normalize(),I=T.clone().cross(_).length()/_.dot(T);a[c]={...p,tan:I,removedLength:d.roundness/I}}}for(let c=0;c<s;c++){let d=c,h=r&&c===o-1?0:c+1,f=a[d],m=a[h];if(f.removedLength!==0||m.removedLength!==0){let p=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,p/2),m.removedLength=Math.min(m.removedLength,p/2)}}let l=[];for(let c=0;c<s;c++){let d=c,h=r&&c===o-1?0:c+1,f=a[d],m=a[h],p=null;if(!mw(e[d].data,e[h].data))f.position.distanceTo(m.position)>yw&&(p=new dl(f.position,f.controlNext,m.controlPrevious,m.position));else{let g=f.position.clone(),y=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&y.add(m.prevDir.clone().setLength(m.removedLength))),g.distanceTo(y)>yw&&(p=new dl(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=p}for(let c=0;c<o;c++){let d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),m=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),p=d.tan*d.removedLength,g=d.prevDir.clone().add(d.nextDir).normalize(),y=f.clone().lerp(m,.5),v=f.distanceTo(m)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(v,2))).add(y),w=g.clone().multiplyScalar(-p).add(x),S=h.distanceTo(w)/h.distanceTo(y),_=d.prevDir.clone().multiplyScalar(S*h.distanceTo(f)).add(h),M=_.clone().lerp(w,2),b=f.clone().lerp(_,4/3),E=m.clone().lerp(M,4/3);l[2*c]=new dl(f,b,E,m)}let u=new gw;return l.forEach(c=>{c&&u.add(c)}),u}var lt;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(lt||(lt={}));var Ls=i=>lt.is(i),Ej={type:"completeState",isfromEntity:!0},ed=i=>class extends Ju(i){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Pf;this._recursiveBBox=new Pf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let r=this.children[n];if(lt.is(r))return r}entityChildrenCount(){let n=this.children.length;for(;n--;)if(lt.is(this.children[n]))return n+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 n=this;for(;n.data.type!=="Instance";){let r=n.parent;if(lt.is(r))n=r;else return}return n}forInstancesRec(n){this.instances.forEach(r=>{r.disposed||n(r),r.forInstancesRec(n)})}super_Entity(n,r){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=r,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,r,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)To.toOps(this.data,o.data).forEach(l=>{let u=Sg.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,r)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=To.patch(this.data,o),To.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,r)}))}s&&this.updateTransformState(this.dataPatched),this.stateSelection=n,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(n,r){n.setScalar(0),r.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Ls(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let r;return this.traverseEntity(s=>{s.uuid===n&&(r=s)}),r}traverseSortNextHelper(){let n=this.parent;if(n){let r=n.children,s=r.indexOf(this)+1;if(lt.is(r[s]))return r[s];if(lt.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&lt.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let r=this;for(;n>0&&r!==null;)r=r.parent,n-=1;return r}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let r=this.parent;for(;r;){if(n===r)return!0;r=r.parent}return!1}countToAccestor(n){let r=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,r+=1}return r}forEachEntity(n){for(let r of this.children)Ls(r)&&n(r)}traverseEntityAncestors(n){this.traverseAncestors(r=>{lt.is(r)&&n(r)})}traverseConcreteEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Ls(o)&&o.isConcreteEntity&&o.traverseEntity(n,r+1)}traverseEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Ls(o)&&o.traverseEntity(n,r+1)}traverseVisibleEntity(n){n(this);for(let r of this.children)Ls(r)&&r.visible&&r.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,r=!1){return super.copy(n,r),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Ls(n))}isAncestorOf(n){if(this.uuid===n)return!1;let r=!1;return this.traverseEntity(s=>{s.uuid===n&&(r=!0)}),r}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return xu(r,n)}updateTransformState(n){let r=!1;return n.position&&(this.position.fromArray(n.position),r=!0),n.rotation&&(this.rotation.fromArray(n.rotation),r=!0),n.scale&&(r=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??ba.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)lt.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{lt.is(n)&&n.disposeRecursively()})}toState(n=[]){let r={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return xu(r,n)}updateByObjUpdateOp(n,r){this.updateByOp({type:0,props:n,path:[]},{...this.data,...n},r,!1)}updateByOp(n,r,s,o){let a=this.data;this.data=r;let l=n,u=Tr(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=Br.zoom(h,n.path.slice(2));if(f)for(let m in n.props)n.props[m]===void 0&&m in f&&(d[m]=f[m])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=Br.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,To.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Tr(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(As.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=Br.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let m=n.props;if(f)for(let[p,g]of Object.entries(n.props))g===void 0&&(m===n.props&&(m={...n.props}),m[p]=f[p]);n={...n,props:m}}h.overrideData=Lu.resolve(r.overrides,c),h.updateByOp(n,yr.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of Mo.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of Mo.rootOverrideProps)if(Tr(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=As.filterOp(d.overrideData,c);h&&d.updateByOp(h,yr.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=As.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=r:f=yr.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,r,s){if(this.dataPatched=r,n.path.length===0&&n.type===0)n.props.type!==void 0&&!Ji.is(n.props.type)&&ts.changeEntityProptotype(this,r,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){ts.changeEntityProptotype(this,r,s);for(let o of this.children)lt.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,r,s)}updateByPatchedOp(n,r,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Tr(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(r.pathSnapping),Tr(n.path,["cloner"])!==null){let o=yr.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(r.cloner,s.scene):(this.setFromClonerState(r.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let r=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(r===null)return;let l=n.find(r);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=yy(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new ie;l.updateMatrixWorld();let m=new ie().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(m);let p={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ie().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(g).add(h),v=new ie().lookAt(h,y,new A(0,1,0)),x=new Gt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(Ej)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,r){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),r&&"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,r),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof ts.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,r){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new ts.Cloner(this,n),r.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,r.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var vy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters),n=e.width/2,r=e.radiusTop??n,s=e.radiusBottom??n;return r===s?(r=n,s=n):r>s?(r=n,s=s*n/r):(r=r*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:r,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=i.parameters,m;return d||f?m=new If(u,c,n,r,s,o,a,l*Math.PI/180,d,d,h,f):m=new fl(u,c,n,r,s,o,a,l*Math.PI/180),m.scale(1,1,e/t),Object.assign(m,{userData:{...i,type:"CylinderGeometry"}})}};function Da(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function iP(i){return new F(i.y,-i.x)}var If=class extends Me{constructor(t,e,n,r,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,r=Math.floor(r)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],y=[],v=0,x=n/2,w=new A,S=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let _=new F(t,x),M=new F(e,-x),b=null,E=null,T=null,I=null,C=_.clone().sub(M),P=0,O=0,B=0;h>0&&(P=Math.min(t,e)*(1-h),O=t-P,B=e-P);let j=_.clone();j.x-=P;let Q=Math.PI-C.angle(),V=C.angle(),q=Math.tan(V/2),W=Math.tan(Q/2),X=q+W,L=h?X:W,U=h?X:q;if(u=Math.min(u,(t-O)/L,C.length()/X),c=Math.min(c,(e-B)/U,C.length()/X),u>0){let Z=u/q;b=_.clone().sub(new F(Z,u)),h&&(T=b.clone(),T.x-=P-X*u),_.sub(C.clone().setLength(Z))}if(c>0){let Z=c/W;E=M.clone().sub(new F(Z,-c)),M.add(C.clone().setLength(Z)),h&&(I=E.clone(),I.x-=P-X*c,j.sub(C.clone().setLength(Z)))}C=_.clone().sub(M);let G=C.length()<.5,H=[];for(let Z=0;Z<=r;Z++){let k=[],he=Z/r,fe=he*l+a,ce=new F(Math.sin(fe),Math.cos(fe));I&&E?(z(k,he,ce,Q,c,I,-1,!0),z(k,he,ce,V,c,E,-1,!1)):E?(re(k,ce,E.x,0,-1),z(k,he,ce,V,c,E,-1,!1)):o||re(k,ce,e,B,-1);let ye=iP(C).normalize();if(Da(ye,ce,w),!G)for(let Se=0;Se<=s;Se++){let ve=Se/s,Ee=C.clone().multiplyScalar(ve).add(M);Da(Ee,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}if(T&&b?(z(k,he,ce,Q,u,b,1,!1),z(k,he,ce,V,u,T,1,!0)):b?(z(k,he,ce,Q,u,b,1,!1),re(k,ce,b.x,0,1)):o||re(k,ce,t,O,1),h&&!G){let Se=iP(C).multiplyScalar(-1).normalize();Da(Se,ce,w);for(let ve=0;ve<=s;ve++){let Ee=ve/s,Te=C.clone().multiplyScalar(-Ee).add(j);Da(Te,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}}h&&!o&&k.push(k[0]),H.push(k)}for(let Z=0;Z<H.length-1;Z++)for(let k=0;k<H[0].length-1;k++){if(o&&h&&k==s)continue;let he=H[Z][k],fe=H[Z+1][k],ce=H[Z+1][k+1],ye=H[Z][k+1],Se=p[ce*3+0],ve=p[ce*3+2];m.push(he,fe,ye),(Se!=0||ve!=0)&&m.push(fe,ce,ye)}l<Math.PI*2&&(K(-1,H[0],a),K(1,H[H.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(y,2));function z(Z,k,he,fe,ce,ye,Se,ve){for(let Ee=0;Ee<d+1;Ee++){let Te=Ee/d,we=Se<0?Te:1-Te;ve&&(we-=1),we*=fe;let He=new F(Math.sin(we),Math.cos(we)*Se),vt=He.clone().multiplyScalar(ce).add(ye);Da(vt,he,S),p.push(S.x,S.y,S.z),Da(He,he,w),g.push(w.x,w.y,w.z),y.push(k,.5+S.y/n),Z.push(v++)}}function re(Z,k,he,fe,ce){let ye=new A,Se=new F,ve=[he,fe];ce<0&&ve.reverse();for(let Ee of ve)Se.set(Ee,x*ce),Da(Se,k,ye),p.push(ye.x,ye.y,ye.z),g.push(0,ce,0),y.push(.5,.5),Z.push(v++)}function K(Z,k,he){let fe=new F(Math.sin(he),Math.cos(he)),ce=new F(-Math.cos(he),Math.sin(he)),ye=new A,Se=Z<0?(Te,we,He)=>m.push(Te,we,He):(Te,we,He)=>m.push(Te,He,we),ve=new F((t+e+O+B)/4,0);Da(ve,fe,ye),p.push(ye.x,ye.y,ye.z),g.push(ce.x,0,ce.y),y.push(.5,.5);let Ee=v++;for(let Te of k){let we=p.slice(Te*3,Te*3+3);p.push(...we),g.push(ce.x,0,ce.y);let He=y.slice(Te*2,Te*2+2);y.push(...He),v++}for(let Te=Ee+1;Te<v-1;Te++)Se(Ee,Te,Te+1);Se(Ee,v-1,Ee+1)}}};var sP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=i.parameters,h;return u>0||c>0||l<360?h=new If(0,t/2,n,r,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new Pc(t/2,n,r,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"ConeGeometry"}})}};var oP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new er(t,e,n,r,s,o):u=new bw(t,e,n,r,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},xw=Math.PI/2,bw=class extends Me{constructor(t=1,e=1,n=1,r=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,r,0),y("x","y","z",1,-1,1,t,e,n,r,1),y("x","y","z",-1,1,1,t,e,n,r,0),y("x","y","z",1,1,-1,t,e,n,r,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function g(x,w,S,_,M,b,E,T,I,C,P){let O=(b-2*a)/I,B=(E-2*a)/C,j=b/2-a,Q=E/2-a,V=T/2,q=I+1,W=C+1,X=0,L=0,U=new A;for(let G=0;G<W;G++){let H=G*B-Q;for(let z=0;z<q;z++){let re=z*O-j;U[x]=re*_,U[w]=H*M,U[S]=V,d.push(U.x,U.y,U.z),U[x]=0,U[w]=0,U[S]=T>0?1:-1,h.push(U.x,U.y,U.z),f.push(z/I),f.push(1-G/C),X+=1}}for(let G=0;G<C;G++)for(let H=0;H<I;H++){let z=m+H+q*G,re=m+H+q*(G+1),K=m+(H+1)+q*(G+1),Z=m+(H+1)+q*G;c.push(z,re,Z),c.push(re,K,Z),L+=6}u.addGroup(p,L,P),p+=L,m+=X}function y(x,w,S,_,M,b,E,T,I,C,P){let O=(E-2*a)/C,B=E/2-a,j=T/2-a,Q=I/2,V=C+1,q=0,W=0,X=new A,L=new A;for(let U=0;U<l+1;U++){let G=U/l*xw,H=Math.sin(G)*a,z=(1-Math.cos(G))*a,re=Math.sin(G),K=Math.cos(G);X[w]=(j+H)*M,X[S]=(Q-z)*b,L[x]=0,L[w]=re*Math.sign(X[w]),L[S]=K*Math.sign(X[S]);for(let Z=0;Z<V;Z++){let k=Z*O-B;X[x]=k*_,d.push(X.x,X.y,X.z),h.push(L.x,L.y,L.z),f.push(Z/C),f.push(0),q+=1}}for(let U=0;U<l;U++)for(let G=0;G<C;G++){let H=m+G+V*U,z=m+G+V*(U+1),re=m+(G+1)+V*(U+1),K=m+(G+1)+V*U;c.push(H,z,K),c.push(z,re,K),W+=6}u.addGroup(p,W,P),p+=W,m+=q}function v(x,w,S){let _=new A,M=new A(t/2,e/2,n/2);M.subScalar(a);let b=[],E=x*w*S>0?(I,C,P)=>c.push(I,C,P):(I,C,P)=>c.push(I,P,C);for(let I=0;I<=l;I++){let C=[],P=xw*(1-I/l),O=Math.cos(P),B=Math.sin(P),j=0;for(let Q=0;Q<=I;Q++){let V=Math.cos(j),q=Math.sin(j);_.x=O*V,_.y=B,_.z=O*q;let W=M.clone().addScaledVector(_,a);d.push(x*W.x,w*W.y,S*W.z),h.push(x*_.x,w*_.y,S*_.z),f.push(0,0),C.push(m++),j+=xw/I}b.push(C)}let T=b.length-1;for(let I=0;I<T;I++){let C=b[I],P=b[I+1],O=C.length-1;E(C[0],P[1],P[0]);for(let B=1;B<=O;B++)E(C[B-1],C[B],P[B]),E(C[B],P[B+1],P[B])}}}};var Oa=class extends Me{constructor(t=[],e=[],n="",r=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new $t,y=s*r,v=r-y,x=o+1,w=new A,S=(q,W)=>w.subVectors(q,W).normalize(),_=(q,W)=>Array(q).fill(void 0).map(W),M=_(t.length/3,(q,W)=>new A().fromArray(t,W*3).setLength(r)),b=[],E=1e6;for(let q=0;q<M.length;q++){let W=M[q],X=[],L,U,G,H=1e10,z=-1;for(;(z=e.indexOf(q,z+1))!=-1;){let k=z-z%3;L=e[k+(z+1)%3],U=e[k+(z+2)%3],G=W.distanceToSquared(M[L]),H=Math.min(H,G),X.push([L,U,G])}H+=1e-6;let re=[],K=0,Z=X.length;for(let k=0;k<Z;k++){[L,U,G]=X[K];let he=b[L]?.includes(q)==!0;G<=H&&re.push(L+ +he*E),K=X.findIndex(fe=>fe[0]==U)}b.push(re)}let T=[];{let q=0,W=0,X,L,U=f==3;for(let G=0;G<=o;G++){X=G*(G+1)/2,L=(G+1)*(G+2)/2;for(let H=0;H<o-G;H++)[q,W]=[X+H+G+2,L+H+G+3],T.push(X,L,...U?[W,X]:[q,L],W,q),[X,L]=[q,W];T.push(X,L,X+o+2)}}let I=m.clone(),C=m.clone(),P=m.clone(),O=m.clone(),B=m.clone(),j=[],Q=_(M.length,()=>_(f,()=>m.clone()));for(let q=0;q<M.length;q++){m.copy(M[q]).normalize(),I.copy(m).multiplyScalar(v);let W=b[q];for(let re=0;re<W.length;re++){let K=W[re],Z=W[(re+1)%f];g.setFromPointsAndIndices(M,q,K%E,Z%E),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(I,Q[q][re])}let X=[],L=[],U=[],G=new A;o==0&&[...Q[q]].reduce((re,K)=>re.add(K),G).multiplyScalar(1/f);for(let re=0;re<f;re++){let K=[],Z=(re-1+f)%f,k=Q[q][Z],he=Q[q][re];m.copy(k).sub(I),p.copy(he).sub(I);let fe=I.angleTo(m),ce=m.angleTo(p),ye=Math.cos(fe)*y;o==0?C.copy(G):C.copy(I).setLength(v+ye),L.push(ye);let Se=[C,k,he];for(let ve=0;ve<2;ve++){let Ee=Se[ve],Te=Se[ve+1];O.subVectors(Ee,I),B.subVectors(Te,I),P.crossVectors(O,B).normalize();for(let we=0;we<x;we++){let He=[fe,ce][ve]*we/x;m.copy(O).applyAxisAngle(P,He).add(I),X.push(m.clone()),ve&&(S(m,I),K.push([we==0?Ee:m.clone(),w.clone()]))}ve&&(S(Te,I),K.push([Te,w.clone()]))}U.push(K)}j.push(U);let H=2*x,z=2;for(let re=0;re<f;re++){let K=H*re,Z=H*((re+1)%f),k=[X[K]];for(let fe=1;fe<x;fe++){O=X[K+fe],B=X[Z+fe],k.push(O);for(let ce=1,ye=fe-z+1;ce<=ye;ce++)m.lerpVectors(O,B,ce/(ye+1)),m.sub(I).setLength(L[re]).add(I),k.push(m.clone());k.push(B)}for(let fe=0;fe<x;fe++)k.push(X[fe+x+K]);k.push(X[Z+x]);let he=T.map(fe=>k[fe]);a.push(...he.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...he.map(fe=>(S(fe,I),[w.x,w.y,w.z])).flat())}}let V=[];for(let q=0;q<b.length;q++)for(let W=0;W<f;W++){let X=b[q][W];if(X<E){let L=b[X].findIndex(H=>H%E==q),U=j[q][W],G=j[X][L];for(let H=0;H<x;H++){let z=U[H],re=G[x-H],K=U[H+1],Z=G[x-(H+1)];[z,re,K,K,re,Z].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),u.push(k[1].x,k[1].y,k[1].z)})}V.push(U[0][0],G[x][0],U[x][0],G[0][0])}}for(;V.length;){let q,W,X,L;[q,W]=V.splice(0,2);let U=[q];for(;q!=W;)U.push(W),X=V.indexOf(W),L=X%2,W=V.splice(X-L,2)[1-L];w.subVectors(U[0],U[1]).cross(m.subVectors(U[0],U[2])).normalize();let G=w.dot(U[0])<0;G&&w.negate();for(let H=1;H<=U.length-2;H++)[U[H+ +G],U[H+1-+G],U[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(w.x,w.y,w.z)})}}function d(){let h=new A;for(let M=0;M<a.length;M+=3){h.x=a[M+0],h.y=a[M+1],h.z=a[M+2];let b=S(h)/2/Math.PI+.5,E=_(h)/Math.PI+.5;l.push(b,1-E)}let f=new A,m=new A,p=new A,g=new A,y=new F,v=new F,x=new F,w=(M,b,E,T)=>{T<0&&M.x===1&&(l[b]=M.x-1),E.x===0&&E.z===0&&(l[b]=T/2/Math.PI+.5)};for(let M=0,b=0;M<a.length;M+=9,b+=6){f.set(a[M+0],a[M+1],a[M+2]),m.set(a[M+3],a[M+4],a[M+5]),p.set(a[M+6],a[M+7],a[M+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(m).add(p).divideScalar(3);let E=S(g);w(y,b+0,f,E),w(v,b+2,m,E),w(x,b+4,p,E)}for(let M=0;M<l.length;M+=6){let b=l[M+0],E=l[M+2],T=l[M+4],I=Math.max(b,E,T),C=Math.min(b,E,T);I>.9&&C<.1&&(b<.2&&(l[M+0]+=1),E<.2&&(l[M+2]+=1),T<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new Oa(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var aP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Df(t*.5,s,o):new Dc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Df=class extends Oa{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=1/r,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new Df(t.radius,t.corner,t.cornerSides)}};var Of=1e-12,td=class{constructor(t){this.position=new F;this.startPosition=new F;this.uuid=Ve.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new td(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},nd=class extends td{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new nd(this.parent).copy(this)}},ns=class extends td{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new nd(this),new nd(this))}static create(e,n){let r=new ns(e,new F(...n.position));return r.controls[0].position.set(...n.controlPrevious.position),r.controls[1].position.set(...n.controlNext.position),r.roundness=n.roundness,r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,r}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let r=0,s=this.controls.length;r<s;r++){let o=this.controls[r];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new ns(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),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new F,n=new F){let[r,s]=this.computeTangents();return r&&s&&(lP(r,e),lP(s,n)),[e,n]}computeTangent(e=new F){let[n,r]=this.computeTangents();return n&&r&&e.copy(n).add(r).normalize(),e}computeNormal(e=new F){let[n,r]=this.computeNormals();return e.copy(n).add(r).normalize(),e}};function lP(i,t=new F){let e=i.length();return t.set(-i.y/e,i.x/e)}var Sw=i=>i,rd=new F,xy=new F,Tj=new F,Cj=new F,Pj=new F,Ij=new F,uP=new A,dP=new A;function hP(i){let t=new F;t.addVectors(i.v0,rd.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(i.v2,xy.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new _r(i.v0,t,e,i.v2)}function Rf(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function Dj(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Oj(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Aw(i,t,e){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((r*r+n*n-s*s)/(2*r*n))}function fP(i,t,e){return cP(i,t)&&cP(t,e)&&ww(i.position,t.position,e.position)}function ww(i,t,e){return rd.copy(t).sub(i).cross(xy.copy(e).sub(i))===0}function pP(i,t,e,n,r){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return n.set(a+l,o+u),r.set(a-l,o-u),[n,r]}function mP(i,t,e){let n=i.distanceTo(e),r=t.distanceTo(e);return n<r?t:i}function gP(i,t,e,n,r,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,u=e.y-i.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return Aw(t,i,e)>Math.PI&&(c*=-1),Rf(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),r.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[r,s]}function _w(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function cP(i,t){return ww(i.position,i.controls[1].position,t.position)&&ww(i.position,t.controls[0].position,t.position)}function yP(i,t,e,n,r=.5){let s=rd.subVectors(t,i).multiplyScalar(r).add(i),o=xy.subVectors(e,t).multiplyScalar(r).add(t),a=Tj.subVectors(n,e).multiplyScalar(r).add(e),l=s,u=Cj.subVectors(o,s).multiplyScalar(r).add(s),c=Pj.subVectors(a,o).multiplyScalar(r).add(o),d=a,h=Ij.subVectors(c,u).multiplyScalar(r).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function vP(i,t,e=12,n=!0){let r=dP.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=Sw(t[l]),c=rd,d=Ra(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof _r||u instanceof ci||u instanceof Mr){if(u.getPoint(h/d,c),r.set(c.x,c.y,0),s!==void 0&&Oj(s,r))continue;s===void 0&&(s=uP),s.copy(r),i.setXYZ(o,r.x,r.y,r.z),o++}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function xP(i,t,e,n=12,r=!0){let s=dP.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Sw(t[l]),d=rd,h=Ra(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof _r||c instanceof ci||c instanceof Mr){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=uP:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function Mw(i,t=12,e=!1){let n=[];for(let r=0,s=i.length;r<s;r++){let o=i[r],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Ra(o.roundedCurveCorner,t)*.5;r>0&&(n[r-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Ra(o.curveAfter,t)),n.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(n[i.length-1]+=Ra(i[0].roundedCurveCorner,t)*.5),n}function Ra(i,t=12){return i&&i instanceof ul?t*2:i&&(i instanceof Mr||i instanceof Wh)?1:i&&i instanceof Tc?t*i.points.length:t}function bP(i,t,e=12,n=!0){let r,s=0;for(let o=0;o<t.length;o++){let a=Sw(t[o]),l=Ra(a,e),u=rd;for(let c=0;c<=l;c++)if(a instanceof _r||a instanceof ci||a instanceof Mr){if(a.getPoint(c/l,u),r!==void 0&&Dj(r,u,Of))continue;r===void 0&&(r=xy),r.copy(u),i.push(u.x,u.y),s++}}return Rf(i[0],i[i.length-2],Of)&&Rf(i[1],i[i.length-1],Of)&&(i.pop(),i.pop()),n&&s>1&&!(Rf(i[s-1],i[1],Of)&&Rf(i[s-2],i[0],Of))&&(i.push(i[0],i[1]),s++),i}var Ew=new F,Rj=new F,Lj=new F,Nj=new F,Bj=new F,Fj=new F,Et=class extends go{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new vn(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ve.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,r){let s=new Et;return s.isClosed=e.isClosed,s.points=e.points.map(o=>ns.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Et.createFromState(o)),n!==void 0&&r!==void 0&&s.applySize(n,r),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,r=this.points.length;n<r;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,r=this.points.findIndex(s=>s.uuid===e);if(r<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return r}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let r=Ew.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(r),a.controls[0].position.multiply(r),a.controls[1].position.multiply(r)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,r=Ve.generateUUID()){let s;e instanceof F?s=e:s=new F(e,n);let o=new ns(r,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,r=this.shapeHoles.length;n<r;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(r=>r.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,r=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=r?this.roundedCurveDivisions:this.curveDivisions;return vP(e,r?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Mw(this.points,e,!1),this.roundedCurveDivisions=Mw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,r=12){return xP(e,this.curves,n,r,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),bP(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Ra(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<r+c)return[l,(a-r+1)/c];r+=c}return[0,1]}getCurveT(e,n,r){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(_w(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(Ew.set(r.x,r.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){_w(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,n.curveAfter=r;let s=r.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],r=this.points[this.points.length-1];this._applyCurveForPoint(n,r)}if(this.points.length>2){let n=0;for(let r=0,s=this.points.length;r<s;r++){let o=this.points[r],a=this.points[r-1]??this.points[this.points.length-1],l=this.points[r+1]??this.points[0],u=o.roundness,c=a&&l&&fP(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,m=o.roundedCurveAfter,p=d.getLength(),g=h.getLength(),y=Math.min(u,p*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/p,S=x/g,_=d.getPointAt(w,Ew),M=h.getPointAt(S,Rj);this._subSplitCurve(d,f,w,_,void 0),this._subSplitCurve(h,m,S,void 0,M);let b;if(this.useCubicForRoundedCorners){let E=Aw(_,o.position,M)/2,T=Math.tan(E)*_.distanceTo(o.position),[I,C]=pP(_,M,T,Lj,Nj),P=mP(I,C,o.position),[O,B]=gP(P,_,M,T,Bj,Fj);b=new _r(_.clone(),O.clone(),B.clone(),M.clone())}else b=new ci(_.clone(),o.position.clone(),M.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(r+n,0,b),n++}}}}_subSplitCurve(e,n,r,s,o){if(e instanceof Mr)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(r,0),c=yP(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let e=new Et(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let r=0;r<n;r++){let s=r*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],d=e.points[s+5],h=e.points[s+6],f=new ns(Ve.generateUUID(),new F(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(r=>{let s=new Et;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof _r&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},r=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof ci&&(s[a]=hP(s[a]));for(a=0,l=s.length;a<l;a++){let d=s[a],h=a>0?s[a-1]:null,f;d instanceof _r?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Mr&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&n(f,h),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof _r?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof Mr&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=r(e.curves),e instanceof go&&(this.shapeHoles=e.holes.map(s=>{let o=new Et;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let r=this.getPointByUuid(e);r&&(n.position!==void 0&&r.position.fromArray(n.position),n.roundness!==void 0&&(r.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var Cw=Math.PI*2;function Tw({x:i,y:t},e,n,r,s){return{x:i*e+r,y:t*n+s}}function Uj(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(i),r=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*e,y:r+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function wP(i,t,e,n){let r=i*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*n));return r*Math.acos(s)}function kj(i,t,e,n,r,s,o,a,l,u){let c=Math.pow(r,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),m=c*d-c*f-d*h;m<0&&(m=0),m/=c*f+d*h,m=Math.sqrt(m)*(l===u?-1:1);let p=m*r/s*a,g=m*-s/r*o,y=p+(i+e)/2,v=g+(t+n)/2,x=(o-p)/r,w=(a-g)/s,S=(-o-p)/r,_=(-a-g)/s,M=wP(1,0,x,w),b=wP(x,w,S,_);return!u&&b>0&&(b-=Cw),u&&b<0&&(b+=Cw),{centerx:y,centery:v,ang1:M,ang2:b}}function SP({px:i,py:t,cx:e,cy:n,rx:r,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(r===0||s===0)return[];let u=(i-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];r=Math.abs(r),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(r,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(r*=Math.sqrt(d),s*=Math.sqrt(d));let h=kj(i,t,e,n,r,s,u,c,o,a),{ang1:f,ang2:m}=h,{centerx:p,centery:g}=h,y=Math.abs(m)/(Cw/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);m/=v;for(let x=0;x<v;x++)l.push(Uj(f,m)),f+=m;return l.map(x=>{let{x:w,y:S}=Tw(x[0],r,s,p,g),{x:_,y:M}=Tw(x[1],r,s,p,g),{x:b,y:E}=Tw(x[2],r,s,p,g);return{x1:w,y1:S,x2:_,y2:M,x:b,y:E}})}var gt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(gt||(gt={}));var an;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(an||(an={}));function $e(i,t){if(!i)throw t||"Assertion Failed!"}var Ye=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,n){$e(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?r<s?e.t-t.t+(t.t-n.t)*(r/(r+s)):e.t-n.t+(n.t-t.t)*(s/(r+s)):0},i.edgeSign=function(t,e,n){$e(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?(e.t-n.t)*r+(e.t-t.t)*s:0},i.transEval=function(t,e,n){$e(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?r<s?e.s-t.s+(t.s-n.s)*(r/(r+s)):e.s-n.s+(n.s-t.s)*(s/(r+s)):0},i.transSign=function(t,e,n){$e(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?(e.s-n.s)*r+(e.s-t.s)*s:0},i.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},i.interpolate=function(t,e,n,r){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+r)/2:e+(r-e)*(t/(t+n)):r+(e-r)*(n/(t+n))},i.intersect=function(t,e,n,r,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(n,r)||(l=n,n=r,r=l),i.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.vertLeq(n,e)?i.vertLeq(e,r)?(o=i.edgeEval(t,n,e),a=i.edgeEval(n,e,r),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,e.s)):(o=i.edgeSign(t,n,e),a=-i.edgeSign(t,r,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,r.s)):s.s=(n.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(n,r)||(l=n,n=r,r=l),i.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.transLeq(n,e)?i.transLeq(e,r)?(o=i.transEval(t,n,e),a=i.transEval(n,e,r),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,e.t)):(o=i.transSign(t,n,e),a=-i.transSign(t,r,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,r.t)):s.t=(n.t+e.t)/2},i}(),Lf=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),by=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),id=function(){function i(){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 i}(),AP=function(){function i(){var t=new id,e=new Lf,n=new by(0),r=new by(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=r,r.next=r,r.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=r}return i.prototype.makeEdge_=function(t){var e=new by(0),n=new by(1);t.Sym.side<t.side&&(t=t.Sym);var r=t.Sym.next;return n.next=r,r.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},i.prototype.splice_=function(t,e){var n=t.Onext,r=e.Onext;n.Sym.Lnext=e,r.Sym.Lnext=t,t.Onext=r,e.Onext=n},i.prototype.makeVertex_=function(t,e,n){var r=t;$e(r,"Vertex can't be null!");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e;var o=e;do o.Org=r,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,n){var r=t;$e(r,"Face can't be null");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e,r.trail=null,r.marked=!1,r.inside=n.inside;var o=e;do o.Lface=r,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},i.prototype.killVertex_=function(t,e){var n=t.anEdge,r=n;do r.Org=e,r=r.Onext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var n=t.anEdge,r=n;do r.Lface=e,r=r.Lnext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new id,e=new id,n=new Lf,r=this.makeEdge_(this.eHead);return this.makeVertex_(t,r,this.vHead),this.makeVertex_(e,r.Sym,this.vHead),this.makeFace_(n,r,this.fHead),r},i.prototype.splice=function(t,e){var n=!1,r=!1;if(t!==e){if(e.Org!==t.Org&&(r=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!r){var s=new id;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Lf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!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),!n){var r=new Lf;this.makeFace_(r,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var r=new id;return this.makeVertex_(r,n,e.Org),e.Lface=n.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},i.prototype.connect=function(t,e){var n=!1,r=this.makeEdge_(t),s=r.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(r,t.Lnext),this.splice_(s,e),r.Org=t.Dst,s.Org=e.Org,r.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Lf;this.makeFace_(o,r,t.Lface)}return r},i.prototype.zapFace=function(t){var e=t.anEdge,n,r,s,o,a;r=e.Lnext;do n=r,r=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},i.prototype.mergeConvexFaces=function(t){var e,n,r,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;r=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Ye.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Ye.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(r=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=r;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,r,s,o,a,l,u;for(s=t,s=t;(r=s.next)!==t;s=r){$e(r.prev===s),l=r.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Lface===r),l=l.Lnext;while(l!==r.anEdge)}for($e(r.prev===s&&r.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){$e(o.prev===a),l=o.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for($e(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)$e(l.Sym.next===u.Sym),$e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Org!==null),$e(l.Dst!==null),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l);$e(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),_P=function(){function i(){this.handle=null}return i}(),MP=function(){function i(){this.key=null,this.node=0}return i}(),zj=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var n=0;n<t+1;n++)this.nodes[n]=new _P,this.handles[n]=new MP;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,$e(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[r].key,n[s].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[r].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var r,s;for(s=this.nodes.length,this.nodes.length=this.max+1,r=s;r<this.nodes.length;r++)this.nodes[r]=new _P;for(s=this.handles.length,this.handles.length=this.max+1,r=s;r<this.handles.length;r++)this.handles[r]=new MP}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,r=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),r},i.prototype.delete=function(t){var e=this.nodes,n=this.handles,r;$e(t>=1&&t<=this.max&&n[t].key!==null),r=n[t].node,e[r].handle=e[this.size].handle,n[e[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[e[r>>1].handle].key,n[e[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},i}(),Pw=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),EP=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),Gj=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new EP,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new EP;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),Vj=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,n){var r=t.event,s=e.eUp,o=n.eUp;if(s.Dst===r)return o.Dst===r?Ye.vertLeq(s.Org,o.Org)?Ye.edgeSign(o.Dst,s.Org,o.Org)<=0:Ye.edgeSign(s.Dst,o.Org,s.Org)>=0:Ye.edgeSign(o.Dst,r,o.Org)<=0;if(o.Dst===r)return Ye.edgeSign(s.Dst,r,s.Org)>=0;var a=Ye.edgeEval(s.Dst,r,s.Org),l=Ye.edgeEval(o.Dst,r,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&$e(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,n){$e(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},i.topLeftRegion=function(t,e){var n=e.eUp.Org,r;do e=i.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(r=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),r===null)return null;i.fixUpperEdge(t,e,r),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,n){var r=new Pw;return r.eUp=n,r.nodeUp=t.dict.insertBefore(e.nodeUp,r),r.fixUpperEdge=!1,r.sentinel=!1,r.dirty=!1,n.activeRegion=r,r},i.isWindingInside=function(t,e){switch(t.windingRule){case gt.ODD:return(e&1)!==0;case gt.NONZERO:return e!==0;case gt.POSITIVE:return e>0;case gt.NEGATIVE:return e<0;case gt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var n=e.eUp,r=n.Lface;r.inside=e.inside,r.anEdge=n,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,n){for(var r,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),r=s.eUp,r.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}r=t.mesh.connect(a.Lprev,r.Sym),i.fixUpperEdge(t,s,r)}a.Onext!==r&&(t.mesh.splice(r.Oprev,r),t.mesh.splice(a,r)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,n,r,s,o){var a,l,u,c,d=!0;u=n;do $e(Ye.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==r);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,$e(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},i.vertexWeights=function(t,e,n){var r=Ye.vertL1dist(e,t),s=Ye.vertL1dist(n,t),o=.5*s/(r+s),a=.5*r/(r+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},i.getIntersectData=function(t,e,n,r,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,n,r),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp;if(Ye.vertLeq(r.Org,s.Org)){if(Ye.edgeSign(s.Dst,r.Org,s.Org)>0)return!1;Ye.vertEq(r.Org,s.Org)?r.Org!==s.Org&&(t.pq.delete(r.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,r)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(r,s.Oprev),e.dirty=n.dirty=!0)}else{if(Ye.edgeSign(r.Dst,s.Org,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Oprev,r)}return!0},i.checkForLeftSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o;if($e(!Ye.vertEq(r.Dst,s.Dst)),Ye.vertLeq(r.Dst,s.Dst)){if(Ye.edgeSign(r.Dst,s.Dst,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(r),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Ye.edgeSign(s.Dst,r.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(r.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o=r.Org,a=s.Org,l=r.Dst,u=s.Dst,c,d,h=new id,f,m;if($e(!Ye.vertEq(u,l)),$e(Ye.edgeSign(l,t.event,o)<=0),$e(Ye.edgeSign(u,t.event,a)>=0),$e(o!==t.event&&a!==t.event),$e(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(Ye.vertLeq(o,a)){if(Ye.edgeSign(u,o,a)>0)return!1}else if(Ye.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Ye.intersect(l,o,u,a,h),$e(Math.min(o.t,l.t)<=h.t),$e(h.t<=Math.max(a.t,u.t)),$e(Math.min(u.s,l.s)<=h.s),$e(h.s<=Math.max(a.s,o.s)),Ye.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=Ye.vertLeq(o,a)?o:a,Ye.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),Ye.vertEq(h,o)||Ye.vertEq(h,a)?(i.checkForRightSplice(t,e),!1):!Ye.vertEq(l,t.event)&&Ye.edgeSign(l,t.event,h)>=0||!Ye.vertEq(u,t.event)&&Ye.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Sym,r),e=i.topLeftRegion(t,e),r=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),n),i.addRightEdges(t,e,r.Oprev,r,r,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(r.Lnext,s.Oprev),n=e,e=i.topRightRegion(e),m=i.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=i.finishLeftRegions(t,n,null),i.addRightEdges(t,e,s.Onext,r.Rprev,m,!0),!0):(Ye.edgeSign(l,t.event,h)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),r.Org.s=t.event.s,r.Org.t=t.event.t),Ye.edgeSign(u,t.event,h)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(r.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,r),r.Org.s=h.s,r.Org.t=h.t,r.Org.pqHandle=t.pq.insert(r.Org),i.getIntersectData(t,r.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var n=i.regionBelow(e),r,s;;){for(;n.dirty;)e=n,n=i.regionBelow(n);if(!e.dirty&&(n=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,r=e.eUp,s=n.eUp,r.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(i.deleteRegion(t,n),t.mesh.delete(s),n=i.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n),r=e.eUp)),r.Org!==s.Org)if(r.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(r.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);r.Org===s.Org&&r.Dst===s.Dst&&(i.addWinding(s,r),i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n))}},i.connectRightVertex=function(t,e,n){var r,s=n.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Ye.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Ye.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,n.Onext,s,s,!0);return}Ye.vertLeq(l.Org,a.Org)?r=l.Oprev:r=a,r=t.mesh.connect(n.Lprev,r),i.addRightEdges(t,e,r,r.Onext,r.Onext,!1),r.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,n){var r,s,o,a,l;if(r=e.eUp,Ye.vertEq(r.Org,n)){$e(!1),i.spliceMergeVertices(t,r,n.anEdge);return}if(!Ye.vertEq(r.Dst,n)){t.mesh.splitEdge(r.Sym),e.fixUpperEdge&&(t.mesh.delete(r.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,r),i.sweepEvent(t,n);return}$e(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&($e(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),Ye.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var n,r,s,o,a,l,u=new Pw;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,r=i.regionBelow(n),!!r){if(o=n.eUp,a=r.eUp,Ye.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,n,e);return}if(s=Ye.vertLeq(a.Dst,o.Dst)?n:r,n.inside||s.fixUpperEdge){if(s===n)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,n,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){i.connectLeftVertex(t,e);return}var r=i.topLeftRegion(t,n.activeRegion);$e(r!==null);var s=i.regionBelow(r),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,r,a):i.addRightEdges(t,r,a.Onext,o,o,!0)},i.addSentinel=function(t,e,n,r){var s=new Pw,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=r,o.Dst.s=e,o.Dst.t=r,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new Gj(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],r=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;i.addSentinel(t,r,s,o),i.addSentinel(t,r,s,a)},i.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||($e(e.fixUpperEdge),$e(++n===1)),$e(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,n,r,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,r=e.Lnext,Ye.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,r,e),t.mesh.delete(e),e=r,r=e.Lnext),r.Lnext===e&&(r!==e&&((r===n||r===n.Sym)&&(n=n.next),t.mesh.delete(r)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,n,r,s=0;for(r=t.mesh.vHead,n=r.next;n!==r;n=n.next)s++;for(s+=8,e=t.pq=new zj(s,Ye.vertLeq),r=t.mesh.vHead,n=r.next;n!==r;n=n.next)n.pqHandle=e.insert(n);return n!==r?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var n,r,s;for(n=e.fHead.next;n!==e.fHead;n=r)r=n.next,s=n.anEdge,$e(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var n,r;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;r=t.pq.min(),!(r===null||!Ye.vertEq(r,n));)r=t.pq.extractMin(),i.spliceMergeVertices(t,n.anEdge,r.anEdge);i.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),Hj=function(){function i(){this.mesh=new AP,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=gt.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 i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,n,r,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;e=p.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,m[g]=e,l[g]=s,f[g]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,m[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,n=m[v],r=f[v],c[0]=n.coords[0]-r.coords[0],c[1]=n.coords[1]-r.coords[1],c[2]=n.coords[2]-r.coords[2],e=p.next;e!==p;e=e.next)d[0]=e.coords[0]-r.coords[0],d[1]=e.coords[1]-r.coords[1],d[2]=e.coords[2]-r.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,r,s=0,o=t.next;o!==t;o=o.next)if(r=o.anEdge,!(r.winding<=0))do s+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(s<0){for(e=n.next;e!==n;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,r,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),n=this.sUnit,r=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,r);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var n,r;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Ye.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Ye.vertLeq(n.Org,n.Dst);n=n.Lnext);r=n.Lprev;for(var s=void 0;n.Lnext!==r;)if(Ye.vertLeq(n.Dst,r.Org)){for(;r.Lnext!==n&&(Ye.edgeGoesLeft(r.Lnext)||Ye.edgeSign(r.Org,r.Dst,r.Lnext.Dst)<=0);)s=t.connect(r.Lnext,r),r=s.Sym;r=r.Lprev}else{for(;r.Lnext!==n&&(Ye.edgeGoesRight(n.Lprev)||Ye.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(r.Lnext===n)throw"Mono region invalid";for(;r.Lnext.Lnext!==n;)s=t.connect(r.Lnext,r),r=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},i.prototype.setWindingNumber_=function(t,e,n){for(var r,s=t.eHead.next;s!==t.eHead;s=r)r=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,n,r){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.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 u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===an.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*r,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*r;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],r>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===an.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var m=l;m<n;++m)this.elements[h++]=-1}}},i.prototype.outputContours_=function(t,e){var n,r,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){r=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==r);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,r=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==r);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new AP),t<2&&(t=2),t>3&&(t=3);for(var n=null,r=0;r<e.length;r+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[r+0],n.Org.coords[1]=e[r+1],t>2?n.Org.coords[2]=e[r+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},i.prototype.tesselate=function(t,e,n,r,s,o){if(t===void 0&&(t=gt.ODD),e===void 0&&(e=an.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,r<2&&(r=2),r>3&&(r=3),!this.mesh)return!1;this.projectPolygon_(),Vj.computeInterior(this,o);var a=this.mesh;return e===an.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===an.BOUNDARY_CONTOURS?this.outputContours_(a,r):this.outputPolymesh_(a,e,n,r),!0},i}();function rs(i){var t=i.windingRule,e=t===void 0?gt.ODD:t,n=i.elementType,r=n===void 0?an.POLYGONS:n,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,d=i.contours,h=d===void 0?[]:d,f=i.strict,m=f===void 0?!0:f,p=i.debug,g=p===void 0?!1:p;if(!h&&m)throw new Error("Contours can't be empty");if(!!h){var y=new Hj;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,r,o,l,c,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Zle=gt.ODD,Jle=gt.NONZERO,$le=gt.POSITIVE,ece=gt.NEGATIVE,tce=gt.ABS_GEQ_TWO,nce=an.POLYGONS,rce=an.CONNECTED_POLYGONS,ice=an.BOUNDARY_CONTOURS;var wy=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*wy.eSize;this.buffer=new ArrayBuffer(n);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*r,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let n=t*wy.eSize,r=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(r,o*s,3*t);o+=3*t;let l=new Float32Array(r,o*s,3*t);o+=3*t;let u=new Float32Array(r,o*s,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=r,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let r=this.capacity;for(;e>r;)r*=2;this.realloc(r)}let n=this.size;return this.size=e,n}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Nf=wy;Nf.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Bf={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Dw={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Ow={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},Iw=(i,t)=>([e,n])=>(n<e&&(n+=t),(i>=e?i:i+t)<=n),sd=class extends Me{constructor(e,n,r=0,s=12,o=3,a=gt.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._bevel=r,this._curveSegments=s,this._bevelSegmentsInput=o,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(M=>{let b=M.extractShapePointsToFlatArray([],s),E=[];for(let T=b.length-1;T>=1;T-=2){let I=b[T-1],C=b[T-0];E.push(I,C)}return E}),c;try{c=rs({windingRule:a,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=Bf}let d;try{d=rs({windingRule:gt.ODD,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=Dw}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let M=0;M<d.elements.length;M++){let b=d.elements[M],E=M%2===0?c.vertexCount:0;c.elements.push(b+E)}for(let M=0;M<d.vertexIndices.length;M++){let b=d.vertexIndices[M],E=c.vertexCount;c.vertexIndices.push(b+E)}for(let M=0;M<d.vertices.length;M++){let b=d.vertices[M];c.vertices.push(b)}}let f=1/0,m=-1/0,p=1/0,g=-1/0;for(let M=0,b=c.vertexCount;M<b;M++){let E=M*2,T=c.vertices[E+0],I=c.vertices[E+1];T<f&&(f=T),T>m&&(m=T),I<p&&(p=I),I>g&&(g=I)}this._minX=f,this._minY=p,this._width=m-f,this._height=g-p,this._buffer=new Nf(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let M=c.elementCount-1;M>=0;M--){let b=M>=h,E=M*2,T=c.elements[E+0],I=c.elements[E+1],C=T+I,P={start:T,count:I,normals:[],continuous:[],concave:[]},O=T,B=C-1,j=T+1,Q=this._shape.roundedCurves.length;do{let X=O-T,L=c.vertices[B*2+0],U=c.vertices[B*2+1],G=c.vertices[O*2+0],H=c.vertices[O*2+1],z=c.vertices[j*2+0],re=c.vertices[j*2+1],K=G-L,Z=H-U,k=Math.sqrt(K*K+Z*Z);K/=k,Z/=k;let he=G-z,fe=H-re,ce=Math.sqrt(he*he+fe*fe);he/=ce,fe/=ce,P.normals[X*2+0]=-fe,P.normals[X*2+1]=he,P.concave[X]=K*fe-Z*he>0;let ye=c.vertexIndices[O];if(Array.isArray(ye))P.continuous[X]=!1;else{let[Se,ve]=this._shape.getCurveIndexFromVertexId(ye-1,!0);if(ve>0&&ve<1)P.continuous[X]=!0;else{let Ee=ve===1?Se+1:Se-1;Ee=(Ee+Q)%Q;let Te=ve===1?0:1,we=this._shape.roundedCurves[Se].getTangent(ve),He=this._shape.roundedCurves[Ee].getTangent(Te);P.continuous[X]=we.dot(He)>.95}}b&&(P.normals[X*2+0]*=-1,P.normals[X*2+1]*=-1),[B,O,j]=[O,j,j+1],j>=C&&(j-=I)}while(j!==T+1);let V=[];V.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(T*2,C*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((X,L)=>[L,L]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(T*2,C*2)});for(let X=1;X<=this._bevelSegments;X++){let L=X/this._bevelSegments*Math.PI/2,U=(1-Math.cos(L))*this._bevelSize,G=[],H=[],z=[],re=[],K=0;for(let k=0;k<I;k++){let he=k*2,fe=(k-1+I)%I*2,ce=c.vertices[P.start*2+he+0],ye=c.vertices[P.start*2+he+1],Se=-P.normals[fe+0]*U,ve=-P.normals[fe+1]*U,Ee=-P.normals[he+0]*U,Te=-P.normals[he+1]*U;if(P.concave[k]||!P.concave[k]&&b){let we=Math.atan2(ve,Se),He=Math.atan2(Te,Ee);He>we&&(He-=Math.PI*2);let vt=He-we;if(P.continuous[k]||b){let R=we+vt/2,D=Math.cos(R)*U,ee=Math.sin(R)*U;G[2*K+0]=ce+D*(b?-1:1),G[2*K+1]=ye+ee*(b?-1:1),re[K]=k,K++}else{let R=Math.max(1,Math.floor(s/4*Math.abs(vt)/Math.PI));for(let D=0;D<=R;D++){let ee=we+vt*(D/R),me=Math.cos(ee)*U,xe=Math.sin(ee)*U;G[2*K+0]=ce+me,G[2*K+1]=ye+xe,re[K]=k,K++}}}else G[2*K+0]=ce+Se,G[2*K+1]=ye+ve,re[K]=k,H[k]=K,K++,G[2*K+0]=ce,G[2*K+1]=ye,re[K]=k,K++,G[2*K+0]=ce+Ee,G[2*K+1]=ye+Te,re[K]=k,z[k]=K,K++}let Z=rs({windingRule:gt.POSITIVE,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[G],edgeCreateCallback:k=>{let fe=k.Org.idx,ce=re[fe],ye=re[(fe+1)%re.length];k.idx=[ce,ye],k.Sym.idx=[ye,ce]},vertexIdCallback:k=>{let he=k.Lprev.idx;return[he?he[1]:0,k.idx?k.idx[0]:0]}});if(!Z)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!Z.vertexCount)break;for(let k=0;k<Z.vertexIndices.length;k++){let[he,fe]=Z.vertexIndices[k];if(he===fe)continue;let ce=fe;fe<he&&(ce+=I);for(let ye=he;ye<ce;ye++){let Se=ye%I,ve=(ye+1)%I;if(!P.continuous[Se]||!P.continuous[ve]){Z.vertexIndices[k]=[he,Se],Z.vertexIndices.splice(k+1,0,[ve,fe]),Z.vertices.splice((k+1)*2,0,Z.vertices[k*2],Z.vertices[k*2+1]);break}}}V.push({bevelI:X,angle:L,size:U,boundary:Z,reverseMap:re,insetPoints:G})}let q=(X,L,U)=>{let G=0,H=X.boundary.vertexIndices.length;for(;G<H&&U(X.boundary.vertexIndices[L]);)L=(L+1)%H,G++;return G},W=y.length;for(let X=1;X<V.length;X++){let L=V[X-1],U=V[X],G=L.boundary.vertexIndices.length,H=U.boundary.vertexIndices.length;if(!G||!H)break;let z=P.concave.length,re=0,K=Iw(re,I);for(;!L.boundary.vertexIndices.filter(K).length||!U.boundary.vertexIndices.filter(K).length;)re++,K=Iw(re,I);let Z=L.boundary.vertexIndices.findIndex(K),k=U.boundary.vertexIndices.findIndex(K);do Z=(Z+1)%G;while(K(L.boundary.vertexIndices[Z]));do k=(k+1)%H;while(K(U.boundary.vertexIndices[k]));re=(re+1)%I;let he=re,fe=this._buildBevelVert(P,L,(Z-1+G)%G),ce=this._buildBevelVert(P,U,(k-1+H)%H),ye=fe,Se=ce,ve,Ee,Te=!1;do{K=Iw(re,I);let we=q(L,Z,K),He=q(U,k,K),vt=Te;if(Te=!1,we&&!He){for(let R=0;R<we;R++)ve=this._buildBevelVert(P,L,(Z+R)%G,R/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve;Te=!0}else if(!we&&He)for(let R=0;R<He;R++)Ee=this._buildBevelVert(P,U,(k+R)%H,R/(He-1)),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,Se.bottomN,Ee.bottomP),Se=Ee;else if(we&&He)if(ve=this._buildBevelVert(P,L,Z,0),Ee=this._buildBevelVert(P,U,k,0),vt?(y.push(ye.topN,Ee.topP,Se.topN),y.push(ye.topN,ve.topP,Ee.topP),y.push(Ee.bottomP,ye.bottomN,Se.bottomN),y.push(Ee.bottomP,ve.bottomP,ye.bottomN)):(y.push(Se.topN,ye.topN,ve.topP),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP)),ye=ve,Se=Ee,we===He)for(let R=1;R<we;R++)ve=this._buildBevelVert(P,L,(Z+R)%G,R/(we-1)),Ee=this._buildBevelVert(P,U,(k+R)%H,R/(He-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),ye=ve,Se=Ee;else if(we>He){let R=we/He,D=0;for(let ee=1;ee<we;ee++)ve=this._buildBevelVert(P,L,(Z+ee)%G,ee/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve,ee>(D+1)*R&&(D++,Ee=this._buildBevelVert(P,U,(k+D)%H,D/(He-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee)}else{let R=He/we,D=0;for(let ee=1;ee<He;ee++)Ee=this._buildBevelVert(P,U,(k+ee)%H,ee/(He-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee,ee>(D+1)*R&&(D++,ve=this._buildBevelVert(P,L,(Z+D)%G,D/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve)}Z=(Z+we)%G,k=(k+He)%H,re=(re+1)%z}while(re!==he)}if(this._depth>this._bevel*2&&this._buildWall(V,P,y),b){let X=[];for(let L=y.length-1;L>=W+2;L-=3){let U=y[L-2],G=y[L-1],H=y[L-0];X.push(H,G,U)}y.splice(W,y.length-W,...X)}if(b){let X=[];for(let L=V[V.length-1].boundary.vertices.length-1;L>=1;L-=2){let U=V[V.length-1].boundary.vertices[L-1],G=V[V.length-1].boundary.vertices[L-0];X.push(U,G)}v.push(X)}if(!b){let X=V[V.length-1],L;try{L=rs({windingRule:V.length>1?gt.POSITIVE:gt.ODD,elementType:an.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,...v]})}catch{L=Ow}if(!L)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let U=0;U<L.elementCount*3;U+=3){let G=this._buildSurfaceVert(L,L.elements[U+0]),H=this._buildSurfaceVert(L,L.elements[U+1]),z=this._buildSurfaceVert(L,L.elements[U+2]);y.push(G.top,H.top,z.top),y.push(z.bottom,H.bottom,G.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Be(Uint32Array.from(y),1),w=new Be(this._buffer.positions,3),S=new Be(this._buffer.normals,3),_=new Be(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,_.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",_),this.setIndex(x)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n){let r=n.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[n*2+0],o=e.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=l,this.vertexCache[r]=h,h}_buildBevelVert(e,n,r,s=1){let o=`${n.bevelI}:${r}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[r],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=e.continuous[c]&&e.continuous[u]):(u=a,c=(u-1+e.count)%e.count,h=e.concave[u]&&n.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=r*2,g=u*2,y=c*2,v=n.boundary.vertices[p+0],x=n.boundary.vertices[p+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,_=(x-this._minY)/this._height,M=e.normals[g+0],b=e.normals[g+1],E=e.normals[y+0],T=e.normals[y+1];if(h){let B=E-M,j=T-b;M=M+B*(1-s),b=b+j*(1-s);let Q=Math.sqrt(M*M+b*b);M/=Q,b/=Q}let I=this._buffer.get(d?2:4),C=I*3,P=I*2,O={i:r,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[C+0]=v,this._buffer.positions[C+1]=x,this._buffer.positions[C+2]=this._depth-w,this._buffer.normals[C+0]=M*f,this._buffer.normals[C+1]=b*f,this._buffer.normals[C+2]=m,this._buffer.uvs[P+0]=S,this._buffer.uvs[P+1]=_,this._buffer.positions[C+3]=v,this._buffer.positions[C+4]=x,this._buffer.positions[C+5]=w,this._buffer.normals[C+3]=M*f,this._buffer.normals[C+4]=b*f,this._buffer.normals[C+5]=-m,this._buffer.uvs[P+2]=_,this._buffer.uvs[P+3]=S,d||(I+=2,C+=6,P+=4,O.topP=I+0,O.bottomP=I+1,this._buffer.positions[C+0]=v,this._buffer.positions[C+1]=x,this._buffer.positions[C+2]=this._depth-w,this._buffer.normals[C+0]=E*f,this._buffer.normals[C+1]=T*f,this._buffer.normals[C+2]=m,this._buffer.uvs[P+0]=S,this._buffer.uvs[P+1]=_,this._buffer.positions[C+3]=v,this._buffer.positions[C+4]=x,this._buffer.positions[C+5]=w,this._buffer.normals[C+3]=E*f,this._buffer.normals[C+4]=T*f,this._buffer.normals[C+5]=-m,this._buffer.uvs[P+2]=_,this._buffer.uvs[P+3]=S),this.vertexCache[o]=O,O}clone(){let e=new sd(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=So(this.userData),e}};var od=class extends Me{constructor(e,n=12,r={}){super();this.type="ShapeGeometry";this.windingRule=gt.ODD;this.elementType=an.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:gt.ODD,elementType:an.POLYGONS,polySize:3,vertexSize:2,strict:!0},r);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=rs({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Bf}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Be(new Float32Array(h*3),3),this._normalAttribute=new Be(new Float32Array(h*3),3),this._uvAttribute=new Be(new Float32Array(h*2),2),this._indexAttribute=new Be(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,y=-1/0;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1];M<m&&(m=M),M>p&&(p=M),b<g&&(g=b),b>y&&(y=b)}let v=p-m,x=y-g;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1],E=(M-m)/v,T=(b-g)/x;this._positionAttribute.setXYZ(w,M,b,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,E,T)}for(let w=0,S=f;w<S;w++){let _=w*3,M=a.elements[_+0],b=a.elements[_+1],E=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,b),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,(a?.elementCount??1)*3)}clone(){let e=new od(this._shape,this._curveSegments);return e.userData=So(this.userData),e}};var ad=class extends sd{constructor(e,n,r=0,s=12,o=3,a=gt.ODD){super(e,n,r,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new ad(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=So(this.userData),e}};var Kr=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:gt.ODD},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Et?(o.width!==n||o.height!==r)&&o.applySize(n,r):o=new Et(n,r).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Et(n,r);return{parameters:Object.assign(e,{width:n,height:r,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:r,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new od(i.shape,r,{windingRule:o}):a=new ad(i.shape,t,e,r,n,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var CP=Math.PI*2,cd=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,angle:r,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,d=e*.5,h=jj(u,c,d,r*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Kr.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function jj(i,t,e,n,r,s){if(n>=CP)return r>30||r%4===0?(qj(i,t,e,s),Math.round(r/4)):TP(i,n,r,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=SP({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return r>30||r%u.length===0?Wj(i,o.x,o.y,u,r,t,e,s):TP(i,n,r,t,e,s)}function Wj(i,t,e,n,r,s,o,a){let l=Math.round(r/n.length);i.addPoint(ld(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=i.points[u],f=ld(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),i.addPoint(f)}return a>0?PP(i,s,o,a):i.addPoint(ld(0,0)),l}function TP(i,t,e,n,r,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*r;i.addPoint(ld(u,c))}return t<CP?s>0?PP(i,n,r,s):i.addPoint(ld(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&IP(i,n,r,s)),1}function qj(i,t,e,n=0,r=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Sy(r-t,s,r-t,s-l,r-t,s+l)),i.addPoint(Sy(r,s+e,r-a,s+e,r+a,s+e)),i.addPoint(Sy(r+t,s,r+t,s+l,r+t,s-l)),i.addPoint(Sy(r,s-e,r+a,s-e,r-a,s-e)),n>0&&IP(i,t,e,n)}function ld(i,t){return new ns(Ve.generateUUID(),new F(i,t))}function Sy(i,t,e,n,r,s){let o=ld(i,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(r,s),o}function PP(i,t,e,n){DP(i,t,e,n).forEach(s=>i.addPoint(s))}function IP(i,t,e,n){let r=DP(i,t,e,n),s=new Et;r.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function DP(i,t,e,n){let r=n*t/100,s=r*(Math.abs(e)/Math.abs(t)),o=new F(r/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Ve.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var OP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:r,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:n,radius:r,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=i.parameters,h=new Ff(!1,t,e,n,r,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...i,type:"HelixGeometry"}})}},Rw=new bs([0,0,0],1),Ff=class extends Me{constructor(t=!0,e=1,n=1,r=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let m=()=>new A,p=new A,g=m(),y=m(),v=m(),x,w,S,_,M,b,E,T,I=m(),C=m(),P=m(),O=m(),B=m(),j=m(),Q=m(),V=m(),q=n-2*l+.001,W=q/o,X=Math.ceil(a*o),L=X+1,U=q/X,G=-q/2,H=c+1,z=2*Math.PI/c,re=Math.PI/2/h,K=.01,Z=Math.min((1-d/100)*l,l-K),k=l-Z,he=0,fe=2,ce=h*fe+fe,ye=H*ce/fe,Se=ye+H*L,ve=H*(L+ce),[Ee,Te,we]=[3,3,2].map(Le=>Array(ve*Le).fill(0)),He=[],vt=s-l;function R(Le,Ie){let Ue=Math.PI/2;b=Ie*U,T=2*Math.PI*(b%W)/W+Ue,b+=G,E=Math.sin(T)*vt,M=Math.cos(T)*vt,t?Le.set(M,E,b):Le.set(M,b,E)}R(p,-1e-10),R(g,0),I.copy(p),R(p,1);let D=p.distanceTo(g),ee=f?0:k+Z,me=D*X+2*ee,xe=Z,Ce=me-ee;for(let Le=0;Le<=X;Le++){R(y,Le),V.subVectors(y,I).normalize(),I.copy(y),j.copy(y).setComponent(+t+1,0).normalize(),Q.crossVectors(V,j).normalize();let Ie=Le===0,Ue=Le===X,Ke=Ie?3*Math.PI/2:re,xt=Ie?xe:Ce,jt=Ie?H:Se,En=Ie?0:ve-H,Y=V.clone().multiplyScalar(Ie?-k:k).add(y),oe=V.clone().multiplyScalar(Ie?-1:1).normalize();for(let ge=0;ge<H;ge++){let Ne=ge*z;if(C.addVectors(p.copy(j).multiplyScalar(l*Math.cos(Ne)),g.copy(Q).multiplyScalar(l*Math.sin(Ne))),P.copy(C).normalize(),Ie||Ue){f||(he=En+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=Y.getComponent(Oe),Te[he*3+Oe]=oe.getComponent(Oe)}),we[he*2]=+Ue,we[he*2+1]=ge/c),g.copy(P).multiplyScalar(Z),v.addVectors(y,g);for(let Oe=0;Oe<h;Oe++){let bt=Oe*re+Ke;O.addVectors(p.copy(V).multiplyScalar(k*Math.sin(bt)),g.copy(P).multiplyScalar(k*Math.cos(bt))),B.copy(O).normalize(),g.addVectors(v,O),O.normalize(),he=jt+Oe*H+ge,[0,1,2].forEach(mn=>{Ee[he*3+mn]=g.getComponent(mn),Te[he*3+mn]=B.getComponent(mn)});let Tn=+Ie+Math.sin(bt);we[he*2]=(xt+k*Tn)/me,we[he*2+1]=ge/c}}g.addVectors(y,C),he=ye+Le*H+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=g.getComponent(Oe),Te[he*3+Oe]=P.getComponent(Oe)}),we[he*2]=(ee+Le*D)/me,we[he*2+1]=ge/c}}let je=L+2*h+fe,Pe=1,[de,Qe]=[+f,je-1];for(let Le=de;Le<=Qe-1;Le++){let Ie=f&&Le===Qe-1;for(let Ue=0;Ue<H-1;Ue++)x=Le*H+Ue,w=x+1,S=(Ie?Ue:x)+H,_=(Ie?Ue+1:w)+H,Le===0?He.push(w,_,S):Le===je-2?He.push(x,w,S):He.push(x,w,S,w,_,S)}this.setIndex(He),this.setAttribute("position",new Ae(Ee,3)),this.setAttribute("normal",new Ae(Te,3)),this.setAttribute("uv",new Ae(we,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,r=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let h=0;h<t.radialSegments;h++)s=c*n+h,o=s+1,a=(d?h:s)+n,l=(d?h+1:o)+n,r[u++]=s,r[u++]=o,r[u++]=a,r[u++]=o,r[u++]=l,r[u++]=a;return r.length=u,Rw.array=r,Rw.count=r.length,Rw}};var RP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Uf(t*.5,s,o):new Rc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},Uf=class extends Oa{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new Uf(t.radius,t.corner,t.cornerSides)}};var LP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:n}=i.parameters,r=new go;r.moveTo(t[0].x,t[0].y),r.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Cc(r.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Ns=new ie,Lw=new ht,Ay=new A,La=class extends Ut{constructor(){super(),this.uuid=Ve.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new en().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Ns.makeRotationX(t),this.applyMatrix4(Ns),this}rotateY(t){return Ns.makeRotationY(t),this.applyMatrix4(Ns),this}rotateZ(t){return Ns.makeRotationZ(t),this.applyMatrix4(Ns),this}translate(t,e,n){return Ns.makeTranslation(t,e,n),this.applyMatrix4(Ns),this}scale(t,e,n){return Ns.makeScale(t,e,n),this.applyMatrix4(Ns),this}lookAt(t){return Lw.lookAt(t),Lw.updateMatrix(),this.applyMatrix4(Lw.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,o=r.normal,a=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Re().fromBufferAttribute(a,h));function c(h,f,m,p){let g=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[m].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],v=new ud(h,f,m,y,g,p);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new F().fromBufferAttribute(l,h),new F().fromBufferAttribute(l,f),new F().fromBufferAttribute(l,m)]),u!==void 0&&e.faceVertexUvs[1].push([new F().fromBufferAttribute(u,h),new F().fromBufferAttribute(u,f),new F().fromBufferAttribute(u,m)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],m=f.start,p=f.count;for(let g=m,y=m+p;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ay).negate(),this.translate(Ay.x,Ay.y,Ay.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new ie;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let n=0,r=this.vertices.length;n<r;n++)e[n]=new A;if(t){let n=new A,r=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),r.subVectors(l,u),n.cross(r),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,o=r.vertexNormals.length;s<o;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let t=new La;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let r=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=r.faceNormals[s],u=r.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _t),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new dn),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(r=new en().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let m=u[h],p,g,y=m.vertexNormals,v=m.vertexColors,x=new ud(m.a+s,m.b+s,m.c+s);x.normal.copy(m.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let w=0,S=y.length;w<S;w++)p=y[w].clone(),r!==void 0&&p.applyMatrix3(r).normalize(),x.vertexNormals.push(p);x.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)g=v[w],x.vertexColors.push(g.clone());x.materialIndex=m.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++)v.push(y[x].clone());this.faceVertexUvs[h].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},n=[],r=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),r[l]=n.length-1):r[l]=r[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=r[c.a],c.b=r[c.b],c.c=r[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new A(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;r&&r.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(r[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(t[p]=m[p]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];e.push(p.x,p.y,p.z)}let n=[],r=[],s={},o=[],a={},l=[],u={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,y=!1,v=this.faceVertexUvs[0][m]!==void 0,x=p.normal.length()>0,w=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,M=0;if(M=c(M,0,0),M=c(M,1,g),M=c(M,2,y),M=c(M,3,v),M=c(M,4,x),M=c(M,5,w),M=c(M,6,S),M=c(M,7,_),n.push(M),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let b=this.faceVertexUvs[0][m];n.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&n.push(d(p.normal)),w){let b=p.vertexNormals;n.push(d(b[0]),d(b[1]),d(b[2]))}if(S&&n.push(h(p.color)),_){let b=p.vertexColors;n.push(h(b[0]),h(b[1]),h(b[2]))}}function c(m,p,g){return g?m|1<<p:m&~(1<<p)}function d(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=r.length/3,r.push(m.x,m.y,m.z)),s[p]}function h(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(m.x,m.y)),u[p]}return t.data={},t.data.vertices=e,t.data.normals=r,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new La().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let r=t.faces;for(let h=0,f=r.length;h<f;h++)this.faces.push(r[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++){let S=y[x];v.push(S.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let m={};if(m.name=s[h].name,s[h].vertices!==void 0){m.vertices=[];for(let p=0,g=s[h].vertices.length;p<g;p++)m.vertices.push(s[h].vertices[p].clone())}if(s[h].normals!==void 0){m.normals=[];for(let p=0,g=s[h].normals.length;p<g;p++)m.normals.push(s[h].normals[p].clone())}this.morphTargets.push(m)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let m={};if(o[h].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[h].vertexNormals.length;p<g;p++){let y=o[h].vertexNormals[p],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),m.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[h].faceNormals.length;p<g;p++)m.faceNormals.push(o[h].faceNormals[p].clone())}this.morphNormals.push(m)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Nw().fromGeometry(this),e=new Me,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",_y.call(new Be(n,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);e.setAttribute("normal",_y.call(new Be(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);e.setAttribute("color",NP.call(new Be(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);e.setAttribute("uv",BP.call(new Be(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",BP.call(new Be(r,2),t.uvs2))}e.groups=t.groups;for(let r in t.morphTargets){let s=[],o=t.morphTargets[r];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new Ae(u.data.length*3,3);c.name=u.name,s.push(_y.call(c,u.data))}e.morphAttributes[r]=s}if(t.skinIndices.length>0){let r=new Ae(t.skinIndices.length*4,4);e.setAttribute("skinIndex",FP.call(r,t.skinIndices))}if(t.skinWeights.length>0){let r=new Ae(t.skinWeights.length*4,4);e.setAttribute("skinWeight",FP.call(r,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Me,n=t.geometry;if(t.isPoints||t.isLine){let r=new Ae(n.vertices.length*3,3),s=new Ae(n.colors.length*3,3);if(e.setAttribute("position",_y.call(r,n.vertices)),e.setAttribute("color",NP.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Ae(n.lineDistances.length,1);e.setAttribute("lineDistance",Yj.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};La.prototype.isGeometry=!0;var Nw=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],n,r,s,o=t.faces;for(r=0;r<o.length;r++){let a=o[r];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=r*3-n.start,e.push(n)),n={start:r*3,materialIndex:s})}n!==void 0&&(n.count=r*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,m=t.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=r[0][y];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new F,new F,new F))}if(o===!0){let S=r[1][y];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new F,new F,new F))}for(let S=0;S<l;S++){let _=a[S].vertices;u[S].data.push(_[v.a],_[v.b],_[v.c])}for(let S=0;S<d;S++){let _=c[S].vertexNormals[y];h[S].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},ud=class{constructor(t,e,n,r,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new A,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Re,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function Yj(i){return this.array.set(i),this}function NP(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Re),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function BP(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new F),t[e++]=s.x,t[e++]=s.y}return this}function _y(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function FP(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new We),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var Xj=["a","b","c"];function Qj(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Bw(i,t,e){let n=Math.min(i,t),r=Math.max(i,t),s=n+"_"+r;return e.get(s)}function Fw(i,t,e,n,r,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(r),s[i].edges.push(u),s[t].edges.push(u)}function Kj(i,t,e,n){let r,s,o;for(r=0,s=i.length;r<s;r++)e[r]={edges:[]};for(r=0,s=t.length;r<s;r++)o=t[r],Fw(o.a,o.b,i,n,o,e),Fw(o.b,o.c,i,n,o,e),Fw(o.c,o.a,i,n,o,e)}function My(i,t,e,n,r){i.push(new ud(t,e,n,void 0,void 0,r))}function dd(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Ey(i,t,e,n){i.push([t.clone(),e.clone(),n.clone()])}var Ty=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Me?t=new La().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,r,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;Kj(l,u,h,f);let m=[],p,g,y,v,x,w,S;for(let K of Array.from(f.keys())){for(g=f.get(K),y=new A,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[Qj(v,Xj[a])],!(p!==g.a&&p!==g.b));a++);p&&e.add(p)}e.multiplyScalar(w),y.add(e),g.newEdge=m.length,m.push(y)}let _,M,b,E,T,I,C,P=[];for(r=0,s=l.length;r<s;r++){for(I=l[r],T=h[r].edges,n=T.length,n==3?_=3/16:n>3&&(_=3/(8*n)),M=1-n*Number(_),b=_,n<=2&&(n==2?(M=3/4,b=1/8):n==1||n==0),C=I.clone().multiplyScalar(M),e.set(0,0,0),o=0;o<n;o++)E=T[o],p=E.a!==I?E.a:E.b,e.add(p);e.multiplyScalar(Number(b)),C.add(e),P.push(C)}let O=P.concat(m),B=P.length,j,Q,V,q=[],W=[],X,L,U,G,H=new F,z=new F,re=new F;for(r=0,s=u.length;r<s;r++)v=u[r],j=Number(Bw(v.a,v.b,f).newEdge)+B,Q=Number(Bw(v.b,v.c,f).newEdge)+B,V=Number(Bw(v.c,v.a,f).newEdge)+B,My(q,j,Q,V,v.materialIndex),My(q,v.a,j,V,v.materialIndex),My(q,v.b,Q,j,v.materialIndex),My(q,v.c,V,Q,v.materialIndex),d&&(X=c[r],L=X[0],U=X[1],G=X[2],H.set(dd(L.x,U.x),dd(L.y,U.y)),z.set(dd(U.x,G.x),dd(U.y,G.y)),re.set(dd(L.x,G.x),dd(L.y,G.y)),Ey(W,H,z,re),Ey(W,L,H,re),Ey(W,U,z,H),Ey(W,G,re,z));t.vertices=O,t.faces=q,d&&(t.faceVertexUvs[0]=W)}};var Yn=new A,UP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Me().copy(new er(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Yn),n={width:Yn.x,height:Yn.y,depth:Yn.z,subdivisions:0}):n=t.parameters;let r={...n,...i.parameters};return{parameters:{width:Math.abs(r.width),height:Math.abs(r.height),depth:Math.abs(r.depth),subdivisions:Math.abs(r.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:n,subdivisions:r}=i.parameters,s=i.geometry??new Me().copy(new er(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Yn)):Yn.set(o.width,o.height,o.depth),(t!==Yn.x||e!==Yn.y||n!==Yn.z)&&s.scale(Yn.x===0?1:t/Yn.x,Yn.y===0?1:e/Yn.y,Yn.z===0?1:n/Yn.z);let a=s.originalGeometry;try{r>0?(a===void 0||o?.subdivisions!==r)&&(a===void 0&&(a=s),s=new Ty(r).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Gc(e).load(i,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Yn);let o=100/Yn.x;Object.assign(s.parameters,{width:100,height:Yn.y*o,depth:Yn.z*o}),t(this.build(s))})}};var Cy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,cornerRadius:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,y=d+Math.sin(g)*u,v=h+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=r;l.roundness=r,l.update();let m=Kr.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...i,type:"PolygonGeometry"}})}};var kP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new kw(t*.5,e,r,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function kf(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Uw(i,t,e,n,r,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===r){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,r/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function Zj(i,t,e){let n=i.clone().sub(t),r=e.clone().sub(t);return n.projectOnVector(r),n.add(t)}var kw=class extends Me{constructor(t=.5,e=1,n=4,r=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),r=Math.floor(r),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,m=Math.PI/n,p=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),w=new A(0,f,0),S=new F(t,-f),_=new F(p,-f),M=new F(0,w.y).sub(_),b=new F(0,w.y).sub(S),E=new F(M.y,-M.x).normalize(),T=new F(b.y,-b.x).normalize(),C=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,C);let P;{let W=new A(E.x,E.y,0),X=new A(Math.cos(g)*W.x,W.y,Math.sin(g)*W.x);P=W.angleTo(X)}let O=o/Math.tan((Math.PI-M.angle())/2),B=o/Math.tan((Math.PI-P)/2),j=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let W=h++,X=[],L=S.clone(),U=O/Math.cos(Math.PI/n);L.x-=U;for(let G=0;G<n;G++){let H=G/n*Math.PI*2+m,z=new F(Math.sin(H),Math.cos(H));kf(L,z,j),u.push(j.x,j.y,j.z),c.push(0,-1,0),d.push(0,0),X.push(h++)}for(let G=0;G<X.length;G++)l.push(X[G],W,X[(G+1)%X.length])}let Q=[];{let W=new A,X=new A,L=new A,U=new A,G=new A,H=new A;for(let z=0;z<n;z++){let re=z/n*Math.PI*2+m,K=(z+.5)/n*Math.PI*2+m,Z=(z+1)/n*Math.PI*2+m,k=new F(Math.sin(re),Math.cos(re)),he=new F(Math.sin(K),Math.cos(K)),fe=new F(Math.sin(Z),Math.cos(Z));kf(S,k,X),kf(S,fe,L),kf(E,he,W),Uw(w,X,L,B,B,U),u.push(U.x,U.y,U.z),Uw(X,w,L,B,O,G),u.push(G.x,G.y,G.z),Uw(L,X,w,O,B,H),u.push(H.x,H.y,H.z),c.push(W.x,W.y,W.z),c.push(W.x,W.y,W.z),c.push(W.x,W.y,W.z),d.push(0,0),d.push(0,0),d.push(0,0);let ce=h++,ye=h++,Se=h++;if(l.push(ce,ye,Se),o>0){{let Te=X.clone().add(L).multiplyScalar(.5),we=w.clone().sub(Te).normalize(),vt=x.clone().sub(Te).normalize().add(we).normalize().multiplyScalar(-1),R=H.clone().sub(G);V(Te,R,vt,M.angle())}let ve,Ee;{let Te=new A;kf(T,fe,Te);let we=H.clone().add(U).multiplyScalar(.5);we=Zj(we,L,w);let He=H.clone().sub(U);[ve,Ee]=V(we,He,Te,P,U.y)}{let Te=ve,we=Te.clone().setY(0).normalize(),He=new A(0,-1,0),vt=we.clone().cross(He);q(Te,we,He,vt)}Q.concat(Ee);{let Te=M.angle(),we=Math.PI-Te,He=w.clone();He.y-=o/Math.sin(Te-Math.PI/2);let vt=new A,R=[];for(let ee=0;ee<a;ee++){let me=[],xe=Math.PI/2-we*ee/a,Ce=Math.cos(xe),je=Math.sin(xe),Pe=K;for(let de=0;de<=ee;de++){let Qe=Math.cos(Pe),Le=Math.sin(Pe);W.x=Ce*Le,W.y=je,W.z=Ce*Qe,vt.copy(He).addScaledVector(W,o),u.push(vt.x,vt.y,vt.z),c.push(W.x,W.y,W.z),d.push(0,0),me.push(h++),Pe+=Math.PI*2/ee/n}R.push(me)}Ee.reverse(),R.push(Ee);let D=R.length-1;for(let ee=0;ee<D;ee++){let me=R[ee],xe=R[ee+1],Ce=me.length-1;l.push(xe[1],me[0],xe[0]);for(let je=1;je<=Ce;je++)l.push(me[je],me[je-1],xe[je]),l.push(xe[je+1],me[je],xe[je])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(d,2));function V(W,X,L,U,G){let H=-U/2,z=(Math.PI-U)/2,re=X.clone().normalize().cross(L);W.addScaledVector(L,-o/Math.sin(z));let K=new A,Z=new A,k=1,he=h,fe=[];for(let ce=0;ce<=a;ce++){let ye=H+ce/a*U;Z.set(0,0,0),Z.addScaledVector(re,Math.sin(ye)),Z.addScaledVector(L,Math.cos(ye));for(let Se=0;Se<=k;Se++){let ve=Se/k-.5;if(K.copy(W),K.addScaledVector(X,ve),K.addScaledVector(Z,o),G!=null){let Ee=Math.max(0,K.y-G);K.addScaledVector(X,-Ee/X.y)}u.push(K.x,K.y,K.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),Se===0&&fe.push(h),h++}}for(let ce=0;ce<a;ce++)for(let ye=0;ye<k;ye++){let Se=he+ye+(k+1)*ce,ve=Se+(k+1),Ee=ve+1,Te=Se+1;l.push(Se,ve,Te),l.push(ve,Ee,Te)}return[W.clone().addScaledVector(X,.5),fe]}function q(W,X,L,U){let G=Math.PI/2,H=b.angle()-G,z=[],re=new A,K=new A;for(let k=0;k<=a;k++){let he=[],fe=k/a;for(let ce=0;ce<=k;ce++){let Se=((k?ce/k:0)-.5)*v,ve=Math.cos(Se),Ee=Math.sin(Se),Te=Math.atan(Math.tan(H)*ve),we=(G+Te)*fe,He=Math.cos(we),vt=Math.sin(we);re.set(0,0,0),re.addScaledVector(X,vt*ve),re.addScaledVector(L,He),re.addScaledVector(U,vt*Ee),K.copy(W).addScaledVector(re,o),u.push(K.x,K.y,K.z),c.push(re.x,re.y,re.z),d.push(0,0),he.push(h++)}z.push(he)}let Z=z.length-1;for(let k=0;k<Z;k++){let he=z[k],fe=z[k+1],ce=he.length-1;l.push(he[0],fe[1],fe[0]);for(let ye=1;ye<=ce;ye++)l.push(he[ye-1],he[ye],fe[ye]),l.push(he[ye],fe[ye+1],fe[ye])}}}};var Py=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(i){let t=i.shape,{width:e,height:n,cornerRadius:r,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(w,S,_){return S>e&&_>n?Math.min(w*e/S,w*n/_):S>e?w*e/S:_>n?w*n/_:w}let f=[];f[0]=r[0]===0?0:h(r[0],r[0]+r[3],r[0]+r[1]),f[1]=r[1]===0?0:h(r[1],r[1]+r[2],r[1]+r[0]),f[2]=r[2]===0?0:h(r[2],r[2]+r[1],r[2]+r[3]),f[3]=r[3]===0?0:h(r[3],r[3]+r[0],r[3]+r[2]);let m=c.x,p=d.x,g=d.y,y=c.y;t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let v=!0;for(let w=0,S=t.points.length;w<S;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Kr.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var zP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:n=t,widthSegments:r=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c=new ml(.5*t,r,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var GP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:r=8}=i.parameters,s=new po(t,e,n,r);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var VP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,angle:r,cornerRadius:s,cornerSegments:o}=i.parameters,a=new zw(t,e,n,r,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},zw=class extends Me{constructor(t=1,e=1,n=1,r=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),r=Math.min(180-c,r),r*=Math.PI/180;let d=[],h=Math.PI/2,f=(K=0,Z=0,k=0)=>new A(K,Z,k),m=f(),p=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,w=+y,[S,_,M]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(K,Z=!1)=>Math.sin(K-Math.PI/(1+ +Z)),E=(K,Z=!1)=>Math.cos(K-Math.PI/(1+ +Z));M.y=Math.sin(r)*e-g;let T=Math.cos(r)*e-v,I=S.z-c;r<=h?(M.z=Math.min(T,I),M.z==I&&(M.y-=(T-I)/Math.tan(h-r))):_.z=Math.min(_.z-T-v,S.z-c),m.subVectors(S,_),p.subVectors(M,_);let C=Math.min(m.length(),p.length())*s/100,P=C*Math.tan(r/2),O=C/Math.cos(r/2),B=m.clone().normalize().add(p.normalize()).setLength(O).add(_);m.set(0,b(r,!0),E(r,!0)),d.push([M,m.clone()]);let j=(Math.PI-r)/o;for(let K=0;K<=o;K++){let Z=h+r+K*j;m.set(0,Math.sin(Z)*P,Math.cos(Z)*P),m.add(B),p.set(0,b(Z),E(Z)),d.push([m.clone(),p.clone()])}d.push([S,f(0,1,0)]);let Q=Math.sin(j/2)*P*2,V=d.length-1,q=d[0][0].distanceTo(d[1][0]),W=d[V-1][0].distanceTo(d[V][0]),X=q+Q*o+W;d[0].push(1);for(let K=0;K<=o;K++)d[K+1].push(1-(q+K*Q)/X);d[V].push(0);let[L,U,G]=d[0],H,z,re;for(let K=1;K<d.length;K++)[H,z,re]=d[K],a.push(x,L.y,L.z,x,H.y,H.z,w,L.y,L.z,w,L.y,L.z,x,H.y,H.z,w,H.y,H.z),l.push(0,U.y,U.z,0,z.y,z.z,0,U.y,U.z,0,U.y,U.z,0,z.y,z.z,0,z.y,z.z),u.push(0,G,0,re,1,G,1,G,0,re,1,re),[L,U,G]=[H,z,re];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var Iy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:n,spikes:r,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,d=t*.5,h=e*.5,f=0,m=0,p=o*Math.PI/360/r,g=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(r===3&&n===50){p=2*Math.PI/r;for(let w=0;w<r;w++){let S=p*w,_=f+Math.sin(S)*d,M=m+Math.cos(S)*h;c.addPoint(c.createPoint(_,M))}}else for(let w=0;w<r;w++){let S=f+Math.cos(g)*d,_=m+Math.sin(g)*h;c.addPoint(c.createPoint(S,_)),g+=p,S=f+Math.cos(g)*y,_=m+Math.sin(g)*v,w<=r,c.addPoint(c.createPoint(S,_)),g+=p}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let x=Kr.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var HP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,n=new po(t,e);return Object.assign(n,{userData:{...i,type:"TextFrameGeometry"}})}};var jP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:r,depth:s})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=Jj(t,e,n,t*.5,o,s,0,0,r,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function Jj(i,t,e,n,r,s,o,a,l,u,c){return[t,e]=[e,t],o=t/2,r/=2*Math.PI,r==1&&(u=0),new Ff(!0,i,t,e,n,r,s,o,a,l,u,c)}var WP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new Lc(a,e,n,r,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var qP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=Kr.create({shape:l,parameters:{roundness:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...i,type:"TriangleGeometry"}})}};function YP(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}function $j(i,t,e){let n=[new A,new A,new A],r=[new A,new A,new A];return i.extractBasis(n[0],n[1],n[2]),t.extractBasis(r[0],r[1],r[2]),n.forEach((s,o)=>{let a=r[o],l=Ve.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ie().makeBasis(n[0],n[1],n[2])}var XP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??cd.create({parameters:Hb}).userData.shape;return{path:i.path??Du.defaultData(),parameters:Object.assign(e,{width:n,height:r,depth:s,extrusion:{...Yg,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new Gw(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Me,{userData:{...i,type:"PathGeometry"}})}},Gw=class extends Me{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)||!YP(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:r,offset:s}=this.inputs.parameters.extrusion,o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((r+s)*o):Math.ceil(Math.min(1,r+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let C=0;C<u;C++){let P=this.inputs.path.isClosed?(C+a)%e.length:Math.min(C+a,e.length-1);c.push(e[P].clone()),d.push(n[P].clone())}let h=(C,P,O)=>{c[C]=c[C].clone().lerp(c[P],O),d[C]=$j(d[C],d[P],O)},f=0,m=s*o%1;(!this.inputs.path.isClosed||r<=1)&&(m||s===0)&&(f=m,h(0,1,f));let p=0,g=(s+r)*o%1;if((this.inputs.path.isClosed&&r<=1||!this.inputs.path.isClosed&&s+r<1)&&g&&(p=g,h(c.length-1,c.length-2,1-p)),r===0){let C=c.length-1;c[C].copy(c[0]),d[C].copy(d[0])}this._applyPathModifiers(d,f,p);let{regions:y,infos:v,vertices:x}=this._computeShapePoints(5),w=0,S=0;v.sort((C,P)=>C.start-P.start),v.forEach(C=>{C.verticesStart=w,C.verticesCount=C.continuous.reduce((P,O,B)=>P+(B===0||!O?2:1),0),S+=C.verticesCount,w=S});let _=S*u,M,b=0;if(this._isOpenEnded()){try{M=rs({windingRule:gt.ODD,elementType:an.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{M=Ow}b=M.vertexCount}let E=_+2*b,T={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},I=[];v.forEach(C=>{this._extrudeRegion(C,x,d,c,T,I,this._isGeometryClosed()&&!this._isOpenEnded())}),M&&(this._closeEnd(M,_,I,T,d[0],c[0],!1),this._closeEnd(M,_+b,I,T,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Be(T.positions,3)),this.setAttribute("normal",new Be(T.normals,3)),this.setAttribute("uv",new Be(T.uvs,2)),this.setIndex(I)}_extractPathPoints(){let n=yy(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let r=[n[0]];return n.forEach(o=>{r[r.length-1].distanceToSquared(o)>.001&&r.push(o)}),this.inputs.path.isClosed&&r[r.length-1].distanceTo(r[0])<.001&&r.pop(),r}_computeBasisMatrices(e){let n=[],r=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let g=0;g<r;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===r-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let w=y.clone().sub(v).normalize(),S=x.clone().sub(y).normalize(),_=w.clone().add(S).normalize();l.copy(_),g===0&&(_.equals(c)||_.clone().negate().equals(c))&&c.set(0,0,1);let M=c.clone().cross(_).normalize(),b=_.clone().cross(M).normalize();c.copy(b),u.copy(M),g===0&&(o.copy(b),a.copy(_));let E=new ie().makeBasis(M,b,_);n.push(E)}let d=s?a:l,h=s?o:new A(0,1,0),f=d.clone().cross(u).normalize(),m=Math.acos(h.dot(f));if(isNaN(m))return n;let p=h.clone().cross(f);d.dot(p)>0&&(m*=-1);for(let g=1;g<n.length;g++){let y=new ie().makeRotationZ(m*g/n.length);n[g].multiply(y)}return n}_applyPathModifiers(e,n,r){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new ie,d=new ie;return e.forEach((h,f)=>{let m=f===0?0:f===s-1?1:(f-n)/(s-(r===0?0:1)-(n+(1-r)));c.makeRotationZ(Ve.lerp(o,o+a,m));let p=Ve.lerp(l,u,m);d.makeScale(p,p,p),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=gt.ODD){let r=this.inputs.shapeData,s=r.extractShapePointsToFlatArray([],e),o=r.shapeHoles.map(p=>{let g=p.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],w=g[v-0];y.push(x,w)}return y}),a;try{a=rs({windingRule:n,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Bf}let l;try{l=rs({windingRule:gt.ODD,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=Dw}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let g=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let p=0;p<l.vertexIndices.length;p++){let g=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let p=0;p<l.vertices.length;p++){let g=l.vertices[p];a.vertices.push(g)}}let c=1/0,d=-1/0,h=1/0,f=-1/0;for(let p=0,g=a.vertexCount;p<g;p++){let y=p*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>d&&(d=v),x<h&&(h=x),x>f&&(f=x)}let m=[];for(let p=a.elementCount-1;p>=0;p--){let g=p>=u,y=p*2,v=a.elements[y+0],x=a.elements[y+1],w=v+x,S={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let _=v,M=w-1,b=v+1,E=r.roundedCurves.length;do{let T=_-v,I=a.vertices[M*2+0],C=a.vertices[M*2+1],P=a.vertices[_*2+0],O=a.vertices[_*2+1],B=a.vertices[b*2+0],j=a.vertices[b*2+1],Q=P-I,V=O-C,q=Math.sqrt(Q*Q+V*V);Q/=q,V/=q;let W=P-B,X=O-j,L=Math.sqrt(W*W+X*X);W/=L,X/=L,S.normals[T*2+0]=-X,S.normals[T*2+1]=W;let U=a.vertexIndices[_];if(Array.isArray(U))S.continuous[T]=!1;else{let[G,H]=r.getCurveIndexFromVertexId(U-1,!0);if(H>0&&H<1)S.continuous[T]=!0;else{let z=H===1?G+1:G-1;z=(z+E)%E;let re=H===1?0:1,K=r.roundedCurves[G].getTangent(H),Z=r.roundedCurves[z].getTangent(re);S.continuous[T]=K.dot(Z)>.95}}g&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[M,_,b]=[_,b,b+1],b>=w&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:m,vertices:a.vertices}}_insertVertex(e,n,r,s,o){let a=n*2,l=n*3;e.positions[l+0]=r.x,e.positions[l+1]=r.y,e.positions[l+2]=r.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,n,r,s,o,a,l){let u=new A,c=new A,d=new A,h=new A,f=new F;r.forEach((p,g)=>{let y=s[g],v=e.verticesStart*r.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let w=(e.start+x)*2;if(u.set(n[w+0],n[w+1],0),d.copy(u).applyMatrix4(p).add(y),e.continuous[x])h.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let S=x==0?(e.start+e.count-1)*2:w-2;c.set(n[S+0],n[S+1],0),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(p).normalize(),f.set(x===0?1:x/e.count,g/(r.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(r.length-1));else{let S=x===e.count-1?e.start*2:w+2;c.set(n[S+0],n[S+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(p).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let m=r.length-1;for(let p=0;p<m;p++){let g=e.verticesStart*r.length+e.verticesCount*p,y=e.verticesStart*r.length+e.verticesCount*(p+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let w=x===e.count-1?0:v+1,S=g+v,_=g+w,M=y+w,b=y+v;e.isHole?a.push(S,M,_,S,b,M):a.push(S,_,M,S,M,b),v++}}}_closeEnd(e,n,r,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),d=new A,h=new F;for(let m=0;m<u;m++){let p=2*m;d.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+m,d,c,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let p=3*m,g=f[p+0]+n,y=f[p+(l?1:2)]+n,v=f[p+(l?2:1)]+n;r.push(g,y,v)}}};function QP(){let i=new Me;return i.setAttribute("position",new Be(new Float32Array([]),3)),i.setIndex(new Be(new Uint16Array([]),1)),i}var eW=QP().attributes,tW=12,nW=1,hd=class extends Me{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,eW),this.userData={parameters:e,type:"TextGeometry"};let r=n.getFont(e.font);r?.isLoaded?(this.font=r,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let r=n.getFont(e);r&&(this.font=r,await r.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=rW(e,n,d),{shapes:f,charWidths:m,charCoords:p}=n.generateShapes(h,e),g=r*.5,y=s*.5,v=f.map(S=>new Et().fromShape(S));this.vectorShapes=v;let x=v.map(S=>Kr.create({shape:S,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?gt.NONZERO:gt.ODD,subdivisions:this.isLowResolution&&o>0?nW:tW}})),w=x.length?$i(x):QP();w.translate(-g,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,_])=>{this.setAttribute(S,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Ki(new Me,hd.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,r])=>{this.setAttribute(n,r)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function rW(i,t,e){e=e??i.text;let n=[""],r="";for(let s of e)r+=s,s===" "||s===`
3138
+ }`;function CF(i,t,e){let n=new Vh,r=new F,s=new F,o=new We,a=new Hh({depthPacking:Hx}),l=new vx,u={},c=e.maxTextureSize,d={[ai]:On,[On]:ai,[Lr]:Lr},h=new rt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:EF,fragmentShader:TF}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new Me;m.setAttribute("position",new Be(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Dn(m,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Nm,this.render=function(w,S,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let M=i.getRenderTarget(),b=i.getActiveCubeFace(),E=i.getActiveMipmapLevel(),T=i.state;T.setBlending(Ot),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let I=0,C=w.length;I<C;I++){let P=w[I],O=P.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);let B=O.getFrameExtents();if(r.multiply(B),s.copy(O.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/B.x),r.x=s.x*B.x,O.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/B.y),r.y=s.y*B.y,O.mapSize.y=s.y)),O.map===null){let Q=this.type!==Oh?{minFilter:Dt,magFilter:Dt}:{};O.map=new ot(r.x,r.y,Q),O.map.texture.name=P.name+".shadowMap",O.camera.updateProjectionMatrix()}i.setRenderTarget(O.map),i.clear();let j=O.getViewportCount();for(let Q=0;Q<j;Q++){let V=O.getViewport(Q);o.set(s.x*V.x,s.y*V.y,s.x*V.z,s.y*V.w),T.viewport(o),O.updateMatrices(P,Q),n=O.getFrustum(),x(S,_,O.camera,P,this.type)}O.isPointLightShadow!==!0&&this.type===Oh&&y(O,_),O.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(M,b,E)};function y(w,S){let _=t.update(p);h.defines.VSM_SAMPLES!==w.blurSamples&&(h.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ot(r.x,r.y)),h.uniforms.shadow_pass.value=w.map.texture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(S,null,_,h,p,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(S,null,_,f,p,null)}function v(w,S,_,M,b,E){let T=null,I=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(I!==void 0)T=I;else if(T=_.isPointLight===!0?l:a,i.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 C=T.uuid,P=S.uuid,O=u[C];O===void 0&&(O={},u[C]=O);let B=O[P];B===void 0&&(B=T.clone(),O[P]=B),T=B}return T.visible=S.visible,T.wireframe=S.wireframe,E===Oh?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:d[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,_.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(_.matrixWorld),T.nearDistance=M,T.farDistance=b),T}function x(w,S,_,M,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===Oh)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let I=t.update(w),C=w.material;if(Array.isArray(C)){let P=I.groups;for(let O=0,B=P.length;O<B;O++){let j=P[O],Q=C[j.materialIndex];if(Q&&Q.visible){let V=v(w,Q,M,_.near,_.far,b);i.renderBufferDirect(_,null,I,V,w,j)}}}else if(C.visible){let P=v(w,C,M,_.near,_.far,b);i.renderBufferDirect(_,null,I,P,w,null)}}let T=w.children;for(let I=0,C=T.length;I<C;I++)x(T[I],S,_,M,b)}}function PF(i,t,e){let n=e.isWebGL2;function r(){let Y=!1,oe=new We,ge=null,Ne=new We(0,0,0,0);return{setMask:function(Oe){ge!==Oe&&!Y&&(i.colorMask(Oe,Oe,Oe,Oe),ge=Oe)},setLocked:function(Oe){Y=Oe},setClear:function(Oe,bt,Tn,mn,Xa){Xa===!0&&(Oe*=mn,bt*=mn,Tn*=mn),oe.set(Oe,bt,Tn,mn),Ne.equals(oe)===!1&&(i.clearColor(Oe,bt,Tn,mn),Ne.copy(oe))},reset:function(){Y=!1,ge=null,Ne.set(-1,0,0,0)}}}function s(){let Y=!1,oe=null,ge=null,Ne=null;return{setTest:function(Oe){Oe?re(2929):K(2929)},setMask:function(Oe){oe!==Oe&&!Y&&(i.depthMask(Oe),oe=Oe)},setFunc:function(Oe){if(ge!==Oe){switch(Oe){case sR:i.depthFunc(512);break;case oR:i.depthFunc(519);break;case aR:i.depthFunc(513);break;case rx:i.depthFunc(515);break;case lR:i.depthFunc(514);break;case cR:i.depthFunc(518);break;case uR:i.depthFunc(516);break;case dR:i.depthFunc(517);break;default:i.depthFunc(515)}ge=Oe}},setLocked:function(Oe){Y=Oe},setClear:function(Oe){Ne!==Oe&&(i.clearDepth(Oe),Ne=Oe)},reset:function(){Y=!1,oe=null,ge=null,Ne=null}}}function o(){let Y=!1,oe=null,ge=null,Ne=null,Oe=null,bt=null,Tn=null,mn=null,Xa=null;return{setTest:function(Jt){Y||(Jt?re(2960):K(2960))},setMask:function(Jt){oe!==Jt&&!Y&&(i.stencilMask(Jt),oe=Jt)},setFunc:function(Jt,no,yi){(ge!==Jt||Ne!==no||Oe!==yi)&&(i.stencilFunc(Jt,no,yi),ge=Jt,Ne=no,Oe=yi)},setOp:function(Jt,no,yi){(bt!==Jt||Tn!==no||mn!==yi)&&(i.stencilOp(Jt,no,yi),bt=Jt,Tn=no,mn=yi)},setLocked:function(Jt){Y=Jt},setClear:function(Jt){Xa!==Jt&&(i.clearStencil(Jt),Xa=Jt)},reset:function(){Y=!1,oe=null,ge=null,Ne=null,Oe=null,bt=null,Tn=null,mn=null,Xa=null}}}let a=new r,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,I=null,C=null,P=null,O=null,B=i.getParameter(35661),j=!1,Q=0,V=i.getParameter(7938);V.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(V)[1]),j=Q>=1):V.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),j=Q>=2);let q=null,W={},X=i.getParameter(3088),L=i.getParameter(2978),U=new We().fromArray(X),G=new We().fromArray(L);function H(Y,oe,ge){let Ne=new Uint8Array(4),Oe=i.createTexture();i.bindTexture(Y,Oe),i.texParameteri(Y,10241,9728),i.texParameteri(Y,10240,9728);for(let bt=0;bt<ge;bt++)i.texImage2D(oe+bt,0,6408,1,1,0,6408,5121,Ne);return Oe}let z={};z[3553]=H(3553,3553,1),z[34067]=H(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(rx),ve(!1),Ee(z1),re(2884),ye(Ot);function re(Y){h[Y]!==!0&&(i.enable(Y),h[Y]=!0)}function K(Y){h[Y]!==!1&&(i.disable(Y),h[Y]=!1)}function Z(Y,oe){return f[Y]!==oe?(i.bindFramebuffer(Y,oe),f[Y]=oe,n&&(Y===36009&&(f[36160]=oe),Y===36160&&(f[36009]=oe)),!0):!1}function k(Y,oe){let ge=p,Ne=!1;if(Y)if(ge=m.get(oe),ge===void 0&&(ge=[],m.set(oe,ge)),Y.isWebGLMultipleRenderTargets){let Oe=Y.texture;if(ge.length!==Oe.length||ge[0]!==36064){for(let bt=0,Tn=Oe.length;bt<Tn;bt++)ge[bt]=36064+bt;ge.length=Oe.length,Ne=!0}}else ge[0]!==36064&&(ge[0]=36064,Ne=!0);else ge[0]!==1029&&(ge[0]=1029,Ne=!0);Ne&&(e.isWebGL2?i.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function he(Y){return g!==Y?(i.useProgram(Y),g=Y,!0):!1}let fe={[gc]:32774,[XO]:32778,[QO]:32779};if(n)fe[j1]=32775,fe[W1]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(fe[j1]=Y.MIN_EXT,fe[W1]=Y.MAX_EXT)}let ce={[KO]:0,[ZO]:1,[JO]:768,[y_]:770,[iR]:776,[nR]:774,[eR]:772,[$O]:769,[v_]:771,[rR]:775,[tR]:773};function ye(Y,oe,ge,Ne,Oe,bt,Tn,mn){if(Y===Ot){y===!0&&(K(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Y!==YO){if(Y!==v||mn!==E){if((x!==gc||_!==gc)&&(i.blendEquation(32774),x=gc,_=gc),mn)switch(Y){case wc:i.blendFuncSeparate(1,771,1,771);break;case G1:i.blendFunc(1,1);break;case V1:i.blendFuncSeparate(0,769,0,1);break;case H1:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case wc:i.blendFuncSeparate(770,771,1,771);break;case G1:i.blendFunc(770,1);break;case V1:i.blendFuncSeparate(0,769,0,1);break;case H1:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}w=null,S=null,M=null,b=null,v=Y,E=mn}return}Oe=Oe||oe,bt=bt||ge,Tn=Tn||Ne,(oe!==x||Oe!==_)&&(i.blendEquationSeparate(fe[oe],fe[Oe]),x=oe,_=Oe),(ge!==w||Ne!==S||bt!==M||Tn!==b)&&(i.blendFuncSeparate(ce[ge],ce[Ne],ce[bt],ce[Tn]),w=ge,S=Ne,M=bt,b=Tn),v=Y,E=!1}function Se(Y,oe){Y.side===Lr?K(2884):re(2884);let ge=Y.side===On;oe&&(ge=!ge),ve(ge),Y.blending===wc&&Y.transparent===!1?ye(Ot):ye(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),a.setMask(Y.colorWrite);let Ne=Y.stencilWrite;u.setTest(Ne),Ne&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),we(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?re(32926):K(32926)}function ve(Y){T!==Y&&(Y?i.frontFace(2304):i.frontFace(2305),T=Y)}function Ee(Y){Y!==jO?(re(2884),Y!==I&&(Y===z1?i.cullFace(1029):Y===WO?i.cullFace(1028):i.cullFace(1032))):K(2884),I=Y}function Te(Y){Y!==C&&(j&&i.lineWidth(Y),C=Y)}function we(Y,oe,ge){Y?(re(32823),(P!==oe||O!==ge)&&(i.polygonOffset(oe,ge),P=oe,O=ge)):K(32823)}function He(Y){Y?re(3089):K(3089)}function vt(Y){Y===void 0&&(Y=33984+B-1),q!==Y&&(i.activeTexture(Y),q=Y)}function R(Y,oe,ge){ge===void 0&&(q===null?ge=33984+B-1:ge=q);let Ne=W[ge];Ne===void 0&&(Ne={type:void 0,texture:void 0},W[ge]=Ne),(Ne.type!==Y||Ne.texture!==oe)&&(q!==ge&&(i.activeTexture(ge),q=ge),i.bindTexture(Y,oe||z[Y]),Ne.type=Y,Ne.texture=oe)}function D(){let Y=W[q];Y!==void 0&&Y.type!==void 0&&(i.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ee(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function xe(){try{i.texSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ce(){try{i.texSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Pe(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{i.texStorage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Qe(){try{i.texStorage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{i.texImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{i.texImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ue(Y){U.equals(Y)===!1&&(i.scissor(Y.x,Y.y,Y.z,Y.w),U.copy(Y))}function Ke(Y){G.equals(Y)===!1&&(i.viewport(Y.x,Y.y,Y.z,Y.w),G.copy(Y))}function xt(Y,oe){let ge=d.get(oe);ge===void 0&&(ge=new WeakMap,d.set(oe,ge));let Ne=ge.get(Y);Ne===void 0&&(Ne=i.getUniformBlockIndex(oe,Y.name),ge.set(Y,Ne))}function jt(Y,oe){let Ne=d.get(oe).get(Y);c.get(oe)!==Ne&&(i.uniformBlockBinding(oe,Ne,Y.__bindingPointIndex),c.set(oe,Ne))}function En(){i.disable(3042),i.disable(2884),i.disable(2929),i.disable(32823),i.disable(3089),i.disable(2960),i.disable(32926),i.blendEquation(32774),i.blendFunc(1,0),i.blendFuncSeparate(1,0,1,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(513),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(519,0,4294967295),i.stencilOp(7680,7680,7680),i.clearStencil(0),i.cullFace(1029),i.frontFace(2305),i.polygonOffset(0,0),i.activeTexture(33984),i.bindFramebuffer(36160,null),n===!0&&(i.bindFramebuffer(36009,null),i.bindFramebuffer(36008,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},q=null,W={},f={},m=new WeakMap,p=[],g=null,y=!1,v=null,x=null,w=null,S=null,_=null,M=null,b=null,E=!1,T=null,I=null,C=null,P=null,O=null,U.set(0,0,i.canvas.width,i.canvas.height),G.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:re,disable:K,bindFramebuffer:Z,drawBuffers:k,useProgram:he,setBlending:ye,setMaterial:Se,setFlipSided:ve,setCullFace:Ee,setLineWidth:Te,setPolygonOffset:we,setScissorTest:He,activeTexture:vt,bindTexture:R,unbindTexture:D,compressedTexImage2D:ee,compressedTexImage3D:me,texImage2D:Le,texImage3D:Ie,updateUBOMapping:xt,uniformBlockBinding:jt,texStorage2D:de,texStorage3D:Qe,texSubImage2D:xe,texSubImage3D:Ce,compressedTexSubImage2D:je,compressedTexSubImage3D:Pe,scissor:Ue,viewport:Ke,reset:En}}function IF(i,t,e,n,r,s,o){let a=r.isWebGL2,l=r.maxTextures,u=r.maxCubemapSize,c=r.maxTextureSize,d=r.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,D){return y?new OffscreenCanvas(R,D):dm("canvas")}function x(R,D,ee,me){let xe=1;if((R.width>me||R.height>me)&&(xe=me/Math.max(R.width,R.height)),xe<1||D===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ce=D?um:Math.floor,je=Ce(xe*R.width),Pe=Ce(xe*R.height);p===void 0&&(p=v(je,Pe));let de=ee?v(je,Pe):p;return de.width=je,de.height=Pe,de.getContext("2d").drawImage(R,0,0,je,Pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+je+"x"+Pe+")."),de}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function w(R){return cx(R.width)&&cx(R.height)}function S(R){return a?!1:R.wrapS!==Wt||R.wrapT!==Wt||R.minFilter!==Dt&&R.minFilter!==Xe}function _(R,D){return R.generateMipmaps&&D&&R.minFilter!==Dt&&R.minFilter!==Xe}function M(R){i.generateMipmap(R)}function b(R,D,ee,me,xe=!1){if(a===!1)return D;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ce=D;return D===6403&&(ee===5126&&(Ce=33326),ee===5131&&(Ce=33325),ee===5121&&(Ce=33321)),D===33319&&(ee===5126&&(Ce=33328),ee===5131&&(Ce=33327),ee===5121&&(Ce=33323)),D===6408&&(ee===5126&&(Ce=34836),ee===5131&&(Ce=34842),ee===5121&&(Ce=me===Ze&&xe===!1?35907:32856),ee===32819&&(Ce=32854),ee===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&t.get("EXT_color_buffer_float"),Ce}function E(R,D,ee){return _(R,ee)===!0||R.isFramebufferTexture&&R.minFilter!==Dt&&R.minFilter!==Xe?Math.log2(Math.max(D.width,D.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?D.mipmaps.length:1}function T(R){return R===Dt||R===q1||R===b0?9728:9729}function I(R){let D=R.target;D.removeEventListener("dispose",I),P(D),D.isVideoTexture&&m.delete(D)}function C(R){let D=R.target;D.removeEventListener("dispose",C),B(D)}function P(R){let D=n.get(R);if(D.__webglInit===void 0)return;let ee=R.source,me=g.get(ee);if(me){let xe=me[D.__cacheKey];xe.usedTimes--,xe.usedTimes===0&&O(R),Object.keys(me).length===0&&g.delete(ee)}n.remove(R)}function O(R){let D=n.get(R);i.deleteTexture(D.__webglTexture);let ee=R.source,me=g.get(ee);delete me[D.__cacheKey],o.memory.textures--}function B(R){let D=R.texture,ee=n.get(R),me=n.get(D);if(me.__webglTexture!==void 0&&(i.deleteTexture(me.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++)i.deleteFramebuffer(ee.__webglFramebuffer[xe]),ee.__webglDepthbuffer&&i.deleteRenderbuffer(ee.__webglDepthbuffer[xe]);else{if(i.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&i.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&i.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let xe=0;xe<ee.__webglColorRenderbuffer.length;xe++)ee.__webglColorRenderbuffer[xe]&&i.deleteRenderbuffer(ee.__webglColorRenderbuffer[xe]);ee.__webglDepthRenderbuffer&&i.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let xe=0,Ce=D.length;xe<Ce;xe++){let je=n.get(D[xe]);je.__webglTexture&&(i.deleteTexture(je.__webglTexture),o.memory.textures--),n.remove(D[xe])}n.remove(D),n.remove(R)}let j=0;function Q(){j=0}function V(){let R=j;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),j+=1,R}function q(R){let D=[];return D.push(R.wrapS),D.push(R.wrapT),D.push(R.wrapR||0),D.push(R.magFilter),D.push(R.minFilter),D.push(R.anisotropy),D.push(R.internalFormat),D.push(R.format),D.push(R.type),D.push(R.generateMipmaps),D.push(R.premultiplyAlpha),D.push(R.flipY),D.push(R.unpackAlignment),D.push(R.encoding),D.join()}function W(R,D){let ee=n.get(R);if(R.isVideoTexture&&He(R),R.isRenderTargetTexture===!1&&R.version>0&&ee.__version!==R.version){let me=R.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(ee,R,D);return}}e.bindTexture(3553,ee.__webglTexture,33984+D)}function X(R,D){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,D);return}e.bindTexture(35866,ee.__webglTexture,33984+D)}function L(R,D){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){K(ee,R,D);return}e.bindTexture(32879,ee.__webglTexture,33984+D)}function U(R,D){let ee=n.get(R);if(R.version>0&&ee.__version!==R.version){Z(ee,R,D);return}e.bindTexture(34067,ee.__webglTexture,33984+D)}let G={[Hi]:10497,[Wt]:33071,[ox]:33648},H={[Dt]:9728,[q1]:9984,[b0]:9986,[Xe]:9729,[xR]:9985,[sl]:9987};function z(R,D,ee){if(ee?(i.texParameteri(R,10242,G[D.wrapS]),i.texParameteri(R,10243,G[D.wrapT]),(R===32879||R===35866)&&i.texParameteri(R,32882,G[D.wrapR]),i.texParameteri(R,10240,H[D.magFilter]),i.texParameteri(R,10241,H[D.minFilter])):(i.texParameteri(R,10242,33071),i.texParameteri(R,10243,33071),(R===32879||R===35866)&&i.texParameteri(R,32882,33071),(D.wrapS!==Wt||D.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,10240,T(D.magFilter)),i.texParameteri(R,10241,T(D.minFilter)),D.minFilter!==Dt&&D.minFilter!==Xe&&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 me=t.get("EXT_texture_filter_anisotropic");if(D.magFilter===Dt||D.minFilter!==b0&&D.minFilter!==sl||D.type===pr&&t.has("OES_texture_float_linear")===!1||a===!1&&D.type===ol&&t.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(i.texParameterf(R,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,r.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function re(R,D){let ee=!1;R.__webglInit===void 0&&(R.__webglInit=!0,D.addEventListener("dispose",I));let me=D.source,xe=g.get(me);xe===void 0&&(xe={},g.set(me,xe));let Ce=q(D);if(Ce!==R.__cacheKey){xe[Ce]===void 0&&(xe[Ce]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),xe[Ce].usedTimes++;let je=xe[R.__cacheKey];je!==void 0&&(xe[R.__cacheKey].usedTimes--,je.usedTimes===0&&O(D)),R.__cacheKey=Ce,R.__webglTexture=xe[Ce].texture}return ee}function K(R,D,ee){let me=3553;(D.isDataArrayTexture||D.isCompressedArrayTexture)&&(me=35866),D.isData3DTexture&&(me=32879);let xe=re(R,D),Ce=D.source;e.bindTexture(me,R.__webglTexture,33984+ee);let je=n.get(Ce);if(Ce.version!==je.__version||xe===!0){e.activeTexture(33984+ee),i.pixelStorei(37440,D.flipY),i.pixelStorei(37441,D.premultiplyAlpha),i.pixelStorei(3317,D.unpackAlignment),i.pixelStorei(37443,0);let Pe=S(D)&&w(D.image)===!1,de=x(D.image,Pe,!1,c);de=vt(D,de);let Qe=w(de)||a,Le=s.convert(D.format,D.encoding),Ie=s.convert(D.type),Ue=b(D.internalFormat,Le,Ie,D.encoding,D.isVideoTexture);z(me,D,Qe);let Ke,xt=D.mipmaps,jt=a&&D.isVideoTexture!==!0,En=je.__version===void 0||xe===!0,Y=E(D,de,Qe);if(D.isDepthTexture)Ue=6402,a?D.type===pr?Ue=36012:D.type===uo?Ue=33190:D.type===$o?Ue=35056:Ue=33189:D.type===pr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===rl&&Ue===6402&&D.type!==w_&&D.type!==uo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=uo,Ie=s.convert(D.type)),D.format===na&&Ue===6402&&(Ue=34041,D.type!==$o&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=$o,Ie=s.convert(D.type))),En&&(jt?e.texStorage2D(3553,1,Ue,de.width,de.height):e.texImage2D(3553,0,Ue,de.width,de.height,0,Le,Ie,null));else if(D.isDataTexture)if(xt.length>0&&Qe){jt&&En&&e.texStorage2D(3553,Y,Ue,xt[0].width,xt[0].height);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],jt?e.texSubImage2D(3553,oe,0,0,Ke.width,Ke.height,Le,Ie,Ke.data):e.texImage2D(3553,oe,Ue,Ke.width,Ke.height,0,Le,Ie,Ke.data);D.generateMipmaps=!1}else jt?(En&&e.texStorage2D(3553,Y,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,de.width,de.height,Le,Ie,de.data)):e.texImage2D(3553,0,Ue,de.width,de.height,0,Le,Ie,de.data);else if(D.isCompressedTexture)if(D.isCompressedArrayTexture){jt&&En&&e.texStorage3D(35866,Y,Ue,xt[0].width,xt[0].height,de.depth);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],D.format!==oi?Le!==null?jt?e.compressedTexSubImage3D(35866,oe,0,0,0,Ke.width,Ke.height,de.depth,Le,Ke.data,0,0):e.compressedTexImage3D(35866,oe,Ue,Ke.width,Ke.height,de.depth,0,Ke.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):jt?e.texSubImage3D(35866,oe,0,0,0,Ke.width,Ke.height,de.depth,Le,Ie,Ke.data):e.texImage3D(35866,oe,Ue,Ke.width,Ke.height,de.depth,0,Le,Ie,Ke.data)}else{jt&&En&&e.texStorage2D(3553,Y,Ue,xt[0].width,xt[0].height);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],D.format!==oi?Le!==null?jt?e.compressedTexSubImage2D(3553,oe,0,0,Ke.width,Ke.height,Le,Ke.data):e.compressedTexImage2D(3553,oe,Ue,Ke.width,Ke.height,0,Ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):jt?e.texSubImage2D(3553,oe,0,0,Ke.width,Ke.height,Le,Ie,Ke.data):e.texImage2D(3553,oe,Ue,Ke.width,Ke.height,0,Le,Ie,Ke.data)}else if(D.isDataArrayTexture)jt?(En&&e.texStorage3D(35866,Y,Ue,de.width,de.height,de.depth),e.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Le,Ie,de.data)):e.texImage3D(35866,0,Ue,de.width,de.height,de.depth,0,Le,Ie,de.data);else if(D.isData3DTexture)jt?(En&&e.texStorage3D(32879,Y,Ue,de.width,de.height,de.depth),e.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Le,Ie,de.data)):e.texImage3D(32879,0,Ue,de.width,de.height,de.depth,0,Le,Ie,de.data);else if(D.isFramebufferTexture){if(En)if(jt)e.texStorage2D(3553,Y,Ue,de.width,de.height);else{let oe=de.width,ge=de.height;for(let Ne=0;Ne<Y;Ne++)e.texImage2D(3553,Ne,Ue,oe,ge,0,Le,Ie,null),oe>>=1,ge>>=1}}else if(xt.length>0&&Qe){jt&&En&&e.texStorage2D(3553,Y,Ue,xt[0].width,xt[0].height);for(let oe=0,ge=xt.length;oe<ge;oe++)Ke=xt[oe],jt?e.texSubImage2D(3553,oe,0,0,Le,Ie,Ke):e.texImage2D(3553,oe,Ue,Le,Ie,Ke);D.generateMipmaps=!1}else jt?(En&&e.texStorage2D(3553,Y,Ue,de.width,de.height),e.texSubImage2D(3553,0,0,0,Le,Ie,de)):e.texImage2D(3553,0,Ue,Le,Ie,de);_(D,Qe)&&M(me),je.__version=Ce.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function Z(R,D,ee){if(D.image.length!==6)return;let me=re(R,D),xe=D.source;e.bindTexture(34067,R.__webglTexture,33984+ee);let Ce=n.get(xe);if(xe.version!==Ce.__version||me===!0){e.activeTexture(33984+ee),i.pixelStorei(37440,D.flipY),i.pixelStorei(37441,D.premultiplyAlpha),i.pixelStorei(3317,D.unpackAlignment),i.pixelStorei(37443,0);let je=D.isCompressedTexture||D.image[0].isCompressedTexture,Pe=D.image[0]&&D.image[0].isDataTexture,de=[];for(let oe=0;oe<6;oe++)!je&&!Pe?de[oe]=x(D.image[oe],!1,!0,u):de[oe]=Pe?D.image[oe].image:D.image[oe],de[oe]=vt(D,de[oe]);let Qe=de[0],Le=w(Qe)||a,Ie=s.convert(D.format,D.encoding),Ue=s.convert(D.type),Ke=b(D.internalFormat,Ie,Ue,D.encoding),xt=a&&D.isVideoTexture!==!0,jt=Ce.__version===void 0||me===!0,En=E(D,Qe,Le);z(34067,D,Le);let Y;if(je){xt&&jt&&e.texStorage2D(34067,En,Ke,Qe.width,Qe.height);for(let oe=0;oe<6;oe++){Y=de[oe].mipmaps;for(let ge=0;ge<Y.length;ge++){let Ne=Y[ge];D.format!==oi?Ie!==null?xt?e.compressedTexSubImage2D(34069+oe,ge,0,0,Ne.width,Ne.height,Ie,Ne.data):e.compressedTexImage2D(34069+oe,ge,Ke,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):xt?e.texSubImage2D(34069+oe,ge,0,0,Ne.width,Ne.height,Ie,Ue,Ne.data):e.texImage2D(34069+oe,ge,Ke,Ne.width,Ne.height,0,Ie,Ue,Ne.data)}}}else{Y=D.mipmaps,xt&&jt&&(Y.length>0&&En++,e.texStorage2D(34067,En,Ke,de[0].width,de[0].height));for(let oe=0;oe<6;oe++)if(Pe){xt?e.texSubImage2D(34069+oe,0,0,0,de[oe].width,de[oe].height,Ie,Ue,de[oe].data):e.texImage2D(34069+oe,0,Ke,de[oe].width,de[oe].height,0,Ie,Ue,de[oe].data);for(let ge=0;ge<Y.length;ge++){let Oe=Y[ge].image[oe].image;xt?e.texSubImage2D(34069+oe,ge+1,0,0,Oe.width,Oe.height,Ie,Ue,Oe.data):e.texImage2D(34069+oe,ge+1,Ke,Oe.width,Oe.height,0,Ie,Ue,Oe.data)}}else{xt?e.texSubImage2D(34069+oe,0,0,0,Ie,Ue,de[oe]):e.texImage2D(34069+oe,0,Ke,Ie,Ue,de[oe]);for(let ge=0;ge<Y.length;ge++){let Ne=Y[ge];xt?e.texSubImage2D(34069+oe,ge+1,0,0,Ie,Ue,Ne.image[oe]):e.texImage2D(34069+oe,ge+1,Ke,Ie,Ue,Ne.image[oe])}}}_(D,Le)&&M(34067),Ce.__version=xe.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function k(R,D,ee,me,xe){let Ce=s.convert(ee.format,ee.encoding),je=s.convert(ee.type),Pe=b(ee.internalFormat,Ce,je,ee.encoding);n.get(D).__hasExternalTextures||(xe===32879||xe===35866?e.texImage3D(xe,0,Pe,D.width,D.height,D.depth,0,Ce,je,null):e.texImage2D(xe,0,Pe,D.width,D.height,0,Ce,je,null)),e.bindFramebuffer(36160,R),we(D)?h.framebufferTexture2DMultisampleEXT(36160,me,xe,n.get(ee).__webglTexture,0,Te(D)):(xe===3553||xe>=34069&&xe<=34074)&&i.framebufferTexture2D(36160,me,xe,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function he(R,D,ee){if(i.bindRenderbuffer(36161,R),D.depthBuffer&&!D.stencilBuffer){let me=33189;if(ee||we(D)){let xe=D.depthTexture;xe&&xe.isDepthTexture&&(xe.type===pr?me=36012:xe.type===uo&&(me=33190));let Ce=Te(D);we(D)?h.renderbufferStorageMultisampleEXT(36161,Ce,me,D.width,D.height):i.renderbufferStorageMultisample(36161,Ce,me,D.width,D.height)}else i.renderbufferStorage(36161,me,D.width,D.height);i.framebufferRenderbuffer(36160,36096,36161,R)}else if(D.depthBuffer&&D.stencilBuffer){let me=Te(D);ee&&we(D)===!1?i.renderbufferStorageMultisample(36161,me,35056,D.width,D.height):we(D)?h.renderbufferStorageMultisampleEXT(36161,me,35056,D.width,D.height):i.renderbufferStorage(36161,34041,D.width,D.height),i.framebufferRenderbuffer(36160,33306,36161,R)}else{let me=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let xe=0;xe<me.length;xe++){let Ce=me[xe],je=s.convert(Ce.format,Ce.encoding),Pe=s.convert(Ce.type),de=b(Ce.internalFormat,je,Pe,Ce.encoding),Qe=Te(D);ee&&we(D)===!1?i.renderbufferStorageMultisample(36161,Qe,de,D.width,D.height):we(D)?h.renderbufferStorageMultisampleEXT(36161,Qe,de,D.width,D.height):i.renderbufferStorage(36161,de,D.width,D.height)}}i.bindRenderbuffer(36161,null)}function fe(R,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),W(D.depthTexture,0);let me=n.get(D.depthTexture).__webglTexture,xe=Te(D);if(D.depthTexture.format===rl)we(D)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,me,0,xe):i.framebufferTexture2D(36160,36096,3553,me,0);else if(D.depthTexture.format===na)we(D)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,me,0,xe):i.framebufferTexture2D(36160,33306,3553,me,0);else throw new Error("Unknown depthTexture format")}function ce(R){let D=n.get(R),ee=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!D.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");fe(D.__webglFramebuffer,R)}else if(ee){D.__webglDepthbuffer=[];for(let me=0;me<6;me++)e.bindFramebuffer(36160,D.__webglFramebuffer[me]),D.__webglDepthbuffer[me]=i.createRenderbuffer(),he(D.__webglDepthbuffer[me],R,!1)}else e.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=i.createRenderbuffer(),he(D.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function ye(R,D,ee){let me=n.get(R);D!==void 0&&k(me.__webglFramebuffer,R,R.texture,36064,3553),ee!==void 0&&ce(R)}function Se(R){let D=R.texture,ee=n.get(R),me=n.get(D);R.addEventListener("dispose",C),R.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=i.createTexture()),me.__version=D.version,o.memory.textures++);let xe=R.isWebGLCubeRenderTarget===!0,Ce=R.isWebGLMultipleRenderTargets===!0,je=w(R)||a;if(xe){ee.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)ee.__webglFramebuffer[Pe]=i.createFramebuffer()}else{if(ee.__webglFramebuffer=i.createFramebuffer(),Ce)if(r.drawBuffers){let Pe=R.texture;for(let de=0,Qe=Pe.length;de<Qe;de++){let Le=n.get(Pe[de]);Le.__webglTexture===void 0&&(Le.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&we(R)===!1){let Pe=Ce?D:[D];ee.__webglMultisampledFramebuffer=i.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let de=0;de<Pe.length;de++){let Qe=Pe[de];ee.__webglColorRenderbuffer[de]=i.createRenderbuffer(),i.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[de]);let Le=s.convert(Qe.format,Qe.encoding),Ie=s.convert(Qe.type),Ue=b(Qe.internalFormat,Le,Ie,Qe.encoding,R.isXRRenderTarget===!0),Ke=Te(R);i.renderbufferStorageMultisample(36161,Ke,Ue,R.width,R.height),i.framebufferRenderbuffer(36160,36064+de,36161,ee.__webglColorRenderbuffer[de])}i.bindRenderbuffer(36161,null),R.depthBuffer&&(ee.__webglDepthRenderbuffer=i.createRenderbuffer(),he(ee.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(xe){e.bindTexture(34067,me.__webglTexture),z(34067,D,je);for(let Pe=0;Pe<6;Pe++)k(ee.__webglFramebuffer[Pe],R,D,36064,34069+Pe);_(D,je)&&M(34067),e.unbindTexture()}else if(Ce){let Pe=R.texture;for(let de=0,Qe=Pe.length;de<Qe;de++){let Le=Pe[de],Ie=n.get(Le);e.bindTexture(3553,Ie.__webglTexture),z(3553,Le,je),k(ee.__webglFramebuffer,R,Le,36064+de,3553),_(Le,je)&&M(3553)}e.unbindTexture()}else{let Pe=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?Pe=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Pe,me.__webglTexture),z(Pe,D,je),k(ee.__webglFramebuffer,R,D,36064,Pe),_(D,je)&&M(Pe),e.unbindTexture()}R.depthBuffer&&ce(R)}function ve(R){let D=w(R)||a,ee=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let me=0,xe=ee.length;me<xe;me++){let Ce=ee[me];if(_(Ce,D)){let je=R.isWebGLCubeRenderTarget?34067:3553,Pe=n.get(Ce).__webglTexture;e.bindTexture(je,Pe),M(je),e.unbindTexture()}}}function Ee(R){if(a&&R.samples>0&&we(R)===!1){let D=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ee=R.width,me=R.height,xe=16384,Ce=[],je=R.stencilBuffer?33306:36096,Pe=n.get(R),de=R.isWebGLMultipleRenderTargets===!0;if(de)for(let Qe=0;Qe<D.length;Qe++)e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Qe,36161,null),e.bindFramebuffer(36160,Pe.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Qe,3553,null,0);e.bindFramebuffer(36008,Pe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Pe.__webglFramebuffer);for(let Qe=0;Qe<D.length;Qe++){Ce.push(36064+Qe),R.depthBuffer&&Ce.push(je);let Le=Pe.__ignoreDepthValues!==void 0?Pe.__ignoreDepthValues:!1;if(Le===!1&&(R.depthBuffer&&(xe|=256),R.stencilBuffer&&(xe|=1024)),de&&i.framebufferRenderbuffer(36008,36064,36161,Pe.__webglColorRenderbuffer[Qe]),Le===!0&&(i.invalidateFramebuffer(36008,[je]),i.invalidateFramebuffer(36009,[je])),de){let Ie=n.get(D[Qe]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Ie,0)}i.blitFramebuffer(0,0,ee,me,0,0,ee,me,xe,9728),f&&i.invalidateFramebuffer(36008,Ce)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),de)for(let Qe=0;Qe<D.length;Qe++){e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Qe,36161,Pe.__webglColorRenderbuffer[Qe]);let Le=n.get(D[Qe]).__webglTexture;e.bindFramebuffer(36160,Pe.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Qe,3553,Le,0)}e.bindFramebuffer(36009,Pe.__webglMultisampledFramebuffer)}}function Te(R){return Math.min(d,R.samples)}function we(R){let D=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function He(R){let D=o.render.frame;m.get(R)!==D&&(m.set(R,D),R.update())}function vt(R,D){let ee=R.encoding,me=R.format,xe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===lx||ee!==li&&(ee===Ze?a===!1?t.has("EXT_sRGB")===!0&&me===oi?(R.format=lx,R.minFilter=Xe,R.generateMipmaps=!1):D=hm.sRGBToLinear(D):(me!==oi||xe!==Qt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ee)),D}this.allocateTextureUnit=V,this.resetTextureUnits=Q,this.setTexture2D=W,this.setTexture2DArray=X,this.setTexture3D=L,this.setTextureCube=U,this.rebindTextures=ye,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=ve,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=ce,this.setupFrameBufferTexture=k,this.useMultisampledRTT=we}function DF(i,t,e){let n=e.isWebGL2;function r(s,o=null){let a;if(s===Qt)return 5121;if(s===AR)return 32819;if(s===_R)return 32820;if(s===bR)return 5120;if(s===wR)return 5122;if(s===w_)return 5123;if(s===SR)return 5124;if(s===uo)return 5125;if(s===pr)return 5126;if(s===ol)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===MR)return 6406;if(s===oi)return 6408;if(s===ER)return 6409;if(s===TR)return 6410;if(s===rl)return 6402;if(s===na)return 34041;if(s===lx)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===CR)return 6403;if(s===PR)return 36244;if(s===kx)return 33319;if(s===IR)return 33320;if(s===DR)return 36249;if(s===w0||s===S0||s===A0||s===_0)if(o===Ze)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===w0)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===S0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===A0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===_0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===w0)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===S0)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===A0)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===_0)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Y1||s===X1||s===Q1||s===K1)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Y1)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===X1)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Q1)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===K1)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===OR)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Z1||s===J1)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Z1)return o===Ze?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===J1)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===$1||s===eA||s===tA||s===nA||s===rA||s===iA||s===sA||s===oA||s===aA||s===lA||s===cA||s===uA||s===dA||s===hA)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===$1)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===eA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===tA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===nA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===rA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===iA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===sA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===oA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===aA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===lA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===cA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===uA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===dA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===hA)return o===Ze?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===M0)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===M0)return o===Ze?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===RR||s===fA||s===pA||s===mA)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===M0)return a.COMPRESSED_RED_RGTC1_EXT;if(s===fA)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===pA)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===mA)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===$o?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:r}}var xx=class extends yn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},xs=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}},OF={type:"move"},Bh=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new xs,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 xs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new xs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let p of t.hand.values()){let g=e.getJointPose(p,n),y=this._getHandJoint(u,p);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,m=.005;u.inputState.pinching&&h>f+m?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=f-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(OF)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new xs;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},bi=class extends qt{constructor(t,e,n,r,s,o,a,l,u,c){if(c=c!==void 0?c:rl,c!==rl&&c!==na)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===rl&&(n=uo),n===void 0&&c===na&&(n=$o),super(null,r,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Dt,this.minFilter=l!==void 0?l:Dt,this.flipY=!1,this.generateMipmaps=!1}},bx=class extends Ut{constructor(t,e){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,m=null,p=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,_=new yn;_.layers.enable(1),_.viewport=new We;let M=new yn;M.layers.enable(2),M.viewport=new We;let b=[_,M],E=new xx;E.layers.enable(1),E.layers.enable(2);let T=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(L){let U=v[L];return U===void 0&&(U=new Bh,v[L]=U),U.getTargetRaySpace()},this.getControllerGrip=function(L){let U=v[L];return U===void 0&&(U=new Bh,v[L]=U),U.getGripSpace()},this.getHand=function(L){let U=v[L];return U===void 0&&(U=new Bh,v[L]=U),U.getHandSpace()};function C(L){let U=x.indexOf(L.inputSource);if(U===-1)return;let G=v[U];G!==void 0&&G.dispatchEvent({type:L.type,data:L.inputSource})}function P(){r.removeEventListener("select",C),r.removeEventListener("selectstart",C),r.removeEventListener("selectend",C),r.removeEventListener("squeeze",C),r.removeEventListener("squeezestart",C),r.removeEventListener("squeezeend",C),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",O);for(let L=0;L<v.length;L++){let U=x[L];U!==null&&(x[L]=null,v[L].disconnect(U))}T=null,I=null,t.setRenderTarget(g),f=null,h=null,d=null,r=null,y=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(L){s=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(L){a=L,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(L){u=L},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(L){if(r=L,r!==null){if(g=t.getRenderTarget(),r.addEventListener("select",C),r.addEventListener("selectstart",C),r.addEventListener("selectend",C),r.addEventListener("squeeze",C),r.addEventListener("squeezestart",C),r.addEventListener("squeezeend",C),r.addEventListener("end",P),r.addEventListener("inputsourceschange",O),p.xrCompatible!==!0&&await e.makeXRCompatible(),r.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let U={antialias:r.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,e,U),r.updateRenderState({baseLayer:f}),y=new ot(f.framebufferWidth,f.framebufferHeight,{format:oi,type:Qt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let U=null,G=null,H=null;p.depth&&(H=p.stencil?35056:33190,U=p.stencil?na:rl,G=p.stencil?$o:uo);let z={colorFormat:32856,depthFormat:H,scaleFactor:s};d=new XRWebGLBinding(r,e),h=d.createProjectionLayer(z),r.updateRenderState({layers:[h]}),y=new ot(h.textureWidth,h.textureHeight,{format:oi,type:Qt,depthTexture:new bi(h.textureWidth,h.textureHeight,G,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let re=t.properties.get(y);re.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await r.requestReferenceSpace(a),X.setContext(r),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function O(L){for(let U=0;U<L.removed.length;U++){let G=L.removed[U],H=x.indexOf(G);H>=0&&(x[H]=null,v[H].disconnect(G))}for(let U=0;U<L.added.length;U++){let G=L.added[U],H=x.indexOf(G);if(H===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(G),H=re;break}else if(x[re]===null){x[re]=G,H=re;break}if(H===-1)break}let z=v[H];z&&z.connect(G)}}let B=new A,j=new A;function Q(L,U,G){B.setFromMatrixPosition(U.matrixWorld),j.setFromMatrixPosition(G.matrixWorld);let H=B.distanceTo(j),z=U.projectionMatrix.elements,re=G.projectionMatrix.elements,K=z[14]/(z[10]-1),Z=z[14]/(z[10]+1),k=(z[9]+1)/z[5],he=(z[9]-1)/z[5],fe=(z[8]-1)/z[0],ce=(re[8]+1)/re[0],ye=K*fe,Se=K*ce,ve=H/(-fe+ce),Ee=ve*-fe;U.matrixWorld.decompose(L.position,L.quaternion,L.scale),L.translateX(Ee),L.translateZ(ve),L.matrixWorld.compose(L.position,L.quaternion,L.scale),L.matrixWorldInverse.copy(L.matrixWorld).invert();let Te=K+ve,we=Z+ve,He=ye-Ee,vt=Se+(H-Ee),R=k*Z/we*Te,D=he*Z/we*Te;L.projectionMatrix.makePerspective(He,vt,R,D,Te,we)}function V(L,U){U===null?L.matrixWorld.copy(L.matrix):L.matrixWorld.multiplyMatrices(U.matrixWorld,L.matrix),L.matrixWorldInverse.copy(L.matrixWorld).invert()}this.updateCamera=function(L){if(r===null)return;E.near=M.near=_.near=L.near,E.far=M.far=_.far=L.far,(T!==E.near||I!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,I=E.far);let U=L.parent,G=E.cameras;V(E,U);for(let z=0;z<G.length;z++)V(G[z],U);E.matrixWorld.decompose(E.position,E.quaternion,E.scale),L.matrix.copy(E.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);let H=L.children;for(let z=0,re=H.length;z<re;z++)H[z].updateMatrixWorld(!0);G.length===2?Q(E,_,M):E.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(L){l=L,h!==null&&(h.fixedFoveation=L),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=L)},this.getPlanes=function(){return w};let q=null;function W(L,U){if(c=U.getViewerPose(u||o),m=U,c!==null){let G=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let H=!1;G.length!==E.cameras.length&&(E.cameras.length=0,H=!0);for(let z=0;z<G.length;z++){let re=G[z],K=null;if(f!==null)K=f.getViewport(re);else{let k=d.getViewSubImage(h,re);K=k.viewport,z===0&&(t.setRenderTargetTextures(y,k.colorTexture,h.ignoreDepthValues?void 0:k.depthStencilTexture),t.setRenderTarget(y))}let Z=b[z];Z===void 0&&(Z=new yn,Z.layers.enable(z),Z.viewport=new We,b[z]=Z),Z.matrix.fromArray(re.transform.matrix),Z.projectionMatrix.fromArray(re.projectionMatrix),Z.viewport.set(K.x,K.y,K.width,K.height),z===0&&E.matrix.copy(Z.matrix),H===!0&&E.cameras.push(Z)}}for(let G=0;G<v.length;G++){let H=x[G],z=v[G];H!==null&&z!==void 0&&z.update(H,U,u||o)}if(q&&q(L,U),U.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:U.detectedPlanes});let G=null;for(let H of w)U.detectedPlanes.has(H)||(G===null&&(G=[]),G.push(H));if(G!==null)for(let H of G)w.delete(H),S.delete(H),n.dispatchEvent({type:"planeremoved",data:H});for(let H of U.detectedPlanes)if(!w.has(H))w.add(H),S.set(H,U.lastChangedTime),n.dispatchEvent({type:"planeadded",data:H});else{let z=S.get(H);H.lastChangedTime>z&&(S.set(H,H.lastChangedTime),n.dispatchEvent({type:"planechanged",data:H}))}}m=null}let X=new E_;X.setAnimationLoop(W),this.setAnimationLoop=function(L){q=L},this.dispose=function(){}}};function RF(i,t){function e(p,g){g.color.getRGB(p.fogColor.value,M_(i)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(p,g):g.isMeshToonMaterial?(r(p,g),c(p,g)):g.isMeshPhongMaterial?(r(p,g),u(p,g)):g.isMeshStandardMaterial?(r(p,g),d(p,g),g.isMeshPhysicalMaterial&&h(p,g,x)):g.isMeshMatcapMaterial?(r(p,g),f(p,g)):g.isMeshDepthMaterial?r(p,g):g.isMeshDistanceMaterial?(r(p,g),m(p,g)):g.isMeshNormalMaterial?r(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,y,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===On&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===On&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let w=i.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uv2Transform.value.copy(x.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,y,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function c(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function d(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function h(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===On&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function LF(i,t,e,n){let r={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let w=x.program;n.uniformBlockBinding(v,w)}function u(v,x){let w=r[v.id];w===void 0&&(m(v),w=c(v),r[v.id]=w,v.addEventListener("dispose",g));let S=x.program;n.updateUBOMapping(v,S);let _=t.render.frame;s[v.id]!==_&&(h(v),s[v.id]=_)}function c(v){let x=d();v.__bindingPointIndex=x;let w=i.createBuffer(),S=v.__size,_=v.usage;return i.bindBuffer(35345,w),i.bufferData(35345,S,_),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,w),w}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let x=r[v.id],w=v.uniforms,S=v.__cache;i.bindBuffer(35345,x);for(let _=0,M=w.length;_<M;_++){let b=w[_];if(f(b,_,S)===!0){let E=b.__offset,T=Array.isArray(b.value)?b.value:[b.value],I=0;for(let C=0;C<T.length;C++){let P=T[C],O=p(P);typeof P=="number"?(b.__data[0]=P,i.bufferSubData(35345,E+I,b.__data)):P.isMatrix3?(b.__data[0]=P.elements[0],b.__data[1]=P.elements[1],b.__data[2]=P.elements[2],b.__data[3]=P.elements[0],b.__data[4]=P.elements[3],b.__data[5]=P.elements[4],b.__data[6]=P.elements[5],b.__data[7]=P.elements[0],b.__data[8]=P.elements[6],b.__data[9]=P.elements[7],b.__data[10]=P.elements[8],b.__data[11]=P.elements[0]):(P.toArray(b.__data,I),I+=O.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,E,b.__data)}}i.bindBuffer(35345,null)}function f(v,x,w){let S=v.value;if(w[x]===void 0){if(typeof S=="number")w[x]=S;else{let _=Array.isArray(S)?S:[S],M=[];for(let b=0;b<_.length;b++)M.push(_[b].clone());w[x]=M}return!0}else if(typeof S=="number"){if(w[x]!==S)return w[x]=S,!0}else{let _=Array.isArray(w[x])?w[x]:[w[x]],M=Array.isArray(S)?S:[S];for(let b=0;b<_.length;b++){let E=_[b];if(E.equals(M[b])===!1)return E.copy(M[b]),!0}}return!1}function m(v){let x=v.uniforms,w=0,S=16,_=0;for(let M=0,b=x.length;M<b;M++){let E=x[M],T={boundary:0,storage:0},I=Array.isArray(E.value)?E.value:[E.value];for(let C=0,P=I.length;C<P;C++){let O=I[C],B=p(O);T.boundary+=B.boundary,T.storage+=B.storage}if(E.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=w,M>0){_=w%S;let C=S-_;_!==0&&C-T.boundary<0&&(w+=S-_,E.__offset=w)}w+=T.storage}return _=w%S,_>0&&(w+=S-_),v.__size=w,v.__cache={},this}function p(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),i.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function y(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:u,dispose:y}}function NF(){let i=dm("canvas");return i.style.display="block",i}function qx(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:NF(),e=i.context!==void 0?i.context:null,n=i.depth!==void 0?i.depth:!0,r=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.alpha:!1;let d=null,h=null,f=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=li,this.physicallyCorrectLights=!1,this.toneMapping=fo,this.toneMappingExposure=1;let p=this,g=!1,y=0,v=0,x=null,w=-1,S=null,_=new We,M=new We,b=null,E=t.width,T=t.height,I=1,C=null,P=null,O=new We(0,0,E,T),B=new We(0,0,E,T),j=!1,Q=new Vh,V=!1,q=!1,W=null,X=new ie,L=new F,U=new A,G={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function H(){return x===null?I:1}let z=e;function re(N,te){for(let ae=0;ae<N.length;ae++){let $=N[ae],ue=t.getContext($,te);if(ue!==null)return ue}return null}try{let N={alpha:!0,depth:n,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${yo}`),t.addEventListener("webglcontextlost",Ue,!1),t.addEventListener("webglcontextrestored",Ke,!1),t.addEventListener("webglcontextcreationerror",xt,!1),z===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),z=re(te,N),z===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let K,Z,k,he,fe,ce,ye,Se,ve,Ee,Te,we,He,vt,R,D,ee,me,xe,Ce,je,Pe,de,Qe;function Le(){K=new nB(z),Z=new KN(z,K,i),K.init(Z),Pe=new DF(z,K,Z),k=new PF(z,K,Z),he=new sB,fe=new yF,ce=new IF(z,K,k,fe,Z,Pe,he),ye=new JN(p),Se=new tB(p),ve=new pL(z,Z),de=new XN(z,K,ve,Z),Ee=new rB(z,ve,he,de),Te=new cB(z,Ee,ve,he),xe=new lB(z,Z,ce),D=new ZN(fe),we=new gF(p,ye,Se,K,Z,de,D),He=new RF(p,fe),vt=new xF,R=new MF(K,Z),me=new YN(p,ye,Se,k,Te,c,o),ee=new CF(p,Te,Z),Qe=new LF(z,he,Z,k),Ce=new QN(z,K,he,Z),je=new iB(z,K,he,Z),he.programs=we.programs,p.capabilities=Z,p.extensions=K,p.properties=fe,p.renderLists=vt,p.shadowMap=ee,p.state=k,p.info=he}Le();let Ie=new bx(p,z);this.xr=Ie,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let N=K.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=K.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(N){N!==void 0&&(I=N,this.setSize(E,T,!1))},this.getSize=function(N){return N.set(E,T)},this.setSize=function(N,te,ae){if(Ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=N,T=te,t.width=Math.floor(N*I),t.height=Math.floor(te*I),ae!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(E*I,T*I).floor()},this.setDrawingBufferSize=function(N,te,ae){E=N,T=te,I=ae,t.width=Math.floor(N*ae),t.height=Math.floor(te*ae),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(_)},this.getViewport=function(N){return N.copy(O)},this.setViewport=function(N,te,ae,$){N.isVector4?O.set(N.x,N.y,N.z,N.w):O.set(N,te,ae,$),k.viewport(_.copy(O).multiplyScalar(I).floor())},this.getScissor=function(N){return N.copy(B)},this.setScissor=function(N,te,ae,$){N.isVector4?B.set(N.x,N.y,N.z,N.w):B.set(N,te,ae,$),k.scissor(M.copy(B).multiplyScalar(I).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(N){k.setScissorTest(j=N)},this.setOpaqueSort=function(N){C=N},this.setTransparentSort=function(N){P=N},this.getClearColor=function(N){return N.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(N=!0,te=!0,ae=!0){let $=0;N&&($|=16384),te&&($|=256),ae&&($|=1024),z.clear($)},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",Ue,!1),t.removeEventListener("webglcontextrestored",Ke,!1),t.removeEventListener("webglcontextcreationerror",xt,!1),vt.dispose(),R.dispose(),fe.dispose(),ye.dispose(),Se.dispose(),Te.dispose(),de.dispose(),Qe.dispose(),we.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",Ne),Ie.removeEventListener("sessionend",Oe),W&&(W.dispose(),W=null),bt.stop()};function Ue(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Ke(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=he.autoReset,te=ee.enabled,ae=ee.autoUpdate,$=ee.needsUpdate,ue=ee.type;Le(),he.autoReset=N,ee.enabled=te,ee.autoUpdate=ae,ee.needsUpdate=$,ee.type=ue}function xt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function jt(N){let te=N.target;te.removeEventListener("dispose",jt),En(te)}function En(N){Y(N),fe.remove(N)}function Y(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(ae){we.releaseProgram(ae)}),N.isShaderMaterial&&we.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,ae,$,ue,tt){te===null&&(te=G);let at=ue.isMesh&&ue.matrixWorld.determinant()<0,dt=RO(N,te,ae,$,ue);k.setMaterial($,at);let mt=ae.index,Ct=1;$.wireframe===!0&&(mt=Ee.getWireframeAttribute(ae),Ct=2);let wt=ae.drawRange,St=ae.attributes.position,Cn=wt.start*Ct,ni=(wt.start+wt.count)*Ct;tt!==null&&(Cn=Math.max(Cn,tt.start*Ct),ni=Math.min(ni,(tt.start+tt.count)*Ct)),mt!==null?(Cn=Math.max(Cn,0),ni=Math.min(ni,mt.count)):St!=null&&(Cn=Math.max(Cn,0),ni=Math.min(ni,St.count));let ro=ni-Cn;if(ro<0||ro===1/0)return;de.setup(ue,$,dt,ae,mt);let Qa,Pn=Ce;if(mt!==null&&(Qa=ve.get(mt),Pn=je,Pn.setIndex(Qa)),ue.isMesh)$.wireframe===!0?(k.setLineWidth($.wireframeLinewidth*H()),Pn.setMode(1)):Pn.setMode(4);else if(ue.isLine){let At=$.linewidth;At===void 0&&(At=1),k.setLineWidth(At*H()),ue.isLineSegments?Pn.setMode(1):ue.isLineLoop?Pn.setMode(2):Pn.setMode(3)}else ue.isPoints?Pn.setMode(0):ue.isSprite&&Pn.setMode(4);if(ue.isInstancedMesh)Pn.renderInstances(Cn,ro,ue.count);else if(ae.isInstancedBufferGeometry){let At=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,m0=Math.min(ae.instanceCount,At);Pn.renderInstances(Cn,ro,m0)}else Pn.render(Cn,ro)},this.compile=function(N,te){function ae($,ue,tt){$.transparent===!0&&$.side===Lr&&$.forceSinglePass===!1?($.side=On,$.needsUpdate=!0,yi($,ue,tt),$.side=ai,$.needsUpdate=!0,yi($,ue,tt),$.side=Lr):yi($,ue,tt)}h=R.get(N),h.init(),m.push(h),N.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),N.traverse(function($){let ue=$.material;if(ue)if(Array.isArray(ue))for(let tt=0;tt<ue.length;tt++){let at=ue[tt];ae(at,N,$)}else ae(ue,N,$)}),m.pop(),h=null};let oe=null;function ge(N){oe&&oe(N)}function Ne(){bt.stop()}function Oe(){bt.start()}let bt=new E_;bt.setAnimationLoop(ge),typeof self<"u"&&bt.setContext(self),this.setAnimationLoop=function(N){oe=N,Ie.setAnimationLoop(N),N===null?bt.stop():bt.start()},Ie.addEventListener("sessionstart",Ne),Ie.addEventListener("sessionend",Oe),this.render=function(N,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(te),te=Ie.getCamera()),N.isScene===!0&&N.onBeforeRender(p,N,te,x),h=R.get(N,m.length),h.init(),m.push(h),X.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),Q.setFromProjectionMatrix(X),q=this.localClippingEnabled,V=D.init(this.clippingPlanes,q),d=vt.get(N,f.length),d.init(),f.push(d),Tn(N,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(C,P),V===!0&&D.beginShadows();let ae=h.state.shadowsArray;if(ee.render(ae,N,te),V===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(d,N),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let ue=0,tt=$.length;ue<tt;ue++){let at=$[ue];mn(d,N,at,at.viewport)}}else mn(d,N,te);x!==null&&(ce.updateMultisampleRenderTarget(x),ce.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(p,N,te),de.resetDefaultState(),w=-1,S=null,m.pop(),m.length>0?h=m[m.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function Tn(N,te,ae,$){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)ae=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||Q.intersectsSprite(N)){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),dt=N.material;dt.visible&&d.push(N,at,dt,ae,U.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==he.render.frame&&(N.skeleton.update(),N.skeleton.frame=he.render.frame),!N.frustumCulled||Q.intersectsObject(N))){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(X);let at=Te.update(N),dt=N.material;if(Array.isArray(dt)){let mt=at.groups;for(let Ct=0,wt=mt.length;Ct<wt;Ct++){let St=mt[Ct],Cn=dt[St.materialIndex];Cn&&Cn.visible&&d.push(N,at,Cn,ae,U.z,St)}}else dt.visible&&d.push(N,at,dt,ae,U.z,null)}}let tt=N.children;for(let at=0,dt=tt.length;at<dt;at++)Tn(tt[at],te,ae,$)}function mn(N,te,ae,$){let ue=N.opaque,tt=N.transmissive,at=N.transparent;h.setupLightsView(ae),V===!0&&D.setGlobalState(p.clippingPlanes,ae),tt.length>0&&Xa(ue,te,ae),$&&k.viewport(_.copy($)),ue.length>0&&Jt(ue,te,ae),tt.length>0&&Jt(tt,te,ae),at.length>0&&Jt(at,te,ae),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function Xa(N,te,ae){let $=Z.isWebGL2;W===null&&(W=new ot(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?ol:Qt,minFilter:sl,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(L),$?W.setSize(L.x,L.y):W.setSize(um(L.x),um(L.y));let ue=p.getRenderTarget();p.setRenderTarget(W),p.clear();let tt=p.toneMapping;p.toneMapping=fo,Jt(N,te,ae),p.toneMapping=tt,ce.updateMultisampleRenderTarget(W),ce.updateRenderTargetMipmap(W),p.setRenderTarget(ue)}function Jt(N,te,ae){let $=te.isScene===!0?te.overrideMaterial:null;for(let ue=0,tt=N.length;ue<tt;ue++){let at=N[ue],dt=at.object,mt=at.geometry,Ct=$===null?at.material:$,wt=at.group;dt.layers.test(ae.layers)&&no(dt,te,ae,mt,Ct,wt)}}function no(N,te,ae,$,ue,tt){N.onBeforeRender(p,te,ae,$,ue,tt),N.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),ue.onBeforeRender(p,te,ae,$,N,tt),ue.transparent===!0&&ue.side===Lr&&ue.forceSinglePass===!1?(ue.side=On,ue.needsUpdate=!0,p.renderBufferDirect(ae,te,$,ue,N,tt),ue.side=ai,ue.needsUpdate=!0,p.renderBufferDirect(ae,te,$,ue,N,tt),ue.side=Lr):p.renderBufferDirect(ae,te,$,ue,N,tt),N.onAfterRender(p,te,ae,$,ue,tt)}function yi(N,te,ae){te.isScene!==!0&&(te=G);let $=fe.get(N),ue=h.state.lights,tt=h.state.shadowsArray,at=ue.state.version,dt=we.getParameters(N,ue.state,tt,te,ae),mt=we.getProgramCacheKey(dt),Ct=$.programs;$.environment=N.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(N.isMeshStandardMaterial?Se:ye).get(N.envMap||$.environment),Ct===void 0&&(N.addEventListener("dispose",jt),Ct=new Map,$.programs=Ct);let wt=Ct.get(mt);if(wt!==void 0){if($.currentProgram===wt&&$.lightsStateVersion===at)return F1(N,dt),wt}else dt.uniforms=we.getUniforms(N),N.onBuild(ae,dt,p),N.onBeforeCompile(dt,p),wt=we.acquireProgram(dt,mt),Ct.set(mt,wt),$.uniforms=dt.uniforms;let St=$.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(St.clippingPlanes=D.uniform),F1(N,dt),$.needsLights=NO(N),$.lightsStateVersion=at,$.needsLights&&(St.ambientLightColor.value=ue.state.ambient,St.lightProbe.value=ue.state.probe,St.directionalLights.value=ue.state.directional,St.directionalLightShadows.value=ue.state.directionalShadow,St.spotLights.value=ue.state.spot,St.spotLightShadows.value=ue.state.spotShadow,St.rectAreaLights.value=ue.state.rectArea,St.ltc_1.value=ue.state.rectAreaLTC1,St.ltc_2.value=ue.state.rectAreaLTC2,St.pointLights.value=ue.state.point,St.pointLightShadows.value=ue.state.pointShadow,St.hemisphereLights.value=ue.state.hemi,St.directionalShadowMap.value=ue.state.directionalShadowMap,St.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,St.spotShadowMap.value=ue.state.spotShadowMap,St.spotLightMatrix.value=ue.state.spotLightMatrix,St.spotLightMap.value=ue.state.spotLightMap,St.pointShadowMap.value=ue.state.pointShadowMap,St.pointShadowMatrix.value=ue.state.pointShadowMatrix);let Cn=wt.getUniforms(),ni=Sc.seqWithValue(Cn.seq,St);return $.currentProgram=wt,$.uniformsList=ni,wt}function F1(N,te){let ae=fe.get(N);ae.outputEncoding=te.outputEncoding,ae.instancing=te.instancing,ae.skinning=te.skinning,ae.morphTargets=te.morphTargets,ae.morphNormals=te.morphNormals,ae.morphColors=te.morphColors,ae.morphTargetsCount=te.morphTargetsCount,ae.numClippingPlanes=te.numClippingPlanes,ae.numIntersection=te.numClipIntersection,ae.vertexAlphas=te.vertexAlphas,ae.vertexTangents=te.vertexTangents,ae.toneMapping=te.toneMapping}function RO(N,te,ae,$,ue){te.isScene!==!0&&(te=G),ce.resetTextureUnits();let tt=te.fog,at=$.isMeshStandardMaterial?te.environment:null,dt=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:li,mt=($.isMeshStandardMaterial?Se:ye).get($.envMap||at),Ct=$.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,wt=!!$.normalMap&&!!ae.attributes.tangent,St=!!ae.morphAttributes.position,Cn=!!ae.morphAttributes.normal,ni=!!ae.morphAttributes.color,ro=$.toneMapped?p.toneMapping:fo,Qa=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Pn=Qa!==void 0?Qa.length:0,At=fe.get($),m0=h.state.lights;if(V===!0&&(q===!0||N!==S)){let ri=N===S&&$.id===w;D.setState($,N,ri)}let Jn=!1;$.version===At.__version?(At.needsLights&&At.lightsStateVersion!==m0.state.version||At.outputEncoding!==dt||ue.isInstancedMesh&&At.instancing===!1||!ue.isInstancedMesh&&At.instancing===!0||ue.isSkinnedMesh&&At.skinning===!1||!ue.isSkinnedMesh&&At.skinning===!0||At.envMap!==mt||$.fog===!0&&At.fog!==tt||At.numClippingPlanes!==void 0&&(At.numClippingPlanes!==D.numPlanes||At.numIntersection!==D.numIntersection)||At.vertexAlphas!==Ct||At.vertexTangents!==wt||At.morphTargets!==St||At.morphNormals!==Cn||At.morphColors!==ni||At.toneMapping!==ro||Z.isWebGL2===!0&&At.morphTargetsCount!==Pn)&&(Jn=!0):(Jn=!0,At.__version=$.version);let Ka=At.currentProgram;Jn===!0&&(Ka=yi($,te,ue));let U1=!1,Sh=!1,g0=!1,fr=Ka.getUniforms(),Za=At.uniforms;if(k.useProgram(Ka.program)&&(U1=!0,Sh=!0,g0=!0),$.id!==w&&(w=$.id,Sh=!0),U1||S!==N){if(fr.setValue(z,"projectionMatrix",N.projectionMatrix),Z.logarithmicDepthBuffer&&fr.setValue(z,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),S!==N&&(S=N,Sh=!0,g0=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let ri=fr.map.cameraPosition;ri!==void 0&&ri.setValue(z,U.setFromMatrixPosition(N.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&fr.setValue(z,"isOrthographic",N.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||ue.isSkinnedMesh)&&fr.setValue(z,"viewMatrix",N.matrixWorldInverse)}if(ue.isSkinnedMesh){fr.setOptional(z,ue,"bindMatrix"),fr.setOptional(z,ue,"bindMatrixInverse");let ri=ue.skeleton;ri&&(Z.floatVertexTextures?(ri.boneTexture===null&&ri.computeBoneTexture(),fr.setValue(z,"boneTexture",ri.boneTexture,ce),fr.setValue(z,"boneTextureSize",ri.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 y0=ae.morphAttributes;if((y0.position!==void 0||y0.normal!==void 0||y0.color!==void 0&&Z.isWebGL2===!0)&&xe.update(ue,ae,$,Ka),(Sh||At.receiveShadow!==ue.receiveShadow)&&(At.receiveShadow=ue.receiveShadow,fr.setValue(z,"receiveShadow",ue.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(Za.envMap.value=mt,Za.flipEnvMap.value=mt.isCubeTexture&&mt.isRenderTargetTexture===!1?-1:1),Sh&&(fr.setValue(z,"toneMappingExposure",p.toneMappingExposure),At.needsLights&&LO(Za,g0),tt&&$.fog===!0&&He.refreshFogUniforms(Za,tt),He.refreshMaterialUniforms(Za,$,I,T,W),Sc.upload(z,At.uniformsList,Za,ce)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Sc.upload(z,At.uniformsList,Za,ce),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&fr.setValue(z,"center",ue.center),fr.setValue(z,"modelViewMatrix",ue.modelViewMatrix),fr.setValue(z,"normalMatrix",ue.normalMatrix),fr.setValue(z,"modelMatrix",ue.matrixWorld),ue.previousModelViewMatrix&&fr.setValue(z,"previousModelViewMatrix",ue.previousModelViewMatrix),N.previousProjectionMatrix&&fr.setValue(z,"previousProjectionMatrix",N.previousProjectionMatrix),$.isShaderMaterial||$.isRawShaderMaterial){let ri=$.uniformsGroups;for(let v0=0,BO=ri.length;v0<BO;v0++)if(Z.isWebGL2){let k1=ri[v0];Qe.update(k1,Ka),Qe.bind(k1,Ka)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ka}function LO(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function NO(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,ae){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=ae;let $=fe.get(N);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=ae===void 0,$.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let ae=fe.get(N);ae.__webglFramebuffer=te,ae.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,ae=0){x=N,y=te,v=ae;let $=!0,ue=null,tt=!1,at=!1;if(N){let mt=fe.get(N);mt.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),$=!1):mt.__webglFramebuffer===void 0?ce.setupRenderTarget(N):mt.__hasExternalTextures&&ce.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let Ct=N.texture;(Ct.isData3DTexture||Ct.isDataArrayTexture||Ct.isCompressedArrayTexture)&&(at=!0);let wt=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(ue=wt[te],tt=!0):Z.isWebGL2&&N.samples>0&&ce.useMultisampledRTT(N)===!1?ue=fe.get(N).__webglMultisampledFramebuffer:ue=wt,_.copy(N.viewport),M.copy(N.scissor),b=N.scissorTest}else _.copy(O).multiplyScalar(I).floor(),M.copy(B).multiplyScalar(I).floor(),b=j;if(k.bindFramebuffer(36160,ue)&&Z.drawBuffers&&$&&k.drawBuffers(N,ue),k.viewport(_),k.scissor(M),k.setScissorTest(b),tt){let mt=fe.get(N.texture);z.framebufferTexture2D(36160,36064,34069+te,mt.__webglTexture,ae)}else if(at){let mt=fe.get(N.texture),Ct=te||0;z.framebufferTextureLayer(36160,36064,mt.__webglTexture,ae||0,Ct)}w=-1},this.readRenderTargetPixels=function(N,te,ae,$,ue,tt,at){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let dt=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&at!==void 0&&(dt=dt[at]),dt){k.bindFramebuffer(36160,dt);try{let mt=N.texture,Ct=mt.format,wt=mt.type;if(Ct!==oi&&Pe.convert(Ct)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let St=wt===ol&&(K.has("EXT_color_buffer_half_float")||Z.isWebGL2&&K.has("EXT_color_buffer_float"));if(wt!==Qt&&Pe.convert(wt)!==z.getParameter(35738)&&!(wt===pr&&(Z.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!St){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-$&&ae>=0&&ae<=N.height-ue&&z.readPixels(te,ae,$,ue,Pe.convert(Ct),Pe.convert(wt),tt)}finally{let mt=x!==null?fe.get(x).__webglFramebuffer:null;k.bindFramebuffer(36160,mt)}}},this.copyFramebufferToTexture=function(N,te,ae=0){let $=Math.pow(2,-ae),ue=Math.floor(te.image.width*$),tt=Math.floor(te.image.height*$);ce.setTexture2D(te,0),z.copyTexSubImage2D(3553,ae,0,0,N.x,N.y,ue,tt),k.unbindTexture()},this.copyTextureToTexture=function(N,te,ae,$=0){let ue=te.image.width,tt=te.image.height,at=Pe.convert(ae.format),dt=Pe.convert(ae.type);ce.setTexture2D(ae,0),z.pixelStorei(37440,ae.flipY),z.pixelStorei(37441,ae.premultiplyAlpha),z.pixelStorei(3317,ae.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,$,N.x,N.y,ue,tt,at,dt,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,$,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,at,te.mipmaps[0].data):z.texSubImage2D(3553,$,N.x,N.y,at,dt,te.image),$===0&&ae.generateMipmaps&&z.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(N,te,ae,$,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let tt=N.max.x-N.min.x+1,at=N.max.y-N.min.y+1,dt=N.max.z-N.min.z+1,mt=Pe.convert($.format),Ct=Pe.convert($.type),wt;if($.isData3DTexture)ce.setTexture3D($,0),wt=32879;else if($.isDataArrayTexture)ce.setTexture2DArray($,0),wt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,$.flipY),z.pixelStorei(37441,$.premultiplyAlpha),z.pixelStorei(3317,$.unpackAlignment);let St=z.getParameter(3314),Cn=z.getParameter(32878),ni=z.getParameter(3316),ro=z.getParameter(3315),Qa=z.getParameter(32877),Pn=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;z.pixelStorei(3314,Pn.width),z.pixelStorei(32878,Pn.height),z.pixelStorei(3316,N.min.x),z.pixelStorei(3315,N.min.y),z.pixelStorei(32877,N.min.z),ae.isDataTexture||ae.isData3DTexture?z.texSubImage3D(wt,ue,te.x,te.y,te.z,tt,at,dt,mt,Ct,Pn.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(wt,ue,te.x,te.y,te.z,tt,at,dt,mt,Pn.data)):z.texSubImage3D(wt,ue,te.x,te.y,te.z,tt,at,dt,mt,Ct,Pn),z.pixelStorei(3314,St),z.pixelStorei(32878,Cn),z.pixelStorei(3316,ni),z.pixelStorei(3315,ro),z.pixelStorei(32877,Qa),ue===0&&$.generateMipmaps&&z.generateMipmap(wt),k.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ce.setTextureCube(N,0):N.isData3DTexture?ce.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ce.setTexture2DArray(N,0):ce.setTexture2D(N,0),k.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,k.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var wx=class extends qx{};wx.prototype.isWebGL1Renderer=!0;var Ec=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Re(t),this.near=e,this.far=n}clone(){return new Ec(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},mr=class extends ht{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},xm=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=ax,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=xi()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=xi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=xi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Or=new A,ll=class{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Or.fromBufferAttribute(this,e),Or.applyMatrix4(t),this.setXYZ(e,Or.x,Or.y,Or.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Or.fromBufferAttribute(this,e),Or.applyNormalMatrix(t),this.setXYZ(e,Or.x,Or.y,Or.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Or.fromBufferAttribute(this,e),Or.transformDirection(t),this.setXYZ(e,Or.x,Or.y,Or.z);return this}setX(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=zt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=ho(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=ho(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=ho(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=ho(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=zt(e,this.array),n=zt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=zt(e,this.array),n=zt(n,this.array),r=zt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=zt(e,this.array),n=zt(n,this.array),r=zt(r,this.array),s=zt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return new Be(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new ll(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var jh=class extends ht{constructor(){super(),this.isBone=!0,this.type="Bone"}},mo=class extends qt{constructor(t=null,e=1,n=1,r,s,o,a,l,u=Dt,c=Dt,d,h){super(null,o,a,l,u,c,r,s,d,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},QA=new ie,BF=new ie,ra=class{constructor(t=[],e=[]){this.uuid=xi(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new ie)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new ie;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:BF;QA.multiplyMatrices(a,e[s]),QA.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ra(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=S_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new mo(e,t,t,oi,pr);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){let s=t.bones[n],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new jh),this.bones.push(o),this.boneInverses.push(new ie().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let r=0,s=e.length;r<s;r++){let o=e[r];t.bones.push(o.uuid);let a=n[r];t.boneInverses.push(a.toArray())}return t}},bm=class extends Be{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var wi=class extends al{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Re(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},KA=new A,ZA=new A,JA=new ie,Z0=new ji,Jp=new dn,cl=class extends ht{constructor(t=new Me,e=new wi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let r=1,s=e.count;r<s;r++)KA.fromBufferAttribute(e,r-1),ZA.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=KA.distanceTo(ZA);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,r=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Jp.copy(n.boundingSphere),Jp.applyMatrix4(r),Jp.radius+=s,t.ray.intersectsSphere(Jp)===!1)return;JA.copy(r).invert(),Z0.copy(t.ray).applyMatrix4(JA);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let y=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){let S=m.getX(x),_=m.getX(x+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,_),Z0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(h);b<t.near||b>t.far||e.push({distance:b,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),Z0.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let _=t.ray.origin.distanceTo(h);_<t.near||_>t.far||e.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},$A=new A,e_=new A,ia=class extends cl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let r=0,s=e.count;r<s;r+=2)$A.fromBufferAttribute(e,r),e_.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+$A.distanceTo(e_);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var wm=class extends qt{constructor(t,e,n,r,s,o,a,l,u){super(t,e,n,r,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Xe,this.magFilter=s!==void 0?s:Xe,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Si=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),r=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),u=n[r]-o,u<0)a=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===o)return r/(s-1);let c=n[r],h=n[r+1]-c,f=(o-c)/h;return(r+f)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),l=e||(o.isVector2?new F:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,r=[],s=[],o=[],a=new A,l=new ie;for(let f=0;f<=t;f++){let m=f/t;r[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(zn(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(r[f],s[f])}if(e===!0){let f=Math.acos(zn(s[0].dot(s[t]),-1,1));f/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],f*m)),o[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},ul=class extends Si{constructor(t=0,e=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new F,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},Sx=class extends ul{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Yx(){let i=0,t=0,e=0,n=0;function r(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){r(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+n*a}}}var $p=new A,J0=new Yx,$0=new Yx,ex=new Yx,Ax=class extends Si{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new A){let n=e,r=this.points,s=r.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=r[(a-1)%s]:($p.subVectors(r[0],r[1]).add(r[0]),u=$p);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?c=r[(a+2)%s]:($p.subVectors(r[s-1],r[s-2]).add(r[s-1]),c=$p),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(c),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),J0.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,m,p,g),$0.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,m,p,g),ex.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(J0.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),$0.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),ex.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(J0.calc(l),$0.calc(l),ex.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new A().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function t_(i,t,e,n,r){let s=(n-t)*.5,o=(r-e)*.5,a=i*i,l=i*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*i+e}function FF(i,t){let e=1-i;return e*e*t}function UF(i,t){return 2*(1-i)*i*t}function kF(i,t){return i*i*t}function Fh(i,t,e,n){return FF(i,t)+UF(i,e)+kF(i,n)}function zF(i,t){let e=1-i;return e*e*e*t}function GF(i,t){let e=1-i;return 3*e*e*i*t}function VF(i,t){return 3*(1-i)*i*i*t}function HF(i,t){return i*i*i*t}function Uh(i,t,e,n,r){return zF(i,t)+GF(i,e)+VF(i,n)+HF(i,r)}var _r=class extends Si{constructor(t=new F,e=new F,n=new F,r=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new F){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Uh(t,r.x,s.x,o.x,a.x),Uh(t,r.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},dl=class extends Si{constructor(t=new A,e=new A,n=new A,r=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Uh(t,r.x,s.x,o.x,a.x),Uh(t,r.y,s.y,o.y,a.y),Uh(t,r.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Mr=class extends Si{constructor(t=new F,e=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new F){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new F;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Wh=class extends Si{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},ci=class extends Si{constructor(t=new F,e=new F,n=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new F){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Fh(t,r.x,s.x,o.x),Fh(t,r.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},_x=class extends Si{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Fh(t,r.x,s.x,o.x),Fh(t,r.y,s.y,o.y),Fh(t,r.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Tc=class extends Si{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new F){let n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],u=r[o],c=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return n.set(t_(a,l.x,u.x,c.x,d.x),t_(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new F().fromArray(r))}return this}},jF=Object.freeze({__proto__:null,ArcCurve:Sx,CatmullRomCurve3:Ax,CubicBezierCurve:_r,CubicBezierCurve3:dl,EllipseCurve:ul,LineCurve:Mr,LineCurve3:Wh,QuadraticBezierCurve:ci,QuadraticBezierCurve3:_x,SplineCurve:Tc}),qh=class extends Si{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Mr(e,t))}getPoint(t,e){let n=t*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(e.push(c),n=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new jF[r.type]().fromJSON(r))}return this}},hl=class extends qh{constructor(t){super(),this.type="Path",this.currentPoint=new F,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Mr(this.currentPoint.clone(),new F(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){let s=new ci(this.currentPoint.clone(),new F(t,e),new F(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){let a=new _r(this.currentPoint.clone(),new F(t,e),new F(n,r),new F(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Tc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,r,s,o,a,l),this}absellipse(t,e,n,r,s,o,a,l){let u=new ul(t,e,n,r,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},Cc=class extends Me{constructor(t=[new F(0,-.5),new F(.5,0),new F(0,.5)],e=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:r},e=Math.floor(e),r=zn(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new F,f=new A,m=new A,p=new A,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let v=0;v<=e;v++){let x=n+v*c*r,w=Math.sin(x),S=Math.cos(x);for(let _=0;_<=t.length-1;_++){d.x=t[_].x*w,d.y=t[_].y,d.z=t[_].x*S,o.push(d.x,d.y,d.z),h.x=v/e,h.y=_/(t.length-1),a.push(h.x,h.y);let M=l[3*_+0]*w,b=l[3*_+1],E=l[3*_+0]*S;u.push(M,b,E)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let w=x+v*t.length,S=w,_=w+t.length,M=w+t.length+1,b=w+1;s.push(S,_,b),s.push(M,b,_)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(u,3))}static fromJSON(t){return new Cc(t.points,t.segments,t.phiStart,t.phiLength)}};var fl=class extends Me{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;r=Math.floor(r),s=Math.floor(s);let c=[],d=[],h=[],f=[],m=0,p=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function v(){let w=new A,S=new A,_=0,M=(e-t)/n;for(let b=0;b<=s;b++){let E=[],T=b/s,I=T*(e-t)+t;for(let C=0;C<=r;C++){let P=C/r,O=P*l+a,B=Math.sin(O),j=Math.cos(O);S.x=I*B,S.y=-T*n+g,S.z=I*j,d.push(S.x,S.y,S.z),w.set(B,M,j).normalize(),h.push(w.x,w.y,w.z),f.push(P,1-T),E.push(m++)}p.push(E)}for(let b=0;b<r;b++)for(let E=0;E<s;E++){let T=p[E][b],I=p[E+1][b],C=p[E+1][b+1],P=p[E][b+1];c.push(T,I,P),c.push(I,C,P),_+=6}u.addGroup(y,_,0),y+=_}function x(w){let S=m,_=new F,M=new A,b=0,E=w===!0?t:e,T=w===!0?1:-1;for(let C=1;C<=r;C++)d.push(0,g*T,0),h.push(0,T,0),f.push(.5,.5),m++;let I=m;for(let C=0;C<=r;C++){let O=C/r*l+a,B=Math.cos(O),j=Math.sin(O);M.x=E*j,M.y=g*T,M.z=E*B,d.push(M.x,M.y,M.z),h.push(0,T,0),_.x=B*.5+.5,_.y=j*.5*T+.5,f.push(_.x,_.y),m++}for(let C=0;C<r;C++){let P=S+C,O=I+C;w===!0?c.push(O,O+1,P):c.push(O+1,O,P),b+=3}u.addGroup(y,b,w===!0?1:2),y+=b}}static fromJSON(t){return new fl(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Pc=class extends fl{constructor(t=1,e=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Pc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Ic=class extends Me{constructor(t=[],e=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};let s=[],o=[];a(r),u(n),c(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,w=new A,S=new A;for(let _=0;_<e.length;_+=3)f(e[_+0],x),f(e[_+1],w),f(e[_+2],S),l(x,w,S,v)}function l(v,x,w,S){let _=S+1,M=[];for(let b=0;b<=_;b++){M[b]=[];let E=v.clone().lerp(w,b/_),T=x.clone().lerp(w,b/_),I=_-b;for(let C=0;C<=I;C++)C===0&&b===_?M[b][C]=E:M[b][C]=E.clone().lerp(T,C/I)}for(let b=0;b<_;b++)for(let E=0;E<2*(_-b)-1;E++){let T=Math.floor(E/2);E%2===0?(h(M[b][T+1]),h(M[b+1][T]),h(M[b][T])):(h(M[b][T+1]),h(M[b+1][T+1]),h(M[b+1][T]))}}function u(v){let x=new A;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,S=y(v)/Math.PI+.5;o.push(w,1-S)}m(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],S=o[v+4],_=Math.max(x,w,S),M=Math.min(x,w,S);_>.9&&M<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function h(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function m(){let v=new A,x=new A,w=new A,S=new A,_=new F,M=new F,b=new F;for(let E=0,T=0;E<s.length;E+=9,T+=6){v.set(s[E+0],s[E+1],s[E+2]),x.set(s[E+3],s[E+4],s[E+5]),w.set(s[E+6],s[E+7],s[E+8]),_.set(o[T+0],o[T+1]),M.set(o[T+2],o[T+3]),b.set(o[T+4],o[T+5]),S.copy(v).add(x).add(w).divideScalar(3);let I=g(S);p(_,T+0,v,I),p(M,T+2,x,I),p(b,T+4,w,I)}}function p(v,x,w,S){S<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new Ic(t.vertices,t.indices,t.radius,t.details)}},Dc=class extends Ic{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Dc(t.radius,t.detail)}};var go=class extends hl{constructor(t){super(t),this.uuid=xi(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new hl().fromJSON(r))}return this}},WF={triangulate:function(i,t,e=2){let n=t&&t.length,r=n?t[0]*e:i.length,s=D_(i,0,r,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=KF(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let m=e;m<r;m+=e)d=i[m],h=i[m+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return Yh(s,o,e,a,l,f,0),o}};function D_(i,t,e,n,r){let s,o;if(r===aU(i,t,e,n)>0)for(s=t;s<e;s+=n)o=n_(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=n_(s,i[s],i[s+1],o);return o&&Fm(o,o.next)&&(Qh(o),o=o.next),o}function pl(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(Fm(e,e.next)||on(e.prev,e,e.next)===0)){if(Qh(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Yh(i,t,e,n,r,s,o){if(!i)return;!o&&s&&tU(i,n,r,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?YF(i,n,r,s):qF(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),Qh(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=XF(pl(i),t,e),Yh(i,t,e,n,r,s,2)):o===2&&QF(i,t,e,n,r,s):Yh(pl(i),t,e,n,r,s,1);break}}}function qF(i){let t=i.prev,e=i,n=i.next;if(on(t,e,n)>=0)return!1;let r=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=r<s?r<o?r:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=r>s?r>o?r:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,m=n.next;for(;m!==t;){if(m.x>=c&&m.x<=h&&m.y>=d&&m.y<=f&&bc(r,a,s,l,o,u,m.x,m.y)&&on(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function YF(i,t,e,n){let r=i.prev,s=i,o=i.next;if(on(r,s,o)>=0)return!1;let a=r.x,l=s.x,u=o.x,c=r.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,m=c<d?c<h?c:h:d<h?d:h,p=a>l?a>u?a:u:l>u?l:u,g=c>d?c>h?c:h:d>h?d:h,y=Mx(f,m,t,e,n),v=Mx(p,g,t,e,n),x=i.prevZ,w=i.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&bc(a,c,l,d,u,h,x.x,x.y)&&on(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==r&&w!==o&&bc(a,c,l,d,u,h,w.x,w.y)&&on(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=m&&x.y<=g&&x!==r&&x!==o&&bc(a,c,l,d,u,h,x.x,x.y)&&on(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=p&&w.y>=m&&w.y<=g&&w!==r&&w!==o&&bc(a,c,l,d,u,h,w.x,w.y)&&on(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function XF(i,t,e){let n=i;do{let r=n.prev,s=n.next.next;!Fm(r,s)&&O_(r,n,n.next,s)&&Xh(r,s)&&Xh(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Qh(n),Qh(n.next),n=i=s),n=n.next}while(n!==i);return pl(n)}function QF(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&iU(o,a)){let l=R_(o,a);o=pl(o,o.next),l=pl(l,l.next),Yh(o,t,e,n,r,s,0),Yh(l,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function KF(i,t,e,n){let r=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:i.length,u=D_(i,a,l,n,!1),u===u.next&&(u.steiner=!0),r.push(rU(u));for(r.sort(ZF),s=0;s<r.length;s++)e=JF(r[s],e);return e}function ZF(i,t){return i.x-t.x}function JF(i,t){let e=$F(i,t);if(!e)return t;let n=R_(e,i);return pl(n,n.next),pl(e,e.next)}function $F(i,t){let e=t,n=-1/0,r,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,r=e.x<e.next.x?e:e.next,h===s))return r}e=e.next}while(e!==t);if(!r)return null;let a=r,l=r.x,u=r.y,c=1/0,d;e=r;do s>=e.x&&e.x>=l&&s!==e.x&&bc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),Xh(e,i)&&(d<c||d===c&&(e.x>r.x||e.x===r.x&&eU(r,e)))&&(r=e,c=d)),e=e.next;while(e!==a);return r}function eU(i,t){return on(i.prev,i,t.prev)<0&&on(t.next,i,i.next)<0}function tU(i,t,e,n){let r=i;do r.z===0&&(r.z=Mx(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,nU(r)}function nU(i){let t,e,n,r,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,u*=2}while(o>1);return i}function Mx(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function rU(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function bc(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function iU(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!sU(i,t)&&(Xh(i,t)&&Xh(t,i)&&oU(i,t)&&(on(i.prev,i,t.prev)||on(i,t.prev,t))||Fm(i,t)&&on(i.prev,i,i.next)>0&&on(t.prev,t,t.next)>0)}function on(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Fm(i,t){return i.x===t.x&&i.y===t.y}function O_(i,t,e,n){let r=tm(on(i,t,e)),s=tm(on(i,t,n)),o=tm(on(e,n,i)),a=tm(on(e,n,t));return!!(r!==s&&o!==a||r===0&&em(i,e,t)||s===0&&em(i,n,t)||o===0&&em(e,i,n)||a===0&&em(e,t,n))}function em(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function tm(i){return i>0?1:i<0?-1:0}function sU(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&O_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Xh(i,t){return on(i.prev,i,i.next)<0?on(i,t,i.next)>=0&&on(i,i.prev,t)>=0:on(i,t,i.prev)<0||on(i,i.next,t)<0}function oU(i,t){let e=i,n=!1,r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function R_(i,t){let e=new Ex(i.i,i.x,i.y),n=new Ex(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function n_(i,t,e,n){let r=new Ex(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Qh(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ex(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function aU(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var Oc=class{static area(t){let e=t.length,n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return Oc.area(t)<0}static triangulateShape(t,e){let n=[],r=[],s=[];r_(t),i_(n,t);let o=t.length;e.forEach(r_);for(let l=0;l<e.length;l++)r.push(o),o+=e[l].length,i_(n,e[l]);let a=WF.triangulate(n,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function r_(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function i_(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var Rc=class extends Ic{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Rc(t.radius,t.detail)}};var ml=class extends Me{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],d=new A,h=new A,f=[],m=[],p=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,w=0;y==0&&o==0?w=.5/e:y==n&&l==Math.PI&&(w=-.5/e);for(let S=0;S<=e;S++){let _=S/e;d.x=-t*Math.cos(r+_*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(r+_*s)*Math.sin(o+x*a),m.push(d.x,d.y,d.z),h.copy(d).normalize(),p.push(h.x,h.y,h.z),g.push(_+w,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],w=c[y][v],S=c[y+1][v],_=c[y+1][v+1];(y!==0||o>0)&&f.push(x,w,_),(y!==n-1||l<Math.PI)&&f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(t){return new ml(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var Lc=class extends Me{constructor(t=1,e=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],l=[],u=[],c=[],d=new A,h=new A,f=new A,m=new A,p=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let w=x/n*s*Math.PI*2;v(w,s,o,t,f),v(w+.01,s,o,t,m),g.subVectors(m,f),y.addVectors(m,f),p.crossVectors(g,y),y.crossVectors(p,g),p.normalize(),y.normalize();for(let S=0;S<=r;++S){let _=S/r*Math.PI*2,M=-e*Math.cos(_),b=e*Math.sin(_);d.x=f.x+(M*y.x+b*p.x),d.y=f.y+(M*y.y+b*p.y),d.z=f.z+(M*y.z+b*p.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(S/r)}}for(let x=1;x<=n;x++)for(let w=1;w<=r;w++){let S=(r+1)*(x-1)+(w-1),_=(r+1)*x+(w-1),M=(r+1)*x+w,b=(r+1)*(x-1)+w;a.push(S,_,b),a.push(_,M,b)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(c,2));function v(x,w,S,_,M){let b=Math.cos(x),E=Math.sin(x),T=S/w*x,I=Math.cos(T);M.x=_*(2+I)*.5*b,M.y=_*(2+I)*E*.5,M.z=_*Math.sin(T)*.5}}static fromJSON(t){return new Lc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Jo(i,t,e){return L_(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function nm(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function L_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function lU(i){function t(r,s){return i[r]-i[s]}let e=i.length,n=new Array(e);for(let r=0;r!==e;++r)n[r]=r;return n.sort(t),n}function s_(i,t,e){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=e[s]*t;for(let l=0;l!==t;++l)r[o++]=i[a+l]}return r}function N_(i,t,e,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=i[r++];while(s!==void 0)}var Nc=class{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],s=e[n-1];e:{t:{let o;n:{r:if(!(t<r)){for(let a=n+2;;){if(r===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=e[++n],t<r)break t}o=e.length;break n}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=e[--n-1],t>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(r=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r;for(let o=0;o!==r;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Tx=class extends Nc{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yc,endingEnd:yc}}intervalChanged_(t,e,n){let r=this.parameterPositions,s=t-2,o=t+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case vc:s=t,a=2*e-n;break;case cm:s=r.length-2,a=e+r[s]-r[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case vc:o=t,l=2*n-e;break;case cm:o=1,l=n+r[1]-r[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(n-e)/(r-e),p=m*m,g=p*m,y=-h*g+2*h*p-h*m,v=(1+h)*g+(-1.5-2*h)*p+(-.5+h)*m+1,x=(-1-f)*g+(1.5+f)*p+.5*m,w=f*g-f*p;for(let S=0;S!==a;++S)s[S]=y*o[c+S]+v*o[u+S]+x*o[l+S]+w*o[d+S];return s}},Sm=class extends Nc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(r-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},Cx=class extends Nc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}},Ai=class{constructor(t,e,n,r){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=nm(e,this.TimeBufferType),this.values=nm(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:nm(t.times,Array),values:nm(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Cx(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Sm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Tx(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case am:e=this.InterpolantFactoryMethodDiscrete;break;case lm:e=this.InterpolantFactoryMethodLinear;break;case E0:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return am;case this.InterpolantFactoryMethodLinear:return lm;case this.InterpolantFactoryMethodSmooth:return E0}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Jo(n,s,o),this.values=Jo(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(r!==void 0&&L_(r))for(let a=0,l=r.length;a!==l;++a){let u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Jo(this.times),e=Jo(this.values),n=this.getValueSize(),r=this.getInterpolation()===E0,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(r)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let m=0;m!==n;++m){let p=e[d+m];if(p!==e[h+m]||p!==e[f+m]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Jo(t,0,o),this.values=Jo(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=Jo(this.times,0),e=Jo(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}};Ai.prototype.TimeBufferType=Float32Array;Ai.prototype.ValueBufferType=Float32Array;Ai.prototype.DefaultInterpolation=lm;var sa=class extends Ai{};sa.prototype.ValueTypeName="bool";sa.prototype.ValueBufferType=Array;sa.prototype.DefaultInterpolation=am;sa.prototype.InterpolantFactoryMethodLinear=void 0;sa.prototype.InterpolantFactoryMethodSmooth=void 0;var Am=class extends Ai{};Am.prototype.ValueTypeName="color";var Bc=class extends Ai{};Bc.prototype.ValueTypeName="number";var Px=class extends Nc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(r-e),u=t*a;for(let c=u+a;u!==c;u+=4)qe.slerpFlat(s,0,o,u-a,o,u,l);return s}},gl=class extends Ai{InterpolantFactoryMethodLinear(t){return new Px(this.times,this.values,this.getValueSize(),t)}};gl.prototype.ValueTypeName="quaternion";gl.prototype.DefaultInterpolation=lm;gl.prototype.InterpolantFactoryMethodSmooth=void 0;var oa=class extends Ai{};oa.prototype.ValueTypeName="string";oa.prototype.ValueBufferType=Array;oa.prototype.DefaultInterpolation=am;oa.prototype.InterpolantFactoryMethodLinear=void 0;oa.prototype.InterpolantFactoryMethodSmooth=void 0;var Fc=class extends Ai{};Fc.prototype.ValueTypeName="vector";var Uc=class{constructor(t,e=-1,n,r=Vx){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=xi(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(uU(n[o]).scale(r));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=n.length;s!==o;++s)e.push(Ai.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(t,e,n,r){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],u=[];l.push((a+s-1)%s,a,(a+1)%s),u.push(0,1,0);let c=lU(l);l=s_(l,1,c),u=s_(u,1,c),!r&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new Bc(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let u=t[a],c=u.name.match(s);if(c&&c.length>1){let d=c[1],h=r[d];h||(r[d]=h=[]),h.push(u)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(d,h,f,m,p){if(f.length!==0){let g=[],y=[];N_(f,g,y,m),g.length!==0&&p.push(new d(h,g,y))}},r=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let d=0;d<u.length;d++){let h=u[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},m;for(m=0;m<h.length;m++)if(h[m].morphTargets)for(let p=0;p<h[m].morphTargets.length;p++)f[h[m].morphTargets[p]]=-1;for(let p in f){let g=[],y=[];for(let v=0;v!==h[m].morphTargets.length;++v){let x=h[m];g.push(x.time),y.push(x.morphTarget===p?1:0)}r.push(new Bc(".morphTargetInfluence["+p+"]",g,y))}l=f.length*o}else{let f=".bones["+e[d].name+"]";n(Fc,f+".position",h,"pos",r),n(gl,f+".quaternion",h,"rot",r),n(Fc,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function cU(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bc;case"vector":case"vector2":case"vector3":case"vector4":return Fc;case"color":return Am;case"quaternion":return gl;case"bool":case"boolean":return sa;case"string":return oa}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function uU(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=cU(i.type);if(i.times===void 0){let e=[],n=[];N_(i.keys,e,n,"value"),i.times=e,i.values=n}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var o_={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},Kh=class{constructor(t,e,n){let r=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&r.onStart!==void 0&&r.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,r.onProgress!==void 0&&r.onProgress(c,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],m=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return m}return null}}},dU=new Kh,kc=class{constructor(t){this.manager=t!==void 0?t:dU,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},co={},Ix=class extends Error{constructor(t,e){super(t),this.response=e}},zc=class extends kc{constructor(t){super(t)}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=o_.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(co[t]!==void 0){co[t].push({onLoad:e,onProgress:n,onError:r});return}co[t]=[],co[t].push({onLoad:e,onProgress:n,onError:r});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=co[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,m=f!==0,p=0,g=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:w})=>{if(x)y.close();else{p+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let _=0,M=c.length;_<M;_++){let b=c[_];b.onProgress&&b.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw new Ix(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(m=>f.decode(m))}}}).then(u=>{o_.add(t,u);let c=co[t];delete co[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=co[t];if(c===void 0)throw this.manager.itemError(t),u;delete co[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var aa=class extends ht{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},_m=class extends aa{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Re(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},tx=new ie,a_=new A,l_=new A,Zh=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Vh,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new We(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;a_.setFromMatrixPosition(t.matrixWorld),e.position.copy(a_),l_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(l_),e.updateMatrixWorld(),tx.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tx),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(tx)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},Dx=class extends Zh{constructor(){super(new yn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=zh*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||r!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=r,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Mm=class extends aa{constructor(t,e,n=0,r=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Dx}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},c_=new ie,Dh=new A,nx=new A,Ox=class extends Zh{constructor(){super(new yn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new We(2,1,1,1),new We(0,1,1,1),new We(3,1,1,1),new We(1,1,1,1),new We(3,0,1,1),new We(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Dh.setFromMatrixPosition(t.matrixWorld),n.position.copy(Dh),nx.copy(n.position),nx.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(nx),n.updateMatrixWorld(),r.makeTranslation(-Dh.x,-Dh.y,-Dh.z),c_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(c_)}},Em=class extends aa{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Ox}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},Rx=class extends Zh{constructor(){super(new Mc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Tm=class extends aa{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DEFAULT_UP),this.updateMatrix(),this.target=new ht,this.shadow=new Rx}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Lx=class extends Me{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Gc=class extends kc{constructor(t){super(t)}load(t,e,n,r){let s=this,o=new zc(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(t)}},n,r)}parse(t){let e={},n={};function r(f,m){if(e[m]!==void 0)return e[m];let g=f.interleavedBuffers[m],y=s(f,g.buffer),v=Rp(g.type,y),x=new xm(v,g.stride);return x.uuid=g.uuid,e[m]=x,x}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],y=new Uint32Array(g).buffer;return n[m]=y,y}let o=t.isInstancedBufferGeometry?new Lx:new Me,a=t.data.index;if(a!==void 0){let f=Rp(a.type,a.array);o.setIndex(new Be(f,1))}let l=t.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=r(t.data,m.data);p=new ll(g,m.itemSize,m.offset,m.normalized)}else{let g=Rp(m.type,m.array),y=m.isInstancedBufferAttribute?bm:Be;p=new y(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let u=t.data.morphAttributes;if(u)for(let f in u){let m=u[f],p=[];for(let g=0,y=m.length;g<y;g++){let v=m[g],x;if(v.isInterleavedBufferAttribute){let w=r(t.data,v.data);x=new ll(w,v.itemSize,v.offset,v.normalized)}else{let w=Rp(v.type,v.array);x=new Be(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),p.push(x)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,m=d.length;f!==m;++f){let p=d[f];o.addGroup(p.start,p.count,p.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new dn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Cm=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=u_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=u_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function u_(){return(typeof performance>"u"?Date:performance).now()}var Nx=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let r,s,o;switch(e){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let n=this.buffer,r=this.valueSize,s=t*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,r=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(n,r,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){a.setValue(n,r);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let s=n,o=r;s!==o;++s)e[s]=e[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,r){qe.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,s){let o=this._workIndex*s;qe.multiplyQuaternionsFlat(t,o,t,e,t,n),qe.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[n+o]*r}}},Xx="\\[\\]\\.:\\/",hU=new RegExp("["+Xx+"]","g"),Qx="[^"+Xx+"]",fU="[^"+Xx.replace("\\.","")+"]",pU=/((?:WC+[\/:])*)/.source.replace("WC",Qx),mU=/(WCOD+)?/.source.replace("WCOD",fU),gU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qx),yU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qx),vU=new RegExp("^"+pU+mU+gU+yU+"$"),xU=["material","materials","bones","map"],Bx=class{constructor(t,e,n){let r=n||It.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},It=class{constructor(t,e,n){this.path=e,this.parsedPath=n||It.parseTrackName(e),this.node=It.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new It.Composite(t,e,n):new It(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(hU,"")}static parseTrackName(t){let e=vU.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);xU.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)t[e++]=n[r]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,r=e.propertyName,s=e.propertyIndex;if(t||(t=It.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[r];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};It.Composite=Bx;It.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};It.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};It.prototype.GetterByBindingType=[It.prototype._getValue_direct,It.prototype._getValue_array,It.prototype._getValue_arrayElement,It.prototype._getValue_toArray];It.prototype.SetterByBindingTypeAndVersioning=[[It.prototype._setValue_direct,It.prototype._setValue_direct_setNeedsUpdate,It.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[It.prototype._setValue_array,It.prototype._setValue_array_setNeedsUpdate,It.prototype._setValue_array_setMatrixWorldNeedsUpdate],[It.prototype._setValue_arrayElement,It.prototype._setValue_arrayElement_setNeedsUpdate,It.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[It.prototype._setValue_fromArray,It.prototype._setValue_fromArray_setNeedsUpdate,It.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Fx=class{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:yc,endingEnd:yc};for(let u=0;u!==o;++u){let c=s[u].createInterpolant(null);a[u]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Gx,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){let r=this._clip.duration,s=t._clip.duration,o=s/r,a=r/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+n,u[0]=t/o,u[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,r){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case LR:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case Vx:default:for(let c=0,d=l.length;c!==d;++c)l[c].evaluate(o),u[c].accumulate(r,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,r=this.time+t,s=this._loopCount,o=n===$h;if(t===0)return s===-1?r:o&&(s&1)===1?e-r:r;if(n===zx){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=e)r=e;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:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=e||r<0){let a=Math.floor(r/e);r-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return e-r}return r}_setEndings(t,e,n){let r=this._interpolantSettings;n?(r.endingStart=vc,r.endingEnd=vc):(t?r.endingStart=this.zeroSlopeAtStart?vc:yc:r.endingStart=cm,e?r.endingEnd=this.zeroSlopeAtEnd?vc:yc:r.endingEnd=cm)}_scheduleFading(t,e,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}},bU=new Float32Array(1),Pm=class extends Ut{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,s=r.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let d=0;d!==s;++d){let h=r[d],f=h.name,m=c[f];if(m!==void 0)++m.referenceCount,o[d]=m;else{if(m=o[d],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}let p=e&&e._propertyBindings[d].binding.parsedPath;m=new Nx(It.create(n,f,p),h.ValueTypeName,h.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),o[d]=m}a[d].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,s=this._actionsByClip[r];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){let r=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,u=l[l.length-1],c=t._byClipCacheIndex;u._byClipCacheIndex=c,l[c]=u,l.pop(),t._byClipCacheIndex=null;let d=a.actionByRoot,h=(t._localRoot||this._root).uuid;delete d[h],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[e];o===void 0&&(o={},r[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new Sm(new Float32Array(2),new Float32Array(2),1,bU),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,s=e[r];t.__cacheIndex=r,e[r]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){let r=e||this._root,s=r.uuid,o=typeof t=="string"?Uc.findByName(r,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Vx),l!==void 0){let d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===n)return d;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new Fx(this,o,e,n);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let n=e||this._root,r=n.uuid,s=typeof t=="string"?Uc.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,n=t.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let u=o[a];this._deactivateAction(u);let c=u._cacheIndex,d=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,d._cacheIndex=c,e[c]=d,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},se=class{constructor(t){this.value=t}clone(){return new se(this.value.clone===void 0?this.value:this.value.clone())}};var Vc=class{constructor(t,e,n=0,r=1/0){this.ray=new ji(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new Gh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return Ux(t,this,n,e),n.sort(d_),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)Ux(t[r],this,n,e);return n.sort(d_),n}};function d_(i,t){return i.distance-t.distance}function Ux(i,t,e,n){if(i.layers.test(t.layers)&&i.raycast(t,e),n===!0){let r=i.children;for(let s=0,o=r.length;s<o;s++)Ux(r[s],t,e,!0)}}var Jh=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(zn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var h_=new F,Im=class{constructor(t=new F(1/0,1/0),e=new F(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=h_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return h_.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},f_=new A,rm=new A,Hn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){f_.subVectors(t,this.start),rm.subVectors(this.end,this.start);let n=rm.dot(rm),s=rm.dot(f_)/n;return e&&(s=zn(s,0,1)),s}closestPointToPoint(t,e,n){let r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},p_=new A,Dm=class extends ht{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Me,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 o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;r.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Ae(r,3));let s=new wi({fog:!1,toneMapped:!1});this.cone=new ia(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),p_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(p_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Om=class extends Dn{constructor(t,e,n){let r=new ml(e,4,2),s=new Wi({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var m_=new A,im=new A,g_=new A,Rm=class extends ht{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let r=new Me;r.setAttribute("position",new Ae([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new wi({fog:!1,toneMapped:!1});this.lightPlane=new cl(r,s),this.add(this.lightPlane),r=new Me,r.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new cl(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),m_.setFromMatrixPosition(this.light.matrixWorld),im.setFromMatrixPosition(this.light.target.matrixWorld),g_.subVectors(im,m_),this.lightPlane.lookAt(im),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(im),this.targetLine.scale.z=g_.length()}},sm=new A,un=new qi,la=class extends ia{constructor(t){let e=new Me,n=new wi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){r.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(r.length/3-1)}e.setAttribute("position",new Ae(r,3)),e.setAttribute("color",new Ae(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Re(16755200),c=new Re(16711680),d=new Re(43775),h=new Re(16777215),f=new Re(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,r=1;un.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),gn("c",e,t,un,0,0,-1),gn("t",e,t,un,0,0,1),gn("n1",e,t,un,-n,-r,-1),gn("n2",e,t,un,n,-r,-1),gn("n3",e,t,un,-n,r,-1),gn("n4",e,t,un,n,r,-1),gn("f1",e,t,un,-n,-r,1),gn("f2",e,t,un,n,-r,1),gn("f3",e,t,un,-n,r,1),gn("f4",e,t,un,n,r,1),gn("u1",e,t,un,n*.7,r*1.1,-1),gn("u2",e,t,un,-n*.7,r*1.1,-1),gn("u3",e,t,un,0,r*2,-1),gn("cf1",e,t,un,-n,0,1),gn("cf2",e,t,un,n,0,1),gn("cf3",e,t,un,0,-r,1),gn("cf4",e,t,un,0,r,1),gn("cn1",e,t,un,-n,0,-1),gn("cn2",e,t,un,n,0,-1),gn("cn3",e,t,un,0,-r,-1),gn("cn4",e,t,un,0,r,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function gn(i,t,e,n,r,s,o){sm.set(r,s,o).unproject(n);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],sm.x,sm.y,sm.z)}}var ca=class extends ia{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Me;s.setIndex(new Be(n,1)),s.setAttribute("position",new Ae(r,3)),super(s,new wi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var Lm=class extends ia{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Me;r.setAttribute("position",new Ae(e,3)),r.setAttribute("color",new Ae(n,3));let s=new wi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(t,e,n){let r=new Re,s=this.geometry.attributes.color.array;return r.set(t),r.toArray(s,0),r.toArray(s,3),r.set(e),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:yo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=yo);var Wc=".",ef=Symbol("target"),Kx=Symbol("unsubscribe");function tf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function B_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var di=Array.isArray;function yl(i){return typeof i=="symbol"}var wU={after:(i,t)=>di(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>di(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=Wc),yl(t)?i+t.toString():i+t):i,initial:i=>{if(di(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(Wc);return t===-1?"":i.slice(0,t)},last:i=>{if(di(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(Wc);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(di(i))for(let e of i)t(e);else if(i!==""){let e=0,n=i.indexOf(Wc);if(n===-1)t(i);else for(;e<i.length;)n===-1&&(n=i.length),t(i.slice(e,n)),e=n+1,n=i.indexOf(Wc,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},Nr=wU;function Zx(i){return typeof i=="object"&&typeof i.next=="function"}function Jx(i,t,e,n,r){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=r(o.value[0],t,o.value[0],n),o.value[1]=r(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[ef].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=r(a.value,t,o.next().value,n)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=r(o.value,t,o.value,n)),o};return i}function Um(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&yl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var nf=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),r=n[e];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(t,e),n[e]=r),r}getProxy(t,e,n,r){if(this.isUnsubscribed)return t;let s=t[r],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,n):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Nr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,r,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,r):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(t);r&&(delete r[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let r=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&r!==void 0&&Object.is(t.value,r.value)&&(t.writable||!1)===(r.writable||!1)&&(t.enumerable||!1)===(r.enumerable||!1)&&(t.configurable||!1)===(r.configurable||!1)&&t.get===r.get&&t.set===r.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function qc(i){return toString.call(i)==="[object Object]"}function Yc(){return!0}function ua(i,t){return i.length!==t.length||i.some((e,n)=>t[n]!==e)}var km=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var SU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),$x={push:Yc,pop:Yc,shift:Yc,unshift:Yc,copyWithin:ua,reverse:ua,sort:ua,splice:ua,flat:ua,fill:ua},F_=new Set([...km,...SU,...Object.keys($x)]);function Xc(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var eb=["keys","values","entries"],tb=new Set(["has","toString"]),nb={add:Xc,clear:Xc,delete:Xc,forEach:Xc},U_=new Set([...tb,...Object.keys(nb),...eb]);function Qc(i,t){if(i.size!==t.size)return!0;let e;for(let[n,r]of i)if(e=t.get(n),e!==r||e===void 0&&!t.has(n))return!0;return!1}var AU=new Set([...tb,"get"]),rb={set:Qc,clear:Qc,delete:Qc,forEach:Qc},k_=new Set([...AU,...Object.keys(rb),...eb]);var nr=class{constructor(t,e,n,r){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return km.has(t)}_shallowClone(t){let e=t;if(qc(t))e={...t};else if(di(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,r]of t.entries())e.set(n,this._shallowClone(r))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,r){return t?(di(r)?this._onIsChanged=$x[e]:r instanceof Set?this._onIsChanged=nb[e]:r instanceof Map&&(this._onIsChanged=rb[e]),r):n}update(t,e,n){let r=Nr.after(t,this._path);if(e!=="length"){let s=this.clone;Nr.walk(r,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:r,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],Nr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Kc=class extends nr{static isHandledMethod(t){return F_.has(t)}};var rf=class extends nr{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Zc=class extends nr{static isHandledMethod(t){return U_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var Jc=class extends nr{static isHandledMethod(t){return k_.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var sf=class extends nr{constructor(t,e,n,r){super(void 0,e,n,r),this._arg1=n[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var of=class extends nr{constructor(t,e,n,r){super(void 0,e,n,r),this._weakKey=n[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Xi=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return qc(t)||di(t)||tf(t)}static isHandledMethod(t,e){return qc(t)?nr.isHandledMethod(e):di(t)?Kc.isHandledMethod(e):t instanceof Set?Zc.isHandledMethod(e):t instanceof Map?Jc.isHandledMethod(e):tf(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let r=nr;di(t)?r=Kc:t instanceof Date?r=rf:t instanceof Set?r=Zc:t instanceof Map?r=Jc:t instanceof WeakSet?r=sf:t instanceof WeakMap&&(r=of),this._stack.push(new r(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:r}=t,s=Xi.isHandledMethod(n,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var _U={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},ib=(i,t,e={})=>{e={..._U,...e};let n=Symbol("ProxyTarget"),{equals:r,isShallow:s,ignoreDetached:o,details:a}=e,l=new nf(r),u=typeof e.onValidate=="function",c=new Xi(u),d=(v,x,w,S,_)=>!u||c.isCloning||e.onValidate(Nr.concat(l.getPath(v),x),w,S,_)===!0,h=(v,x,w,S)=>{!Um(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,_)=>{c.isCloning?c.update(v,x,S):t(Nr.concat(v,x),w,S,_)},m=v=>v&&(v[n]||v),p=(v,x,w,S)=>B_(v)||w==="constructor"||s&&!Xi.isHandledMethod(x,w)||Um(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,Nr.concat(S,w),g,n)),g={get(v,x,w){if(yl(x)){if(x===n||x===ef)return v;if(x===Kx&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=tf(v)?Reflect.get(v,x):Reflect.get(v,x,w);return p(S,v,x)},set(v,x,w,S){w=m(w);let _=v[n]||v,M=_[x];if(r(M,w)&&x in v)return!0;let b=d(v,x,w,M);return b&&l.setProperty(_,x,w,S,M)?(h(v,x,v[x],M),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];d(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&h(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=d(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(h(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&Xi.isHandledType(S)){let _=Nr.initial(l.getPath(v)),M=Xi.isHandledMethod(S,v.name);c.start(S,_,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),M?w.map(I=>m(I)):w),E=c.isChanged(S,r),T=c.stop();if(Xi.isHandledType(b)&&M&&(x instanceof Map&&v.name==="get"&&(_=Nr.concat(_,w[0])),b=l.getProxy(b,_,g)),E){let I={name:v.name,args:w,result:b},C=c.isCloning?Nr.initial(_):_,P=c.isCloning?Nr.last(_):"";d(Nr.get(i,C),P,S,T,I)?f(C,P,S,T,I):c.undo(S)}return(x instanceof Map||x instanceof Set)&&Zx(b)?Jx(b,v,x,_,p):b}return Reflect.apply(v,x,w)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};ib.target=i=>i&&i[ef]||i;ib.unsubscribe=i=>i[Kx]||i;var sb=ib;var MU=typeof global=="object"&&global&&global.Object===Object&&global,zm=MU;var EU=typeof self=="object"&&self&&self.Object===Object&&self,TU=zm||EU||Function("return this")(),hn=TU;var CU=hn.Symbol,rr=CU;var z_=Object.prototype,PU=z_.hasOwnProperty,IU=z_.toString,af=rr?rr.toStringTag:void 0;function DU(i){var t=PU.call(i,af),e=i[af];try{i[af]=void 0;var n=!0}catch{}var r=IU.call(i);return n&&(t?i[af]=e:delete i[af]),r}var G_=DU;var OU=Object.prototype,RU=OU.toString;function LU(i){return RU.call(i)}var V_=LU;var NU="[object Null]",BU="[object Undefined]",H_=rr?rr.toStringTag:void 0;function FU(i){return i==null?i===void 0?BU:NU:H_&&H_ in Object(i)?G_(i):V_(i)}var hi=FU;function UU(i){return i!=null&&typeof i=="object"}var gr=UU;var kU="[object Symbol]";function zU(i){return typeof i=="symbol"||gr(i)&&hi(i)==kU}var da=zU;function GU(i,t){for(var e=-1,n=i==null?0:i.length,r=Array(n);++e<n;)r[e]=t(i[e],e,i);return r}var Gm=GU;var VU=Array.isArray,jn=VU;var HU=1/0,j_=rr?rr.prototype:void 0,W_=j_?j_.toString:void 0;function q_(i){if(typeof i=="string")return i;if(jn(i))return Gm(i,q_)+"";if(da(i))return W_?W_.call(i):"";var t=i+"";return t=="0"&&1/i==-HU?"-0":t}var Y_=q_;var jU=/\s/;function WU(i){for(var t=i.length;t--&&jU.test(i.charAt(t)););return t}var X_=WU;var qU=/^\s+/;function YU(i){return i&&i.slice(0,X_(i)+1).replace(qU,"")}var Q_=YU;function XU(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Rn=XU;var K_=0/0,QU=/^[-+]0x[0-9a-f]+$/i,KU=/^0b[01]+$/i,ZU=/^0o[0-7]+$/i,JU=parseInt;function $U(i){if(typeof i=="number")return i;if(da(i))return K_;if(Rn(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Rn(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Q_(i);var e=KU.test(i);return e||ZU.test(i)?JU(i.slice(2),e?2:8):QU.test(i)?K_:+i}var ob=$U;function ek(i){return i}var Z_=ek;var tk="[object AsyncFunction]",nk="[object Function]",rk="[object GeneratorFunction]",ik="[object Proxy]";function sk(i){if(!Rn(i))return!1;var t=hi(i);return t==nk||t==rk||t==tk||t==ik}var Vm=sk;var ok=hn["__core-js_shared__"],Hm=ok;var J_=function(){var i=/[^.]+$/.exec(Hm&&Hm.keys&&Hm.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function ak(i){return!!J_&&J_ in i}var $_=ak;var lk=Function.prototype,ck=lk.toString;function uk(i){if(i!=null){try{return ck.call(i)}catch{}try{return i+""}catch{}}return""}var vo=uk;var dk=/[\\^$.*+?()[\]{}|]/g,hk=/^\[object .+?Constructor\]$/,fk=Function.prototype,pk=Object.prototype,mk=fk.toString,gk=pk.hasOwnProperty,yk=RegExp("^"+mk.call(gk).replace(dk,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function vk(i){if(!Rn(i)||$_(i))return!1;var t=Vm(i)?yk:hk;return t.test(vo(i))}var eM=vk;function xk(i,t){return i?.[t]}var tM=xk;function bk(i,t){var e=tM(i,t);return eM(e)?e:void 0}var Wr=bk;var wk=Wr(hn,"WeakMap"),jm=wk;var nM=Object.create,Sk=function(){function i(){}return function(t){if(!Rn(t))return{};if(nM)return nM(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),rM=Sk;function Ak(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var iM=Ak;function _k(i,t){var e=-1,n=i.length;for(t||(t=Array(n));++e<n;)t[e]=i[e];return t}var sM=_k;var Mk=800,Ek=16,Tk=Date.now;function Ck(i){var t=0,e=0;return function(){var n=Tk(),r=Ek-(n-e);if(e=n,r>0){if(++t>=Mk)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var oM=Ck;function Pk(i){return function(){return i}}var aM=Pk;var Ik=function(){try{var i=Wr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),$c=Ik;var Dk=$c?function(i,t){return $c(i,"toString",{configurable:!0,enumerable:!1,value:aM(t),writable:!0})}:Z_,lM=Dk;var Ok=oM(lM),cM=Ok;function Rk(i,t){for(var e=-1,n=i==null?0:i.length;++e<n&&t(i[e],e,i)!==!1;);return i}var uM=Rk;var Lk=9007199254740991,Nk=/^(?:0|[1-9]\d*)$/;function Bk(i,t){var e=typeof i;return t=t??Lk,!!t&&(e=="number"||e!="symbol"&&Nk.test(i))&&i>-1&&i%1==0&&i<t}var eu=Bk;function Fk(i,t,e){t=="__proto__"&&$c?$c(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Wm=Fk;function Uk(i,t){return i===t||i!==i&&t!==t}var tu=Uk;var kk=Object.prototype,zk=kk.hasOwnProperty;function Gk(i,t,e){var n=i[t];(!(zk.call(i,t)&&tu(n,e))||e===void 0&&!(t in i))&&Wm(i,t,e)}var nu=Gk;function Vk(i,t,e,n){var r=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),r?Wm(e,a,l):nu(e,a,l)}return e}var ws=Vk;var dM=Math.max;function Hk(i,t,e){return t=dM(t===void 0?i.length-1:t,0),function(){for(var n=arguments,r=-1,s=dM(n.length-t,0),o=Array(s);++r<s;)o[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=e(o),iM(i,this,a)}}var hM=Hk;var jk=9007199254740991;function Wk(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=jk}var ru=Wk;function qk(i){return i!=null&&ru(i.length)&&!Vm(i)}var qm=qk;var Yk=Object.prototype;function Xk(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Yk;return i===e}var iu=Xk;function Qk(i,t){for(var e=-1,n=Array(i);++e<i;)n[e]=t(e);return n}var fM=Qk;var Kk="[object Arguments]";function Zk(i){return gr(i)&&hi(i)==Kk}var ab=Zk;var pM=Object.prototype,Jk=pM.hasOwnProperty,$k=pM.propertyIsEnumerable,ez=ab(function(){return arguments}())?ab:function(i){return gr(i)&&Jk.call(i,"callee")&&!$k.call(i,"callee")},su=ez;function tz(){return!1}var mM=tz;var vM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,gM=vM&&typeof module=="object"&&module&&!module.nodeType&&module,nz=gM&&gM.exports===vM,yM=nz?hn.Buffer:void 0,rz=yM?yM.isBuffer:void 0,iz=rz||mM,vl=iz;var sz="[object Arguments]",oz="[object Array]",az="[object Boolean]",lz="[object Date]",cz="[object Error]",uz="[object Function]",dz="[object Map]",hz="[object Number]",fz="[object Object]",pz="[object RegExp]",mz="[object Set]",gz="[object String]",yz="[object WeakMap]",vz="[object ArrayBuffer]",xz="[object DataView]",bz="[object Float32Array]",wz="[object Float64Array]",Sz="[object Int8Array]",Az="[object Int16Array]",_z="[object Int32Array]",Mz="[object Uint8Array]",Ez="[object Uint8ClampedArray]",Tz="[object Uint16Array]",Cz="[object Uint32Array]",Kt={};Kt[bz]=Kt[wz]=Kt[Sz]=Kt[Az]=Kt[_z]=Kt[Mz]=Kt[Ez]=Kt[Tz]=Kt[Cz]=!0;Kt[sz]=Kt[oz]=Kt[vz]=Kt[az]=Kt[xz]=Kt[lz]=Kt[cz]=Kt[uz]=Kt[dz]=Kt[hz]=Kt[fz]=Kt[pz]=Kt[mz]=Kt[gz]=Kt[yz]=!1;function Pz(i){return gr(i)&&ru(i.length)&&!!Kt[hi(i)]}var xM=Pz;function Iz(i){return function(t){return i(t)}}var ou=Iz;var bM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lf=bM&&typeof module=="object"&&module&&!module.nodeType&&module,Dz=lf&&lf.exports===bM,lb=Dz&&zm.process,Oz=function(){try{var i=lf&&lf.require&&lf.require("util").types;return i||lb&&lb.binding&&lb.binding("util")}catch{}}(),xo=Oz;var wM=xo&&xo.isTypedArray,Rz=wM?ou(wM):xM,Ym=Rz;var Lz=Object.prototype,Nz=Lz.hasOwnProperty;function Bz(i,t){var e=jn(i),n=!e&&su(i),r=!e&&!n&&vl(i),s=!e&&!n&&!r&&Ym(i),o=e||n||r||s,a=o?fM(i.length,String):[],l=a.length;for(var u in i)(t||Nz.call(i,u))&&!(o&&(u=="length"||r&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||eu(u,l)))&&a.push(u);return a}var Xm=Bz;function Fz(i,t){return function(e){return i(t(e))}}var Qm=Fz;var Uz=Qm(Object.keys,Object),SM=Uz;var kz=Object.prototype,zz=kz.hasOwnProperty;function Gz(i){if(!iu(i))return SM(i);var t=[];for(var e in Object(i))zz.call(i,e)&&e!="constructor"&&t.push(e);return t}var AM=Gz;function Vz(i){return qm(i)?Xm(i):AM(i)}var au=Vz;function Hz(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var _M=Hz;var jz=Object.prototype,Wz=jz.hasOwnProperty;function qz(i){if(!Rn(i))return _M(i);var t=iu(i),e=[];for(var n in i)n=="constructor"&&(t||!Wz.call(i,n))||e.push(n);return e}var MM=qz;function Yz(i){return qm(i)?Xm(i,!0):MM(i)}var lu=Yz;var Xz=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qz=/^\w*$/;function Kz(i,t){if(jn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||da(i)?!0:Qz.test(i)||!Xz.test(i)||t!=null&&i in Object(t)}var EM=Kz;var Zz=Wr(Object,"create"),bo=Zz;function Jz(){this.__data__=bo?bo(null):{},this.size=0}var TM=Jz;function $z(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var CM=$z;var eG="__lodash_hash_undefined__",tG=Object.prototype,nG=tG.hasOwnProperty;function rG(i){var t=this.__data__;if(bo){var e=t[i];return e===eG?void 0:e}return nG.call(t,i)?t[i]:void 0}var PM=rG;var iG=Object.prototype,sG=iG.hasOwnProperty;function oG(i){var t=this.__data__;return bo?t[i]!==void 0:sG.call(t,i)}var IM=oG;var aG="__lodash_hash_undefined__";function lG(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=bo&&t===void 0?aG:t,this}var DM=lG;function cu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}cu.prototype.clear=TM;cu.prototype.delete=CM;cu.prototype.get=PM;cu.prototype.has=IM;cu.prototype.set=DM;var cb=cu;function cG(){this.__data__=[],this.size=0}var OM=cG;function uG(i,t){for(var e=i.length;e--;)if(tu(i[e][0],t))return e;return-1}var ha=uG;var dG=Array.prototype,hG=dG.splice;function fG(i){var t=this.__data__,e=ha(t,i);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():hG.call(t,e,1),--this.size,!0}var RM=fG;function pG(i){var t=this.__data__,e=ha(t,i);return e<0?void 0:t[e][1]}var LM=pG;function mG(i){return ha(this.__data__,i)>-1}var NM=mG;function gG(i,t){var e=this.__data__,n=ha(e,i);return n<0?(++this.size,e.push([i,t])):e[n][1]=t,this}var BM=gG;function uu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}uu.prototype.clear=OM;uu.prototype.delete=RM;uu.prototype.get=LM;uu.prototype.has=NM;uu.prototype.set=BM;var fa=uu;var yG=Wr(hn,"Map"),pa=yG;function vG(){this.size=0,this.__data__={hash:new cb,map:new(pa||fa),string:new cb}}var FM=vG;function xG(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var UM=xG;function bG(i,t){var e=i.__data__;return UM(t)?e[typeof t=="string"?"string":"hash"]:e.map}var ma=bG;function wG(i){var t=ma(this,i).delete(i);return this.size-=t?1:0,t}var kM=wG;function SG(i){return ma(this,i).get(i)}var zM=SG;function AG(i){return ma(this,i).has(i)}var GM=AG;function _G(i,t){var e=ma(this,i),n=e.size;return e.set(i,t),this.size+=e.size==n?0:1,this}var VM=_G;function du(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}du.prototype.clear=FM;du.prototype.delete=kM;du.prototype.get=zM;du.prototype.has=GM;du.prototype.set=VM;var xl=du;var MG="Expected a function";function ub(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(MG);var e=function(){var n=arguments,r=t?t.apply(this,n):n[0],s=e.cache;if(s.has(r))return s.get(r);var o=i.apply(this,n);return e.cache=s.set(r,o)||s,o};return e.cache=new(ub.Cache||xl),e}ub.Cache=xl;var HM=ub;var EG=500;function TG(i){var t=HM(i,function(n){return e.size===EG&&e.clear(),n}),e=t.cache;return t}var jM=TG;var CG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,PG=/\\(\\)?/g,IG=jM(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(CG,function(e,n,r,s){t.push(r?s.replace(PG,"$1"):n||e)}),t}),WM=IG;function DG(i){return i==null?"":Y_(i)}var qM=DG;function OG(i,t){return jn(i)?i:EM(i,t)?[i]:WM(qM(i))}var _i=OG;var RG=1/0;function LG(i){if(typeof i=="string"||da(i))return i;var t=i+"";return t=="0"&&1/i==-RG?"-0":t}var ga=LG;function NG(i,t){t=_i(t,i);for(var e=0,n=t.length;i!=null&&e<n;)i=i[ga(t[e++])];return e&&e==n?i:void 0}var Km=NG;function BG(i,t){for(var e=-1,n=t.length,r=i.length;++e<n;)i[r+e]=t[e];return i}var hu=BG;var YM=rr?rr.isConcatSpreadable:void 0;function FG(i){return jn(i)||su(i)||!!(YM&&i&&i[YM])}var XM=FG;function QM(i,t,e,n,r){var s=-1,o=i.length;for(e||(e=XM),r||(r=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?QM(a,t-1,e,n,r):hu(r,a):n||(r[r.length]=a)}return r}var KM=QM;function UG(i){var t=i==null?0:i.length;return t?KM(i,1):[]}var ZM=UG;function kG(i){return cM(hM(i,void 0,ZM),i+"")}var Zm=kG;var zG=Qm(Object.getPrototypeOf,Object),fu=zG;var GG="[object Object]",VG=Function.prototype,HG=Object.prototype,JM=VG.toString,jG=HG.hasOwnProperty,WG=JM.call(Object);function qG(i){if(!gr(i)||hi(i)!=GG)return!1;var t=fu(i);if(t===null)return!0;var e=jG.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&JM.call(e)==WG}var $M=qG;function YG(i,t,e){var n=-1,r=i.length;t<0&&(t=-t>r?0:r+t),e=e>r?r:e,e<0&&(e+=r),r=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(r);++n<r;)s[n]=i[n+t];return s}var eE=YG;function XG(){this.__data__=new fa,this.size=0}var tE=XG;function QG(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var nE=QG;function KG(i){return this.__data__.get(i)}var rE=KG;function ZG(i){return this.__data__.has(i)}var iE=ZG;var JG=200;function $G(i,t){var e=this.__data__;if(e instanceof fa){var n=e.__data__;if(!pa||n.length<JG-1)return n.push([i,t]),this.size=++e.size,this;e=this.__data__=new xl(n)}return e.set(i,t),this.size=e.size,this}var sE=$G;function pu(i){var t=this.__data__=new fa(i);this.size=t.size}pu.prototype.clear=tE;pu.prototype.delete=nE;pu.prototype.get=rE;pu.prototype.has=iE;pu.prototype.set=sE;var mu=pu;function eV(i,t){return i&&ws(t,au(t),i)}var oE=eV;function tV(i,t){return i&&ws(t,lu(t),i)}var aE=tV;var dE=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lE=dE&&typeof module=="object"&&module&&!module.nodeType&&module,nV=lE&&lE.exports===dE,cE=nV?hn.Buffer:void 0,uE=cE?cE.allocUnsafe:void 0;function rV(i,t){if(t)return i.slice();var e=i.length,n=uE?uE(e):new i.constructor(e);return i.copy(n),n}var hE=rV;function iV(i,t){for(var e=-1,n=i==null?0:i.length,r=0,s=[];++e<n;){var o=i[e];t(o,e,i)&&(s[r++]=o)}return s}var fE=iV;function sV(){return[]}var Jm=sV;var oV=Object.prototype,aV=oV.propertyIsEnumerable,pE=Object.getOwnPropertySymbols,lV=pE?function(i){return i==null?[]:(i=Object(i),fE(pE(i),function(t){return aV.call(i,t)}))}:Jm,gu=lV;function cV(i,t){return ws(i,gu(i),t)}var mE=cV;var uV=Object.getOwnPropertySymbols,dV=uV?function(i){for(var t=[];i;)hu(t,gu(i)),i=fu(i);return t}:Jm,$m=dV;function hV(i,t){return ws(i,$m(i),t)}var gE=hV;function fV(i,t,e){var n=t(i);return jn(i)?n:hu(n,e(i))}var eg=fV;function pV(i){return eg(i,au,gu)}var cf=pV;function mV(i){return eg(i,lu,$m)}var tg=mV;var gV=Wr(hn,"DataView"),ng=gV;var yV=Wr(hn,"Promise"),rg=yV;var vV=Wr(hn,"Set"),ig=vV;var yE="[object Map]",xV="[object Object]",vE="[object Promise]",xE="[object Set]",bE="[object WeakMap]",wE="[object DataView]",bV=vo(ng),wV=vo(pa),SV=vo(rg),AV=vo(ig),_V=vo(jm),bl=hi;(ng&&bl(new ng(new ArrayBuffer(1)))!=wE||pa&&bl(new pa)!=yE||rg&&bl(rg.resolve())!=vE||ig&&bl(new ig)!=xE||jm&&bl(new jm)!=bE)&&(bl=function(i){var t=hi(i),e=t==xV?i.constructor:void 0,n=e?vo(e):"";if(n)switch(n){case bV:return wE;case wV:return yE;case SV:return vE;case AV:return xE;case _V:return bE}return t});var wo=bl;var MV=Object.prototype,EV=MV.hasOwnProperty;function TV(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&EV.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var SE=TV;var CV=hn.Uint8Array,yu=CV;function PV(i){var t=new i.constructor(i.byteLength);return new yu(t).set(new yu(i)),t}var vu=PV;function IV(i,t){var e=t?vu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var AE=IV;var DV=/\w*$/;function OV(i){var t=new i.constructor(i.source,DV.exec(i));return t.lastIndex=i.lastIndex,t}var _E=OV;var ME=rr?rr.prototype:void 0,EE=ME?ME.valueOf:void 0;function RV(i){return EE?Object(EE.call(i)):{}}var TE=RV;function LV(i,t){var e=t?vu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var CE=LV;var NV="[object Boolean]",BV="[object Date]",FV="[object Map]",UV="[object Number]",kV="[object RegExp]",zV="[object Set]",GV="[object String]",VV="[object Symbol]",HV="[object ArrayBuffer]",jV="[object DataView]",WV="[object Float32Array]",qV="[object Float64Array]",YV="[object Int8Array]",XV="[object Int16Array]",QV="[object Int32Array]",KV="[object Uint8Array]",ZV="[object Uint8ClampedArray]",JV="[object Uint16Array]",$V="[object Uint32Array]";function e4(i,t,e){var n=i.constructor;switch(t){case HV:return vu(i);case NV:case BV:return new n(+i);case jV:return AE(i,e);case WV:case qV:case YV:case XV:case QV:case KV:case ZV:case JV:case $V:return CE(i,e);case FV:return new n;case UV:case GV:return new n(i);case kV:return _E(i);case zV:return new n;case VV:return TE(i)}}var PE=e4;function t4(i){return typeof i.constructor=="function"&&!iu(i)?rM(fu(i)):{}}var IE=t4;var n4="[object Map]";function r4(i){return gr(i)&&wo(i)==n4}var DE=r4;var OE=xo&&xo.isMap,i4=OE?ou(OE):DE,RE=i4;var s4="[object Set]";function o4(i){return gr(i)&&wo(i)==s4}var LE=o4;var NE=xo&&xo.isSet,a4=NE?ou(NE):LE,BE=a4;var l4=1,c4=2,u4=4,FE="[object Arguments]",d4="[object Array]",h4="[object Boolean]",f4="[object Date]",p4="[object Error]",UE="[object Function]",m4="[object GeneratorFunction]",g4="[object Map]",y4="[object Number]",kE="[object Object]",v4="[object RegExp]",x4="[object Set]",b4="[object String]",w4="[object Symbol]",S4="[object WeakMap]",A4="[object ArrayBuffer]",_4="[object DataView]",M4="[object Float32Array]",E4="[object Float64Array]",T4="[object Int8Array]",C4="[object Int16Array]",P4="[object Int32Array]",I4="[object Uint8Array]",D4="[object Uint8ClampedArray]",O4="[object Uint16Array]",R4="[object Uint32Array]",Yt={};Yt[FE]=Yt[d4]=Yt[A4]=Yt[_4]=Yt[h4]=Yt[f4]=Yt[M4]=Yt[E4]=Yt[T4]=Yt[C4]=Yt[P4]=Yt[g4]=Yt[y4]=Yt[kE]=Yt[v4]=Yt[x4]=Yt[b4]=Yt[w4]=Yt[I4]=Yt[D4]=Yt[O4]=Yt[R4]=!0;Yt[p4]=Yt[UE]=Yt[S4]=!1;function sg(i,t,e,n,r,s){var o,a=t&l4,l=t&c4,u=t&u4;if(e&&(o=r?e(i,n,r,s):e(i)),o!==void 0)return o;if(!Rn(i))return i;var c=jn(i);if(c){if(o=SE(i),!a)return sM(i,o)}else{var d=wo(i),h=d==UE||d==m4;if(vl(i))return hE(i,a);if(d==kE||d==FE||h&&!r){if(o=l||h?{}:IE(i),!a)return l?gE(i,aE(o,i)):mE(i,oE(o,i))}else{if(!Yt[d])return r?i:{};o=PE(i,d,a)}}s||(s=new mu);var f=s.get(i);if(f)return f;s.set(i,o),BE(i)?i.forEach(function(g){o.add(sg(g,t,e,g,i,s))}):RE(i)&&i.forEach(function(g,y){o.set(y,sg(g,t,e,y,i,s))});var m=u?l?tg:cf:l?lu:au,p=c?void 0:m(i);return uM(p||i,function(g,y){p&&(y=g,g=i[y]),nu(o,y,sg(g,t,e,y,i,s))}),o}var og=sg;var L4=1,N4=4;function B4(i){return og(i,L4|N4)}var So=B4;var F4="__lodash_hash_undefined__";function U4(i){return this.__data__.set(i,F4),this}var zE=U4;function k4(i){return this.__data__.has(i)}var GE=k4;function ag(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new xl;++t<e;)this.add(i[t])}ag.prototype.add=ag.prototype.push=zE;ag.prototype.has=GE;var VE=ag;function z4(i,t){for(var e=-1,n=i==null?0:i.length;++e<n;)if(t(i[e],e,i))return!0;return!1}var HE=z4;function G4(i,t){return i.has(t)}var jE=G4;var V4=1,H4=2;function j4(i,t,e,n,r,s){var o=e&V4,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var d=-1,h=!0,f=e&H4?new VE:void 0;for(s.set(i,t),s.set(t,i);++d<a;){var m=i[d],p=t[d];if(n)var g=o?n(p,m,d,t,i,s):n(m,p,d,i,t,s);if(g!==void 0){if(g)continue;h=!1;break}if(f){if(!HE(t,function(y,v){if(!jE(f,v)&&(m===y||r(m,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(m===p||r(m,p,e,n,s))){h=!1;break}}return s.delete(i),s.delete(t),h}var lg=j4;function W4(i){var t=-1,e=Array(i.size);return i.forEach(function(n,r){e[++t]=[r,n]}),e}var WE=W4;function q4(i){var t=-1,e=Array(i.size);return i.forEach(function(n){e[++t]=n}),e}var qE=q4;var Y4=1,X4=2,Q4="[object Boolean]",K4="[object Date]",Z4="[object Error]",J4="[object Map]",$4="[object Number]",eH="[object RegExp]",tH="[object Set]",nH="[object String]",rH="[object Symbol]",iH="[object ArrayBuffer]",sH="[object DataView]",YE=rr?rr.prototype:void 0,db=YE?YE.valueOf:void 0;function oH(i,t,e,n,r,s,o){switch(e){case sH:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case iH:return!(i.byteLength!=t.byteLength||!s(new yu(i),new yu(t)));case Q4:case K4:case $4:return tu(+i,+t);case Z4:return i.name==t.name&&i.message==t.message;case eH:case nH:return i==t+"";case J4:var a=WE;case tH:var l=n&Y4;if(a||(a=qE),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;n|=X4,o.set(i,t);var c=lg(a(i),a(t),n,r,s,o);return o.delete(i),c;case rH:if(db)return db.call(i)==db.call(t)}return!1}var XE=oH;var aH=1,lH=Object.prototype,cH=lH.hasOwnProperty;function uH(i,t,e,n,r,s){var o=e&aH,a=cf(i),l=a.length,u=cf(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:cH.call(t,h)))return!1}var f=s.get(i),m=s.get(t);if(f&&m)return f==t&&m==i;var p=!0;s.set(i,t),s.set(t,i);for(var g=o;++d<l;){h=a[d];var y=i[h],v=t[h];if(n)var x=o?n(v,y,h,t,i,s):n(y,v,h,i,t,s);if(!(x===void 0?y===v||r(y,v,e,n,s):x)){p=!1;break}g||(g=h=="constructor")}if(p&&!g){var w=i.constructor,S=t.constructor;w!=S&&"constructor"in i&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(p=!1)}return s.delete(i),s.delete(t),p}var QE=uH;var dH=1,KE="[object Arguments]",ZE="[object Array]",cg="[object Object]",hH=Object.prototype,JE=hH.hasOwnProperty;function fH(i,t,e,n,r,s){var o=jn(i),a=jn(t),l=o?ZE:wo(i),u=a?ZE:wo(t);l=l==KE?cg:l,u=u==KE?cg:u;var c=l==cg,d=u==cg,h=l==u;if(h&&vl(i)){if(!vl(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new mu),o||Ym(i)?lg(i,t,e,n,r,s):XE(i,t,l,e,n,r,s);if(!(e&dH)){var f=c&&JE.call(i,"__wrapped__"),m=d&&JE.call(t,"__wrapped__");if(f||m){var p=f?i.value():i,g=m?t.value():t;return s||(s=new mu),r(p,g,e,n,s)}}return h?(s||(s=new mu),QE(i,t,e,n,r,s)):!1}var $E=fH;function eT(i,t,e,n,r){return i===t?!0:i==null||t==null||!gr(i)&&!gr(t)?i!==i&&t!==t:$E(i,t,e,n,eT,r)}var tT=eT;function pH(i,t){return i!=null&&t in Object(i)}var nT=pH;function mH(i,t,e){t=_i(t,i);for(var n=-1,r=t.length,s=!1;++n<r;){var o=ga(t[n]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++n!=r?s:(r=i==null?0:i.length,!!r&&ru(r)&&eu(o,r)&&(jn(i)||su(i)))}var rT=mH;function gH(i,t){return i!=null&&rT(i,t,nT)}var iT=gH;var yH=function(){return hn.Date.now()},ug=yH;var vH="Expected a function",xH=Math.max,bH=Math.min;function wH(i,t,e){var n,r,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof i!="function")throw new TypeError(vH);t=ob(t)||0,Rn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?xH(ob(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(_){var M=n,b=r;return n=r=void 0,u=_,o=i.apply(b,M),o}function m(_){return u=_,a=setTimeout(y,t),c?f(_):o}function p(_){var M=_-l,b=_-u,E=t-M;return d?bH(E,s-b):E}function g(_){var M=_-l,b=_-u;return l===void 0||M>=t||M<0||d&&b>=s}function y(){var _=ug();if(g(_))return v(_);a=setTimeout(y,p(_))}function v(_){return a=void 0,h&&n?f(_):(n=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0}function w(){return a===void 0?o:v(ug())}function S(){var _=ug(),M=g(_);if(n=arguments,r=this,l=_,M){if(a===void 0)return m(l);if(d)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return S.cancel=x,S.flush=w,S}var wl=wH;function SH(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var sT=SH;function AH(i,t){return t.length<2?i:Km(i,eE(t,0,-1))}var oT=AH;function _H(i,t){return tT(i,t)}var Sl=_H;function MH(i,t){return t=_i(t,i),i=oT(i,t),i==null||delete i[ga(sT(t))]}var aT=MH;function EH(i){return $M(i)?void 0:i}var lT=EH;var TH=1,CH=2,PH=4,IH=Zm(function(i,t){var e={};if(i==null)return e;var n=!1;t=Gm(t,function(s){return s=_i(s,i),n||(n=s.length>1),s}),ws(i,tg(i),e),n&&(e=og(e,TH|CH|PH,lT));for(var r=t.length;r--;)aT(e,t[r]);return e}),xu=IH;function DH(i,t,e,n){if(!Rn(i))return i;t=_i(t,i);for(var r=-1,s=t.length,o=s-1,a=i;a!=null&&++r<s;){var l=ga(t[r]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(r!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Rn(c)?c:eu(t[r+1])?[]:{})}nu(a,l,u),a=a[l]}return i}var cT=DH;function OH(i,t,e){for(var n=-1,r=t.length,s={};++n<r;){var o=t[n],a=Km(i,o);e(a,o)&&cT(s,_i(o,i),a)}return s}var uT=OH;function RH(i,t){return uT(i,t,function(e,n){return iT(i,n)})}var dT=RH;var LH=Zm(function(i,t){return i==null?{}:dT(i,t)}),Qi=LH;var NH="Expected a function";function BH(i,t,e){var n=!0,r=!0;if(typeof i!="function")throw new TypeError(NH);return Rn(e)&&(n="leading"in e?!!e.leading:n,r="trailing"in e?!!e.trailing:r),wl(i,t,{leading:n,maxWait:t,trailing:r})}var hb=BH;function hT(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ki(i,t){return Object.setPrototypeOf(i,t),i}var FH=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),UH=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),kH=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Al&&"ontouchend"in document,zH=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,GH=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,VH=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},HH=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},jte=FH(),Al=UH(),dg=kH(),fT=zH(),Wn=GH(),fb=VH(),pb=Number(HH());function hg(i){return Array.isArray(i)?i:[i]}function pT(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function uf(i){return Al?i.metaKey:i.ctrlKey}var ke=[],pg={},df={},fg={};function mT(i){ke.includes(i)||ke.push(i)}function bu(i){delete pg[i.pointerId];for(let t=0;t<ke.length;t++)if(ke[t].pointerId===i.pointerId){ke.splice(t,1);break}}function gT(){ke.splice(0,ke.length)}function mg(i){if(i.pointerType!=="touch")return;let t=pg[i.pointerId];t===void 0&&(t={x:0,y:0},pg[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function gg(i){let t=i.pointerId===ke[0].pointerId?ke[1]:ke[0];return pg[t.pointerId]}function yT(i){df[i.key]=!0,fg[i.key]=fg[i.key]===void 0?1:fg[i.key]+1}function vT(i){if(Al&&df.Meta)for(let t in df)df[t]=!1;else df[i.key]=!1;fg={}}function xT(i){i.addEventListener("pointerdown",mT,!0),i.addEventListener("pointerdown",mg,!0),i.addEventListener("pointermove",mg,!0),i.addEventListener("pointerup",bu,!0),i.addEventListener("pointercancel",bu,!0),i.addEventListener("pointerleave",bu,!0),window.addEventListener("keydown",yT,!0),window.addEventListener("keyup",vT,!0)}function bT(i){i.removeEventListener("pointerdown",mT,!0),i.removeEventListener("pointerdown",mg,!0),i.removeEventListener("pointermove",mg,!0),i.removeEventListener("pointerup",bu,!0),i.removeEventListener("pointercancel",bu,!0),i.removeEventListener("pointerleave",bu,!0),window.removeEventListener("keydown",yT,!0),window.removeEventListener("keyup",vT,!0)}var wT,ST=new Promise(i=>{wT=i});var yg;function AT(){if(yg)return yg;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.402/build",[n,r]=await Promise.all([import("./navmesh.js"),fetch(`${e}/navmesh.wasm`).then(a=>a.arrayBuffer())]),s=n.default,o=await s({wasmBinary:r});wT(o)}return yg=i(),yg}var _T,MT=new Promise(i=>{_T=i});var vg;function ET(){if(vg)return vg;async function i(){let t=await import("./physics.js");await t.init(),_T(t)}return vg=i(),vg}var kt=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,kt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let n=e[t.id],r;n===void 0?r={type:2,id:t.id}:r={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,kt.prototype),{data:a,actual:t,reverse:r}}else if(t.type===2){let{id:n}=t,r=e[n];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,kt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:r}}}}return null}};function hf(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let n=i[e];n&&typeof n=="object"&&hf(n)}return Object.freeze(i)}function TT(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var wu=class extends Error{};function xg(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ss(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let n=[],r=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*r;n.push(o)}return n}function Su(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function CT(){return typeof process<"u"}function PT(i,t){for(let e of i)t(e.id,e.data)!==!0&&PT(e.children,t)}function IT(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)IT(e,t)}var tn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,tn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hf(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let r of e.children)this.fillCaches0(r,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,n){if(!this.has(e))return!0;for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}rootAcestor(e){for(;e;){let n=this.parent(e);if(n)e=n;else return e}return e}isDescendantOf(e,n){for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}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,n){if(e===null)this.traverse(n);else{let r=this.get(e);r&&IT(r,n)}}traverse(e){PT(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,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let r=e,s=n;for(;r!==null;){let a=s,l=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,tn.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:n}){if(this.get(e)!==void 0)return!0;for(let r of n)if(this.checkDuplicatedIdRec(r))return!0;return!1}addOp(e){let{parent:n,fi:r,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:r,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let r=this.parent(n);if(r===void 0)return null;let s=this.childrenArray(r),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(r,s),actual:e,reverse:{type:7,...a,parent:r}}}}moveOp(e){let{parent:n,fi:r,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new wu("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:r},l=[...l,c],l.sort((f,m)=>f.fi-m.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let r=null;for(let s of this.childrenArray(e)){if(s.id===n)return r;r=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)+1;if(s<r.length)return r[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(r[s].id):n}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push({...r,...s})}n.sort((r,s)=>TT(r.sortKey,s.sortKey));for(let r of n)delete r.sortKey;return n}getWithSortKey(e){var n=e;let r=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)r.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:r}}}insertBeforeHelper(e,n,r){return this.insertAfterHelper(e,this.previous(e,n),r)}insertAfterHelper(e,n,r){let s=this.childrenArray(e);if(n===null){if(s.length===0)return Ss(0,r,r);{let o=s[0].fi;return Ss(o-r,o,r)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ss(l,l+r,r)}else return Ss(o.fi,a.fi,r)}}};var Au;(t=>{function i(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let r=n.props,s={},o=[...e],a=!1;if(r)for(let l of Object.keys(r)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=r[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let r=n.props,s={},o={...e},a=!1;if(r)for(let l of Object.keys(r)){s[l]=o[l];let u=r[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=i})(Au||(Au={}));var ze=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ze.prototype)}deepFreeze(){let e=0;for(;e<this.length;)hf(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,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,ze.prototype);let n=e;return CT()||n.fillCaches(),n}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:n,id:r,data:s}=e,o=this,a={fi:n,id:r,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:r}}}deleteOp(e){let{id:n}=e,r=this,s=r.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,r=[...r];let o=r.splice(s,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:r}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===r);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let r of this){if(r.id===e)return n;n=r.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let r=this;if(e===null){if(r.length===0)return Ss(0,n,n);{let s=r[0].fi;return Ss(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=r.find(a=>a.fi>s.fi);if(o===void 0){let a=r[r.length-1].fi;return Ss(a,a+n,n)}else return Ss(s.fi,o.fi,n)}}};function _u(i){return i&&typeof i=="object"&&i instanceof nn}var nn=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,r=0,s={};for(;r<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[r]],n!==void 0&&!_u(n))return null;r+=1}n=n?xg(n):new nn;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;r>0;){if(Object.keys(n).length===0){let l=e[r-1];l&&(n=xg(l),delete n[t.path[r-1]])}else{let l=e[r-1];if(l){let u=xg(l);u[t.path[r-1]]=n,n=u}else{let u=new nn;u[t.path[r-1]]=n,n=u}}r-=1}let o=Object.setPrototypeOf(n,nn.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},As;(n=>{function i(r,s){return ff(r,s)??r}n.apply=i;function t(r,s){return gb(r,s)}n.merge=t;function e(r,s){let o=0,a=s.path,l=r;for(;o<a.length&&l!==void 0;){if(l=Br.zoomOnce(l,a[o]),l===void 0)return s;if(!_u(l))return;o+=1}if(l===void 0)return s;if(!!_u(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=mb([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(As||(As={}));function mb(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=ff(r.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=r.data),r.children){let a=mb(r.children,t);return a!==void 0?e=!0:a=r.children,{...r,id:s,data:o,children:a}}else return{...r,id:s,data:o}});if(e)return n}function jH(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=ff(r.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=r.data),{...r,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function ff(i,t){if(!_u(t))return t;if(i instanceof tn){let e=mb(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof ze)return jH(i,t);if(Array.isArray(i)){let e=!1,n=i.map((r,s)=>{let o=ff(r,t[s]);return e=e||o!==void 0,o===void 0&&(o=r),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else{if(i instanceof nn)return gb(i,t);if(i&&typeof i=="object"){let e={},n=!1;for(let[r,s]of Object.entries(i)){let o=ff(s,t[r]);n=n||o!==void 0,o===void 0&&(o=s),e[r]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function gb(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!_u(t))return t;if(!_u(i))return As.apply(i,t);let e=new Set;for(let r of Object.keys(i))e.add(r);for(let r of Object.keys(t))e.add(r);let n=new nn;for(let r of e){let s=gb(i===void 0?void 0:i[r],t===void 0?void 0:t[r]);n[r]=s}return n}function DT(i,t){let e={cur:[],result:[],len:0};return i=pf(i,t,e)??i,[i,e.result]}function bg(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function wg(i){i&&(i.len-=1)}function WH(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function OT(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=pf(s.data,t,bg(e,o));wg(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=OT(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return r}function qH(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=pf(s.data,t,bg(e,o));return wg(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function pf(i,t,e){if(i instanceof tn){let n=OT(i,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}else{if(i instanceof ze)return qH(i,t,e);if(Array.isArray(i)){let n=!1,r=i.map((s,o)=>{let a=pf(s,t,bg(e,o));return wg(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(i&&typeof i=="object"&&!Su(i)){let n={},r=!1;for(let[s,o]of Object.entries(i))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");r=!0,s=a}let l=pf(o,t,bg(e,s));wg(e),r=r||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(typeof i=="string"){let n=t[i];if(n!==void 0){if(i.length!==36)throw new Error("for now you should only call this method when the key is a uuid");WH(e)}return n}else return}}var Sg;(t=>{function i(e,n){let r=Br.zoom(n,e.path);if(typeof r=="object"){let s={};for(let o of Object.keys(e.props))s[o]=r[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(Sg||(Sg={}));var yr;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof nn&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof tn||l instanceof ze||l instanceof kt?h=l.runOp(u):h=Au.runOp(l,u)),h!==void 0)if(h!==null){let p=h.data;for(let g=d.length-1;g>=0;g--){let y=c[g],v=d[g];if(v instanceof tn){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof ze){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof kt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof nn){let x={...v,[y]:p};p=Object.setPrototypeOf(x,nn.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=p;p=[...v],p[y]=x}else p={...v,[y]:p};else return null}return{data:p,actual:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],m;if(l instanceof tn){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof ze){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)d.push(l),l=m;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function r(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=r;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&r(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(yr||(yr={}));var yb;(l=>{function i(){return[]}l.empty=i;function t(u,c){let d=[];for(let h of u){let[f,...m]=h.path;f===c&&d.push({...h,path:m})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function r(u,c){return[...u.filter(h=>!c.some(f=>yr.subsumed(h,f))),...c]}l.compress=r;function s(u,c){return u.every(d=>c.every(h=>yr.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],f=[];for(let m of c)try{if(m.type===3){let p=Br.zoom(d,[...m.path,m.id]),g=yr.apply(d,{...m,type:2});if(g!==null){d=g.data;let[y,v]=DT(d,{[m.id]:p});d=y;for(let x of v){let w=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[w]:p}}),f.push({type:0,path:x,props:{[w]:m.id}})}f.push(g.reverse),h.push(g.actual)}}else{let p=yr.apply(d,m);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof wu)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(yb||(yb={}));var RT=Symbol(),YH=Symbol(),_g=Symbol(),_l=class{reportOp(t,e,n=[]){let r=this;if(e===null)return;r._current=e.data;let s=n;for(;!(r instanceof Ag);){let o=r._path,a=r._current;if(o!==""&&s.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[_g];n&&n(),delete this._children[t]}}}},xb=class extends _l{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Au.runOp(this._current,t),t.path)}},bb=class extends _l{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,kt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},LT={get(i,t){if(t===_g)return()=>{i._parent=null};if(t===RT)return i._current;if(t===YH)return i;let{_current:e,_children:n}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e[t],o=Mg(i,t,s);return o!==s?(n===void 0&&(n={},i._children=n),n[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},XH={...LT,set(i,t,e){let n={type:0,props:{[t]:Ln(e)??e}};return i.deleteChildren(t),i.runOp(n),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},QH={...LT,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},Mu=class extends _l{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[_g]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Mg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,r,s){this.runOp({type:7,parent:t,fi:e,id:n,data:r,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}moveBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Eu=class extends _l{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[_g]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),r,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=Mg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function vb(i,t,e){if(i.length>0){let n=i[i.length-1];if(n.type===0&&t.type===0&&Br.equal(n.path,e)){Object.assign(n.props,t.props);return}}i.push({...t,path:e})}var Ag=class extends _l{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,n,r){vb(this.ts,e,t),vb(this.actual,n,t),vb(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Mg(i,t,e){return e instanceof tn?new Mu(i,t,e):e instanceof ze?new Eu(i,t,e):e instanceof kt?new Proxy(new bb(i,t,e),QH):e!==null&&typeof e=="object"?Su(e)?e:new Proxy(new xb(i,t,e),XH):e}function wb(i){let t=new Ag(i);return[Mg(t,"",i),t]}function Tu(i,t){let[e,n]=wb(i);return t(e),n.result()}function Ln(i){return i instanceof Mu||i instanceof Eu?i._current:i!==null&&typeof i=="object"?i[RT]:i}var Br;(r=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}r.equal=i;function t(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}r.removeOverridden=t;function e(s,o){if((s instanceof tn||s instanceof Mu)&&typeof o=="string")return s.data(o);if((s instanceof ze||s instanceof Eu)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}r.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}r.zoom=n})(Br||(Br={}));function NT(i,t){let e=[];if(t.length===i.length)for(var n=0;n<i.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}function Tr(i,t){let e=[];if(t.length<=i.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}var Eg=class{},mf=class extends Eg{constructor(e){super();this.id=e}},gf=class extends Eg{constructor(e){super();this.data=e}};var Ab;try{Ab=new TextDecoder}catch{}var De,va,J=0;var HT=[],_b=HT,Mb=0,qr={},Pt,ya,Mi=0,_s=0,fi,Ao,Fr=[],Nt,BT={useRecords:!1,mapsAsObjects:!0},yf=class{},Tb=new yf;Tb.name="MessagePack 0xC1";var Cu=!1,Ms=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(De)return XT(()=>(Cg(),this?this.unpack(t,e):Ms.prototype.unpack.call(BT,t,e)));va=e>-1?e:t.length,J=0,Mb=0,_s=0,ya=null,_b=HT,fi=null,De=t;try{Nt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw De=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ms){if(qr=this,this.structures)return Pt=this.structures,Tg();(!Pt||Pt.length>0)&&(Pt=[])}else qr=BT,(!Pt||Pt.length>0)&&(Pt=[]);return Tg()}unpackMultiple(t,e){let n,r=0;try{Cu=!0;let s=t.length,o=this?this.unpack(t,s):Dg.unpack(t,s);if(e){for(e(o);J<s;)if(r=J,e(Tg())===!1)return}else{for(n=[o];J<s;)r=J,n.push(Tg());return n}}catch(s){throw s.lastPosition=r,s.values=n,s}finally{Cu=!1,Cg()}}_mergeStructures(t,e){t=t||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let r=t[n],s=e[n];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[n]=r),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Tg(){try{if(!qr.trusted&&!Cu){let t=Pt.sharedLength||0;t<Pt.length&&(Pt.length=t)}let i=fn();if(J==va)Pt.restoreStructures&&FT(),Pt=null,De=null,Ao&&(Ao=null);else if(J>va){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Cu)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Pt.restoreStructures&&FT(),Cg(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function FT(){for(let i in Pt.restoreStructures)Pt[i]=Pt.restoreStructures[i];Pt.restoreStructures=null}function fn(){let i=De[J++];if(i<160)if(i<128){if(i<64)return i;{let t=Pt[i&63]||qr.getStructures&&jT()[i&63];return t?(t.read||(t.read=Cb(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,qr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[qT()]=fn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(fn(),fn());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=fn();return t}else if(i<192){let t=i-160;if(_s>=J)return ya.slice(J-Mi,(J+=t)-Mi);if(_s==0&&va<140){let e=t<16?Pb(t):WT(t);if(e!=null)return e}return Eb(t)}else{let t;switch(i){case 192:return null;case 193:return fi?(t=fn(),t>0?fi[1].slice(fi.position1,fi.position1+=t):fi[0].slice(fi.position0,fi.position0-=t)):Tb;case 194:return!1;case 195:return!0;case 196:return Sb(De[J++]);case 197:return t=Nt.getUint16(J),J+=2,Sb(t);case 198:return t=Nt.getUint32(J),J+=4,Sb(t);case 199:return Ml(De[J++]);case 200:return t=Nt.getUint16(J),J+=2,Ml(t);case 201:return t=Nt.getUint32(J),J+=4,Ml(t);case 202:if(t=Nt.getFloat32(J),qr.useFloat32>2){let e=Ig[(De[J]&127)<<1|De[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=Nt.getFloat64(J),J+=8,t;case 204:return De[J++];case 205:return t=Nt.getUint16(J),J+=2,t;case 206:return t=Nt.getUint32(J),J+=4,t;case 207:return qr.int64AsNumber?(t=Nt.getUint32(J)*4294967296,t+=Nt.getUint32(J+4)):t=Nt.getBigUint64(J),J+=8,t;case 208:return Nt.getInt8(J++);case 209:return t=Nt.getInt16(J),J+=2,t;case 210:return t=Nt.getInt32(J),J+=4,t;case 211:return qr.int64AsNumber?(t=Nt.getInt32(J)*4294967296,t+=Nt.getUint32(J+4)):t=Nt.getBigInt64(J),J+=8,t;case 212:if(t=De[J++],t==114)return VT(De[J++]&63);{let e=Fr[t];if(e)return e.read?(J++,e.read(fn())):e.noBuffer?(J++,e()):e(De.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=De[J],t==114?(J++,VT(De[J++]&63,De[J++])):Ml(2);case 214:return Ml(4);case 215:return Ml(8);case 216:return Ml(16);case 217:return t=De[J++],_s>=J?ya.slice(J-Mi,(J+=t)-Mi):ZH(t);case 218:return t=Nt.getUint16(J),J+=2,_s>=J?ya.slice(J-Mi,(J+=t)-Mi):JH(t);case 219:return t=Nt.getUint32(J),J+=4,_s>=J?ya.slice(J-Mi,(J+=t)-Mi):$H(t);case 220:return t=Nt.getUint16(J),J+=2,kT(t);case 221:return t=Nt.getUint32(J),J+=4,kT(t);case 222:return t=Nt.getUint16(J),J+=2,zT(t);case 223:return t=Nt.getUint32(J),J+=4,zT(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var KH=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Cb(i,t){function e(){if(e.count++>2){let r=i.read=new Function("r","return function(){return {"+i.map(s=>KH.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(fn);return i.highByte===0&&(i.read=UT(t,i.read)),r()}let n={};for(let r=0,s=i.length;r<s;r++){let o=i[r];n[o]=fn()}return n}return e.count=0,i.highByte===0?UT(t,e):e}var UT=(i,t)=>function(){let e=De[J++];if(e===0)return t();let n=i<32?-(i+(e<<5)):i+(e<<5),r=Pt[n]||jT()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=Cb(r,i)),r.read()};function jT(){let i=XT(()=>(De=null,qr.getStructures()));return Pt=qr._mergeStructures(i,Pt)}var Eb=Pg,ZH=Pg,JH=Pg,$H=Pg;function Pg(i){let t;if(i<16&&(t=Pb(i)))return t;if(i>64&&Ab)return Ab.decode(De.subarray(J,J+=i));let e=J+i,n=[];for(t="";J<e;){let r=De[J++];if((r&128)===0)n.push(r);else if((r&224)===192){let s=De[J++]&63;n.push((r&31)<<6|s)}else if((r&240)===224){let s=De[J++]&63,o=De[J++]&63;n.push((r&31)<<12|s<<6|o)}else if((r&248)===240){let s=De[J++]&63,o=De[J++]&63,a=De[J++]&63,l=(r&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(r);n.length>=4096&&(t+=ir.apply(String,n),n.length=0)}return n.length>0&&(t+=ir.apply(String,n)),t}function kT(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=fn();return t}function zT(i){if(qr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[qT()]=fn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(fn(),fn());return t}}var ir=String.fromCharCode;function WT(i){let t=J,e=new Array(i);for(let n=0;n<i;n++){let r=De[J++];if((r&128)>0){J=t;return}e[n]=r}return ir.apply(String,e)}function Pb(i){if(i<4)if(i<2){if(i===0)return"";{let t=De[J++];if((t&128)>1){J-=1;return}return ir(t)}}else{let t=De[J++],e=De[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(i<3)return ir(t,e);let n=De[J++];if((n&128)>0){J-=3;return}return ir(t,e,n)}else{let t=De[J++],e=De[J++],n=De[J++],r=De[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(r&128)>0){J-=4;return}if(i<6){if(i===4)return ir(t,e,n,r);{let s=De[J++];if((s&128)>0){J-=5;return}return ir(t,e,n,r,s)}}else if(i<8){let s=De[J++],o=De[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(i<7)return ir(t,e,n,r,s,o);let a=De[J++];if((a&128)>0){J-=7;return}return ir(t,e,n,r,s,o,a)}else{let s=De[J++],o=De[J++],a=De[J++],l=De[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(i<10){if(i===8)return ir(t,e,n,r,s,o,a,l);{let u=De[J++];if((u&128)>0){J-=9;return}return ir(t,e,n,r,s,o,a,l,u)}}else if(i<12){let u=De[J++],c=De[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(i<11)return ir(t,e,n,r,s,o,a,l,u,c);let d=De[J++];if((d&128)>0){J-=11;return}return ir(t,e,n,r,s,o,a,l,u,c,d)}else{let u=De[J++],c=De[J++],d=De[J++],h=De[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(i<14){if(i===12)return ir(t,e,n,r,s,o,a,l,u,c,d,h);{let f=De[J++];if((f&128)>0){J-=13;return}return ir(t,e,n,r,s,o,a,l,u,c,d,h,f)}}else{let f=De[J++],m=De[J++];if((f&128)>0||(m&128)>0){J-=14;return}if(i<15)return ir(t,e,n,r,s,o,a,l,u,c,d,h,f,m);let p=De[J++];if((p&128)>0){J-=15;return}return ir(t,e,n,r,s,o,a,l,u,c,d,h,f,m,p)}}}}}function Sb(i){return qr.copyBuffers?Uint8Array.prototype.slice.call(De,J,J+=i):De.subarray(J,J+=i)}function Ml(i){let t=De[J++];if(Fr[t])return Fr[t](De.subarray(J,J+=i));throw new Error("Unknown extension type "+t)}var GT=new Array(4096);function qT(){let i=De[J++];if(i>=160&&i<192){if(i=i-160,_s>=J)return ya.slice(J-Mi,(J+=i)-Mi);if(!(_s==0&&va<180))return Eb(i)}else return J--,fn();let t=(i<<5^(i>1?Nt.getUint16(J):i>0?De[J]:0))&4095,e=GT[t],n=J,r=J+i-3,s,o=0;if(e&&e.bytes==i){for(;n<r;){if(s=Nt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(r+=3;n<r;)if(s=De[n++],s!=e[o++]){n=1879048192;break}if(n===r)return J=n,e.string;r-=3,n=J}for(e=[],GT[t]=e,e.bytes=i;n<r;)s=Nt.getUint32(n),e.push(s),n+=4;for(r+=3;n<r;)s=De[n++],e.push(s);let a=i<16?Pb(i):WT(i);return a!=null?e.string=a:e.string=Eb(i)}var VT=(i,t)=>{var e=fn();let n=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let r=Pt[i];return r&&r.isShared&&((Pt.restoreStructures||(Pt.restoreStructures=[]))[i]=r),Pt[i]=e,e.read=Cb(e,n),e.read()},YT=typeof self=="object"?self:global;Fr[0]=()=>{};Fr[0].noBuffer=!0;Fr[101]=()=>{let i=fn();return(YT[i[0]]||Error)(i[1])};Fr[105]=i=>{let t=Nt.getUint32(J-4);Ao||(Ao=new Map);let e=De[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let r={target:n};Ao.set(t,r);let s=fn();return r.used?Object.assign(n,s):(r.target=s,s)};Fr[112]=i=>{let t=Nt.getUint32(J-4),e=Ao.get(t);return e.used=!0,e.target};Fr[115]=()=>new Set(fn());var Ib=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Fr[116]=i=>{let t=i[0],e=Ib[t];if(!e)throw new Error("Could not find typed array for code "+t);return new YT[e](Uint8Array.prototype.slice.call(i,1).buffer)};Fr[120]=()=>{let i=fn();return new RegExp(i[0],i[1])};Fr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=J;J+=t-4,fi=[fn(),fn()],fi.position0=0,fi.position1=0;let n=J;J=e;try{return fn()}finally{J=n}};Fr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function XT(i){let t=va,e=J,n=Mb,r=Mi,s=_s,o=ya,a=_b,l=Ao,u=fi,c=new Uint8Array(De.slice(0,va)),d=Pt,h=Pt.slice(0,Pt.length),f=qr,m=Cu,p=i();return va=t,J=e,Mb=n,Mi=r,_s=s,ya=o,_b=a,Ao=l,fi=u,De=c,Cu=m,Pt=d,Pt.splice(0,Pt.length,...h),qr=f,Nt=new DataView(De.buffer,De.byteOffset,De.byteLength),p}function Cg(){De=null,Ao=null,Pt=null}function QT(i){i.unpack?Fr[i.type]=i.unpack:Fr[i.type]=i}var Ig=new Array(147);for(let i=0;i<256;i++)Ig[i]=+("1e"+Math.floor(45.15-i*.30103));var Dg=new Ms({useRecords:!1}),e5=Dg.unpack,t5=Dg.unpackMultiple,n5=Dg.unpack,Og={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},r5=new Float32Array(1),tre=new Uint8Array(r5.buffer,0,4);var Rg;try{Rg=new TextEncoder}catch{}var Lg,Ob,Ng=typeof Buffer<"u",Db=Ng?Buffer.allocUnsafeSlow:Uint8Array,$T=Ng?Buffer:Uint8Array,KT=Ng?4294967296:2144337920,le,xn,ne=0,Es,Ts=null,i5=/[\u0080-\uFFFF]/,vf=Symbol("record-id"),El=class extends Ms{constructor(t){super(t),this.offset=0;let e,n,r,s,o,a,l=0,u=$T.prototype.utf8Write?function(b,E,T){return le.utf8Write(b,E,T)}:Rg&&Rg.encodeInto?function(b,E){return Rg.encodeInto(b,le.subarray(E)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=t.maxOwnStructures;m==null&&(m=h?32:64),d&&!t.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,y=f+m+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,w=0;this.pack=this.encode=function(b,E){if(le||(le=new Db(8192),xn=new DataView(le.buffer,0,8192),ne=0),Es=le.length-10,Es-ne<2048?(le=new Db(le.length),xn=new DataView(le.buffer,0,le.length),Es=le.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(Ts=["",""],le[ne++]=214,le[ne++]=98,Ts.position=ne-n,ne+=4):Ts=null,r=c.structures,r){r.uninitialized&&(r=c._mergeStructures(c.getStructures()));let T=r.sharedLength||0;if(T>f)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 I=0;I<T;I++){let C=r[I];if(!C)continue;let P,O=r.transitions;for(let B=0,j=C.length;B<j;B++){let Q=C[B];P=O[Q],P||(P=O[Q]=Object.create(null)),O=P}O[vf]=I+64}l=T}d||(r.nextId=T+64)}s&&(s=!1),o=r||[];try{if(S(b),Ts){xn.setUint32(Ts.position+n,ne-Ts.position-n);let T=Ts;Ts=null,S(T[0]),S(T[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>Es&&M(ne),c.offset=ne;let T=o5(le.subarray(n,ne),a.idsToInsert);return a=null,T}return E&tC?(le.start=n,le.end=ne,le):le.subarray(n,ne)}finally{if(r){if(w<10&&w++,x>1e4)r.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let T=0,I=v.length;T<I;T++)v[T][vf]=0;v=[]}if(s&&c.saveStructures){let T=r.sharedLength||f;r.length>T&&(r=r.slice(0,T));let I=le.subarray(n,ne);return c.saveStructures(r,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,I)}}E&f5&&(ne=n)}};let S=b=>{ne>Es&&(le=M(ne));var E=typeof b,T;if(E==="string"){let I=b.length;if(Ts&&I>=8&&I<4096){let O=i5.test(b);Ts[O?0:1]+=b,le[ne++]=193,S(O?-I:I);return}let C;I<32?C=1:I<256?C=2:I<65536?C=3:C=5;let P=I*3;if(ne+P>Es&&(le=M(ne+P)),I<64||!u){let O,B,j,Q=ne+C;for(O=0;O<I;O++)B=b.charCodeAt(O),B<128?le[Q++]=B:B<2048?(le[Q++]=B>>6|192,le[Q++]=B&63|128):(B&64512)===55296&&((j=b.charCodeAt(O+1))&64512)===56320?(B=65536+((B&1023)<<10)+(j&1023),O++,le[Q++]=B>>18|240,le[Q++]=B>>12&63|128,le[Q++]=B>>6&63|128,le[Q++]=B&63|128):(le[Q++]=B>>12|224,le[Q++]=B>>6&63|128,le[Q++]=B&63|128);T=Q-ne-C}else T=u(b,ne+C,P);T<32?le[ne++]=160|T:T<256?(C<2&&le.copyWithin(ne+2,ne+1,ne+1+T),le[ne++]=217,le[ne++]=T):T<65536?(C<3&&le.copyWithin(ne+3,ne+2,ne+2+T),le[ne++]=218,le[ne++]=T>>8,le[ne++]=T&255):(C<5&&le.copyWithin(ne+5,ne+3,ne+3+T),le[ne++]=219,xn.setUint32(ne,T),ne+=4),ne+=T}else if(E==="number")if(b>>>0===b)b<64?le[ne++]=b:b<256?(le[ne++]=204,le[ne++]=b):b<65536?(le[ne++]=205,le[ne++]=b>>8,le[ne++]=b&255):(le[ne++]=206,xn.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?le[ne++]=256+b:b>=-128?(le[ne++]=208,le[ne++]=b+256):b>=-32768?(le[ne++]=209,xn.setInt16(ne,b),ne+=2):(le[ne++]=210,xn.setInt32(ne,b),ne+=4);else{let I;if((I=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){le[ne++]=202,xn.setFloat32(ne,b);let C;if(I<4||(C=b*Ig[(le[ne]&127)<<1|le[ne+1]>>7])>>0===C){ne+=4;return}else ne--}le[ne++]=203,xn.setFloat64(ne,b),ne+=8}else if(E==="object")if(!b)le[ne++]=192;else{if(a){let C=a.get(b);if(C){if(!C.id){let P=a.idsToInsert||(a.idsToInsert=[]);C.id=P.push(C)}le[ne++]=214,le[ne++]=112,xn.setUint32(ne,C.id),ne+=4;return}else a.set(b,{offset:ne-n})}let I=b.constructor;if(I===Object)_(b,!0);else if(I===Array){T=b.length,T<16?le[ne++]=144|T:T<65536?(le[ne++]=220,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=221,xn.setUint32(ne,T),ne+=4);for(let C=0;C<T;C++)S(b[C])}else if(I===Map){T=b.size,T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,xn.setUint32(ne,T),ne+=4);for(let[C,P]of b)S(C),S(P)}else{for(let C=0,P=Lg.length;C<P;C++){let O=Ob[C];if(b instanceof O){let B=Lg[C];if(B.write){B.type&&(le[ne++]=212,le[ne++]=B.type,le[ne++]=0),S(B.write.call(this,b));return}let j=le,Q=xn,V=ne;le=null;let q;try{q=B.pack.call(this,b,W=>(le=j,j=null,ne+=W,ne>Es&&M(ne),{target:le,targetView:xn,position:ne-W}),S)}finally{j&&(le=j,xn=Q,ne=V,Es=le.length-10)}q&&(q.length+ne>Es&&M(q.length+ne),ne=s5(q,le,ne,B.type));return}}_(b,!b.hasOwnProperty)}}else if(E==="boolean")le[ne++]=b?195:194;else if(E==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))le[ne++]=211,xn.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)le[ne++]=207,xn.setBigUint64(ne,b);else if(this.largeBigIntToFloat)le[ne++]=203,xn.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(E==="undefined")this.encodeUndefinedAsNil?le[ne++]=192:(le[ne++]=212,le[ne++]=0,le[ne++]=0);else if(E==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+E)},_=this.useRecords===!1?this.variableMapSize?b=>{let E=Object.keys(b),T=E.length;T<16?le[ne++]=128|T:T<65536?(le[ne++]=222,le[ne++]=T>>8,le[ne++]=T&255):(le[ne++]=223,xn.setUint32(ne,T),ne+=4);let I;for(let C=0;C<T;C++)S(I=E[C]),S(b[I])}:(b,E)=>{le[ne++]=222;let T=ne-n;ne+=2;let I=0;for(let C in b)(E||b.hasOwnProperty(C))&&(S(C),S(b[C]),I++);le[T+++n]=I>>8,le[T+n]=I&255}:b=>{let E=Object.keys(b),T,I=o.transitions||(o.transitions=Object.create(null)),C=0;for(let O=0,B=E.length;O<B;O++){let j=E[O];T=I[j],T||(T=I[j]=Object.create(null),C++),I=T}let P=I[vf];if(P)P>=96&&p?(le[ne++]=((P-=96)&31)+96,le[ne++]=P>>5):le[ne++]=P;else{P=o.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(E)?(P=o.nextOwnId,P<y||(P=g),o.nextOwnId=P+1):(P>=y&&(P=g),o.nextId=P+1);let O=E.highByte=P>=96&&p?P-96>>5:-1;I[vf]=P,o[P-64]=E,P<g?(E.isShared=!0,o.sharedLength=P-63,s=!0,O>=0?(le[ne++]=(P&31)+96,le[ne++]=O):le[ne++]=P):(O>=0?(le[ne++]=213,le[ne++]=114,le[ne++]=(P&31)+96,le[ne++]=O):(le[ne++]=212,le[ne++]=114,le[ne++]=P),C&&(x+=w*C),v.length>=m&&(v.shift()[vf]=0),v.push(I),S(E))}for(let O=0,B=E.length;O<B;O++)S(b[E[O]])},M=b=>{let E;if(b>16777216){if(b-n>KT)throw new Error("Packed buffer would be larger than maximum buffer size");E=Math.min(KT,Math.round(Math.max((b-n)*(b>67108864?1.25:2),4194304)/4096)*4096)}else E=(Math.max(b-n<<2,le.length-1)>>12)+1<<12;let T=new Db(E);return xn=new DataView(T.buffer,0,E),le.copy?le.copy(T,0,n,b):T.set(le.slice(n,b)),ne-=n,n=0,Es=T.length-10,le=T}}useBuffer(t){le=t,xn=new DataView(le.buffer,le.byteOffset,le.byteLength),ne=0}};Ob=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,yf];Lg=[{pack(i,t,e){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:s,position:o}=t(6);r[o++]=214,r[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:r,targetView:s,position:o}=t(10);r[o++]=215,r[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:r,targetView:s,position:o}=t(3);r[o++]=212,r[o++]=255,r[o++]=255}else{let{target:r,targetView:s,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(i,t,e){let n=Array.from(i),{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=115,r[s++]=0),e(n)}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=101,n[r++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=120,n[r++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?ZT(i,16,t):JT(Ng?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==$T&&this.structuredClone?ZT(i,Ib.indexOf(e.name),t):JT(i,t)}},{pack(i,t){let{target:e,position:n}=t(1);e[n]=193}}];function ZT(i,t,e,n){let r=i.byteLength;if(r+1<256){var{target:s,position:o}=e(4+r);s[o++]=199,s[o++]=r+1}else if(r+1<65536){var{target:s,position:o}=e(5+r);s[o++]=200,s[o++]=r+1>>8,s[o++]=r+1&255}else{var{target:s,position:o,targetView:a}=e(7+r);s[o++]=201,a.setUint32(o,r+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function JT(i,t){let e=i.byteLength;var n,r;if(e<256){var{target:n,position:r}=t(e+2);n[r++]=196,n[r++]=e}else if(e<65536){var{target:n,position:r}=t(e+3);n[r++]=197,n[r++]=e>>8,n[r++]=e&255}else{var{target:n,position:r,targetView:s}=t(e+5);n[r++]=198,s.setUint32(r,e),r+=4}n.set(i,r)}function s5(i,t,e,n){let r=i.length;switch(r){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:r<256?(t[e++]=199,t[e++]=r):r<65536?(t[e++]=200,t[e++]=r>>8,t[e++]=r&255):(t[e++]=201,t[e++]=r>>24,t[e++]=r>>16&255,t[e++]=r>>8&255,t[e++]=r&255)}return t[e++]=n,t.set(i,e),e+=r,e}function o5(i,t){let e,n=t.length*6,r=i.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+n,s,r),n-=6;let a=s+n;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,r=s}return i}function xa(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ob.unshift(i.Class),Lg.unshift(i)}QT(i)}var eC=new El({useRecords:!1}),a5=eC.pack,l5=eC.pack;var{NEVER:c5,ALWAYS:u5,DECIMAL_ROUND:d5,DECIMAL_FIT:h5}=Og,tC=512,f5=1024;var nC=new El({structuredClone:!0});xa({Class:kt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,kt.prototype),i}});xa({Class:ze.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ze.prototype),i}});xa({Class:tn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,tn.prototype),i}});xa({Class:mf.prototype.constructor,type:4,write(i){return i.id},read(i){return new mf(i)}});xa({Class:gf.prototype.constructor,type:5,write(i){return i.data},read(i){return new gf(i)}});xa({Class:nn.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,nn.prototype),i}});function p5(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let n=i[e];t=(t<<5)-t+n,t=t&t}return t}function Rb(i){if(Su(i))return i;if(Array.isArray(i))return i.map(Rb);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Rb(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var Bg;(n=>{function i(r){return nC.pack(r)}n.serialize=i;function t(r){return nC.unpack(r)}n.deserialize=t;function e(r){return p5(i(Rb(r))).toString()}n.checksum=e})(Bg||(Bg={}));var Zi={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition"],["Scroll"]:["Transition","Animation","Create"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset"],["GameControl"]:["Transition","Animation","Audio","Video","Create"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"]},rC;(e=>{function i(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=i;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,toggle:!1,actions:new ze}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new ze}}e.defaultData=t})(rC||(rC={}));var Fg;(e=>{function i(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(Fg||(Fg={}));var Lb;(n=>{function i(r){return{type:"Comparison",operator:"==",lOperand:Fg.propertyDefaultData(r),rOperand:{...Fg.valueDefaultData}}}n.comparisonDefaultData=i;function t(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}}n.distanceDefaultData=t;function e(r,s){return{type:"State",object:r??null,state:s??null}}n.stateDefaultData=e})(Lb||(Lb={}));var iC;(e=>{function i(n){return n.type==="Conditional"}e.is=i;function t(n){return{type:"Conditional",disabled:!1,inActions:new ze,outActions:new ze,condition:Lb.distanceDefaultData(n)}}e.defaultData=t})(iC||(iC={}));var sC;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ze,drop:new ze}})(sC||(sC={}));var Ug;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ze})(Ug||(Ug={}));var kg;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(kg||(kg={}));var oC;(e=>{function i(n){return n.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new ze}}e.defaultData=t})(oC||(oC={}));var aC;(e=>{function i(n){return n.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ze}}e.defaultData=t})(aC||(aC={}));var lC;(e=>{function i(n){return n.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new ze}}e.defaultData=t})(lC||(lC={}));var cC;(e=>{function i(n){return n.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new ze}}e.defaultData=t})(cC||(cC={}));var uC;(e=>{function i(n){return n.type==="Trigger"}e.is=i;function t(n,r){return{type:"Trigger",disabled:!1,toggle:!1,target:"all",triggeringObjects:[],actions:new ze,triggerZone:"box",position:r.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}e.defaultData=t})(uC||(uC={}));var Ei="personal camera",wa="a218fcc3-276b-49b9-b485-49037fd14f5f",fC=2960946,qn=5526619;var Tl;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s]}e.lerp=t})(Tl||(Tl={}));var Cs;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function r(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=r;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(Cs||(Cs={}));var xf;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s,n[2]+(r[2]-n[2])*s,n[3]+(r[3]-n[3])*s]}e.lerp=t})(xf||(xf={}));var ba;(r=>{r.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}r.isEqual=t;function e(s){return s??r.identity}r.simplify=e;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}r.applyMatrix4=n})(ba||(ba={}));var Nn;(c=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function r(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}c.toRgb255a1=r;function s(d){return{r:d.r,g:d.g,b:d.b}}c.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}c.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}c.toHex=a;function l(d,h){return d.r===h.r&&d.g===h.g&&d.b===h.b}c.equals=l;function u(d,h,f){return{r:d.r+(h.r-d.r)*f,g:d.g+(h.g-d.g)*f,b:d.b+(h.b-d.b)*f}}c.lerp=u})(Nn||(Nn={}));var Ur;(a=>{a.white={...Nn.white,a:1},a.transparent={...Nn.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...Nn.fromHex(l),a:u}}a.fromHexAndA=n;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=r;function s(l,u){return Nn.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Ur||(Ur={}));var zg;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(zg||(zg={}));var dC;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(dC||(dC={}));var hC;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(hC||(hC={}));var _o;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(_o||(_o={}));var Ji;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(Ji||(Ji={}));var Sa;(r=>{r.DefaultUp=[0,1,0],r.DefaultTargetOffset=1e3,r.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:r.DefaultUp,isUpVectorFlipped:!1,targetOffset:r.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}r.getZoom=n})(Sa||(Sa={}));var Ps;(e=>{function i(n,r=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*r,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+r)),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=i;function t(n,r){let s={...n};if(Nb.forEach(o=>{Object.assign(s,{[o]:r[o]??n[o]})}),s.radial={...n.radial},r.radial){let o=n.radial,a=r.radial;Bb.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},r.linear){let o=n.linear,a=r.linear;Fb.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},r.grid){let o=n.grid,a=r.grid;Ub.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},r.toObject){let o=n.toObject,a=r.toObject;kb.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},r.randomnessObject){let o=n.randomnessObject,a=r.randomnessObject;zb.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Ps||(Ps={}));var Gg;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(r,s){let o=[];r.count!==void 0&&o.push({type:0,path:s,props:{count:r.count}});for(let a of t){let l=r[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(Gg||(Gg={}));var Nb=["count"],Bb=["radius","start","end","position","scale","rotation"],Fb=["position","scale","rotation"],Ub=["count","size"],kb=["count","position","scale","rotation"],zb=["strength","scale","rotation","position","movement","seed","freqScale"];var Vg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(Vg||(Vg={}));var Hg;(e=>{function i(n){return t(n)}e.defaultData=i;function t(n){if(n==="PointLight")return{type:n,color:Ur.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(n==="SpotLight")return{type:n,color:Ur.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(n==="DirectionalLight")return{type:n,color:Ur.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Hg||(Hg={}));var Aa;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Aa||(Aa={}));var Gb;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,r){return n.castShadow===r.castShadow&&n.receiveShadow===r.receiveShadow}e.equals=t})(Gb||(Gb={}));var Vb;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe}e.equals=t})(Vb||(Vb={}));var jg;(t=>t.defaultData={...Vb.defaultData,...Gb.defaultData})(jg||(jg={}));var Pu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Pu||(Pu={}));var pC;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(pC||(pC={}));function gC(i){return i.type!=="displace"}var mC;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(mC||(mC={}));var Wg=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],yC=["wrapping","image","video","name"],kr;(r=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}r.patch=i;function t(s,o){return s==="light"&&o?e(o):n(s)}r.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function n(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Pu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:Nn.fromHex(qn)};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:{...Nn.fromHex(6710886),a:1},colorB:{...Nn.fromHex(6710886),a:1},colorC:{...Nn.fromHex(16777215),a:1},colorD:{...Nn.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:Ur.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:Ur.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Ur.fromHexAndA(0,1),contourColor:Ur.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]}};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:{...Nn.fromHex(0),a:1},colorB:{...Nn.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}}}})(kr||(kr={}));var sr;(l=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${f}`,Array.isArray(f)?f.forEach(m=>c+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new ze}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function r(u,c){return{...u,name:c}}l.withName=r;function s(u,c="layer1",d="layer2"){let h=new ze;return h.push({fi:0,data:kr.defaultData("light",u),id:c}),h.push({fi:1,data:kr.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=kr.defaultData("texture");Object.assign(f.texture,{image:u});let m=new ze;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:kr.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=kr.defaultData("video");Object.assign(f.texture,{video:u});let m=new ze;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:kr.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerVideoTextureData=a})(sr||(sr={}));var Iu;(t=>{function i(){return{points:new ze,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Iu||(Iu={}));var Du;(t=>{function i(){return{points:new ze,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Du||(Du={}));var Hb={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var qg;(t=>{function i(e,n){let r={...e};return jb.forEach(s=>{Object.assign(r,{[s]:n[s]??e[s]})}),r}t.merge=i})(qg||(qg={}));var Yg={shape:Hb,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},jb=["depth","offset","angle","twist","startScale","endScale"];var bf;(e=>{function i(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=i;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(bf||(bf={}));var Xg;(t=>{function i(e,n){let r={...e};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...e.extrusion},Object.assign(r.extrusion,qg.merge(r.extrusion,n.extrusion))),r}t.merge=i})(Xg||(Xg={}));var _a;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Du.defaultData(),extrusion:Yg};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Iu.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}t.defaultData=i})(_a||(_a={}));var Wb=["width","height","depth"];var Qg;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Nn.white,near:.1,far:2e3})(Qg||(Qg={}));var Ou;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(Ou||(Ou={}));var qb;(t=>t.defaultData={softShadowQuality:"low"})(qb||(qb={}));var Yb;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Yb||(Yb={}));var Xb;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Xb||(Xb={}));var Ma;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ma||(Ma={}));var Qb;(t=>t.defaultData={playCamera:Ei,gameControlObject:null})(Qb||(Qb={}));var Kg;(t=>t.defaultData={backgroundColor:Ur.fromHexAndA(fC,1),postprocessing:Ou.defaultData,fog:Qg.defaultData,globalPhysics:Ma.defaultData,ambient:Yb.defaultData,ao:Xb.defaultData,shadow:qb.defaultData,publish:Qb.defaultData})(Kg||(Kg={}));var vC;(e=>{function i(n){return n==="Component"||n==="Instance"}e.isComponentRelated=i;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(vC||(vC={}));var Ru;(r=>{r.identity={...zg.identity,hiddenMatrix:ba.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}r.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}r.merge=e;function n(s,o){return hT({position:Cs.isEqual(s.position,o.position)?void 0:o.position,rotation:Cs.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Cs.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:ba.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}r.diff=n})(Ru||(Ru={}));var Cr;(t=>t.defaultData={states:new ze,events:new ze,visible:!0,raycastLock:!1,physics:Aa.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ru.identity,cloner:null})(Cr||(Cr={}));var xC;(t=>t.defaultData={type:"Empty",...Cr.defaultData})(xC||(xC={}));var bC;(t=>t.defaultData={type:"Component",...Cr.defaultData})(bC||(bC={}));var Cl;(t=>t.defaultData={type:"Mesh",...Cr.defaultData,...jg.defaultData})(Cl||(Cl={}));var Pl;(t=>t.defaultData={...Cr.defaultData,...Ru.identity,position:[0,0,Sa.DefaultTargetOffset],...Sa.defaultData})(Pl||(Pl={}));var Zg;(e=>{function i(n){return{...Cr.defaultData,...Hg.defaultData(n)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Zg||(Zg={}));var Lu;(e=>{function i(n,r,s=0){for(;s<r.length;){let o=n?n[r[s]]:void 0;if(r.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(n,r,s=0){let o=i(n,r,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(Lu||(Lu={}));var Mo;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...Cr.defaultData,...a,component:o,overrides:new nn,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=n;function r(o){let a=Ru.fromObject(o.data);return n(o.id,a)}s.fromComponentData=r})(Mo||(Mo={}));var Eo;(t=>t.defaultData={type:"Page",...Cr.defaultData,physics:{...Aa.defaultData,fusedBody:!1},...Kg.defaultData,camera:Pl.defaultData})(Eo||(Eo={}));var Jg;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:ba.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Aa.defaultData,states:new ze,events:new ze,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Sa.defaultData},s.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"]},s.defaultMeshObject={name:"Rectangle",...Cr.defaultData,...Cl.defaultData,geometry:_a.defaultData("RectangleGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Cr.defaultData,...Cl.defaultData,geometry:_a.defaultData("BooleanGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Cr.defaultData,...Cl.defaultData,geometry:_a.defaultData("TextGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")}))(Jg||(Jg={}));var To;(r=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new nn}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new nn})))):Ji.is(s.type)&&(a.perspective={},a.orthographic={}),a}r.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Tu(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&kr.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Tu(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&kr.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,m]of Object.entries(h.layers)){let{texture:p,...g}=m;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...d,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...d,"layers",f],props:g,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...Gg.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,m]of Object.entries(h))c(["materials",f],m);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}r.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Ru.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Ji.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Xg.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Ps.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Ps.merge(a.cloner,o.cloner)});else if(Vg.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Nn.clone(l.color))}return a}r.patch=n})(To||(To={}));var Nu;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Nu||(Nu={}));var Is;(t=>t.defaultData={orbitControls:Nu.defaultData,playPage:wa,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let r=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?r=30:(n===4||n===11||n===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Is||(Is={}));var Kb;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Kb||(Kb={}));var Zb;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Zb||(Zb={}));var Ea;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Kb.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Zb.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ea||(Ea={}));var Ta;(e=>{function i(n){return n.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(n,r,s){n.traverseFrom(r,(o,a)=>{if(a.type==="Instance"){let l=n.data(a.component);l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Ta||(Ta={}));var $g;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=Jg.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:Zg.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let d=new tn;return d.push({fi:1,id:wa,data:{...Eo.defaultData,name:"Scene 1"},children:u}),d}a.defaultData={objects:t(),publish:Is.defaultData,styles:Ea.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new tn,publish:Is.defaultData,styles:Ea.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:Is.defaultData,styles:Ea.defaultData()}};function s(l){return{...a.defaultData,objects:Ki(l,tn.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})($g||($g={}));var Bu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Bu||(Bu={}));var ey;(n=>{function i(){let r={};return r["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ki(r,kt.prototype)}n.defaultColors=i;function t(r){let s={};return r?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Bu.emptyImage,name:"AI generated image"}),Ki(s,kt.prototype)}n.defaultImages=t;function e(){return{materials:new kt,images:new kt,videos:new kt,colors:new kt,audios:new kt,fonts:new kt}}n.emptyData=e})(ey||(ey={}));var ty;(t=>t.list=["idle","move","jump","run"])(ty||(ty={}));var Fu;(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 ze,move:new ze,jump:new ze,run:new ze},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ur.fromHexAndA(3728051,1)}}))(Fu||(Fu={}));function wC(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,r=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)r.push(r[1]),s.push(1);let o={...Qi(Ln(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:r,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Ln(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Co(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Po(i,t){i.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach(r=>{typeof r!="string"&&t(r)}):"material"in n&&typeof n.material!="string"&&t(n.material),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&t(r.material)})})}function g5(i){Object.assign(i.scene.publish,{orbitControls:{...Nu.defaultData,...Ln(i.scene.publish.orbitControls)}})}function y5(i){Object.assign(i.scene.publish.settings,{video:{...Is.defaultData.settings.video,...Ln(i.scene.publish.settings.video)}})}function v5(i){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[r,s]of Object.entries(n))if((Wg.includes(r)||typeof s=="boolean")&&delete n[r],r==="texture")for(let[o,a]of Object.entries(s))(yC.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,n)=>{n.states.forEach(r=>{let s=r;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function x5(i){i.scene.publish.withBackground=!0}function b5(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function w5(i){i.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(r=>r+1),n.linear.scale=n.linear.scale.map(r=>r+1))})}function S5(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function A5(i){i.scene.objects.traverse((t,e)=>{let n=i.scene.objects.unproxy().parent(t);if(n){let r=Ln(i.scene.objects.data(n));r&&r.type==="Mesh"&&r.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Ln(e).booleanExclude!==!0)}})}function _5(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function M5(i){function t(n){Object.setPrototypeOf(n,nn.prototype),n.texture&&Object.setPrototypeOf(n.texture,nn.prototype)}function e(n){Object.setPrototypeOf(n,nn.prototype);for(let r in n)t(n[r])}i.scene.objects.traverse((n,r)=>{r.states.forEach(s=>{let o=s;if(o.material){let a=Ln(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=Ln(l).layers;e(u),l.layers=u}})})}function SC(i){i.layers===void 0&&Object.assign(i,sr.defaultTwoLayerData("lambert"))}function Jb(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let n=[...t.steps];n.push(t.steps[9]);let r={...Ln(t),colors:e,steps:n};Object.assign(t,r)}})}function E5(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function AC(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&Jb(n)}):"material"in e&&typeof e.material!="string"&&Jb(e.material)}),Object.values(i.shared.materials).forEach(t=>Jb(t))}function T5(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function C5(i){i.shared.audios=Ki({},kt.prototype)}function P5(i){i.shared.videos=Ki({},kt.prototype)}function I5(i){let t=i.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let r={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:r})}})}function D5(i){Object.entries(Ln(i.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.images[n]}),Object.entries(Ln(i.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.audios[n]})}function O5(i){i.scene.publish.settings.web.preload=!1}function _C(i){i.layers&&i.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 MC(i){i.layers&&i.layers.forEach(t=>{gC(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 R5(i){i.shared.fonts=Ki({},kt.prototype)}function L5(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function N5(i){let t=[];i.scene.objects.traverse((e,n)=>{let r=n;if(r.type==="TextFrame"){let s=sr.defaultTwoLayerData("phong"),o=typeof r.color=="string"?i.shared.colors[r.color]:r.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=r.alpha;let a=L5(r.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:r.name,...Cr.defaultData,...Cl.defaultData,flatShading:!1,wireframe:!1,geometry:{..._a.defaultData("TextGeometry"),width:r.width,height:r.height,font:a,depth:0,horizontalAlign:r.horizontalAlign,verticalAlign:r.verticalAlign,fontSize:r.fontSize*1.40625,lineHeight:r.lineHeight/1.40625,letterSpacing:r.letterSpacing-1,text:r.text,textTransform:r.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Ln(r.states),events:Ln(r.events),visible:r.visible,raycastLock:r.raycastLock,position:r.position,rotation:r.rotation,scale:r.scale,hiddenMatrix:r.hiddenMatrix},u=Ln(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function B5(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,n)=>{n.events.forEach(r=>{if(!!t[Number(r.type)])if(Object.assign(r,{type:t[Number(r.type)]}),r.type==="Audio"&&"audioEvent"in r&&(Object.assign(r,{playAudio:r.audioEvent}),delete r.audioEvent),r.type==="GameControl")Object.assign(r,{gameActions:{idle:new ze,move:new ze,jump:new ze}});else{let s=new ze;Object.assign(r,{actions:s}),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp")&&"url"in r&&s.push({fi:0,id:Ve.generateUUID(),data:{type:"Link",url:r.url,delay:0}}),"targets"in r&&(r.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Qi(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ze({fi:0,id:Ve.generateUUID(),data:u},{fi:1,id:Ve.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete r.targets)}})})}function F5(i){i.scene.objects.traverse((t,e)=>{function n(r,s){let o=new ze,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Qi(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={...Qi(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===r)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Ve.generateUUID(),data:{type:r,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function EC(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=kr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function TC(i){Co(i,EC),Po(i,EC)}function U5(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function k5(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function z5(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=sr.defaultTwoLayerData("phong"))})}function G5(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function V5(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function H5(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function j5(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function W5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function q5(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function Y5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=Fu.defaultDataThirdPerson.navmesh)})})}function X5(i){i.scene.styles||(i.scene.styles=Ea.defaultData())}function CC(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Q5(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Po(i,CC),Co(i,CC)}function K5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&Object.assign(n.gameActions,{run:new ze})})})}function Z5(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.keyAssignments=[...n.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function PC(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function IC(i,t){if(t<1&&(Po(i,wC),Co(i,wC),i.schema=1),t<2&&(g5(i),i.schema=2),t<3&&(v5(i),i.schema=3),t<4&&(x5(i),i.schema=4),t<5&&(b5(i),i.schema=5),t<6&&(w5(i),i.schema=6),t<7&&(S5(i),i.schema=7),t<8&&(i.schema=8),t<9&&(AC(i),i.schema=9),t<10&&(E5(i),i.schema=10),t<11&&(T5(i),i.schema=11),t<12&&(AC(i),i.schema=12),t<13&&(C5(i),i.schema=13),t<14&&(I5(i),i.schema=14),t<15&&(D5(i),i.schema=15),t<16&&(O5(i),i.schema=16),t<17&&(Po(i,_C),Co(i,_C),i.schema=17),t<18&&(Po(i,SC),Co(i,SC),i.schema=18),t<19&&(y5(i),i.schema=19),t<20&&(R5(i),N5(i),i.schema=20),t<21&&(B5(i),F5(i),i.schema=21),t<22&&(TC(i),i.schema=22),t<23&&(U5(i),i.schema=23),t<24&&(k5(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(P5(i),t<25&&(i.schema=25)),t<26&&(A5(i),i.schema=26),t<27&&(_5(i),i.schema=27),t<28&&(TC(i),i.schema=28),t<29&&(M5(i),i.schema=29),t<30&&(z5(i),i.schema=30),t<31&&(G5(i),i.schema=31),t<33&&(V5(i),i.schema=33),t<34&&(H5(i),i.schema=34),t<35&&(j5(i),i.schema=35),t<36&&(W5(i),i.schema=36),t<37&&(q5(i),i.schema=37),t<38&&(Po(i,MC),Co(i,MC),i.schema=38),t<39&&(Y5(i),i.schema=39),t<40&&(X5(i),i.schema=40),t<41&&(Q5(i),i.schema=41),t<42&&(K5(i),i.schema=42),t<43&&(Z5(i),i.schema=43),t<99){Po(i,PC),Co(i,PC),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Ei);let e=Ln(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=wa,n.insertBefore(null,null,[{id:wa,data:{...Eo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Qi(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Qi(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ma.defaultData,...Qi(i.scene.environment,"usePhysics","gravity")},camera:Ln(i.scene.ownerCamera)??Eo.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==$g.TRASH_CAN_ID&&n.move(wa,o.fi,o.id);let r=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(r,2)],r+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Aa.defaultData)),a.physics!==void 0&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function DC(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}var OC=101;function RC(i){let t=i.schema??0;t!==OC&&(console.warn("updating from ",t,"to ",OC),IC(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Is.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Po(i,DC),Co(i,DC),i.schema=101))}function $i(i,t=!1){let e=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Me,u=0;for(let c=0;c<i.length;++c){let d=i[c],h=0;if(e!==(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 f in d.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(d.attributes[f]),h++}if(h!==n.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(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in d.morphAttributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=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(u,f,c),u+=f}}if(e){let c=0,d=[];for(let h=0;h<i.length;++h){let f=i[h].index;for(let m=0;m<f.count;++m)d.push(f.getX(m)+c);c+=i[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=LC(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 o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][h]);let m=LC(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(m)}}return l}function LC(i){let t,e,n,r=0;for(let a=0;a<i.length;++a){let l=i[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=l.array.length}let s=new t(r),o=0;for(let a=0;a<i.length;++a)s.set(i[a].array,o),o+=i[a].array.length;return new Be(s,e,n)}var NC=Math.pow(2,-24);var Il=class{constructor(){}};function Ti(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function $b(i){let t=-1,e=-1/0;for(let n=0;n<3;n++){let r=i[n+3]-i[n];r>e&&(e=r,t=n)}return t}function ew(i,t){t.set(i)}function tw(i,t,e){let n,r;for(let s=0;s<3;s++){let o=s+3;n=i[s],r=t[s],e[s]=n<r?n:r,n=i[o],r=t[o],e[o]=n>r?n:r}}function Sf(i,t,e){for(let n=0;n<3;n++){let r=t[i+2*n],s=t[i+2*n+1],o=r-s,a=r+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Uu(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function ej(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r;e>65535?r=new Uint32Array(new n(4*e)):r=new Uint16Array(new n(2*e)),i.setIndex(new Be(r,1));for(let s=0;s<e;s++)r[s]=s}}function tj(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let r of i.groups)e.add(r.start),e.add(r.start+r.count);let n=Array.from(e.values()).sort((r,s)=>r-s);for(let r=0;r<n.length-1;r++){let s=n[r],o=n[r+1];t.push({offset:s/3,count:(o-s)/3})}return t}function rw(i,t,e,n,r=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,y=r!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let w=i[v+0],S=i[v+1],_=w-S,M=w+S;_<s&&(s=_),M>l&&(l=M),y&&w<d&&(d=w),y&&w>m&&(m=w);let b=i[v+2],E=i[v+3],T=b-E,I=b+E;T<o&&(o=T),I>u&&(u=I),y&&b<h&&(h=b),y&&b>p&&(p=b);let C=i[v+4],P=i[v+5],O=C-P,B=C+P;O<a&&(a=O),B>c&&(c=B),y&&C<f&&(f=C),y&&C>g&&(g=C)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(r[0]=d,r[1]=h,r[2]=f,r[3]=m,r[4]=p,r[5]=g)}function nj(i,t,e,n){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=i[c+0];h<r&&(r=h),h>a&&(a=h);let f=i[c+2];f<s&&(s=f),f>l&&(l=f);let m=i[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=r,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function rj(i,t,e,n,r){let s=e,o=e+n-1,a=r.pos,l=r.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=i[s*3+u];i[s*3+u]=i[o*3+u],i[o*3+u]=c;let d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var Io=32,ij=(i,t)=>i.candidate-t.candidate,Ca=new Array(Io).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ny=new Float32Array(6);function sj(i,t,e,n,r,s){let o=-1,a=0;if(s===0)o=$b(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=$b(i),o!==-1&&(a=oj(e,n,r,o));else if(s===2){let l=Uu(i),u=1.25*r,c=n*6,d=(n+r)*6;for(let h=0;h<3;h++){let f=t[h],g=(t[h+3]-f)/Io;if(r<Io/4){let y=[...Ca];y.length=r;let v=0;for(let w=c;w<d;w+=6,v++){let S=y[v];S.candidate=e[w+2*h],S.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:b}=S;for(let E=0;E<3;E++)b[E]=1/0,b[E+3]=-1/0,M[E]=1/0,M[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;Sf(w,e,_)}y.sort(ij);let x=r;for(let w=0;w<x;w++){let S=y[w];for(;w+1<x&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),x--}for(let w=c;w<d;w+=6){let S=e[w+2*h];for(let _=0;_<x;_++){let M=y[_];S>=M.candidate?Sf(w,e,M.rightCacheBounds):(Sf(w,e,M.leftCacheBounds),M.count++)}}for(let w=0;w<x;w++){let S=y[w],_=S.count,M=r-S.count,b=S.leftCacheBounds,E=S.rightCacheBounds,T=0;_!==0&&(T=Uu(b)/l);let I=0;M!==0&&(I=Uu(E)/l);let C=1+1.25*(T*_+I*M);C<u&&(o=h,u=C,a=S.candidate)}}else{for(let x=0;x<Io;x++){let w=Ca[x];w.count=0,w.candidate=f+g+x*g;let S=w.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let x=c;x<d;x+=6){let _=~~((e[x+2*h]-f)/g);_>=Io&&(_=Io-1);let M=Ca[_];M.count++,Sf(x,e,M.bounds)}let y=Ca[Io-1];ew(y.bounds,y.rightCacheBounds);for(let x=Io-2;x>=0;x--){let w=Ca[x],S=Ca[x+1];tw(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;x<Io-1;x++){let w=Ca[x],S=w.count,_=w.bounds,b=Ca[x+1].rightCacheBounds;S!==0&&(v===0?ew(_,ny):tw(_,ny,ny)),v+=S;let E=0,T=0;v!==0&&(E=Uu(ny)/l);let I=r-v;I!==0&&(T=Uu(b)/l);let C=1+1.25*(E*v+T*I);C<u&&(o=h,u=C,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function oj(i,t,e,n){let r=0;for(let s=t,o=t+e;s<o;s++)r+=i[s*6+n*2];return r/e}function aj(i,t){let e=i.attributes.position,n=i.index.array,r=n.length/3,s=new Float32Array(r*6),o=e.normalized,a=e.array,l=e.offset||0,u=3;e.isInterleavedBufferAttribute&&(u=e.data.stride);let c=["getX","getY","getZ"];for(let d=0;d<r;d++){let h=d*3,f=d*6,m,p,g;o?(m=n[h+0],p=n[h+1],g=n[h+2]):(m=n[h+0]*u+l,p=n[h+1]*u+l,g=n[h+2]*u+l);for(let y=0;y<3;y++){let v,x,w;o?(v=e[c[y]](m),x=e[c[y]](p),w=e[c[y]](g)):(v=a[m+y],x=a[p+y],w=a[g+y]);let S=v;x<S&&(S=x),w<S&&(S=w);let _=v;x>_&&(_=x),w>_&&(_=w);let M=(_-S)/2,b=y*2;s[f+b+0]=S+M,s[f+b+1]=M+(Math.abs(S)+M)*NC,S<t[y]&&(t[y]=S),_>t[y+3]&&(t[y+3]=_)}}return s}function lj(i,t){function e(y){h&&h(y/f)}function n(y,v,x,w=null,S=0){if(!m&&S>=l&&(m=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let _=sj(y.boundingData,w,o,v,x,d);if(_.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=rj(a,o,v,x,_);if(M===v||M===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=_.axis;let b=new Il,E=v,T=M-v;y.left=b,b.boundingData=new Float32Array(6),rw(o,E,T,b.boundingData,s),n(b,E,T,s,S+1);let I=new Il,C=M,P=x-T;y.right=I,I.boundingData=new Float32Array(6),rw(o,C,P,I.boundingData,s),n(I,C,P,s,S+1)}return y}ej(i,t);let r=new Float32Array(6),s=new Float32Array(6),o=aj(i,r),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=i.index.count/3,m=!1,p=[],g=tj(i);if(g.length===1){let y=g[0],v=new Il;v.boundingData=r,nj(o,y.offset,y.count,s),n(v,y.offset,y.count,s),p.push(v)}else for(let y of g){let v=new Il;v.boundingData=new Float32Array(6),rw(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function UC(i,t){let e=lj(i,t),n,r,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),r=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,m=!!d.count,p=d.boundingData;for(let g=0;g<6;g++)n[h+g]=p[g];if(m){let g=d.offset,y=d.count;return r[h+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=d.left,y=d.right,v=d.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[h+6]=x/4,x=u(x,y),r[h+7]=v,x}}}var Yr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,r=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}setFromPoints(t,e){let n=1/0,r=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}};Yr.prototype.setFromBox=function(){let i=new A;return function(e,n){let r=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=r.x*l+s.x*(1-l),i.y=r.y*u+s.y*(1-u),i.z=r.z*c+s.z*(1-c);let d=e.dot(i);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var Poe=function(){let i=new Yr;return function(e,n){let r=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let d=o[c],h=s[c];if(i.setFromPoints(h,a),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(i.setFromPoints(h,r),d.isSeparated(i))return!1}}}();var cj=function(){let i=new A,t=new A,e=new A;return function(r,s,o){let a=r.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),m=e.dot(l),g=l.dot(l)*f-h*h,y,v;g!==0?y=(d*h-m*f)/g:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),Af=function(){let i=new F,t=new A,e=new A;return function(r,s,o,a){cj(r,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){r.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=r.start:c=r.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),kC=function(){let i=new A,t=new A,e=new vn,n=new Hn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var uj=1e-15;function ku(i){return Math.abs(i)<uj}var Xr=class extends $t{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Yr),this.points=[this.a,this.b,this.c],this.sphere=new dn,this.plane=new vn,this.needsUpdate=!0}intersectsSphere(t){return kC(t,this)}update(){let t=this.a,e=this.b,n=this.c,r=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,r);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,r);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,r);let f=s[3],m=o[3];f.subVectors(n,t),m.setFromPoints(f,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Xr.prototype.closestPointToSegment=function(){let i=new A,t=new A,e=new Hn;return function(r,s=null,o=null){let{start:a,end:l}=r,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),Af(e,r,i,t),c=i.distanceToSquared(t),c<d&&(d=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<d&&(d=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(d)}}();Xr.prototype.intersectsTriangle=function(){let i=new Xr,t=new Array(3),e=new Array(3),n=new Yr,r=new Yr,s=new A,o=new A,a=new A,l=new A,u=new Hn,c=new Hn,d=new Hn;return function(f,m=null,p=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let _=0;_<4;_++){let M=v[_],b=x[_];if(n.setFromPoints(b,e),M.isSeparated(n))return!1}let w=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let M=w[_],b=S[_];if(n.setFromPoints(b,t),M.isSeparated(n))return!1}for(let _=0;_<4;_++){let M=x[_];for(let b=0;b<4;b++){let E=S[b];if(s.crossVectors(M,E),n.setFromPoints(s,t),r.setFromPoints(s,e),n.isSeparated(r))return!1}}return m&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let v=this.points,x=!1,w=0;for(let O=0;O<3;O++){let B=v[O],j=v[(O+1)%3];u.start.copy(B),u.end.copy(j),u.delta(o);let Q=x?c.start:c.end,V=ku(y.distanceToPoint(B));if(ku(y.normal.dot(o))&&V){c.copy(u),w=2;break}if((y.intersectLine(u,Q)||V)&&!ku(Q.distanceTo(j))){if(w++,x)break;x=!0}}if(w===1&&f.containsPoint(c.end))return m&&(m.start.copy(c.end),m.end.copy(c.end)),!0;if(w!==2)return!1;let S=f.points,_=!1,M=0;for(let O=0;O<3;O++){let B=S[O],j=S[(O+1)%3];u.start.copy(B),u.end.copy(j),u.delta(a);let Q=_?d.start:d.end,V=ku(g.distanceToPoint(B));if(ku(g.normal.dot(a))&&V){d.copy(u),M=2;break}if((g.intersectLine(u,Q)||V)&&!ku(Q.distanceTo(j))){if(M++,_)break;_=!0}}if(M===1&&this.containsPoint(d.end))return m&&(m.start.copy(d.end),m.end.copy(d.end)),!0;if(M!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let O=d.start;d.start=d.end,d.end=O}let b=c.start.dot(o),E=c.end.dot(o),T=d.start.dot(o),I=d.end.dot(o),C=E<T,P=b<I;return b!==I&&T!==E&&C===P?!1:(m&&(l.subVectors(c.start,d.start),l.dot(o)>0?m.start.copy(c.start):m.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?m.end.copy(c.end):m.end.copy(d.end)),!0)}}}();Xr.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Xr.prototype.distanceToTriangle=function(){let i=new A,t=new A,e=["a","b","c"],n=new Hn,r=new Hn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],m=o[f];this.closestPointToPoint(m,i),h=m.distanceToSquared(i),h<c&&(c=h,a&&a.copy(i),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,i),h=p.distanceToSquared(i),h<c&&(c=h,a&&a.copy(p),l&&l.copy(i))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let m=0;m<3;m++){let p=e[m],g=e[(m+1)%3];r.set(o[p],o[g]),Af(n,r,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var Qr=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new A,this.max=new A,this.matrix=new ie,this.invMatrix=new ie,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Yr),this.alignedSatBounds=new Array(3).fill().map(()=>new Yr),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Qr.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,r=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=r[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=r[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=r[h];c.subVectors(a,f),d.setFromPoints(c,r)}let l=this.alignedSatBounds;l[0].setFromPointsField(r,"x"),l[1].setFromPointsField(r,"y"),l[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Qr.prototype.intersectsBox=function(){let i=new Yr;return function(e){this.needsUpdate&&this.update();let n=e.min,r=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=n.x,i.max=r.x,a[0].isSeparated(i)||(i.min=n.y,i.max=r.y,a[1].isSeparated(i))||(i.min=n.z,i.max=r.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(i.setFromBox(u,e),c.isSeparated(i))return!1}return!0}}();Qr.prototype.intersectsTriangle=function(){let i=new Xr,t=new Array(3),e=new Yr,n=new Yr,r=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let h=0;h<3;h++){let f=a[h],m=l[h];if(e.setFromPoints(m,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],m=c[h];if(e.setFromPoints(m,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let m=0;m<4;m++){let p=c[m];if(r.crossVectors(f,p),e.setFromPoints(r,t),n.setFromPoints(r,d),e.isSeparated(n))return!1}}return!0}}();Qr.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Qr.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Qr.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Hn),e=new Array(12).fill().map(()=>new Hn),n=new A,r=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(r),this.closestPointToPoint(r,n),o.closestPointToPoint(n,r),l&&l.copy(n),u&&u.copy(r)),0;let c=a*a,d=o.min,h=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let y=f[g];r.copy(y).clamp(d,h);let v=y.distanceToSquared(r);if(v<m&&(m=v,l&&l.copy(y),u&&u.copy(r),v<c))return Math.sqrt(v)}let p=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,w=(g+2)%3,S=y<<x|v<<w,_=1<<g|y<<x|v<<w,M=f[S],b=f[_];t[p].set(M,b);let T=i[g],I=i[x],C=i[w],P=e[p],O=P.start,B=P.end;O[T]=d[T],O[I]=y?d[I]:h[I],O[C]=v?d[C]:h[I],B[T]=h[T],B[I]=y?d[I]:h[I],B[C]=v?d[C]:h[I],p++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){r.x=g?h.x:d.x,r.y=y?h.y:d.y,r.z=v?h.z:d.z,this.closestPointToPoint(r,n);let x=r.distanceToSquared(n);if(x<m&&(m=x,l&&l.copy(n),u&&u.copy(r),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Af(y,x,n,r);let w=n.distanceToSquared(r);if(w<m&&(m=w,l&&l.copy(n),u&&u.copy(r),w<c))return Math.sqrt(w)}}return Math.sqrt(m)}}();var zu=new A,Gu=new A,Vu=new A,iy=new F,sy=new F,oy=new F,zC=new A,GC=new A,VC=new A,ay=new A;function dj(i,t,e,n,r,s){let o;return s===On?o=i.intersectTriangle(n,e,t,!0,r):o=i.intersectTriangle(t,e,n,s!==Lr,r),o===null?null:{distance:i.origin.distanceTo(r),point:r.clone()}}function hj(i,t,e,n,r,s,o,a,l){zu.fromBufferAttribute(t,s),Gu.fromBufferAttribute(t,o),Vu.fromBufferAttribute(t,a);let u=dj(i,zu,Gu,Vu,ay,l);if(u){n&&(iy.fromBufferAttribute(n,s),sy.fromBufferAttribute(n,o),oy.fromBufferAttribute(n,a),u.uv=$t.getInterpolation(ay,zu,Gu,Vu,iy,sy,oy,new F)),r&&(iy.fromBufferAttribute(r,s),sy.fromBufferAttribute(r,o),oy.fromBufferAttribute(r,a),u.uv1=$t.getInterpolation(ay,zu,Gu,Vu,iy,sy,oy,new F)),e&&(zC.fromBufferAttribute(e,s),GC.fromBufferAttribute(e,o),VC.fromBufferAttribute(e,a),u.normal=$t.getInterpolation(ay,zu,Gu,Vu,zC,GC,VC,new A),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new A,materialIndex:0};$t.getNormal(zu,Gu,Vu,c.normal),u.face=c,u.faceIndex=s}return u}function sw(i,t,e,n,r){let s=n*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:d,uv1:h}=i.attributes,f=hj(e,u,c,d,h,o,a,l,t);return f?(f.faceIndex=n,r&&r.push(f),f):null}function HC(i,t,e,n,r,s){for(let o=n,a=n+r;o<a;o++)sw(i,t,e,o,s)}function jC(i,t,e,n,r){let s=1/0,o=null;for(let a=n,l=n+r;a<l;a++){let u=sw(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Ci(i,t,e,n){let r=i.a,s=i.b,o=i.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),r.x=n.getX(a),r.y=n.getY(a),r.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function ow(i,t,e,n,r,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Ci(o,u*3,a,l),o.needsUpdate=!0,n(o,u,r,s))return!0;return!1}var Hu=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function Do(i,t){return t[i+15]===65535}function Dl(i,t){return t[i+6]}function ju(i,t){return t[i+14]}function Wu(i){return i+8}function qu(i,t){return t[i+6]}function WC(i,t){return t[i+7]}var Yu=new _t,cy=new A,pj=["x","y","z"];function uy(i,t,e,n,r){let s=i*2,o=Xu,a=Pa,l=Ia;if(Do(s,a)){let c=Dl(i,l),d=ju(s,a);HC(t,e,n,c,d,r)}else{let c=Wu(i);hy(c,o,n,cy)&&uy(c,t,e,n,r);let d=qu(i,l);hy(d,o,n,cy)&&uy(d,t,e,n,r)}}function dy(i,t,e,n){let r=i*2,s=Xu,o=Pa,a=Ia;if(Do(r,o)){let u=Dl(i,a),c=ju(r,o);return jC(t,e,n,u,c)}else{let u=WC(i,a),c=pj[u],h=n.direction[c]>=0,f,m;h?(f=Wu(i),m=qu(i,a)):(f=qu(i,a),m=Wu(i));let g=hy(f,s,n,cy)?dy(f,t,e,n):null;if(g){let x=g.point[c];if(h?x<=s[m+u]:x>=s[m+u+3])return g}let v=hy(m,s,n,cy)?dy(m,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var qC=function(){let i,t,e=[],n=new Hu(()=>new _t);return function(...o){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let a=r(...o);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function r(s,o,a,l,u=null,c=0,d=0){function h(x){let w=x*2,S=Pa,_=Ia;for(;!Do(w,S);)x=Wu(x),w=x*2;return Dl(x,_)}function f(x){let w=x*2,S=Pa,_=Ia;for(;!Do(w,S);)x=qu(x,_),w=x*2;return Dl(x,_)+ju(w,S)}let m=s*2,p=Xu,g=Pa,y=Ia;if(Do(m,g)){let x=Dl(s,y),w=ju(m,g);return Ti(s,p,i),l(x,w,!1,d,c+s,i)}else{let x=Wu(s),w=qu(s,y),S=x,_=w,M,b,E,T;if(u&&(E=i,T=t,Ti(S,p,E),Ti(_,p,T),M=u(E),b=u(T),b<M)){S=w,_=x;let Q=M;M=b,b=Q,E=T}E||(E=i,Ti(S,p,E));let I=Do(S*2,g),C=a(E,I,M,d+1,c+S),P;if(C===2){let Q=h(S),q=f(S)-Q;P=l(Q,q,!0,d+1,c+S,E)}else P=C&&r(S,o,a,l,u,c,d+1);if(P)return!0;T=t,Ti(_,p,T);let O=Do(_*2,g),B=a(T,O,b,d+1,c+_),j;if(B===2){let Q=h(_),q=f(_)-Q;j=l(Q,q,!0,d+1,c+_,T)}else j=B&&r(_,o,a,l,u,c,d+1);return!!j}}}(),YC=function(){let i=new Xr,t=new Xr,e=new ie,n=new Qr,r=new Qr;return function s(o,a,l,u,c=null){let d=o*2,h=Xu,f=Pa,m=Ia;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),Do(d,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,w=l.attributes.position,S=Dl(o,m),_=ju(d,f);if(e.copy(u).invert(),l.boundsTree)return Ti(o,h,r),r.matrix.copy(e),r.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>r.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let E=S*3,T=(_+S)*3;E<T;E+=3)if(Ci(t,E,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let M=S*3,b=_+S*3;M<b;M+=3){Ci(i,M,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let E=0,T=x.count;E<T;E+=3)if(Ci(t,E,x,w),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=m[o+6];return Ti(g,h,Yu),!!(c.intersectsBox(Yu)&&s(g,a,l,u,c)||(Ti(y,h,Yu),c.intersectsBox(Yu)&&s(y,a,l,u,c)))}}}();function hy(i,t,e,n){return Ti(i,t,Yu),e.intersectBox(Yu,n)}var aw=[],ly,Xu,Pa,Ia;function Qu(i){ly&&aw.push(ly),ly=i,Xu=new Float32Array(i),Pa=new Uint16Array(i),Ia=new Uint32Array(i)}function _f(){ly=null,Xu=null,Pa=null,Ia=null,aw.length&&Qu(aw.pop())}var lw=Symbol("skip tree generation"),cw=new _t,uw=new _t,Ku=new ie,Ol=new Qr,Mf=new Qr,Ef=new A,fy=new A,mj=new A,gj=new A,yj=new A,XC=new _t,Ds=new Hu(()=>new Xr),Os=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Os.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,r=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:r.map(a=>a.slice()),index:s.array.slice()}:o={roots:r,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Os.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:r,roots:s}=t,o=new Os(e,{...n,[lw]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Be(t.index,1,!1);e.setIndex(l)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[lw]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[lw]||(this._roots=UC(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new _t))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,r=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let h=0,f=c.length;h<f;h++)s=c[h],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,u),u+=s.byteLength;function d(h,f,m=!1){let p=h*2;if(a[p+15]===65535){let y=o[h+6],v=a[p+14],x=1/0,w=1/0,S=1/0,_=-1/0,M=-1/0,b=-1/0;for(let E=3*y,T=3*(y+v);E<T;E++){let I=n[E],C=r.getX(I),P=r.getY(I),O=r.getZ(I);C<x&&(x=C),C>_&&(_=C),P<w&&(w=P),P>M&&(M=P),O<S&&(S=O),O>b&&(b=O)}return l[h+0]!==x||l[h+1]!==w||l[h+2]!==S||l[h+3]!==_||l[h+4]!==M||l[h+5]!==b?(l[h+0]=x,l[h+1]=w,l[h+2]=S,l[h+3]=_,l[h+4]=M,l[h+5]=b,!0):!1}else{let y=h+8,v=o[h+6],x=y+f,w=v+f,S=m,_=!1,M=!1;t?S||(_=t.has(x),M=t.has(w),S=!_&&!M):(_=!0,M=!0);let b=S||_,E=S||M,T=!1;b&&(T=d(y,f,S));let I=!1;E&&(I=d(v,f,S));let C=T||I;if(C)for(let P=0;P<3;P++){let O=y+P,B=v+P,j=l[O],Q=l[O+3],V=l[B],q=l[B+3];l[h+P]=j<V?j:V,l[h+P+3]=Q>q?Q:q}return C}}}traverse(t,e=0){let n=this._roots[e],r=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=r[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=r[a+6],f=r[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=ai){let n=this._roots,r=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=r.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(Qu(n[c]),uy(0,r,h,t,s),_f(),a){let m=l[c].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(t,e=ai){let n=this._roots,r=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=r.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;Qu(n[c]);let f=dy(0,r,h,t);_f(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,r=!1;for(let s of this._roots)if(Qu(s),r=YC(0,n,t,e),_f(),r)break;return r}shapecast(t,e,n){let r=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,m,p,g)=>{let y=m*3;return h(f,y,y+1,y+2,p,g)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Ds.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,m,p,g,y)=>h(f,m,p,g,y)?!0:ow(f,m,r,u,p,g,s)}else l||(u?l=(h,f,m,p)=>ow(h,f,r,u,m,p,s):l=(h,f,m)=>m);let c=!1,d=0;for(let h of this._roots){if(Qu(h),c=qC(0,r,a,l,o,d),_f(),c)break;d+=h.byteLength}return Ds.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:r,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;Ku.copy(e).invert();let c=Ds.getPrimitive(),d=Ds.getPrimitive();if(s){let f=function(m,p,g,y,v,x,w,S){for(let _=g,M=g+y;_<M;_++){Ci(d,_*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let b=m,E=m+p;b<E;b++)if(Ci(c,b*3,o,a),c.needsUpdate=!0,s(c,d,b,_,v,x,w,S))return!0}return!1};if(r){let m=r;r=function(p,g,y,v,x,w,S,_){return m(p,g,y,v,x,w,S,_)?!0:f(p,g,y,v,x,w,S,_)}}else r=f}t.getBoundingBox(uw),uw.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>uw.intersectsBox(f),intersectsRange:(f,m,p,g,y,v)=>(cw.copy(v),cw.applyMatrix4(Ku),t.shapecast({intersectsBounds:x=>cw.intersectsBox(x),intersectsRange:(x,w,S,_,M)=>r(f,m,x,w,g,y,_,M)}))});return Ds.releasePrimitive(c),Ds.releasePrimitive(d),h}intersectsBox(t,e){return Ol.set(t.min,t.max,e),Ol.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Ol.intersectsBox(n),intersectsTriangle:n=>Ol.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Ol.set(t.boundingBox.min,t.boundingBox.max,e),Ol.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=Ds.getPrimitive(),f=Ds.getPrimitive(),m=fy,p=mj,g=null,y=null;r&&(g=gj,y=yj);let v=1/0,x=null,w=null;return Ku.copy(e).invert(),Mf.matrix.copy(Ku),this.shapecast({boundsTraverseOrder:S=>Ol.distanceToBox(S),intersectsBounds:(S,_,M)=>M<v&&M<o?(_&&(Mf.min.copy(S.min),Mf.max.copy(S.max),Mf.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>Mf.distanceToBox(M),intersectsBounds:(M,b,E)=>E<v&&E<o,intersectsRange:(M,b)=>{for(let E=M*3,T=(M+b)*3;E<T;E+=3){Ci(f,E,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let I=S*3,C=(S+_)*3;I<C;I+=3){Ci(h,I,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,m,g);if(P<v&&(p.copy(m),y&&y.copy(g),v=P,x=I/3,w=E/3),P<s)return!0}}}});{let M=d?d.count:c.count;for(let b=0,E=M;b<E;b+=3){Ci(f,b,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let T=S*3,I=(S+_)*3;T<I;T+=3){Ci(h,T,u,l),h.needsUpdate=!0;let C=h.distanceToTriangle(f,m,g);if(C<v&&(p.copy(m),y&&y.copy(g),v=C,x=T/3,w=b/3),C<s)return!0}}}}}),Ds.releasePrimitive(h),Ds.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=x,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(Ku),p.applyMatrix4(Ku),r.distance=p.sub(r.point).length(),r.faceIndex=w),n)}closestPointToPoint(t,e={},n=0,r=1/0){let s=n*n,o=r*r,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(Ef.copy(t).clamp(c.min,c.max),Ef.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,Ef);let h=t.distanceToSquared(Ef);return h<a&&(fy.copy(Ef),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(fy):e.point=fy.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ti(0,new Float32Array(n),XC),t.union(XC)}),t}};var Gd=Ah(KC());var vj=.5*(Math.sqrt(3)-1),Tf=(3-Math.sqrt(3))/6,xj=1/3,Rs=1/6,Sae=(Math.sqrt(5)-1)/4,Aae=(5-Math.sqrt(5))/20,Cf=i=>Math.floor(i)|0,ZC=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]),hw=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 py(i=Math.random){let t=$C(i),e=new Float64Array(t).map(r=>ZC[r%12*2]),n=new Float64Array(t).map(r=>ZC[r%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*vj,d=Cf(s+c),h=Cf(o+c),f=(d+h)*Tf,m=d-f,p=h-f,g=s-m,y=o-p,v,x;g>y?(v=1,x=0):(v=0,x=1);let w=g-v+Tf,S=y-x+Tf,_=g-1+2*Tf,M=y-1+2*Tf,b=d&255,E=h&255,T=.5-g*g-y*y;if(T>=0){let P=b+t[E],O=e[P],B=n[P];T*=T,a=T*T*(O*g+B*y)}let I=.5-w*w-S*S;if(I>=0){let P=b+v+t[E+x],O=e[P],B=n[P];I*=I,l=I*I*(O*w+B*S)}let C=.5-_*_-M*M;if(C>=0){let P=b+1+t[E+1],O=e[P],B=n[P];C*=C,u=C*C*(O*_+B*M)}return 70*(a+l+u)}}function JC(i=Math.random){let t=$C(i),e=new Float64Array(t).map(s=>hw[s%12*3]),n=new Float64Array(t).map(s=>hw[s%12*3+1]),r=new Float64Array(t).map(s=>hw[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*xj,m=Cf(o+f),p=Cf(a+f),g=Cf(l+f),y=(m+p+g)*Rs,v=m-y,x=p-y,w=g-y,S=o-v,_=a-x,M=l-w,b,E,T,I,C,P;S>=_?_>=M?(b=1,E=0,T=0,I=1,C=1,P=0):S>=M?(b=1,E=0,T=0,I=1,C=0,P=1):(b=0,E=0,T=1,I=1,C=0,P=1):_<M?(b=0,E=0,T=1,I=0,C=1,P=1):S<M?(b=0,E=1,T=0,I=0,C=1,P=1):(b=0,E=1,T=0,I=1,C=1,P=0);let O=S-b+Rs,B=_-E+Rs,j=M-T+Rs,Q=S-I+2*Rs,V=_-C+2*Rs,q=M-P+2*Rs,W=S-1+3*Rs,X=_-1+3*Rs,L=M-1+3*Rs,U=m&255,G=p&255,H=g&255,z=.6-S*S-_*_-M*M;if(z<0)u=0;else{let k=U+t[G+t[H]];z*=z,u=z*z*(e[k]*S+n[k]*_+r[k]*M)}let re=.6-O*O-B*B-j*j;if(re<0)c=0;else{let k=U+b+t[G+E+t[H+T]];re*=re,c=re*re*(e[k]*O+n[k]*B+r[k]*j)}let K=.6-Q*Q-V*V-q*q;if(K<0)d=0;else{let k=U+I+t[G+C+t[H+P]];K*=K,d=K*K*(e[k]*Q+n[k]*V+r[k]*q)}let Z=.6-W*W-X*X-L*L;if(Z<0)h=0;else{let k=U+1+t[G+1+t[H+1]];Z*=Z,h=Z*Z*(e[k]*W+n[k]*X+r[k]*L)}return 32*(u+c+d+h)}}function $C(i){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let r=n+~~(i()*(256-n)),s=e[n];e[n]=e[r],e[r]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var es=new $t,my=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let r=0;r<t.count;r+=3){let s=1;es.a.fromBufferAttribute(t,r),es.b.fromBufferAttribute(t,r+1),es.c.fromBufferAttribute(t,r+2),s*=es.getArea(),e[r/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let r=0;r<e.length;r++)n+=e[r],this.distribution[r]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*n);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,r=e.length-1,s=-1;for(;n<=r;){let o=Math.ceil((n+r)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?r=o-1:n=o+1}return s}sampleFace(t,e,n){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),es.a.fromBufferAttribute(this.positionAttribute,t*3),es.b.fromBufferAttribute(this.positionAttribute,t*3+1),es.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(es.a,r).addScaledVector(es.b,s).addScaledVector(es.c,1-(r+s)),es.getNormal(n),this}};var tP=Ah(fw()),bj=new ie,wj=new ie,Sj=new ie,Zu;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(Zu||(Zu={}));var Ju=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ie;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ie;this.matrixWorldRigid=new ie;this.shearScale=new ie;this.shearScaleInv=new ie}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof ht&&(n=n.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===n)return!0;r=r.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let r of this.children)r.updateMatrixWorld(n)}updateWorldMatrix(n,r){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(n,r=0){for(let s of this.children)Zu.is(s)&&s.traverseObject(n,r+1)}traverseObject(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Zu.is(o)&&o.traverseObject(n,r+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,r=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,tP.SVD)(r),l=bj.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=wj.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=Sj.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,r){this.updateWorldMatrix(!0,!1);let s=new ie().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof ie?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),r!==void 0&&(this.children.pop(),this.children.splice(r,0,n)),this}copy(n,r=!1){return super.copy(n,r),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,r,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var pw=class extends Ju(ht){},Aj=i=>i.type==="Mesh",rn=class extends pw{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let r=this.children[e];r?.object!==n&&(r&&this.remove(r),r=new rn(n),this.add(r),this.children.splice(e,0,this.children.pop()),r.matrixWorldNeedsUpdate=!0,r.matrixAutoUpdate=!1,r.matrix=n.matrix,r.hiddenMatrix=n.hiddenMatrix),r.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return Aj(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Rl=new A,Ll=new A,$u=new ie,rP=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],_j=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Mj=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],nP=(i,t,e)=>{i.updateEntityBoxSize(Rl,Ll),$u.copy(t).multiply(i.matrixWorld),Ll.x===0&&Ll.y===0&&Ll.z===0?e.push(new A(Rl.x,Rl.y,Rl.z).applyMatrix4($u)):rP.forEach(n=>{e.push(n.clone().multiply(Ll).add(Rl).applyMatrix4($u))})},Pf=class extends _t{constructor(){super(...arguments);this.matrix=new ie;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new ie().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,n)}expandByObjectSize(e,n,r=!1){let s=[];return r===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}nP(o,n,s)}}):nP(e,n,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4($u.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ll).multiplyScalar(.5),this.getCenter(Rl),$u.copy(this.matrix).setPosition(Rl),this.vertices=rP.map(e=>e.clone().multiply(Ll).applyMatrix4($u))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=_j.map(([e,n])=>new Hn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Mj.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var ts={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var gw=class extends qh{constructor(){super()}getPoints(t=12){let e=[],n,r=this.getCurveLengths(),o=r[r.length-1]/r.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?r[a]:r[a]-r[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let m=h[f];n&&n.equals(m)||(e.push(m),n=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var yw=.001;function vw(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=yw}function mw(i,t){let e=new A(...i.position),n=new A(...i.controlNext.position),r=new A(...t.controlPrevious.position),s=new A(...t.position);return vw(e,n,s)&&vw(e,r,s)}function yy(i){let t=i.points.map(c=>new A(...c.data.position)),e=[i.points[0]],n=new A(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)vw(n,t[c],t[c+1])||(e.push(i.points[c]),n=t[c]);e.push(i.points[i.points.length-1]);let r=i.isClosed,s=e.length-(r?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new A(...d.position),f=new A(...d.controlPrevious.position),m=new A(...d.controlNext.position),p={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...p,removedLength:0};continue}let g=r&&c==0?o-1:c-1,y=r&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,w=new A(...v.position),S=new A(...x.position),_=w.clone().sub(h).normalize(),M=S.clone().sub(h).normalize();Object.assign(p,{prevDir:_,nextDir:M});let b=mw(v,d),E=mw(d,x);if(!b||!E)a[c]={...p,removedLength:0};else{let T=_.clone().add(M).normalize(),I=T.clone().cross(_).length()/_.dot(T);a[c]={...p,tan:I,removedLength:d.roundness/I}}}for(let c=0;c<s;c++){let d=c,h=r&&c===o-1?0:c+1,f=a[d],m=a[h];if(f.removedLength!==0||m.removedLength!==0){let p=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,p/2),m.removedLength=Math.min(m.removedLength,p/2)}}let l=[];for(let c=0;c<s;c++){let d=c,h=r&&c===o-1?0:c+1,f=a[d],m=a[h],p=null;if(!mw(e[d].data,e[h].data))f.position.distanceTo(m.position)>yw&&(p=new dl(f.position,f.controlNext,m.controlPrevious,m.position));else{let g=f.position.clone(),y=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&y.add(m.prevDir.clone().setLength(m.removedLength))),g.distanceTo(y)>yw&&(p=new dl(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=p}for(let c=0;c<o;c++){let d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),m=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),p=d.tan*d.removedLength,g=d.prevDir.clone().add(d.nextDir).normalize(),y=f.clone().lerp(m,.5),v=f.distanceTo(m)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(v,2))).add(y),w=g.clone().multiplyScalar(-p).add(x),S=h.distanceTo(w)/h.distanceTo(y),_=d.prevDir.clone().multiplyScalar(S*h.distanceTo(f)).add(h),M=_.clone().lerp(w,2),b=f.clone().lerp(_,4/3),E=m.clone().lerp(M,4/3);l[2*c]=new dl(f,b,E,m)}let u=new gw;return l.forEach(c=>{c&&u.add(c)}),u}var lt;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(lt||(lt={}));var Ls=i=>lt.is(i),Ej={type:"completeState",isfromEntity:!0},ed=i=>class extends Ju(i){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Pf;this._recursiveBBox=new Pf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let r=this.children[n];if(lt.is(r))return r}entityChildrenCount(){let n=this.children.length;for(;n--;)if(lt.is(this.children[n]))return n+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 n=this;for(;n.data.type!=="Instance";){let r=n.parent;if(lt.is(r))n=r;else return}return n}forInstancesRec(n){this.instances.forEach(r=>{r.disposed||n(r),r.forInstancesRec(n)})}super_Entity(n,r){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=r,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,r,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)To.toOps(this.data,o.data).forEach(l=>{let u=Sg.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,r)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=To.patch(this.data,o),To.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,r)}))}s&&this.updateTransformState(this.dataPatched),this.stateSelection=n,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(n,r){n.setScalar(0),r.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Ls(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let r;return this.traverseEntity(s=>{s.uuid===n&&(r=s)}),r}traverseSortNextHelper(){let n=this.parent;if(n){let r=n.children,s=r.indexOf(this)+1;if(lt.is(r[s]))return r[s];if(lt.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&lt.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let r=this;for(;n>0&&r!==null;)r=r.parent,n-=1;return r}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let r=this.parent;for(;r;){if(n===r)return!0;r=r.parent}return!1}countToAccestor(n){let r=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,r+=1}return r}forEachEntity(n){for(let r of this.children)Ls(r)&&n(r)}traverseEntityAncestors(n){this.traverseAncestors(r=>{lt.is(r)&&n(r)})}traverseConcreteEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Ls(o)&&o.isConcreteEntity&&o.traverseEntity(n,r+1)}traverseEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Ls(o)&&o.traverseEntity(n,r+1)}traverseVisibleEntity(n){n(this);for(let r of this.children)Ls(r)&&r.visible&&r.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,r=!1){return super.copy(n,r),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Ls(n))}isAncestorOf(n){if(this.uuid===n)return!1;let r=!1;return this.traverseEntity(s=>{s.uuid===n&&(r=!0)}),r}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return xu(r,n)}updateTransformState(n){let r=!1;return n.position&&(this.position.fromArray(n.position),r=!0),n.rotation&&(this.rotation.fromArray(n.rotation),r=!0),n.scale&&(r=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??ba.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)lt.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{lt.is(n)&&n.disposeRecursively()})}toState(n=[]){let r={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return xu(r,n)}updateByObjUpdateOp(n,r){this.updateByOp({type:0,props:n,path:[]},{...this.data,...n},r,!1)}updateByOp(n,r,s,o){let a=this.data;this.data=r;let l=n,u=Tr(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=Br.zoom(h,n.path.slice(2));if(f)for(let m in n.props)n.props[m]===void 0&&m in f&&(d[m]=f[m])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=Br.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,To.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Tr(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(As.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=Br.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let m=n.props;if(f)for(let[p,g]of Object.entries(n.props))g===void 0&&(m===n.props&&(m={...n.props}),m[p]=f[p]);n={...n,props:m}}h.overrideData=Lu.resolve(r.overrides,c),h.updateByOp(n,yr.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of Mo.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of Mo.rootOverrideProps)if(Tr(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=As.filterOp(d.overrideData,c);h&&d.updateByOp(h,yr.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=As.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=r:f=yr.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,r,s){if(this.dataPatched=r,n.path.length===0&&n.type===0)n.props.type!==void 0&&!Ji.is(n.props.type)&&ts.changeEntityProptotype(this,r,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){ts.changeEntityProptotype(this,r,s);for(let o of this.children)lt.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,r,s)}updateByPatchedOp(n,r,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Tr(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(r.pathSnapping),Tr(n.path,["cloner"])!==null){let o=yr.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(r.cloner,s.scene):(this.setFromClonerState(r.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let r=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(r===null)return;let l=n.find(r);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=yy(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new ie;l.updateMatrixWorld();let m=new ie().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(m);let p={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ie().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(g).add(h),v=new ie().lookAt(h,y,new A(0,1,0)),x=new Gt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(Ej)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,r){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),r&&"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,r),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof ts.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,r){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new ts.Cloner(this,n),r.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,r.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var vy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters),n=e.width/2,r=e.radiusTop??n,s=e.radiusBottom??n;return r===s?(r=n,s=n):r>s?(r=n,s=s*n/r):(r=r*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:r,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=i.parameters,m;return d||f?m=new If(u,c,n,r,s,o,a,l*Math.PI/180,d,d,h,f):m=new fl(u,c,n,r,s,o,a,l*Math.PI/180),m.scale(1,1,e/t),Object.assign(m,{userData:{...i,type:"CylinderGeometry"}})}};function Da(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function iP(i){return new F(i.y,-i.x)}var If=class extends Me{constructor(t,e,n,r,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,r=Math.floor(r)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],y=[],v=0,x=n/2,w=new A,S=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let _=new F(t,x),M=new F(e,-x),b=null,E=null,T=null,I=null,C=_.clone().sub(M),P=0,O=0,B=0;h>0&&(P=Math.min(t,e)*(1-h),O=t-P,B=e-P);let j=_.clone();j.x-=P;let Q=Math.PI-C.angle(),V=C.angle(),q=Math.tan(V/2),W=Math.tan(Q/2),X=q+W,L=h?X:W,U=h?X:q;if(u=Math.min(u,(t-O)/L,C.length()/X),c=Math.min(c,(e-B)/U,C.length()/X),u>0){let Z=u/q;b=_.clone().sub(new F(Z,u)),h&&(T=b.clone(),T.x-=P-X*u),_.sub(C.clone().setLength(Z))}if(c>0){let Z=c/W;E=M.clone().sub(new F(Z,-c)),M.add(C.clone().setLength(Z)),h&&(I=E.clone(),I.x-=P-X*c,j.sub(C.clone().setLength(Z)))}C=_.clone().sub(M);let G=C.length()<.5,H=[];for(let Z=0;Z<=r;Z++){let k=[],he=Z/r,fe=he*l+a,ce=new F(Math.sin(fe),Math.cos(fe));I&&E?(z(k,he,ce,Q,c,I,-1,!0),z(k,he,ce,V,c,E,-1,!1)):E?(re(k,ce,E.x,0,-1),z(k,he,ce,V,c,E,-1,!1)):o||re(k,ce,e,B,-1);let ye=iP(C).normalize();if(Da(ye,ce,w),!G)for(let Se=0;Se<=s;Se++){let ve=Se/s,Ee=C.clone().multiplyScalar(ve).add(M);Da(Ee,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}if(T&&b?(z(k,he,ce,Q,u,b,1,!1),z(k,he,ce,V,u,T,1,!0)):b?(z(k,he,ce,Q,u,b,1,!1),re(k,ce,b.x,0,1)):o||re(k,ce,t,O,1),h&&!G){let Se=iP(C).multiplyScalar(-1).normalize();Da(Se,ce,w);for(let ve=0;ve<=s;ve++){let Ee=ve/s,Te=C.clone().multiplyScalar(-Ee).add(j);Da(Te,ce,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(he,.5+S.y/n),k.push(v++)}}h&&!o&&k.push(k[0]),H.push(k)}for(let Z=0;Z<H.length-1;Z++)for(let k=0;k<H[0].length-1;k++){if(o&&h&&k==s)continue;let he=H[Z][k],fe=H[Z+1][k],ce=H[Z+1][k+1],ye=H[Z][k+1],Se=p[ce*3+0],ve=p[ce*3+2];m.push(he,fe,ye),(Se!=0||ve!=0)&&m.push(fe,ce,ye)}l<Math.PI*2&&(K(-1,H[0],a),K(1,H[H.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(y,2));function z(Z,k,he,fe,ce,ye,Se,ve){for(let Ee=0;Ee<d+1;Ee++){let Te=Ee/d,we=Se<0?Te:1-Te;ve&&(we-=1),we*=fe;let He=new F(Math.sin(we),Math.cos(we)*Se),vt=He.clone().multiplyScalar(ce).add(ye);Da(vt,he,S),p.push(S.x,S.y,S.z),Da(He,he,w),g.push(w.x,w.y,w.z),y.push(k,.5+S.y/n),Z.push(v++)}}function re(Z,k,he,fe,ce){let ye=new A,Se=new F,ve=[he,fe];ce<0&&ve.reverse();for(let Ee of ve)Se.set(Ee,x*ce),Da(Se,k,ye),p.push(ye.x,ye.y,ye.z),g.push(0,ce,0),y.push(.5,.5),Z.push(v++)}function K(Z,k,he){let fe=new F(Math.sin(he),Math.cos(he)),ce=new F(-Math.cos(he),Math.sin(he)),ye=new A,Se=Z<0?(Te,we,He)=>m.push(Te,we,He):(Te,we,He)=>m.push(Te,He,we),ve=new F((t+e+O+B)/4,0);Da(ve,fe,ye),p.push(ye.x,ye.y,ye.z),g.push(ce.x,0,ce.y),y.push(.5,.5);let Ee=v++;for(let Te of k){let we=p.slice(Te*3,Te*3+3);p.push(...we),g.push(ce.x,0,ce.y);let He=y.slice(Te*2,Te*2+2);y.push(...He),v++}for(let Te=Ee+1;Te<v-1;Te++)Se(Ee,Te,Te+1);Se(Ee,v-1,Ee+1)}}};var sP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=i.parameters,h;return u>0||c>0||l<360?h=new If(0,t/2,n,r,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new Pc(t/2,n,r,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"ConeGeometry"}})}};var oP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new er(t,e,n,r,s,o):u=new bw(t,e,n,r,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},xw=Math.PI/2,bw=class extends Me{constructor(t=1,e=1,n=1,r=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,r,0),y("x","y","z",1,-1,1,t,e,n,r,1),y("x","y","z",-1,1,1,t,e,n,r,0),y("x","y","z",1,1,-1,t,e,n,r,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Ae(d,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function g(x,w,S,_,M,b,E,T,I,C,P){let O=(b-2*a)/I,B=(E-2*a)/C,j=b/2-a,Q=E/2-a,V=T/2,q=I+1,W=C+1,X=0,L=0,U=new A;for(let G=0;G<W;G++){let H=G*B-Q;for(let z=0;z<q;z++){let re=z*O-j;U[x]=re*_,U[w]=H*M,U[S]=V,d.push(U.x,U.y,U.z),U[x]=0,U[w]=0,U[S]=T>0?1:-1,h.push(U.x,U.y,U.z),f.push(z/I),f.push(1-G/C),X+=1}}for(let G=0;G<C;G++)for(let H=0;H<I;H++){let z=m+H+q*G,re=m+H+q*(G+1),K=m+(H+1)+q*(G+1),Z=m+(H+1)+q*G;c.push(z,re,Z),c.push(re,K,Z),L+=6}u.addGroup(p,L,P),p+=L,m+=X}function y(x,w,S,_,M,b,E,T,I,C,P){let O=(E-2*a)/C,B=E/2-a,j=T/2-a,Q=I/2,V=C+1,q=0,W=0,X=new A,L=new A;for(let U=0;U<l+1;U++){let G=U/l*xw,H=Math.sin(G)*a,z=(1-Math.cos(G))*a,re=Math.sin(G),K=Math.cos(G);X[w]=(j+H)*M,X[S]=(Q-z)*b,L[x]=0,L[w]=re*Math.sign(X[w]),L[S]=K*Math.sign(X[S]);for(let Z=0;Z<V;Z++){let k=Z*O-B;X[x]=k*_,d.push(X.x,X.y,X.z),h.push(L.x,L.y,L.z),f.push(Z/C),f.push(0),q+=1}}for(let U=0;U<l;U++)for(let G=0;G<C;G++){let H=m+G+V*U,z=m+G+V*(U+1),re=m+(G+1)+V*(U+1),K=m+(G+1)+V*U;c.push(H,z,K),c.push(z,re,K),W+=6}u.addGroup(p,W,P),p+=W,m+=q}function v(x,w,S){let _=new A,M=new A(t/2,e/2,n/2);M.subScalar(a);let b=[],E=x*w*S>0?(I,C,P)=>c.push(I,C,P):(I,C,P)=>c.push(I,P,C);for(let I=0;I<=l;I++){let C=[],P=xw*(1-I/l),O=Math.cos(P),B=Math.sin(P),j=0;for(let Q=0;Q<=I;Q++){let V=Math.cos(j),q=Math.sin(j);_.x=O*V,_.y=B,_.z=O*q;let W=M.clone().addScaledVector(_,a);d.push(x*W.x,w*W.y,S*W.z),h.push(x*_.x,w*_.y,S*_.z),f.push(0,0),C.push(m++),j+=xw/I}b.push(C)}let T=b.length-1;for(let I=0;I<T;I++){let C=b[I],P=b[I+1],O=C.length-1;E(C[0],P[1],P[0]);for(let B=1;B<=O;B++)E(C[B-1],C[B],P[B]),E(C[B],P[B+1],P[B])}}}};var Oa=class extends Me{constructor(t=[],e=[],n="",r=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new $t,y=s*r,v=r-y,x=o+1,w=new A,S=(q,W)=>w.subVectors(q,W).normalize(),_=(q,W)=>Array(q).fill(void 0).map(W),M=_(t.length/3,(q,W)=>new A().fromArray(t,W*3).setLength(r)),b=[],E=1e6;for(let q=0;q<M.length;q++){let W=M[q],X=[],L,U,G,H=1e10,z=-1;for(;(z=e.indexOf(q,z+1))!=-1;){let k=z-z%3;L=e[k+(z+1)%3],U=e[k+(z+2)%3],G=W.distanceToSquared(M[L]),H=Math.min(H,G),X.push([L,U,G])}H+=1e-6;let re=[],K=0,Z=X.length;for(let k=0;k<Z;k++){[L,U,G]=X[K];let he=b[L]?.includes(q)==!0;G<=H&&re.push(L+ +he*E),K=X.findIndex(fe=>fe[0]==U)}b.push(re)}let T=[];{let q=0,W=0,X,L,U=f==3;for(let G=0;G<=o;G++){X=G*(G+1)/2,L=(G+1)*(G+2)/2;for(let H=0;H<o-G;H++)[q,W]=[X+H+G+2,L+H+G+3],T.push(X,L,...U?[W,X]:[q,L],W,q),[X,L]=[q,W];T.push(X,L,X+o+2)}}let I=m.clone(),C=m.clone(),P=m.clone(),O=m.clone(),B=m.clone(),j=[],Q=_(M.length,()=>_(f,()=>m.clone()));for(let q=0;q<M.length;q++){m.copy(M[q]).normalize(),I.copy(m).multiplyScalar(v);let W=b[q];for(let re=0;re<W.length;re++){let K=W[re],Z=W[(re+1)%f];g.setFromPointsAndIndices(M,q,K%E,Z%E),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(I,Q[q][re])}let X=[],L=[],U=[],G=new A;o==0&&[...Q[q]].reduce((re,K)=>re.add(K),G).multiplyScalar(1/f);for(let re=0;re<f;re++){let K=[],Z=(re-1+f)%f,k=Q[q][Z],he=Q[q][re];m.copy(k).sub(I),p.copy(he).sub(I);let fe=I.angleTo(m),ce=m.angleTo(p),ye=Math.cos(fe)*y;o==0?C.copy(G):C.copy(I).setLength(v+ye),L.push(ye);let Se=[C,k,he];for(let ve=0;ve<2;ve++){let Ee=Se[ve],Te=Se[ve+1];O.subVectors(Ee,I),B.subVectors(Te,I),P.crossVectors(O,B).normalize();for(let we=0;we<x;we++){let He=[fe,ce][ve]*we/x;m.copy(O).applyAxisAngle(P,He).add(I),X.push(m.clone()),ve&&(S(m,I),K.push([we==0?Ee:m.clone(),w.clone()]))}ve&&(S(Te,I),K.push([Te,w.clone()]))}U.push(K)}j.push(U);let H=2*x,z=2;for(let re=0;re<f;re++){let K=H*re,Z=H*((re+1)%f),k=[X[K]];for(let fe=1;fe<x;fe++){O=X[K+fe],B=X[Z+fe],k.push(O);for(let ce=1,ye=fe-z+1;ce<=ye;ce++)m.lerpVectors(O,B,ce/(ye+1)),m.sub(I).setLength(L[re]).add(I),k.push(m.clone());k.push(B)}for(let fe=0;fe<x;fe++)k.push(X[fe+x+K]);k.push(X[Z+x]);let he=T.map(fe=>k[fe]);a.push(...he.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...he.map(fe=>(S(fe,I),[w.x,w.y,w.z])).flat())}}let V=[];for(let q=0;q<b.length;q++)for(let W=0;W<f;W++){let X=b[q][W];if(X<E){let L=b[X].findIndex(H=>H%E==q),U=j[q][W],G=j[X][L];for(let H=0;H<x;H++){let z=U[H],re=G[x-H],K=U[H+1],Z=G[x-(H+1)];[z,re,K,K,re,Z].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),u.push(k[1].x,k[1].y,k[1].z)})}V.push(U[0][0],G[x][0],U[x][0],G[0][0])}}for(;V.length;){let q,W,X,L;[q,W]=V.splice(0,2);let U=[q];for(;q!=W;)U.push(W),X=V.indexOf(W),L=X%2,W=V.splice(X-L,2)[1-L];w.subVectors(U[0],U[1]).cross(m.subVectors(U[0],U[2])).normalize();let G=w.dot(U[0])<0;G&&w.negate();for(let H=1;H<=U.length-2;H++)[U[H+ +G],U[H+1-+G],U[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(w.x,w.y,w.z)})}}function d(){let h=new A;for(let M=0;M<a.length;M+=3){h.x=a[M+0],h.y=a[M+1],h.z=a[M+2];let b=S(h)/2/Math.PI+.5,E=_(h)/Math.PI+.5;l.push(b,1-E)}let f=new A,m=new A,p=new A,g=new A,y=new F,v=new F,x=new F,w=(M,b,E,T)=>{T<0&&M.x===1&&(l[b]=M.x-1),E.x===0&&E.z===0&&(l[b]=T/2/Math.PI+.5)};for(let M=0,b=0;M<a.length;M+=9,b+=6){f.set(a[M+0],a[M+1],a[M+2]),m.set(a[M+3],a[M+4],a[M+5]),p.set(a[M+6],a[M+7],a[M+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(m).add(p).divideScalar(3);let E=S(g);w(y,b+0,f,E),w(v,b+2,m,E),w(x,b+4,p,E)}for(let M=0;M<l.length;M+=6){let b=l[M+0],E=l[M+2],T=l[M+4],I=Math.max(b,E,T),C=Math.min(b,E,T);I>.9&&C<.1&&(b<.2&&(l[M+0]+=1),E<.2&&(l[M+2]+=1),T<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new Oa(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var aP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Df(t*.5,s,o):new Dc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Df=class extends Oa{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=1/r,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new Df(t.radius,t.corner,t.cornerSides)}};var Of=1e-12,td=class{constructor(t){this.position=new F;this.startPosition=new F;this.uuid=Ve.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new td(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},nd=class extends td{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new nd(this.parent).copy(this)}},ns=class extends td{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new nd(this),new nd(this))}static create(e,n){let r=new ns(e,new F(...n.position));return r.controls[0].position.set(...n.controlPrevious.position),r.controls[1].position.set(...n.controlNext.position),r.roundness=n.roundness,r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,r}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let r=0,s=this.controls.length;r<s;r++){let o=this.controls[r];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new ns(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),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new F,n=new F){let[r,s]=this.computeTangents();return r&&s&&(lP(r,e),lP(s,n)),[e,n]}computeTangent(e=new F){let[n,r]=this.computeTangents();return n&&r&&e.copy(n).add(r).normalize(),e}computeNormal(e=new F){let[n,r]=this.computeNormals();return e.copy(n).add(r).normalize(),e}};function lP(i,t=new F){let e=i.length();return t.set(-i.y/e,i.x/e)}var Sw=i=>i,rd=new F,xy=new F,Tj=new F,Cj=new F,Pj=new F,Ij=new F,uP=new A,dP=new A;function hP(i){let t=new F;t.addVectors(i.v0,rd.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(i.v2,xy.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new _r(i.v0,t,e,i.v2)}function Rf(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function Dj(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Oj(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Aw(i,t,e){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((r*r+n*n-s*s)/(2*r*n))}function fP(i,t,e){return cP(i,t)&&cP(t,e)&&ww(i.position,t.position,e.position)}function ww(i,t,e){return rd.copy(t).sub(i).cross(xy.copy(e).sub(i))===0}function pP(i,t,e,n,r){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return n.set(a+l,o+u),r.set(a-l,o-u),[n,r]}function mP(i,t,e){let n=i.distanceTo(e),r=t.distanceTo(e);return n<r?t:i}function gP(i,t,e,n,r,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,u=e.y-i.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return Aw(t,i,e)>Math.PI&&(c*=-1),Rf(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),r.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[r,s]}function _w(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function cP(i,t){return ww(i.position,i.controls[1].position,t.position)&&ww(i.position,t.controls[0].position,t.position)}function yP(i,t,e,n,r=.5){let s=rd.subVectors(t,i).multiplyScalar(r).add(i),o=xy.subVectors(e,t).multiplyScalar(r).add(t),a=Tj.subVectors(n,e).multiplyScalar(r).add(e),l=s,u=Cj.subVectors(o,s).multiplyScalar(r).add(s),c=Pj.subVectors(a,o).multiplyScalar(r).add(o),d=a,h=Ij.subVectors(c,u).multiplyScalar(r).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function vP(i,t,e=12,n=!0){let r=dP.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=Sw(t[l]),c=rd,d=Ra(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof _r||u instanceof ci||u instanceof Mr){if(u.getPoint(h/d,c),r.set(c.x,c.y,0),s!==void 0&&Oj(s,r))continue;s===void 0&&(s=uP),s.copy(r),i.setXYZ(o,r.x,r.y,r.z),o++}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function xP(i,t,e,n=12,r=!0){let s=dP.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Sw(t[l]),d=rd,h=Ra(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof _r||c instanceof ci||c instanceof Mr){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=uP:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function Mw(i,t=12,e=!1){let n=[];for(let r=0,s=i.length;r<s;r++){let o=i[r],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Ra(o.roundedCurveCorner,t)*.5;r>0&&(n[r-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Ra(o.curveAfter,t)),n.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(n[i.length-1]+=Ra(i[0].roundedCurveCorner,t)*.5),n}function Ra(i,t=12){return i&&i instanceof ul?t*2:i&&(i instanceof Mr||i instanceof Wh)?1:i&&i instanceof Tc?t*i.points.length:t}function bP(i,t,e=12,n=!0){let r,s=0;for(let o=0;o<t.length;o++){let a=Sw(t[o]),l=Ra(a,e),u=rd;for(let c=0;c<=l;c++)if(a instanceof _r||a instanceof ci||a instanceof Mr){if(a.getPoint(c/l,u),r!==void 0&&Dj(r,u,Of))continue;r===void 0&&(r=xy),r.copy(u),i.push(u.x,u.y),s++}}return Rf(i[0],i[i.length-2],Of)&&Rf(i[1],i[i.length-1],Of)&&(i.pop(),i.pop()),n&&s>1&&!(Rf(i[s-1],i[1],Of)&&Rf(i[s-2],i[0],Of))&&(i.push(i[0],i[1]),s++),i}var Ew=new F,Rj=new F,Lj=new F,Nj=new F,Bj=new F,Fj=new F,Et=class extends go{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new vn(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ve.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,r){let s=new Et;return s.isClosed=e.isClosed,s.points=e.points.map(o=>ns.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Et.createFromState(o)),n!==void 0&&r!==void 0&&s.applySize(n,r),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,r=this.points.length;n<r;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,r=this.points.findIndex(s=>s.uuid===e);if(r<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return r}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let r=Ew.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(r),a.controls[0].position.multiply(r),a.controls[1].position.multiply(r)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,r=Ve.generateUUID()){let s;e instanceof F?s=e:s=new F(e,n);let o=new ns(r,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,r=this.shapeHoles.length;n<r;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(r=>r.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,r=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=r?this.roundedCurveDivisions:this.curveDivisions;return vP(e,r?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Mw(this.points,e,!1),this.roundedCurveDivisions=Mw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,r=12){return xP(e,this.curves,n,r,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),bP(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Ra(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<r+c)return[l,(a-r+1)/c];r+=c}return[0,1]}getCurveT(e,n,r){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(_w(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(Ew.set(r.x,r.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){_w(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,n.curveAfter=r;let s=r.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],r=this.points[this.points.length-1];this._applyCurveForPoint(n,r)}if(this.points.length>2){let n=0;for(let r=0,s=this.points.length;r<s;r++){let o=this.points[r],a=this.points[r-1]??this.points[this.points.length-1],l=this.points[r+1]??this.points[0],u=o.roundness,c=a&&l&&fP(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,m=o.roundedCurveAfter,p=d.getLength(),g=h.getLength(),y=Math.min(u,p*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/p,S=x/g,_=d.getPointAt(w,Ew),M=h.getPointAt(S,Rj);this._subSplitCurve(d,f,w,_,void 0),this._subSplitCurve(h,m,S,void 0,M);let b;if(this.useCubicForRoundedCorners){let E=Aw(_,o.position,M)/2,T=Math.tan(E)*_.distanceTo(o.position),[I,C]=pP(_,M,T,Lj,Nj),P=mP(I,C,o.position),[O,B]=gP(P,_,M,T,Bj,Fj);b=new _r(_.clone(),O.clone(),B.clone(),M.clone())}else b=new ci(_.clone(),o.position.clone(),M.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(r+n,0,b),n++}}}}_subSplitCurve(e,n,r,s,o){if(e instanceof Mr)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(r,0),c=yP(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let e=new Et(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let r=0;r<n;r++){let s=r*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],d=e.points[s+5],h=e.points[s+6],f=new ns(Ve.generateUUID(),new F(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(r=>{let s=new Et;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof _r&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},r=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof ci&&(s[a]=hP(s[a]));for(a=0,l=s.length;a<l;a++){let d=s[a],h=a>0?s[a-1]:null,f;d instanceof _r?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Mr&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&n(f,h),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof _r?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof Mr&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=r(e.curves),e instanceof go&&(this.shapeHoles=e.holes.map(s=>{let o=new Et;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let r=this.getPointByUuid(e);r&&(n.position!==void 0&&r.position.fromArray(n.position),n.roundness!==void 0&&(r.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var Cw=Math.PI*2;function Tw({x:i,y:t},e,n,r,s){return{x:i*e+r,y:t*n+s}}function Uj(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(i),r=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*e,y:r+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function wP(i,t,e,n){let r=i*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*n));return r*Math.acos(s)}function kj(i,t,e,n,r,s,o,a,l,u){let c=Math.pow(r,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),m=c*d-c*f-d*h;m<0&&(m=0),m/=c*f+d*h,m=Math.sqrt(m)*(l===u?-1:1);let p=m*r/s*a,g=m*-s/r*o,y=p+(i+e)/2,v=g+(t+n)/2,x=(o-p)/r,w=(a-g)/s,S=(-o-p)/r,_=(-a-g)/s,M=wP(1,0,x,w),b=wP(x,w,S,_);return!u&&b>0&&(b-=Cw),u&&b<0&&(b+=Cw),{centerx:y,centery:v,ang1:M,ang2:b}}function SP({px:i,py:t,cx:e,cy:n,rx:r,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(r===0||s===0)return[];let u=(i-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];r=Math.abs(r),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(r,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(r*=Math.sqrt(d),s*=Math.sqrt(d));let h=kj(i,t,e,n,r,s,u,c,o,a),{ang1:f,ang2:m}=h,{centerx:p,centery:g}=h,y=Math.abs(m)/(Cw/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);m/=v;for(let x=0;x<v;x++)l.push(Uj(f,m)),f+=m;return l.map(x=>{let{x:w,y:S}=Tw(x[0],r,s,p,g),{x:_,y:M}=Tw(x[1],r,s,p,g),{x:b,y:E}=Tw(x[2],r,s,p,g);return{x1:w,y1:S,x2:_,y2:M,x:b,y:E}})}var gt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(gt||(gt={}));var an;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(an||(an={}));function $e(i,t){if(!i)throw t||"Assertion Failed!"}var Ye=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,n){$e(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?r<s?e.t-t.t+(t.t-n.t)*(r/(r+s)):e.t-n.t+(n.t-t.t)*(s/(r+s)):0},i.edgeSign=function(t,e,n){$e(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?(e.t-n.t)*r+(e.t-t.t)*s:0},i.transEval=function(t,e,n){$e(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?r<s?e.s-t.s+(t.s-n.s)*(r/(r+s)):e.s-n.s+(n.s-t.s)*(s/(r+s)):0},i.transSign=function(t,e,n){$e(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?(e.s-n.s)*r+(e.s-t.s)*s:0},i.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},i.interpolate=function(t,e,n,r){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+r)/2:e+(r-e)*(t/(t+n)):r+(e-r)*(n/(t+n))},i.intersect=function(t,e,n,r,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(n,r)||(l=n,n=r,r=l),i.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.vertLeq(n,e)?i.vertLeq(e,r)?(o=i.edgeEval(t,n,e),a=i.edgeEval(n,e,r),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,e.s)):(o=i.edgeSign(t,n,e),a=-i.edgeSign(t,r,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,r.s)):s.s=(n.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(n,r)||(l=n,n=r,r=l),i.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.transLeq(n,e)?i.transLeq(e,r)?(o=i.transEval(t,n,e),a=i.transEval(n,e,r),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,e.t)):(o=i.transSign(t,n,e),a=-i.transSign(t,r,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,r.t)):s.t=(n.t+e.t)/2},i}(),Lf=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),by=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),id=function(){function i(){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 i}(),AP=function(){function i(){var t=new id,e=new Lf,n=new by(0),r=new by(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=r,r.next=r,r.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=r}return i.prototype.makeEdge_=function(t){var e=new by(0),n=new by(1);t.Sym.side<t.side&&(t=t.Sym);var r=t.Sym.next;return n.next=r,r.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},i.prototype.splice_=function(t,e){var n=t.Onext,r=e.Onext;n.Sym.Lnext=e,r.Sym.Lnext=t,t.Onext=r,e.Onext=n},i.prototype.makeVertex_=function(t,e,n){var r=t;$e(r,"Vertex can't be null!");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e;var o=e;do o.Org=r,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,n){var r=t;$e(r,"Face can't be null");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e,r.trail=null,r.marked=!1,r.inside=n.inside;var o=e;do o.Lface=r,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},i.prototype.killVertex_=function(t,e){var n=t.anEdge,r=n;do r.Org=e,r=r.Onext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var n=t.anEdge,r=n;do r.Lface=e,r=r.Lnext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new id,e=new id,n=new Lf,r=this.makeEdge_(this.eHead);return this.makeVertex_(t,r,this.vHead),this.makeVertex_(e,r.Sym,this.vHead),this.makeFace_(n,r,this.fHead),r},i.prototype.splice=function(t,e){var n=!1,r=!1;if(t!==e){if(e.Org!==t.Org&&(r=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!r){var s=new id;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Lf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!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),!n){var r=new Lf;this.makeFace_(r,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var r=new id;return this.makeVertex_(r,n,e.Org),e.Lface=n.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},i.prototype.connect=function(t,e){var n=!1,r=this.makeEdge_(t),s=r.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(r,t.Lnext),this.splice_(s,e),r.Org=t.Dst,s.Org=e.Org,r.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Lf;this.makeFace_(o,r,t.Lface)}return r},i.prototype.zapFace=function(t){var e=t.anEdge,n,r,s,o,a;r=e.Lnext;do n=r,r=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},i.prototype.mergeConvexFaces=function(t){var e,n,r,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;r=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Ye.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Ye.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(r=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=r;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,r,s,o,a,l,u;for(s=t,s=t;(r=s.next)!==t;s=r){$e(r.prev===s),l=r.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Lface===r),l=l.Lnext;while(l!==r.anEdge)}for($e(r.prev===s&&r.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){$e(o.prev===a),l=o.anEdge;do $e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l),$e(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for($e(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)$e(l.Sym.next===u.Sym),$e(l.Sym!==l),$e(l.Sym.Sym===l),$e(l.Org!==null),$e(l.Dst!==null),$e(l.Lnext.Onext.Sym===l),$e(l.Onext.Sym.Lnext===l);$e(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),_P=function(){function i(){this.handle=null}return i}(),MP=function(){function i(){this.key=null,this.node=0}return i}(),zj=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var n=0;n<t+1;n++)this.nodes[n]=new _P,this.handles[n]=new MP;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,$e(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[r].key,n[s].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[r].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var r,s;for(s=this.nodes.length,this.nodes.length=this.max+1,r=s;r<this.nodes.length;r++)this.nodes[r]=new _P;for(s=this.handles.length,this.handles.length=this.max+1,r=s;r<this.handles.length;r++)this.handles[r]=new MP}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,r=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),r},i.prototype.delete=function(t){var e=this.nodes,n=this.handles,r;$e(t>=1&&t<=this.max&&n[t].key!==null),r=n[t].node,e[r].handle=e[this.size].handle,n[e[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[e[r>>1].handle].key,n[e[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},i}(),Pw=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),EP=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),Gj=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new EP,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new EP;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),Vj=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,n){var r=t.event,s=e.eUp,o=n.eUp;if(s.Dst===r)return o.Dst===r?Ye.vertLeq(s.Org,o.Org)?Ye.edgeSign(o.Dst,s.Org,o.Org)<=0:Ye.edgeSign(s.Dst,o.Org,s.Org)>=0:Ye.edgeSign(o.Dst,r,o.Org)<=0;if(o.Dst===r)return Ye.edgeSign(s.Dst,r,s.Org)>=0;var a=Ye.edgeEval(s.Dst,r,s.Org),l=Ye.edgeEval(o.Dst,r,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&$e(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,n){$e(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},i.topLeftRegion=function(t,e){var n=e.eUp.Org,r;do e=i.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(r=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),r===null)return null;i.fixUpperEdge(t,e,r),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,n){var r=new Pw;return r.eUp=n,r.nodeUp=t.dict.insertBefore(e.nodeUp,r),r.fixUpperEdge=!1,r.sentinel=!1,r.dirty=!1,n.activeRegion=r,r},i.isWindingInside=function(t,e){switch(t.windingRule){case gt.ODD:return(e&1)!==0;case gt.NONZERO:return e!==0;case gt.POSITIVE:return e>0;case gt.NEGATIVE:return e<0;case gt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var n=e.eUp,r=n.Lface;r.inside=e.inside,r.anEdge=n,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,n){for(var r,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),r=s.eUp,r.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}r=t.mesh.connect(a.Lprev,r.Sym),i.fixUpperEdge(t,s,r)}a.Onext!==r&&(t.mesh.splice(r.Oprev,r),t.mesh.splice(a,r)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,n,r,s,o){var a,l,u,c,d=!0;u=n;do $e(Ye.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==r);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,$e(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},i.vertexWeights=function(t,e,n){var r=Ye.vertL1dist(e,t),s=Ye.vertL1dist(n,t),o=.5*s/(r+s),a=.5*r/(r+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},i.getIntersectData=function(t,e,n,r,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,n,r),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp;if(Ye.vertLeq(r.Org,s.Org)){if(Ye.edgeSign(s.Dst,r.Org,s.Org)>0)return!1;Ye.vertEq(r.Org,s.Org)?r.Org!==s.Org&&(t.pq.delete(r.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,r)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(r,s.Oprev),e.dirty=n.dirty=!0)}else{if(Ye.edgeSign(r.Dst,s.Org,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Oprev,r)}return!0},i.checkForLeftSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o;if($e(!Ye.vertEq(r.Dst,s.Dst)),Ye.vertLeq(r.Dst,s.Dst)){if(Ye.edgeSign(r.Dst,s.Dst,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(r),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Ye.edgeSign(s.Dst,r.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(r.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o=r.Org,a=s.Org,l=r.Dst,u=s.Dst,c,d,h=new id,f,m;if($e(!Ye.vertEq(u,l)),$e(Ye.edgeSign(l,t.event,o)<=0),$e(Ye.edgeSign(u,t.event,a)>=0),$e(o!==t.event&&a!==t.event),$e(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(Ye.vertLeq(o,a)){if(Ye.edgeSign(u,o,a)>0)return!1}else if(Ye.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Ye.intersect(l,o,u,a,h),$e(Math.min(o.t,l.t)<=h.t),$e(h.t<=Math.max(a.t,u.t)),$e(Math.min(u.s,l.s)<=h.s),$e(h.s<=Math.max(a.s,o.s)),Ye.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=Ye.vertLeq(o,a)?o:a,Ye.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),Ye.vertEq(h,o)||Ye.vertEq(h,a)?(i.checkForRightSplice(t,e),!1):!Ye.vertEq(l,t.event)&&Ye.edgeSign(l,t.event,h)>=0||!Ye.vertEq(u,t.event)&&Ye.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Sym,r),e=i.topLeftRegion(t,e),r=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),n),i.addRightEdges(t,e,r.Oprev,r,r,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(r.Lnext,s.Oprev),n=e,e=i.topRightRegion(e),m=i.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=i.finishLeftRegions(t,n,null),i.addRightEdges(t,e,s.Onext,r.Rprev,m,!0),!0):(Ye.edgeSign(l,t.event,h)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),r.Org.s=t.event.s,r.Org.t=t.event.t),Ye.edgeSign(u,t.event,h)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(r.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,r),r.Org.s=h.s,r.Org.t=h.t,r.Org.pqHandle=t.pq.insert(r.Org),i.getIntersectData(t,r.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var n=i.regionBelow(e),r,s;;){for(;n.dirty;)e=n,n=i.regionBelow(n);if(!e.dirty&&(n=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,r=e.eUp,s=n.eUp,r.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(i.deleteRegion(t,n),t.mesh.delete(s),n=i.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n),r=e.eUp)),r.Org!==s.Org)if(r.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(r.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);r.Org===s.Org&&r.Dst===s.Dst&&(i.addWinding(s,r),i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n))}},i.connectRightVertex=function(t,e,n){var r,s=n.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Ye.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Ye.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,n.Onext,s,s,!0);return}Ye.vertLeq(l.Org,a.Org)?r=l.Oprev:r=a,r=t.mesh.connect(n.Lprev,r),i.addRightEdges(t,e,r,r.Onext,r.Onext,!1),r.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,n){var r,s,o,a,l;if(r=e.eUp,Ye.vertEq(r.Org,n)){$e(!1),i.spliceMergeVertices(t,r,n.anEdge);return}if(!Ye.vertEq(r.Dst,n)){t.mesh.splitEdge(r.Sym),e.fixUpperEdge&&(t.mesh.delete(r.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,r),i.sweepEvent(t,n);return}$e(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&($e(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),Ye.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var n,r,s,o,a,l,u=new Pw;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,r=i.regionBelow(n),!!r){if(o=n.eUp,a=r.eUp,Ye.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,n,e);return}if(s=Ye.vertLeq(a.Dst,o.Dst)?n:r,n.inside||s.fixUpperEdge){if(s===n)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,n,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){i.connectLeftVertex(t,e);return}var r=i.topLeftRegion(t,n.activeRegion);$e(r!==null);var s=i.regionBelow(r),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,r,a):i.addRightEdges(t,r,a.Onext,o,o,!0)},i.addSentinel=function(t,e,n,r){var s=new Pw,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=r,o.Dst.s=e,o.Dst.t=r,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new Gj(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],r=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;i.addSentinel(t,r,s,o),i.addSentinel(t,r,s,a)},i.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||($e(e.fixUpperEdge),$e(++n===1)),$e(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,n,r,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,r=e.Lnext,Ye.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,r,e),t.mesh.delete(e),e=r,r=e.Lnext),r.Lnext===e&&(r!==e&&((r===n||r===n.Sym)&&(n=n.next),t.mesh.delete(r)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,n,r,s=0;for(r=t.mesh.vHead,n=r.next;n!==r;n=n.next)s++;for(s+=8,e=t.pq=new zj(s,Ye.vertLeq),r=t.mesh.vHead,n=r.next;n!==r;n=n.next)n.pqHandle=e.insert(n);return n!==r?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var n,r,s;for(n=e.fHead.next;n!==e.fHead;n=r)r=n.next,s=n.anEdge,$e(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var n,r;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;r=t.pq.min(),!(r===null||!Ye.vertEq(r,n));)r=t.pq.extractMin(),i.spliceMergeVertices(t,n.anEdge,r.anEdge);i.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),Hj=function(){function i(){this.mesh=new AP,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=gt.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 i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,n,r,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;e=p.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,m[g]=e,l[g]=s,f[g]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,m[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,n=m[v],r=f[v],c[0]=n.coords[0]-r.coords[0],c[1]=n.coords[1]-r.coords[1],c[2]=n.coords[2]-r.coords[2],e=p.next;e!==p;e=e.next)d[0]=e.coords[0]-r.coords[0],d[1]=e.coords[1]-r.coords[1],d[2]=e.coords[2]-r.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,r,s=0,o=t.next;o!==t;o=o.next)if(r=o.anEdge,!(r.winding<=0))do s+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(s<0){for(e=n.next;e!==n;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,r,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),n=this.sUnit,r=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,r);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var n,r;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Ye.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Ye.vertLeq(n.Org,n.Dst);n=n.Lnext);r=n.Lprev;for(var s=void 0;n.Lnext!==r;)if(Ye.vertLeq(n.Dst,r.Org)){for(;r.Lnext!==n&&(Ye.edgeGoesLeft(r.Lnext)||Ye.edgeSign(r.Org,r.Dst,r.Lnext.Dst)<=0);)s=t.connect(r.Lnext,r),r=s.Sym;r=r.Lprev}else{for(;r.Lnext!==n&&(Ye.edgeGoesRight(n.Lprev)||Ye.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(r.Lnext===n)throw"Mono region invalid";for(;r.Lnext.Lnext!==n;)s=t.connect(r.Lnext,r),r=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},i.prototype.setWindingNumber_=function(t,e,n){for(var r,s=t.eHead.next;s!==t.eHead;s=r)r=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,n,r){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.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 u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===an.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*r,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*r;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],r>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===an.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var m=l;m<n;++m)this.elements[h++]=-1}}},i.prototype.outputContours_=function(t,e){var n,r,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){r=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==r);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,r=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==r);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new AP),t<2&&(t=2),t>3&&(t=3);for(var n=null,r=0;r<e.length;r+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[r+0],n.Org.coords[1]=e[r+1],t>2?n.Org.coords[2]=e[r+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},i.prototype.tesselate=function(t,e,n,r,s,o){if(t===void 0&&(t=gt.ODD),e===void 0&&(e=an.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,r<2&&(r=2),r>3&&(r=3),!this.mesh)return!1;this.projectPolygon_(),Vj.computeInterior(this,o);var a=this.mesh;return e===an.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===an.BOUNDARY_CONTOURS?this.outputContours_(a,r):this.outputPolymesh_(a,e,n,r),!0},i}();function rs(i){var t=i.windingRule,e=t===void 0?gt.ODD:t,n=i.elementType,r=n===void 0?an.POLYGONS:n,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,d=i.contours,h=d===void 0?[]:d,f=i.strict,m=f===void 0?!0:f,p=i.debug,g=p===void 0?!1:p;if(!h&&m)throw new Error("Contours can't be empty");if(!!h){var y=new Hj;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,r,o,l,c,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Zle=gt.ODD,Jle=gt.NONZERO,$le=gt.POSITIVE,ece=gt.NEGATIVE,tce=gt.ABS_GEQ_TWO,nce=an.POLYGONS,rce=an.CONNECTED_POLYGONS,ice=an.BOUNDARY_CONTOURS;var wy=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*wy.eSize;this.buffer=new ArrayBuffer(n);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*r,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let n=t*wy.eSize,r=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(r,o*s,3*t);o+=3*t;let l=new Float32Array(r,o*s,3*t);o+=3*t;let u=new Float32Array(r,o*s,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=r,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let r=this.capacity;for(;e>r;)r*=2;this.realloc(r)}let n=this.size;return this.size=e,n}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Nf=wy;Nf.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Bf={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Dw={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Ow={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},Iw=(i,t)=>([e,n])=>(n<e&&(n+=t),(i>=e?i:i+t)<=n),sd=class extends Me{constructor(e,n,r=0,s=12,o=3,a=gt.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._bevel=r,this._curveSegments=s,this._bevelSegmentsInput=o,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(M=>{let b=M.extractShapePointsToFlatArray([],s),E=[];for(let T=b.length-1;T>=1;T-=2){let I=b[T-1],C=b[T-0];E.push(I,C)}return E}),c;try{c=rs({windingRule:a,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=Bf}let d;try{d=rs({windingRule:gt.ODD,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=Dw}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let M=0;M<d.elements.length;M++){let b=d.elements[M],E=M%2===0?c.vertexCount:0;c.elements.push(b+E)}for(let M=0;M<d.vertexIndices.length;M++){let b=d.vertexIndices[M],E=c.vertexCount;c.vertexIndices.push(b+E)}for(let M=0;M<d.vertices.length;M++){let b=d.vertices[M];c.vertices.push(b)}}let f=1/0,m=-1/0,p=1/0,g=-1/0;for(let M=0,b=c.vertexCount;M<b;M++){let E=M*2,T=c.vertices[E+0],I=c.vertices[E+1];T<f&&(f=T),T>m&&(m=T),I<p&&(p=I),I>g&&(g=I)}this._minX=f,this._minY=p,this._width=m-f,this._height=g-p,this._buffer=new Nf(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let M=c.elementCount-1;M>=0;M--){let b=M>=h,E=M*2,T=c.elements[E+0],I=c.elements[E+1],C=T+I,P={start:T,count:I,normals:[],continuous:[],concave:[]},O=T,B=C-1,j=T+1,Q=this._shape.roundedCurves.length;do{let X=O-T,L=c.vertices[B*2+0],U=c.vertices[B*2+1],G=c.vertices[O*2+0],H=c.vertices[O*2+1],z=c.vertices[j*2+0],re=c.vertices[j*2+1],K=G-L,Z=H-U,k=Math.sqrt(K*K+Z*Z);K/=k,Z/=k;let he=G-z,fe=H-re,ce=Math.sqrt(he*he+fe*fe);he/=ce,fe/=ce,P.normals[X*2+0]=-fe,P.normals[X*2+1]=he,P.concave[X]=K*fe-Z*he>0;let ye=c.vertexIndices[O];if(Array.isArray(ye))P.continuous[X]=!1;else{let[Se,ve]=this._shape.getCurveIndexFromVertexId(ye-1,!0);if(ve>0&&ve<1)P.continuous[X]=!0;else{let Ee=ve===1?Se+1:Se-1;Ee=(Ee+Q)%Q;let Te=ve===1?0:1,we=this._shape.roundedCurves[Se].getTangent(ve),He=this._shape.roundedCurves[Ee].getTangent(Te);P.continuous[X]=we.dot(He)>.95}}b&&(P.normals[X*2+0]*=-1,P.normals[X*2+1]*=-1),[B,O,j]=[O,j,j+1],j>=C&&(j-=I)}while(j!==T+1);let V=[];V.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(T*2,C*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((X,L)=>[L,L]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(T*2,C*2)});for(let X=1;X<=this._bevelSegments;X++){let L=X/this._bevelSegments*Math.PI/2,U=(1-Math.cos(L))*this._bevelSize,G=[],H=[],z=[],re=[],K=0;for(let k=0;k<I;k++){let he=k*2,fe=(k-1+I)%I*2,ce=c.vertices[P.start*2+he+0],ye=c.vertices[P.start*2+he+1],Se=-P.normals[fe+0]*U,ve=-P.normals[fe+1]*U,Ee=-P.normals[he+0]*U,Te=-P.normals[he+1]*U;if(P.concave[k]||!P.concave[k]&&b){let we=Math.atan2(ve,Se),He=Math.atan2(Te,Ee);He>we&&(He-=Math.PI*2);let vt=He-we;if(P.continuous[k]||b){let R=we+vt/2,D=Math.cos(R)*U,ee=Math.sin(R)*U;G[2*K+0]=ce+D*(b?-1:1),G[2*K+1]=ye+ee*(b?-1:1),re[K]=k,K++}else{let R=Math.max(1,Math.floor(s/4*Math.abs(vt)/Math.PI));for(let D=0;D<=R;D++){let ee=we+vt*(D/R),me=Math.cos(ee)*U,xe=Math.sin(ee)*U;G[2*K+0]=ce+me,G[2*K+1]=ye+xe,re[K]=k,K++}}}else G[2*K+0]=ce+Se,G[2*K+1]=ye+ve,re[K]=k,H[k]=K,K++,G[2*K+0]=ce,G[2*K+1]=ye,re[K]=k,K++,G[2*K+0]=ce+Ee,G[2*K+1]=ye+Te,re[K]=k,z[k]=K,K++}let Z=rs({windingRule:gt.POSITIVE,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[G],edgeCreateCallback:k=>{let fe=k.Org.idx,ce=re[fe],ye=re[(fe+1)%re.length];k.idx=[ce,ye],k.Sym.idx=[ye,ce]},vertexIdCallback:k=>{let he=k.Lprev.idx;return[he?he[1]:0,k.idx?k.idx[0]:0]}});if(!Z)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!Z.vertexCount)break;for(let k=0;k<Z.vertexIndices.length;k++){let[he,fe]=Z.vertexIndices[k];if(he===fe)continue;let ce=fe;fe<he&&(ce+=I);for(let ye=he;ye<ce;ye++){let Se=ye%I,ve=(ye+1)%I;if(!P.continuous[Se]||!P.continuous[ve]){Z.vertexIndices[k]=[he,Se],Z.vertexIndices.splice(k+1,0,[ve,fe]),Z.vertices.splice((k+1)*2,0,Z.vertices[k*2],Z.vertices[k*2+1]);break}}}V.push({bevelI:X,angle:L,size:U,boundary:Z,reverseMap:re,insetPoints:G})}let q=(X,L,U)=>{let G=0,H=X.boundary.vertexIndices.length;for(;G<H&&U(X.boundary.vertexIndices[L]);)L=(L+1)%H,G++;return G},W=y.length;for(let X=1;X<V.length;X++){let L=V[X-1],U=V[X],G=L.boundary.vertexIndices.length,H=U.boundary.vertexIndices.length;if(!G||!H)break;let z=P.concave.length,re=0,K=Iw(re,I);for(;!L.boundary.vertexIndices.filter(K).length||!U.boundary.vertexIndices.filter(K).length;)re++,K=Iw(re,I);let Z=L.boundary.vertexIndices.findIndex(K),k=U.boundary.vertexIndices.findIndex(K);do Z=(Z+1)%G;while(K(L.boundary.vertexIndices[Z]));do k=(k+1)%H;while(K(U.boundary.vertexIndices[k]));re=(re+1)%I;let he=re,fe=this._buildBevelVert(P,L,(Z-1+G)%G),ce=this._buildBevelVert(P,U,(k-1+H)%H),ye=fe,Se=ce,ve,Ee,Te=!1;do{K=Iw(re,I);let we=q(L,Z,K),He=q(U,k,K),vt=Te;if(Te=!1,we&&!He){for(let R=0;R<we;R++)ve=this._buildBevelVert(P,L,(Z+R)%G,R/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve;Te=!0}else if(!we&&He)for(let R=0;R<He;R++)Ee=this._buildBevelVert(P,U,(k+R)%H,R/(He-1)),y.push(Se.topN,ye.topP,Ee.topP),y.push(ye.bottomP,Se.bottomN,Ee.bottomP),Se=Ee;else if(we&&He)if(ve=this._buildBevelVert(P,L,Z,0),Ee=this._buildBevelVert(P,U,k,0),vt?(y.push(ye.topN,Ee.topP,Se.topN),y.push(ye.topN,ve.topP,Ee.topP),y.push(Ee.bottomP,ye.bottomN,Se.bottomN),y.push(Ee.bottomP,ve.bottomP,ye.bottomN)):(y.push(Se.topN,ye.topN,ve.topP),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP)),ye=ve,Se=Ee,we===He)for(let R=1;R<we;R++)ve=this._buildBevelVert(P,L,(Z+R)%G,R/(we-1)),Ee=this._buildBevelVert(P,U,(k+R)%H,R/(He-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,ye.bottomN,Se.bottomN),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),ye=ve,Se=Ee;else if(we>He){let R=we/He,D=0;for(let ee=1;ee<we;ee++)ve=this._buildBevelVert(P,L,(Z+ee)%G,ee/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve,ee>(D+1)*R&&(D++,Ee=this._buildBevelVert(P,U,(k+D)%H,D/(He-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee)}else{let R=He/we,D=0;for(let ee=1;ee<He;ee++)Ee=this._buildBevelVert(P,U,(k+ee)%H,ee/(He-1)),y.push(Se.topN,ve.topP,Ee.topP),y.push(ve.bottomP,Se.bottomN,Ee.bottomP),Se=Ee,ee>(D+1)*R&&(D++,ve=this._buildBevelVert(P,L,(Z+D)%G,D/(we-1)),y.push(ye.topN,ve.topP,Se.topN),y.push(ve.bottomP,ye.bottomN,Se.bottomN),ye=ve)}Z=(Z+we)%G,k=(k+He)%H,re=(re+1)%z}while(re!==he)}if(this._depth>this._bevel*2&&this._buildWall(V,P,y),b){let X=[];for(let L=y.length-1;L>=W+2;L-=3){let U=y[L-2],G=y[L-1],H=y[L-0];X.push(H,G,U)}y.splice(W,y.length-W,...X)}if(b){let X=[];for(let L=V[V.length-1].boundary.vertices.length-1;L>=1;L-=2){let U=V[V.length-1].boundary.vertices[L-1],G=V[V.length-1].boundary.vertices[L-0];X.push(U,G)}v.push(X)}if(!b){let X=V[V.length-1],L;try{L=rs({windingRule:V.length>1?gt.POSITIVE:gt.ODD,elementType:an.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,...v]})}catch{L=Ow}if(!L)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let U=0;U<L.elementCount*3;U+=3){let G=this._buildSurfaceVert(L,L.elements[U+0]),H=this._buildSurfaceVert(L,L.elements[U+1]),z=this._buildSurfaceVert(L,L.elements[U+2]);y.push(G.top,H.top,z.top),y.push(z.bottom,H.bottom,G.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Be(Uint32Array.from(y),1),w=new Be(this._buffer.positions,3),S=new Be(this._buffer.normals,3),_=new Be(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,_.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",_),this.setIndex(x)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n){let r=n.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[n*2+0],o=e.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=l,this.vertexCache[r]=h,h}_buildBevelVert(e,n,r,s=1){let o=`${n.bevelI}:${r}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[r],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=e.continuous[c]&&e.continuous[u]):(u=a,c=(u-1+e.count)%e.count,h=e.concave[u]&&n.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=r*2,g=u*2,y=c*2,v=n.boundary.vertices[p+0],x=n.boundary.vertices[p+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,_=(x-this._minY)/this._height,M=e.normals[g+0],b=e.normals[g+1],E=e.normals[y+0],T=e.normals[y+1];if(h){let B=E-M,j=T-b;M=M+B*(1-s),b=b+j*(1-s);let Q=Math.sqrt(M*M+b*b);M/=Q,b/=Q}let I=this._buffer.get(d?2:4),C=I*3,P=I*2,O={i:r,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[C+0]=v,this._buffer.positions[C+1]=x,this._buffer.positions[C+2]=this._depth-w,this._buffer.normals[C+0]=M*f,this._buffer.normals[C+1]=b*f,this._buffer.normals[C+2]=m,this._buffer.uvs[P+0]=S,this._buffer.uvs[P+1]=_,this._buffer.positions[C+3]=v,this._buffer.positions[C+4]=x,this._buffer.positions[C+5]=w,this._buffer.normals[C+3]=M*f,this._buffer.normals[C+4]=b*f,this._buffer.normals[C+5]=-m,this._buffer.uvs[P+2]=_,this._buffer.uvs[P+3]=S,d||(I+=2,C+=6,P+=4,O.topP=I+0,O.bottomP=I+1,this._buffer.positions[C+0]=v,this._buffer.positions[C+1]=x,this._buffer.positions[C+2]=this._depth-w,this._buffer.normals[C+0]=E*f,this._buffer.normals[C+1]=T*f,this._buffer.normals[C+2]=m,this._buffer.uvs[P+0]=S,this._buffer.uvs[P+1]=_,this._buffer.positions[C+3]=v,this._buffer.positions[C+4]=x,this._buffer.positions[C+5]=w,this._buffer.normals[C+3]=E*f,this._buffer.normals[C+4]=T*f,this._buffer.normals[C+5]=-m,this._buffer.uvs[P+2]=_,this._buffer.uvs[P+3]=S),this.vertexCache[o]=O,O}clone(){let e=new sd(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=So(this.userData),e}};var od=class extends Me{constructor(e,n=12,r={}){super();this.type="ShapeGeometry";this.windingRule=gt.ODD;this.elementType=an.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:gt.ODD,elementType:an.POLYGONS,polySize:3,vertexSize:2,strict:!0},r);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=rs({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Bf}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Be(new Float32Array(h*3),3),this._normalAttribute=new Be(new Float32Array(h*3),3),this._uvAttribute=new Be(new Float32Array(h*2),2),this._indexAttribute=new Be(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,y=-1/0;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1];M<m&&(m=M),M>p&&(p=M),b<g&&(g=b),b>y&&(y=b)}let v=p-m,x=y-g;for(let w=0,S=h;w<S;w++){let _=w*2,M=a.vertices[_+0],b=a.vertices[_+1],E=(M-m)/v,T=(b-g)/x;this._positionAttribute.setXYZ(w,M,b,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,E,T)}for(let w=0,S=f;w<S;w++){let _=w*3,M=a.elements[_+0],b=a.elements[_+1],E=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,b),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,(a?.elementCount??1)*3)}clone(){let e=new od(this._shape,this._curveSegments);return e.userData=So(this.userData),e}};var ad=class extends sd{constructor(e,n,r=0,s=12,o=3,a=gt.ODD){super(e,n,r,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new ad(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=So(this.userData),e}};var Kr=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:gt.ODD},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Et?(o.width!==n||o.height!==r)&&o.applySize(n,r):o=new Et(n,r).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Et(n,r);return{parameters:Object.assign(e,{width:n,height:r,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:r,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new od(i.shape,r,{windingRule:o}):a=new ad(i.shape,t,e,r,n,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var CP=Math.PI*2,cd=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,angle:r,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,d=e*.5,h=jj(u,c,d,r*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Kr.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function jj(i,t,e,n,r,s){if(n>=CP)return r>30||r%4===0?(qj(i,t,e,s),Math.round(r/4)):TP(i,n,r,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=SP({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return r>30||r%u.length===0?Wj(i,o.x,o.y,u,r,t,e,s):TP(i,n,r,t,e,s)}function Wj(i,t,e,n,r,s,o,a){let l=Math.round(r/n.length);i.addPoint(ld(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=i.points[u],f=ld(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),i.addPoint(f)}return a>0?PP(i,s,o,a):i.addPoint(ld(0,0)),l}function TP(i,t,e,n,r,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*r;i.addPoint(ld(u,c))}return t<CP?s>0?PP(i,n,r,s):i.addPoint(ld(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&IP(i,n,r,s)),1}function qj(i,t,e,n=0,r=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Sy(r-t,s,r-t,s-l,r-t,s+l)),i.addPoint(Sy(r,s+e,r-a,s+e,r+a,s+e)),i.addPoint(Sy(r+t,s,r+t,s+l,r+t,s-l)),i.addPoint(Sy(r,s-e,r+a,s-e,r-a,s-e)),n>0&&IP(i,t,e,n)}function ld(i,t){return new ns(Ve.generateUUID(),new F(i,t))}function Sy(i,t,e,n,r,s){let o=ld(i,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(r,s),o}function PP(i,t,e,n){DP(i,t,e,n).forEach(s=>i.addPoint(s))}function IP(i,t,e,n){let r=DP(i,t,e,n),s=new Et;r.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function DP(i,t,e,n){let r=n*t/100,s=r*(Math.abs(e)/Math.abs(t)),o=new F(r/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Ve.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var OP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:r,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:n,radius:r,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=i.parameters,h=new Ff(!1,t,e,n,r,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...i,type:"HelixGeometry"}})}},Rw=new bs([0,0,0],1),Ff=class extends Me{constructor(t=!0,e=1,n=1,r=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let m=()=>new A,p=new A,g=m(),y=m(),v=m(),x,w,S,_,M,b,E,T,I=m(),C=m(),P=m(),O=m(),B=m(),j=m(),Q=m(),V=m(),q=n-2*l+.001,W=q/o,X=Math.ceil(a*o),L=X+1,U=q/X,G=-q/2,H=c+1,z=2*Math.PI/c,re=Math.PI/2/h,K=.01,Z=Math.min((1-d/100)*l,l-K),k=l-Z,he=0,fe=2,ce=h*fe+fe,ye=H*ce/fe,Se=ye+H*L,ve=H*(L+ce),[Ee,Te,we]=[3,3,2].map(Le=>Array(ve*Le).fill(0)),He=[],vt=s-l;function R(Le,Ie){let Ue=Math.PI/2;b=Ie*U,T=2*Math.PI*(b%W)/W+Ue,b+=G,E=Math.sin(T)*vt,M=Math.cos(T)*vt,t?Le.set(M,E,b):Le.set(M,b,E)}R(p,-1e-10),R(g,0),I.copy(p),R(p,1);let D=p.distanceTo(g),ee=f?0:k+Z,me=D*X+2*ee,xe=Z,Ce=me-ee;for(let Le=0;Le<=X;Le++){R(y,Le),V.subVectors(y,I).normalize(),I.copy(y),j.copy(y).setComponent(+t+1,0).normalize(),Q.crossVectors(V,j).normalize();let Ie=Le===0,Ue=Le===X,Ke=Ie?3*Math.PI/2:re,xt=Ie?xe:Ce,jt=Ie?H:Se,En=Ie?0:ve-H,Y=V.clone().multiplyScalar(Ie?-k:k).add(y),oe=V.clone().multiplyScalar(Ie?-1:1).normalize();for(let ge=0;ge<H;ge++){let Ne=ge*z;if(C.addVectors(p.copy(j).multiplyScalar(l*Math.cos(Ne)),g.copy(Q).multiplyScalar(l*Math.sin(Ne))),P.copy(C).normalize(),Ie||Ue){f||(he=En+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=Y.getComponent(Oe),Te[he*3+Oe]=oe.getComponent(Oe)}),we[he*2]=+Ue,we[he*2+1]=ge/c),g.copy(P).multiplyScalar(Z),v.addVectors(y,g);for(let Oe=0;Oe<h;Oe++){let bt=Oe*re+Ke;O.addVectors(p.copy(V).multiplyScalar(k*Math.sin(bt)),g.copy(P).multiplyScalar(k*Math.cos(bt))),B.copy(O).normalize(),g.addVectors(v,O),O.normalize(),he=jt+Oe*H+ge,[0,1,2].forEach(mn=>{Ee[he*3+mn]=g.getComponent(mn),Te[he*3+mn]=B.getComponent(mn)});let Tn=+Ie+Math.sin(bt);we[he*2]=(xt+k*Tn)/me,we[he*2+1]=ge/c}}g.addVectors(y,C),he=ye+Le*H+ge,[0,1,2].forEach(Oe=>{Ee[he*3+Oe]=g.getComponent(Oe),Te[he*3+Oe]=P.getComponent(Oe)}),we[he*2]=(ee+Le*D)/me,we[he*2+1]=ge/c}}let je=L+2*h+fe,Pe=1,[de,Qe]=[+f,je-1];for(let Le=de;Le<=Qe-1;Le++){let Ie=f&&Le===Qe-1;for(let Ue=0;Ue<H-1;Ue++)x=Le*H+Ue,w=x+1,S=(Ie?Ue:x)+H,_=(Ie?Ue+1:w)+H,Le===0?He.push(w,_,S):Le===je-2?He.push(x,w,S):He.push(x,w,S,w,_,S)}this.setIndex(He),this.setAttribute("position",new Ae(Ee,3)),this.setAttribute("normal",new Ae(Te,3)),this.setAttribute("uv",new Ae(we,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,r=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let h=0;h<t.radialSegments;h++)s=c*n+h,o=s+1,a=(d?h:s)+n,l=(d?h+1:o)+n,r[u++]=s,r[u++]=o,r[u++]=a,r[u++]=o,r[u++]=l,r[u++]=a;return r.length=u,Rw.array=r,Rw.count=r.length,Rw}};var RP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Uf(t*.5,s,o):new Rc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},Uf=class extends Oa{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new Uf(t.radius,t.corner,t.cornerSides)}};var LP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:n}=i.parameters,r=new go;r.moveTo(t[0].x,t[0].y),r.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Cc(r.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Ns=new ie,Lw=new ht,Ay=new A,La=class extends Ut{constructor(){super(),this.uuid=Ve.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new en().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Ns.makeRotationX(t),this.applyMatrix4(Ns),this}rotateY(t){return Ns.makeRotationY(t),this.applyMatrix4(Ns),this}rotateZ(t){return Ns.makeRotationZ(t),this.applyMatrix4(Ns),this}translate(t,e,n){return Ns.makeTranslation(t,e,n),this.applyMatrix4(Ns),this}scale(t,e,n){return Ns.makeScale(t,e,n),this.applyMatrix4(Ns),this}lookAt(t){return Lw.lookAt(t),Lw.updateMatrix(),this.applyMatrix4(Lw.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,o=r.normal,a=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Re().fromBufferAttribute(a,h));function c(h,f,m,p){let g=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[m].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],v=new ud(h,f,m,y,g,p);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new F().fromBufferAttribute(l,h),new F().fromBufferAttribute(l,f),new F().fromBufferAttribute(l,m)]),u!==void 0&&e.faceVertexUvs[1].push([new F().fromBufferAttribute(u,h),new F().fromBufferAttribute(u,f),new F().fromBufferAttribute(u,m)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],m=f.start,p=f.count;for(let g=m,y=m+p;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ay).negate(),this.translate(Ay.x,Ay.y,Ay.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new ie;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let n=0,r=this.vertices.length;n<r;n++)e[n]=new A;if(t){let n=new A,r=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),r.subVectors(l,u),n.cross(r),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,o=r.vertexNormals.length;s<o;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let t=new La;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let r=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=r.faceNormals[s],u=r.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _t),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new dn),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(r=new en().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let m=u[h],p,g,y=m.vertexNormals,v=m.vertexColors,x=new ud(m.a+s,m.b+s,m.c+s);x.normal.copy(m.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let w=0,S=y.length;w<S;w++)p=y[w].clone(),r!==void 0&&p.applyMatrix3(r).normalize(),x.vertexNormals.push(p);x.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)g=v[w],x.vertexColors.push(g.clone());x.materialIndex=m.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++)v.push(y[x].clone());this.faceVertexUvs[h].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},n=[],r=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),r[l]=n.length-1):r[l]=r[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=r[c.a],c.b=r[c.b],c.c=r[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new A(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;r&&r.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(r[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(t[p]=m[p]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];e.push(p.x,p.y,p.z)}let n=[],r=[],s={},o=[],a={},l=[],u={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,y=!1,v=this.faceVertexUvs[0][m]!==void 0,x=p.normal.length()>0,w=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,M=0;if(M=c(M,0,0),M=c(M,1,g),M=c(M,2,y),M=c(M,3,v),M=c(M,4,x),M=c(M,5,w),M=c(M,6,S),M=c(M,7,_),n.push(M),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let b=this.faceVertexUvs[0][m];n.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&n.push(d(p.normal)),w){let b=p.vertexNormals;n.push(d(b[0]),d(b[1]),d(b[2]))}if(S&&n.push(h(p.color)),_){let b=p.vertexColors;n.push(h(b[0]),h(b[1]),h(b[2]))}}function c(m,p,g){return g?m|1<<p:m&~(1<<p)}function d(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=r.length/3,r.push(m.x,m.y,m.z)),s[p]}function h(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(m.x,m.y)),u[p]}return t.data={},t.data.vertices=e,t.data.normals=r,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new La().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let r=t.faces;for(let h=0,f=r.length;h<f;h++)this.faces.push(r[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let m=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,g=m.length;p<g;p++){let y=m[p],v=[];for(let x=0,w=y.length;x<w;x++){let S=y[x];v.push(S.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let m={};if(m.name=s[h].name,s[h].vertices!==void 0){m.vertices=[];for(let p=0,g=s[h].vertices.length;p<g;p++)m.vertices.push(s[h].vertices[p].clone())}if(s[h].normals!==void 0){m.normals=[];for(let p=0,g=s[h].normals.length;p<g;p++)m.normals.push(s[h].normals[p].clone())}this.morphTargets.push(m)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let m={};if(o[h].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[h].vertexNormals.length;p<g;p++){let y=o[h].vertexNormals[p],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),m.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[h].faceNormals.length;p<g;p++)m.faceNormals.push(o[h].faceNormals[p].clone())}this.morphNormals.push(m)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Nw().fromGeometry(this),e=new Me,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",_y.call(new Be(n,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);e.setAttribute("normal",_y.call(new Be(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);e.setAttribute("color",NP.call(new Be(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);e.setAttribute("uv",BP.call(new Be(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",BP.call(new Be(r,2),t.uvs2))}e.groups=t.groups;for(let r in t.morphTargets){let s=[],o=t.morphTargets[r];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new Ae(u.data.length*3,3);c.name=u.name,s.push(_y.call(c,u.data))}e.morphAttributes[r]=s}if(t.skinIndices.length>0){let r=new Ae(t.skinIndices.length*4,4);e.setAttribute("skinIndex",FP.call(r,t.skinIndices))}if(t.skinWeights.length>0){let r=new Ae(t.skinWeights.length*4,4);e.setAttribute("skinWeight",FP.call(r,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Me,n=t.geometry;if(t.isPoints||t.isLine){let r=new Ae(n.vertices.length*3,3),s=new Ae(n.colors.length*3,3);if(e.setAttribute("position",_y.call(r,n.vertices)),e.setAttribute("color",NP.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Ae(n.lineDistances.length,1);e.setAttribute("lineDistance",Yj.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};La.prototype.isGeometry=!0;var Nw=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],n,r,s,o=t.faces;for(r=0;r<o.length;r++){let a=o[r];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=r*3-n.start,e.push(n)),n={start:r*3,materialIndex:s})}n!==void 0&&(n.count=r*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,m=t.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=r[0][y];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new F,new F,new F))}if(o===!0){let S=r[1][y];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new F,new F,new F))}for(let S=0;S<l;S++){let _=a[S].vertices;u[S].data.push(_[v.a],_[v.b],_[v.c])}for(let S=0;S<d;S++){let _=c[S].vertexNormals[y];h[S].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},ud=class{constructor(t,e,n,r,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new A,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Re,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function Yj(i){return this.array.set(i),this}function NP(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Re),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function BP(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new F),t[e++]=s.x,t[e++]=s.y}return this}function _y(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function FP(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new We),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var Xj=["a","b","c"];function Qj(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Bw(i,t,e){let n=Math.min(i,t),r=Math.max(i,t),s=n+"_"+r;return e.get(s)}function Fw(i,t,e,n,r,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(r),s[i].edges.push(u),s[t].edges.push(u)}function Kj(i,t,e,n){let r,s,o;for(r=0,s=i.length;r<s;r++)e[r]={edges:[]};for(r=0,s=t.length;r<s;r++)o=t[r],Fw(o.a,o.b,i,n,o,e),Fw(o.b,o.c,i,n,o,e),Fw(o.c,o.a,i,n,o,e)}function My(i,t,e,n,r){i.push(new ud(t,e,n,void 0,void 0,r))}function dd(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Ey(i,t,e,n){i.push([t.clone(),e.clone(),n.clone()])}var Ty=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Me?t=new La().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,r,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;Kj(l,u,h,f);let m=[],p,g,y,v,x,w,S;for(let K of Array.from(f.keys())){for(g=f.get(K),y=new A,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[Qj(v,Xj[a])],!(p!==g.a&&p!==g.b));a++);p&&e.add(p)}e.multiplyScalar(w),y.add(e),g.newEdge=m.length,m.push(y)}let _,M,b,E,T,I,C,P=[];for(r=0,s=l.length;r<s;r++){for(I=l[r],T=h[r].edges,n=T.length,n==3?_=3/16:n>3&&(_=3/(8*n)),M=1-n*Number(_),b=_,n<=2&&(n==2?(M=3/4,b=1/8):n==1||n==0),C=I.clone().multiplyScalar(M),e.set(0,0,0),o=0;o<n;o++)E=T[o],p=E.a!==I?E.a:E.b,e.add(p);e.multiplyScalar(Number(b)),C.add(e),P.push(C)}let O=P.concat(m),B=P.length,j,Q,V,q=[],W=[],X,L,U,G,H=new F,z=new F,re=new F;for(r=0,s=u.length;r<s;r++)v=u[r],j=Number(Bw(v.a,v.b,f).newEdge)+B,Q=Number(Bw(v.b,v.c,f).newEdge)+B,V=Number(Bw(v.c,v.a,f).newEdge)+B,My(q,j,Q,V,v.materialIndex),My(q,v.a,j,V,v.materialIndex),My(q,v.b,Q,j,v.materialIndex),My(q,v.c,V,Q,v.materialIndex),d&&(X=c[r],L=X[0],U=X[1],G=X[2],H.set(dd(L.x,U.x),dd(L.y,U.y)),z.set(dd(U.x,G.x),dd(U.y,G.y)),re.set(dd(L.x,G.x),dd(L.y,G.y)),Ey(W,H,z,re),Ey(W,L,H,re),Ey(W,U,z,H),Ey(W,G,re,z));t.vertices=O,t.faces=q,d&&(t.faceVertexUvs[0]=W)}};var Yn=new A,UP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Me().copy(new er(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Yn),n={width:Yn.x,height:Yn.y,depth:Yn.z,subdivisions:0}):n=t.parameters;let r={...n,...i.parameters};return{parameters:{width:Math.abs(r.width),height:Math.abs(r.height),depth:Math.abs(r.depth),subdivisions:Math.abs(r.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:n,subdivisions:r}=i.parameters,s=i.geometry??new Me().copy(new er(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Yn)):Yn.set(o.width,o.height,o.depth),(t!==Yn.x||e!==Yn.y||n!==Yn.z)&&s.scale(Yn.x===0?1:t/Yn.x,Yn.y===0?1:e/Yn.y,Yn.z===0?1:n/Yn.z);let a=s.originalGeometry;try{r>0?(a===void 0||o?.subdivisions!==r)&&(a===void 0&&(a=s),s=new Ty(r).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Gc(e).load(i,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Yn);let o=100/Yn.x;Object.assign(s.parameters,{width:100,height:Yn.y*o,depth:Yn.z*o}),t(this.build(s))})}};var Cy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,cornerRadius:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,y=d+Math.sin(g)*u,v=h+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=r;l.roundness=r,l.update();let m=Kr.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...i,type:"PolygonGeometry"}})}};var kP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new kw(t*.5,e,r,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function kf(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Uw(i,t,e,n,r,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===r){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,r/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function Zj(i,t,e){let n=i.clone().sub(t),r=e.clone().sub(t);return n.projectOnVector(r),n.add(t)}var kw=class extends Me{constructor(t=.5,e=1,n=4,r=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),r=Math.floor(r),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,m=Math.PI/n,p=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),w=new A(0,f,0),S=new F(t,-f),_=new F(p,-f),M=new F(0,w.y).sub(_),b=new F(0,w.y).sub(S),E=new F(M.y,-M.x).normalize(),T=new F(b.y,-b.x).normalize(),C=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,C);let P;{let W=new A(E.x,E.y,0),X=new A(Math.cos(g)*W.x,W.y,Math.sin(g)*W.x);P=W.angleTo(X)}let O=o/Math.tan((Math.PI-M.angle())/2),B=o/Math.tan((Math.PI-P)/2),j=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let W=h++,X=[],L=S.clone(),U=O/Math.cos(Math.PI/n);L.x-=U;for(let G=0;G<n;G++){let H=G/n*Math.PI*2+m,z=new F(Math.sin(H),Math.cos(H));kf(L,z,j),u.push(j.x,j.y,j.z),c.push(0,-1,0),d.push(0,0),X.push(h++)}for(let G=0;G<X.length;G++)l.push(X[G],W,X[(G+1)%X.length])}let Q=[];{let W=new A,X=new A,L=new A,U=new A,G=new A,H=new A;for(let z=0;z<n;z++){let re=z/n*Math.PI*2+m,K=(z+.5)/n*Math.PI*2+m,Z=(z+1)/n*Math.PI*2+m,k=new F(Math.sin(re),Math.cos(re)),he=new F(Math.sin(K),Math.cos(K)),fe=new F(Math.sin(Z),Math.cos(Z));kf(S,k,X),kf(S,fe,L),kf(E,he,W),Uw(w,X,L,B,B,U),u.push(U.x,U.y,U.z),Uw(X,w,L,B,O,G),u.push(G.x,G.y,G.z),Uw(L,X,w,O,B,H),u.push(H.x,H.y,H.z),c.push(W.x,W.y,W.z),c.push(W.x,W.y,W.z),c.push(W.x,W.y,W.z),d.push(0,0),d.push(0,0),d.push(0,0);let ce=h++,ye=h++,Se=h++;if(l.push(ce,ye,Se),o>0){{let Te=X.clone().add(L).multiplyScalar(.5),we=w.clone().sub(Te).normalize(),vt=x.clone().sub(Te).normalize().add(we).normalize().multiplyScalar(-1),R=H.clone().sub(G);V(Te,R,vt,M.angle())}let ve,Ee;{let Te=new A;kf(T,fe,Te);let we=H.clone().add(U).multiplyScalar(.5);we=Zj(we,L,w);let He=H.clone().sub(U);[ve,Ee]=V(we,He,Te,P,U.y)}{let Te=ve,we=Te.clone().setY(0).normalize(),He=new A(0,-1,0),vt=we.clone().cross(He);q(Te,we,He,vt)}Q.concat(Ee);{let Te=M.angle(),we=Math.PI-Te,He=w.clone();He.y-=o/Math.sin(Te-Math.PI/2);let vt=new A,R=[];for(let ee=0;ee<a;ee++){let me=[],xe=Math.PI/2-we*ee/a,Ce=Math.cos(xe),je=Math.sin(xe),Pe=K;for(let de=0;de<=ee;de++){let Qe=Math.cos(Pe),Le=Math.sin(Pe);W.x=Ce*Le,W.y=je,W.z=Ce*Qe,vt.copy(He).addScaledVector(W,o),u.push(vt.x,vt.y,vt.z),c.push(W.x,W.y,W.z),d.push(0,0),me.push(h++),Pe+=Math.PI*2/ee/n}R.push(me)}Ee.reverse(),R.push(Ee);let D=R.length-1;for(let ee=0;ee<D;ee++){let me=R[ee],xe=R[ee+1],Ce=me.length-1;l.push(xe[1],me[0],xe[0]);for(let je=1;je<=Ce;je++)l.push(me[je],me[je-1],xe[je]),l.push(xe[je+1],me[je],xe[je])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(d,2));function V(W,X,L,U,G){let H=-U/2,z=(Math.PI-U)/2,re=X.clone().normalize().cross(L);W.addScaledVector(L,-o/Math.sin(z));let K=new A,Z=new A,k=1,he=h,fe=[];for(let ce=0;ce<=a;ce++){let ye=H+ce/a*U;Z.set(0,0,0),Z.addScaledVector(re,Math.sin(ye)),Z.addScaledVector(L,Math.cos(ye));for(let Se=0;Se<=k;Se++){let ve=Se/k-.5;if(K.copy(W),K.addScaledVector(X,ve),K.addScaledVector(Z,o),G!=null){let Ee=Math.max(0,K.y-G);K.addScaledVector(X,-Ee/X.y)}u.push(K.x,K.y,K.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),Se===0&&fe.push(h),h++}}for(let ce=0;ce<a;ce++)for(let ye=0;ye<k;ye++){let Se=he+ye+(k+1)*ce,ve=Se+(k+1),Ee=ve+1,Te=Se+1;l.push(Se,ve,Te),l.push(ve,Ee,Te)}return[W.clone().addScaledVector(X,.5),fe]}function q(W,X,L,U){let G=Math.PI/2,H=b.angle()-G,z=[],re=new A,K=new A;for(let k=0;k<=a;k++){let he=[],fe=k/a;for(let ce=0;ce<=k;ce++){let Se=((k?ce/k:0)-.5)*v,ve=Math.cos(Se),Ee=Math.sin(Se),Te=Math.atan(Math.tan(H)*ve),we=(G+Te)*fe,He=Math.cos(we),vt=Math.sin(we);re.set(0,0,0),re.addScaledVector(X,vt*ve),re.addScaledVector(L,He),re.addScaledVector(U,vt*Ee),K.copy(W).addScaledVector(re,o),u.push(K.x,K.y,K.z),c.push(re.x,re.y,re.z),d.push(0,0),he.push(h++)}z.push(he)}let Z=z.length-1;for(let k=0;k<Z;k++){let he=z[k],fe=z[k+1],ce=he.length-1;l.push(he[0],fe[1],fe[0]);for(let ye=1;ye<=ce;ye++)l.push(he[ye-1],he[ye],fe[ye]),l.push(he[ye],fe[ye+1],fe[ye])}}}};var Py=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(i){let t=i.shape,{width:e,height:n,cornerRadius:r,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(w,S,_){return S>e&&_>n?Math.min(w*e/S,w*n/_):S>e?w*e/S:_>n?w*n/_:w}let f=[];f[0]=r[0]===0?0:h(r[0],r[0]+r[3],r[0]+r[1]),f[1]=r[1]===0?0:h(r[1],r[1]+r[2],r[1]+r[0]),f[2]=r[2]===0?0:h(r[2],r[2]+r[1],r[2]+r[3]),f[3]=r[3]===0?0:h(r[3],r[3]+r[0],r[3]+r[2]);let m=c.x,p=d.x,g=d.y,y=c.y;t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let v=!0;for(let w=0,S=t.points.length;w<S;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Kr.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var zP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:n=t,widthSegments:r=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c=new ml(.5*t,r,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var GP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:r=8}=i.parameters,s=new po(t,e,n,r);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var VP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,angle:r,cornerRadius:s,cornerSegments:o}=i.parameters,a=new zw(t,e,n,r,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},zw=class extends Me{constructor(t=1,e=1,n=1,r=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),r=Math.min(180-c,r),r*=Math.PI/180;let d=[],h=Math.PI/2,f=(K=0,Z=0,k=0)=>new A(K,Z,k),m=f(),p=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,w=+y,[S,_,M]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(K,Z=!1)=>Math.sin(K-Math.PI/(1+ +Z)),E=(K,Z=!1)=>Math.cos(K-Math.PI/(1+ +Z));M.y=Math.sin(r)*e-g;let T=Math.cos(r)*e-v,I=S.z-c;r<=h?(M.z=Math.min(T,I),M.z==I&&(M.y-=(T-I)/Math.tan(h-r))):_.z=Math.min(_.z-T-v,S.z-c),m.subVectors(S,_),p.subVectors(M,_);let C=Math.min(m.length(),p.length())*s/100,P=C*Math.tan(r/2),O=C/Math.cos(r/2),B=m.clone().normalize().add(p.normalize()).setLength(O).add(_);m.set(0,b(r,!0),E(r,!0)),d.push([M,m.clone()]);let j=(Math.PI-r)/o;for(let K=0;K<=o;K++){let Z=h+r+K*j;m.set(0,Math.sin(Z)*P,Math.cos(Z)*P),m.add(B),p.set(0,b(Z),E(Z)),d.push([m.clone(),p.clone()])}d.push([S,f(0,1,0)]);let Q=Math.sin(j/2)*P*2,V=d.length-1,q=d[0][0].distanceTo(d[1][0]),W=d[V-1][0].distanceTo(d[V][0]),X=q+Q*o+W;d[0].push(1);for(let K=0;K<=o;K++)d[K+1].push(1-(q+K*Q)/X);d[V].push(0);let[L,U,G]=d[0],H,z,re;for(let K=1;K<d.length;K++)[H,z,re]=d[K],a.push(x,L.y,L.z,x,H.y,H.z,w,L.y,L.z,w,L.y,L.z,x,H.y,H.z,w,H.y,H.z),l.push(0,U.y,U.z,0,z.y,z.z,0,U.y,U.z,0,U.y,U.z,0,z.y,z.z,0,z.y,z.z),u.push(0,G,0,re,1,G,1,G,0,re,1,re),[L,U,G]=[H,z,re];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var Iy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:n,spikes:r,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,d=t*.5,h=e*.5,f=0,m=0,p=o*Math.PI/360/r,g=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(r===3&&n===50){p=2*Math.PI/r;for(let w=0;w<r;w++){let S=p*w,_=f+Math.sin(S)*d,M=m+Math.cos(S)*h;c.addPoint(c.createPoint(_,M))}}else for(let w=0;w<r;w++){let S=f+Math.cos(g)*d,_=m+Math.sin(g)*h;c.addPoint(c.createPoint(S,_)),g+=p,S=f+Math.cos(g)*y,_=m+Math.sin(g)*v,w<=r,c.addPoint(c.createPoint(S,_)),g+=p}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let x=Kr.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var HP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,n=new po(t,e);return Object.assign(n,{userData:{...i,type:"TextFrameGeometry"}})}};var jP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:r,depth:s})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=Jj(t,e,n,t*.5,o,s,0,0,r,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function Jj(i,t,e,n,r,s,o,a,l,u,c){return[t,e]=[e,t],o=t/2,r/=2*Math.PI,r==1&&(u=0),new Ff(!0,i,t,e,n,r,s,o,a,l,u,c)}var WP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new Lc(a,e,n,r,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var qP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Et?i.shape:new Et,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=Kr.create({shape:l,parameters:{roundness:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...i,type:"TriangleGeometry"}})}};function YP(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}function $j(i,t,e){let n=[new A,new A,new A],r=[new A,new A,new A];return i.extractBasis(n[0],n[1],n[2]),t.extractBasis(r[0],r[1],r[2]),n.forEach((s,o)=>{let a=r[o],l=Ve.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ie().makeBasis(n[0],n[1],n[2])}var XP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??cd.create({parameters:Hb}).userData.shape;return{path:i.path??Du.defaultData(),parameters:Object.assign(e,{width:n,height:r,depth:s,extrusion:{...Yg,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new Gw(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Me,{userData:{...i,type:"PathGeometry"}})}},Gw=class extends Me{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)||!YP(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:r,offset:s}=this.inputs.parameters.extrusion,o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((r+s)*o):Math.ceil(Math.min(1,r+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let C=0;C<u;C++){let P=this.inputs.path.isClosed?(C+a)%e.length:Math.min(C+a,e.length-1);c.push(e[P].clone()),d.push(n[P].clone())}let h=(C,P,O)=>{c[C]=c[C].clone().lerp(c[P],O),d[C]=$j(d[C],d[P],O)},f=0,m=s*o%1;(!this.inputs.path.isClosed||r<=1)&&(m||s===0)&&(f=m,h(0,1,f));let p=0,g=(s+r)*o%1;if((this.inputs.path.isClosed&&r<=1||!this.inputs.path.isClosed&&s+r<1)&&g&&(p=g,h(c.length-1,c.length-2,1-p)),r===0){let C=c.length-1;c[C].copy(c[0]),d[C].copy(d[0])}this._applyPathModifiers(d,f,p);let{regions:y,infos:v,vertices:x}=this._computeShapePoints(5),w=0,S=0;v.sort((C,P)=>C.start-P.start),v.forEach(C=>{C.verticesStart=w,C.verticesCount=C.continuous.reduce((P,O,B)=>P+(B===0||!O?2:1),0),S+=C.verticesCount,w=S});let _=S*u,M,b=0;if(this._isOpenEnded()){try{M=rs({windingRule:gt.ODD,elementType:an.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{M=Ow}b=M.vertexCount}let E=_+2*b,T={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},I=[];v.forEach(C=>{this._extrudeRegion(C,x,d,c,T,I,this._isGeometryClosed()&&!this._isOpenEnded())}),M&&(this._closeEnd(M,_,I,T,d[0],c[0],!1),this._closeEnd(M,_+b,I,T,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Be(T.positions,3)),this.setAttribute("normal",new Be(T.normals,3)),this.setAttribute("uv",new Be(T.uvs,2)),this.setIndex(I)}_extractPathPoints(){let n=yy(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let r=[n[0]];return n.forEach(o=>{r[r.length-1].distanceToSquared(o)>.001&&r.push(o)}),this.inputs.path.isClosed&&r[r.length-1].distanceTo(r[0])<.001&&r.pop(),r}_computeBasisMatrices(e){let n=[],r=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let g=0;g<r;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===r-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let w=y.clone().sub(v).normalize(),S=x.clone().sub(y).normalize(),_=w.clone().add(S).normalize();l.copy(_),g===0&&(_.equals(c)||_.clone().negate().equals(c))&&c.set(0,0,1);let M=c.clone().cross(_).normalize(),b=_.clone().cross(M).normalize();c.copy(b),u.copy(M),g===0&&(o.copy(b),a.copy(_));let E=new ie().makeBasis(M,b,_);n.push(E)}let d=s?a:l,h=s?o:new A(0,1,0),f=d.clone().cross(u).normalize(),m=Math.acos(h.dot(f));if(isNaN(m))return n;let p=h.clone().cross(f);d.dot(p)>0&&(m*=-1);for(let g=1;g<n.length;g++){let y=new ie().makeRotationZ(m*g/n.length);n[g].multiply(y)}return n}_applyPathModifiers(e,n,r){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new ie,d=new ie;return e.forEach((h,f)=>{let m=f===0?0:f===s-1?1:(f-n)/(s-(r===0?0:1)-(n+(1-r)));c.makeRotationZ(Ve.lerp(o,o+a,m));let p=Ve.lerp(l,u,m);d.makeScale(p,p,p),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=gt.ODD){let r=this.inputs.shapeData,s=r.extractShapePointsToFlatArray([],e),o=r.shapeHoles.map(p=>{let g=p.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],w=g[v-0];y.push(x,w)}return y}),a;try{a=rs({windingRule:n,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Bf}let l;try{l=rs({windingRule:gt.ODD,elementType:an.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=Dw}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let g=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let p=0;p<l.vertexIndices.length;p++){let g=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let p=0;p<l.vertices.length;p++){let g=l.vertices[p];a.vertices.push(g)}}let c=1/0,d=-1/0,h=1/0,f=-1/0;for(let p=0,g=a.vertexCount;p<g;p++){let y=p*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>d&&(d=v),x<h&&(h=x),x>f&&(f=x)}let m=[];for(let p=a.elementCount-1;p>=0;p--){let g=p>=u,y=p*2,v=a.elements[y+0],x=a.elements[y+1],w=v+x,S={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let _=v,M=w-1,b=v+1,E=r.roundedCurves.length;do{let T=_-v,I=a.vertices[M*2+0],C=a.vertices[M*2+1],P=a.vertices[_*2+0],O=a.vertices[_*2+1],B=a.vertices[b*2+0],j=a.vertices[b*2+1],Q=P-I,V=O-C,q=Math.sqrt(Q*Q+V*V);Q/=q,V/=q;let W=P-B,X=O-j,L=Math.sqrt(W*W+X*X);W/=L,X/=L,S.normals[T*2+0]=-X,S.normals[T*2+1]=W;let U=a.vertexIndices[_];if(Array.isArray(U))S.continuous[T]=!1;else{let[G,H]=r.getCurveIndexFromVertexId(U-1,!0);if(H>0&&H<1)S.continuous[T]=!0;else{let z=H===1?G+1:G-1;z=(z+E)%E;let re=H===1?0:1,K=r.roundedCurves[G].getTangent(H),Z=r.roundedCurves[z].getTangent(re);S.continuous[T]=K.dot(Z)>.95}}g&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[M,_,b]=[_,b,b+1],b>=w&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:m,vertices:a.vertices}}_insertVertex(e,n,r,s,o){let a=n*2,l=n*3;e.positions[l+0]=r.x,e.positions[l+1]=r.y,e.positions[l+2]=r.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,n,r,s,o,a,l){let u=new A,c=new A,d=new A,h=new A,f=new F;r.forEach((p,g)=>{let y=s[g],v=e.verticesStart*r.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let w=(e.start+x)*2;if(u.set(n[w+0],n[w+1],0),d.copy(u).applyMatrix4(p).add(y),e.continuous[x])h.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let S=x==0?(e.start+e.count-1)*2:w-2;c.set(n[S+0],n[S+1],0),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(p).normalize(),f.set(x===0?1:x/e.count,g/(r.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(r.length-1));else{let S=x===e.count-1?e.start*2:w+2;c.set(n[S+0],n[S+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(p).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let m=r.length-1;for(let p=0;p<m;p++){let g=e.verticesStart*r.length+e.verticesCount*p,y=e.verticesStart*r.length+e.verticesCount*(p+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let w=x===e.count-1?0:v+1,S=g+v,_=g+w,M=y+w,b=y+v;e.isHole?a.push(S,M,_,S,b,M):a.push(S,_,M,S,M,b),v++}}}_closeEnd(e,n,r,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),d=new A,h=new F;for(let m=0;m<u;m++){let p=2*m;d.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+m,d,c,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let p=3*m,g=f[p+0]+n,y=f[p+(l?1:2)]+n,v=f[p+(l?2:1)]+n;r.push(g,y,v)}}};function QP(){let i=new Me;return i.setAttribute("position",new Be(new Float32Array([]),3)),i.setIndex(new Be(new Uint16Array([]),1)),i}var eW=QP().attributes,tW=12,nW=1,hd=class extends Me{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,eW),this.userData={parameters:e,type:"TextGeometry"};let r=n.getFont(e.font);r?.isLoaded?(this.font=r,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let r=n.getFont(e);r&&(this.font=r,await r.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=rW(e,n,d),{shapes:f,charWidths:m,charCoords:p}=n.generateShapes(h,e),g=r*.5,y=s*.5,v=f.map(S=>new Et().fromShape(S));this.vectorShapes=v;let x=v.map(S=>Kr.create({shape:S,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?gt.NONZERO:gt.ODD,subdivisions:this.isLowResolution&&o>0?nW:tW}})),w=x.length?$i(x):QP();w.translate(-g,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,_])=>{this.setAttribute(S,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Ki(new Me,hd.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,r])=>{this.setAttribute(n,r)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function rW(i,t,e){e=e??i.text;let n=[""],r="";for(let s of e)r+=s,s===" "||s===`
3139
3139
  `?(n[n.length-1]+=r,r="",s===`
3140
- `&&n.push("")):t.getTextWidth(n[n.length-1]+r,i)>i.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+r,i)>i.width&&(r.length===1?(n[n.length-1]+=r,r=""):(n[n.length-1]+=r.slice(0,-1),r=r[r.length-1],n.push(""))));return n[n.length-1]+=r,n}var ZP,fd=new Promise(i=>{ZP=i}),KP=!1;var Dy;function JP(){if(KP)return;if(Dy)return Dy;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.400/build",[n,r]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(a=>a.arrayBuffer())]),s=n.default,o=await s({wasmBinary:r});ZP(o),KP=!0}return Dy=i(),Dy}function Nl(i,t,e){let n={parameters:i,type:i.type};if(i.type==="PathGeometry")n.path=i.path;else if(i.type==="VectorGeometry"){let s=Et.createFromState(i.shape,i.width,i.height);n.shape=s}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new Gc().parse(i);else{if(i.type==="SubdivGeometry")return new bn(i,e);if(i.type==="TextGeometry")return new hd(i,t)}let r;try{r=Vw(n)}catch(s){console.error(s)}if(!r){let s=Et.createFromState(Iu.defaultData(),100,100);n.shape=s,r=Vw(n)}return r}var iW=new ie;function zf(i,t,e,n){let r=i.position.array,s=i.normal.array,o=iW.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=r.length;c<d;c+=3)r[c]*=t,r[c+1]*=e,r[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Oy=new _t,pd=new A,Je;fd.then(i=>{Je=i});var $P=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),e2=new Uint32Array([0,1,2,3]),t2=new Uint8Array([4]),bn=class extends Me{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let r=this.data.scaleBaked,s=Cs.div(n,r);this.subdividedGeometry&&zf(this.subdividedGeometry.attributes,...s),this.originalGeometry&&zf(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(pd.fromArray(s));let a=pd.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,r;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:r}=bn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new er(100,100,100),r=0}this.subdivPointer=r,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(bn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new dn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,r=e.boundingSphere.center;Oy.setFromBufferAttribute(n),Oy.getCenter(r),e.boundingSphere.radius=r.distanceTo(Oy.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Oy.getSize(pd);let s={width:pd.x,height:pd.y,depth:pd.z};return this.userData.parameters=s,s}static build(e,n,r,s){let o,a,l,u=e?.phongAngle??35;r===!1&&(u=-1),n&&(Je.free_bvh(n),Je.free_subdivision_surface(n));try{o=bn.allocate(e,s)}catch(c){console.error(c,e),o=bn.allocate({positionWASM:$P,indexWASM:e2,verticesPerFaceWASM:t2},s)}if(Je.set_destination_refinement_level(o,0),a=bn.buildLevel(o,!0,u),e.subdivisions>0)try{Je.set_destination_refinement_level(o,e.subdivisions),l=bn.buildLevel(o,!1,u)}catch{try{Je.set_destination_refinement_level(o,e.subdivisions-1),l=bn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,r){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?n.geometry:Nl(e,r,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=Bl(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=qw(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let r,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(r=$P,s=e2,o=t2);let u=r.length,c=s.length,d=o.length,h=r.length+a.length+l.length,f=s.length+o.length,m=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=Je._malloc(m),v=new Float32Array(Je.HEAPF32.buffer,y,h),x=new Uint32Array(Je.HEAPU32.buffer,y+p,f);v.set(r,0),v.set(a,r.length),v.set(l,r.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new ie().makeScale(...e.scaleBaked)),n&&(w?w.premultiply(n):w=n);let S=w?Je.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Je.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Je._free(y),S}static buildLevel(e,n,r,s,o){let a=o?Je.get_mesh_data2(e,n?Je.Level.CONTROL:Je.Level.REFINED,r,o.elements):Je.get_mesh_data(e,n?Je.Level.CONTROL:Je.Level.REFINED,r),l=8,u=Je.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Je.HEAPU32[u[d]>>2],f=Je.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let m=Je.HEAPU32[u[d]>>2],p=Je.HEAPF32.subarray(m>>2,(m>>2)+c[d]);d++;let g=Je.HEAPU32[u[d]>>2],y=Je.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=Je.HEAPU32[u[d]>>2],x=Je.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let w=new Me;if(w.setIndex(new bs(x,1)),w.setAttribute("position",new Ae(f,3)),w.setAttribute("normal",new Ae(p,3)),n){w.setAttribute("faceMap",new bs(y,1));let S=new Float32Array(p.length/3*4).fill(0);w.setAttribute("color",new Be(S,4))}return Je.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Je.free_mesh_data(a)}static freeSubdivPointer(e){Je.free_bvh(e),Je.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,r){let s=Je.get_wireframe_data_for_base_level(e),o=4,a=Je.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Je.HEAPU32[a[u]>>2],d=Je.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Je.HEAPU32[a[u]>>2],f=Je.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let m=new Me;m.setAttribute("position",new Ae(d,3));let p=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)p[g++]=r.r,p[g++]=r.g,p[g++]=r.b;return m.setAttribute("color",new Be(p,3)),m.setIndex(new bs(f,1)),Je.free_wireframe_data_for_base_level(s),m}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Je.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,r){let s=n===0;s||Je.set_destination_refinement_level(e,n);let o=r?Je.get_topological_data2(e,s?Je.Level.CONTROL:Je.Level.REFINED,r.elements):Je.get_topological_data(e,s?Je.Level.CONTROL:Je.Level.REFINED),a=6,l=Je.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Je.HEAPU32[l[c]>>2],h=new Float32Array(Je.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Je.HEAPU32[l[c]>>2],m=new Uint32Array(Je.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Je.HEAPU32[l[c]>>2],g=new Uint8Array(Je.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Je.free_topological_data(o),{positions:h,indices:m,verticesPerFace:g}}};var n2=["getX","getY","getZ"];function Bl(i,t){let e={},n=t?t.count:i.count,r=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(i[n2[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(i[n2[h]](c));e[d]=r,s.push(r),r++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Ry=new A,Hw=new A,jw=new A,Ww=new A;function qw(i,t,e,n){let r=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);i.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)i.push(o[c],o[c+1],0),r.push(u++);else for(let c=o.length-2;c>=0;c-=2)i.push(o[c],o[c+1],0),r.push(u++);return s.push(u),{indices:r,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)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]){Ry.set(i[t[o]*3],i[t[o]*3+1],i[t[o]*3+2]),Hw.set(i[t[o+1]*3],i[t[o+1]*3+1],i[t[o+1]*3+2]),jw.set(i[t[o+4]*3],i[t[o+4]*3+1],i[t[o+4]*3+2]),Ww.set(i[t[o+5]*3],i[t[o+5]*3+1],i[t[o+5]*3+2]),Hw.sub(Ry).normalize(),jw.sub(Ry).normalize(),Ww.sub(Ry).normalize();let l=Hw.cross(jw).dot(Ww);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(r.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(r.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else r.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<i.length;c+=3,d++)i[c+2]===0&&(o.push(d),l++),i[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),r.push(...o,...a),s.push(l,l)}return{indices:r,verticesPerFace:s}}var Pi={};VO(Pi,{calcBoolean:()=>aW,calcBooleanTopological:()=>oW,freeMeshSet:()=>dW,getMeshSet:()=>lW,hasOpenEdges:()=>cW,transformMeshSet:()=>uW});var r2,i2=new Promise(i=>{r2=i});var Ly;function s2(){if(Ly)return Ly;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.400/build",[n,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(a=>a.arrayBuffer())]),s=n.default,o=await s({wasmBinary:r});r2(o)}return Ly=i(),Ly}var ct,md;i2.then(i=>ct=i);function sW(i,t,e){let n,r;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?r=i.getClosedTorusIndicesForBooleanOrSubdiv():r=i.getIndex();let{positions:s,triIndices:o}=Bl(i.getAttribute("position"),r),a;if(t&&e){let{indices:l,verticesPerFace:u}=qw(s,o,i);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function o2(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,r=Number.isInteger(i[0])?e:n,s=ct._malloc(r);return(Number.isInteger(i[0])?new Uint32Array(ct.HEAPU32.buffer,s,t):new Float32Array(ct.HEAPF32.buffer,s,t)).set(i,0),s}function a2(i){switch(i){case 0:return ct.OP.UNION;case 1:return ct.OP.INTERSECTION;case 2:return ct.OP.A_MINUS_B;case 3:return ct.OP.B_MINUS_A;case 4:return ct.OP.SYMMETRIC_DIFFERENCE;case 5:return ct.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function oW(i,t){md===void 0&&(md=ct.init_csg());let e=o2(i),n=ct.csg_calc_topological(md,e,i.length,a2(t));ct._free(e);let r=6,s=ct.HEAPU32.subarray(n>>2,(n>>2)+r),o=s.subarray(3,3+3),a=0,l=ct.HEAPU32[s[a]>>2],u=new Float32Array(ct.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ct.HEAPU32[s[a]>>2],d=new Uint32Array(ct.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=ct.HEAPU32[s[a]>>2],f=new Uint8Array(ct.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return ct.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function aW(i,t,e,n){md===void 0&&(md=ct.init_csg());let r=o2(i),s=ct.csg_calc(md,r,i.length,n,a2(t));ct._free(r);let o=5,a=ct.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ct.HEAPU32[a[u]>>2],d=ct.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=ct.HEAPU32[a[u]>>2],f=ct.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let m=l[u];e.setAttribute("position",new Ae(d,3)),e.setAttribute("normal",new Ae(f,3));let p=ct.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new dn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ct.free_mesh_data(s),m}function lW(i,t,e){if(ct===void 0)return-1;let n,r,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,n=g.positions,r=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){r[x++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)r[x++]=g.indices[v++]}}else({positions:n,faceIndices:r,nFaces:s}=sW(i,t,e));let o=n.length,a=r.length,l=n.length,u=r.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=ct._malloc(c),m=new Float32Array(ct.HEAPF32.buffer,f,l),p=new Uint32Array(ct.HEAPU32.buffer,f+d,u);return m.set(n,0),p.set(r,0),ct.get_csg_mesh(f,o,f+d,a,s)}function cW(i){return ct.has_open_edges(i)}function uW(i,t){ct.transform_csg_mesh(i,t.elements)}function dW(i){ct.free_csg_mesh(i)}var hW={ConeGeometry:sP,CubeGeometry:oP,CylinderGeometry:vy,DodecahedronGeometry:aP,EllipseGeometry:cd,HelixGeometry:OP,IcosahedronGeometry:RP,LatheGeometry:LP,NonParametricGeometry:UP,PolygonGeometry:Cy,PyramidGeometry:kP,RectangleGeometry:Py,SphereGeometry:zP,PlaneGeometry:GP,BackdropGeometry:VP,StarGeometry:Iy,TextFrameGeometry:HP,TorusGeometry:jP,TorusKnotGeometry:WP,TriangleGeometry:qP,PathGeometry:XP,VectorGeometry:Kr},Vw=i=>hW[i.type].create(i);function Gf(i){return i!==null&&"booleanOp"in i}var gd=class extends ed(Dn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ie}updateVisible(){super.updateVisible(),this.visible=!Gf(this.parent)&&this.visible,Gf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Pi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Gf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof gd&&(e.freeBooleanPointer(),Gf(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&Gf(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Ny=new _t;function Vf(i,t=0,e=i.count,n,r){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=i.getX(d),f=i.getY(d),m=i.getZ(d);h<s&&(s=h),f<o&&(o=f),m<a&&(a=m),h>l&&(l=h),f>u&&(u=f),m>c&&(c=m)}Ny.min.set(s,o,a),Ny.max.set(l,u,c),Ny.getCenter(n),Ny.getSize(r).multiplyScalar(.5)}var fW=new Me,pW=new Wi,Vt=class extends gd{constructor(t,e){super(fW,pW),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?Vf(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var Hf=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var or=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ve.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let r={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),r}build(t,e,n){e=e??this.getType(t,e);let r=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,r,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,r,s,o){return""}generate(t,e,n,r,s){return""}parse(t,e,n,r){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let r=t.getTypeLength(n);(r>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=r,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof or&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)e=this.hashProperties[r],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Yw=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xn=new Yw;var Ge=class extends or{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,r,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Ve.generateUUID()),r=e.getUUID(r??this.getUUID(),!o);let a=e.getNodeData(r),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,r)):super.build(e,n,r);if(o)return a.name=a.name||super.build(e,n,r),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,r);r=this.getUUID(!1);let u=this.getTemp(e,r);if(u)return e.format(u,l,n);{u=super.generate(e,n,r,a.output,s);let c=this.generate(e,l,r);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,r)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let r=e.getVars()[n];return r?r.name:void 0}generate(e,n,r,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),r=r??this.uuid,e.getTempVar(r,s??this.getType(e),o,this.getLabel()).name}};var Bt=class extends Ge{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,r,s,o,a){r=e.getUUID(r??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,r,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var ln=class extends Bt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(e,n)}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,n,r,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var vr=class extends Bt{constructor(e=0,n,r){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,r,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var sn=class extends Re{constructor(e,n,r,s){super(e,n,r);this.isColorA=!0;this.a=s}setRGBA(e,n,r,s){super.setRGB(e,n,r),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let r;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(r=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Zr=class extends Bt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof sn?e:new sn(e.r,e.g,e.b,e.a)}generateReadonly(e,n,r,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var mW=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,l2=/[a-z_0-9]+/gi,pe=class extends Ge{constructor(e,n,r,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,r,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,r,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=l2.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&Xn.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=Xn.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||Xn.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}p=g.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Xn.contains(p)&&e.include(Xn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,r,s){if(this.src=e||"",this.includes=n??[],this.extensions=r??{},this.keywords=s??{},this.isMethod){let o=mW.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(l2);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var gW=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Xw=class extends Ge{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Xw.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,r,s,o){this.src=e||"";let a,l,u="",c=gW.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="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),n)}generate(e,n,r,s,o){return e.format(this.name,this.getType(e),n)}},Mt=Xw;Mt.PI="PI",Mt.PI2="PI2",Mt.RECIPROCAL_PI="RECIPROCAL_PI",Mt.RECIPROCAL_PI2="RECIPROCAL_PI2",Mt.LOG2="LOG2",Mt.EPSILON="EPSILON";var yW=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3140
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+r,i)>i.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+r,i)>i.width&&(r.length===1?(n[n.length-1]+=r,r=""):(n[n.length-1]+=r.slice(0,-1),r=r[r.length-1],n.push(""))));return n[n.length-1]+=r,n}var ZP,fd=new Promise(i=>{ZP=i}),KP=!1;var Dy;function JP(){if(KP)return;if(Dy)return Dy;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.402/build",[n,r]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(a=>a.arrayBuffer())]),s=n.default,o=await s({wasmBinary:r});ZP(o),KP=!0}return Dy=i(),Dy}function Nl(i,t,e){let n={parameters:i,type:i.type};if(i.type==="PathGeometry")n.path=i.path;else if(i.type==="VectorGeometry"){let s=Et.createFromState(i.shape,i.width,i.height);n.shape=s}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new Gc().parse(i);else{if(i.type==="SubdivGeometry")return new bn(i,e);if(i.type==="TextGeometry")return new hd(i,t)}let r;try{r=Vw(n)}catch(s){console.error(s)}if(!r){let s=Et.createFromState(Iu.defaultData(),100,100);n.shape=s,r=Vw(n)}return r}var iW=new ie;function zf(i,t,e,n){let r=i.position.array,s=i.normal.array,o=iW.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=r.length;c<d;c+=3)r[c]*=t,r[c+1]*=e,r[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Oy=new _t,pd=new A,Je;fd.then(i=>{Je=i});var $P=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),e2=new Uint32Array([0,1,2,3]),t2=new Uint8Array([4]),bn=class extends Me{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let r=this.data.scaleBaked,s=Cs.div(n,r);this.subdividedGeometry&&zf(this.subdividedGeometry.attributes,...s),this.originalGeometry&&zf(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(pd.fromArray(s));let a=pd.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,r;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:r}=bn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new er(100,100,100),r=0}this.subdivPointer=r,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(bn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new dn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,r=e.boundingSphere.center;Oy.setFromBufferAttribute(n),Oy.getCenter(r),e.boundingSphere.radius=r.distanceTo(Oy.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Oy.getSize(pd);let s={width:pd.x,height:pd.y,depth:pd.z};return this.userData.parameters=s,s}static build(e,n,r,s){let o,a,l,u=e?.phongAngle??35;r===!1&&(u=-1),n&&(Je.free_bvh(n),Je.free_subdivision_surface(n));try{o=bn.allocate(e,s)}catch(c){console.error(c,e),o=bn.allocate({positionWASM:$P,indexWASM:e2,verticesPerFaceWASM:t2},s)}if(Je.set_destination_refinement_level(o,0),a=bn.buildLevel(o,!0,u),e.subdivisions>0)try{Je.set_destination_refinement_level(o,e.subdivisions),l=bn.buildLevel(o,!1,u)}catch{try{Je.set_destination_refinement_level(o,e.subdivisions-1),l=bn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,r){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?n.geometry:Nl(e,r,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=Bl(s.getAttribute("position"),o));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,f=h+e.radialSegments*3;d=[h,f]}return{indices:l,verticesPerFace:u}=qw(a,c,s,d),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let r,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(r=$P,s=e2,o=t2);let u=r.length,c=s.length,d=o.length,h=r.length+a.length+l.length,f=s.length+o.length,m=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=Je._malloc(m),v=new Float32Array(Je.HEAPF32.buffer,y,h),x=new Uint32Array(Je.HEAPU32.buffer,y+p,f);v.set(r,0),v.set(a,r.length),v.set(l,r.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new ie().makeScale(...e.scaleBaked)),n&&(w?w.premultiply(n):w=n);let S=w?Je.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Je.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Je._free(y),S}static buildLevel(e,n,r,s,o){let a=o?Je.get_mesh_data2(e,n?Je.Level.CONTROL:Je.Level.REFINED,r,o.elements):Je.get_mesh_data(e,n?Je.Level.CONTROL:Je.Level.REFINED,r),l=8,u=Je.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Je.HEAPU32[u[d]>>2],f=Je.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let m=Je.HEAPU32[u[d]>>2],p=Je.HEAPF32.subarray(m>>2,(m>>2)+c[d]);d++;let g=Je.HEAPU32[u[d]>>2],y=Je.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=Je.HEAPU32[u[d]>>2],x=Je.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let w=new Me;if(w.setIndex(new bs(x,1)),w.setAttribute("position",new Ae(f,3)),w.setAttribute("normal",new Ae(p,3)),n){w.setAttribute("faceMap",new bs(y,1));let S=new Float32Array(p.length/3*4).fill(0);w.setAttribute("color",new Be(S,4))}return Je.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Je.free_mesh_data(a)}static freeSubdivPointer(e){Je.free_bvh(e),Je.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,r){let s=Je.get_wireframe_data_for_base_level(e),o=4,a=Je.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Je.HEAPU32[a[u]>>2],d=Je.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Je.HEAPU32[a[u]>>2],f=Je.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let m=new Me;m.setAttribute("position",new Ae(d,3));let p=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)p[g++]=r.r,p[g++]=r.g,p[g++]=r.b;return m.setAttribute("color",new Be(p,3)),m.setIndex(new bs(f,1)),Je.free_wireframe_data_for_base_level(s),m}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Je.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,r){let s=n===0;s||Je.set_destination_refinement_level(e,n);let o=r?Je.get_topological_data2(e,s?Je.Level.CONTROL:Je.Level.REFINED,r.elements):Je.get_topological_data(e,s?Je.Level.CONTROL:Je.Level.REFINED),a=6,l=Je.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Je.HEAPU32[l[c]>>2],h=new Float32Array(Je.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Je.HEAPU32[l[c]>>2],m=new Uint32Array(Je.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Je.HEAPU32[l[c]>>2],g=new Uint8Array(Je.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Je.free_topological_data(o),{positions:h,indices:m,verticesPerFace:g}}};var n2=["getX","getY","getZ"];function Bl(i,t){let e={},n=t?t.count:i.count,r=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(i[n2[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(i[n2[h]](c));e[d]=r,s.push(r),r++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Ry=new A,Hw=new A,jw=new A,Ww=new A;function qw(i,t,e,n){let r=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);i.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)i.push(o[c],o[c+1],0),r.push(u++);else for(let c=o.length-2;c>=0;c-=2)i.push(o[c],o[c+1],0),r.push(u++);return s.push(u),{indices:r,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)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]){Ry.set(i[t[o]*3],i[t[o]*3+1],i[t[o]*3+2]),Hw.set(i[t[o+1]*3],i[t[o+1]*3+1],i[t[o+1]*3+2]),jw.set(i[t[o+4]*3],i[t[o+4]*3+1],i[t[o+4]*3+2]),Ww.set(i[t[o+5]*3],i[t[o+5]*3+1],i[t[o+5]*3+2]),Hw.sub(Ry).normalize(),jw.sub(Ry).normalize(),Ww.sub(Ry).normalize();let l=Hw.cross(jw).dot(Ww);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(r.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(r.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else r.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<i.length;c+=3,d++)i[c+2]===0&&(o.push(d),l++),i[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),r.push(...o,...a),s.push(l,l)}return{indices:r,verticesPerFace:s}}var Pi={};VO(Pi,{calcBoolean:()=>aW,calcBooleanTopological:()=>oW,freeMeshSet:()=>dW,getMeshSet:()=>lW,hasOpenEdges:()=>cW,transformMeshSet:()=>uW});var r2,i2=new Promise(i=>{r2=i});var Ly;function s2(){if(Ly)return Ly;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.402/build",[n,r]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(a=>a.arrayBuffer())]),s=n.default,o=await s({wasmBinary:r});r2(o)}return Ly=i(),Ly}var ct,md;i2.then(i=>ct=i);function sW(i,t,e){let n,r;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?r=i.getClosedTorusIndicesForBooleanOrSubdiv():r=i.getIndex();let{positions:s,triIndices:o}=Bl(i.getAttribute("position"),r),a;if(t&&e){let{indices:l,verticesPerFace:u}=qw(s,o,i);a=u.length,n=[];for(let c=0,d=0;c<a;c++){n.push(u[c]);for(let h=0;h<u[c];h++)n.push(l[d++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function o2(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,r=Number.isInteger(i[0])?e:n,s=ct._malloc(r);return(Number.isInteger(i[0])?new Uint32Array(ct.HEAPU32.buffer,s,t):new Float32Array(ct.HEAPF32.buffer,s,t)).set(i,0),s}function a2(i){switch(i){case 0:return ct.OP.UNION;case 1:return ct.OP.INTERSECTION;case 2:return ct.OP.A_MINUS_B;case 3:return ct.OP.B_MINUS_A;case 4:return ct.OP.SYMMETRIC_DIFFERENCE;case 5:return ct.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function oW(i,t){md===void 0&&(md=ct.init_csg());let e=o2(i),n=ct.csg_calc_topological(md,e,i.length,a2(t));ct._free(e);let r=6,s=ct.HEAPU32.subarray(n>>2,(n>>2)+r),o=s.subarray(3,3+3),a=0,l=ct.HEAPU32[s[a]>>2],u=new Float32Array(ct.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ct.HEAPU32[s[a]>>2],d=new Uint32Array(ct.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=ct.HEAPU32[s[a]>>2],f=new Uint8Array(ct.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return ct.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function aW(i,t,e,n){md===void 0&&(md=ct.init_csg());let r=o2(i),s=ct.csg_calc(md,r,i.length,n,a2(t));ct._free(r);let o=5,a=ct.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ct.HEAPU32[a[u]>>2],d=ct.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=ct.HEAPU32[a[u]>>2],f=ct.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let m=l[u];e.setAttribute("position",new Ae(d,3)),e.setAttribute("normal",new Ae(f,3));let p=ct.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new dn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ct.free_mesh_data(s),m}function lW(i,t,e){if(ct===void 0)return-1;let n,r,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,n=g.positions,r=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){r[x++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)r[x++]=g.indices[v++]}}else({positions:n,faceIndices:r,nFaces:s}=sW(i,t,e));let o=n.length,a=r.length,l=n.length,u=r.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=ct._malloc(c),m=new Float32Array(ct.HEAPF32.buffer,f,l),p=new Uint32Array(ct.HEAPU32.buffer,f+d,u);return m.set(n,0),p.set(r,0),ct.get_csg_mesh(f,o,f+d,a,s)}function cW(i){return ct.has_open_edges(i)}function uW(i,t){ct.transform_csg_mesh(i,t.elements)}function dW(i){ct.free_csg_mesh(i)}var hW={ConeGeometry:sP,CubeGeometry:oP,CylinderGeometry:vy,DodecahedronGeometry:aP,EllipseGeometry:cd,HelixGeometry:OP,IcosahedronGeometry:RP,LatheGeometry:LP,NonParametricGeometry:UP,PolygonGeometry:Cy,PyramidGeometry:kP,RectangleGeometry:Py,SphereGeometry:zP,PlaneGeometry:GP,BackdropGeometry:VP,StarGeometry:Iy,TextFrameGeometry:HP,TorusGeometry:jP,TorusKnotGeometry:WP,TriangleGeometry:qP,PathGeometry:XP,VectorGeometry:Kr},Vw=i=>hW[i.type].create(i);function Gf(i){return i!==null&&"booleanOp"in i}var gd=class extends ed(Dn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ie}updateVisible(){super.updateVisible(),this.visible=!Gf(this.parent)&&this.visible,Gf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Pi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Gf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof gd&&(e.freeBooleanPointer(),Gf(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&Gf(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Ny=new _t;function Vf(i,t=0,e=i.count,n,r){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=i.getX(d),f=i.getY(d),m=i.getZ(d);h<s&&(s=h),f<o&&(o=f),m<a&&(a=m),h>l&&(l=h),f>u&&(u=f),m>c&&(c=m)}Ny.min.set(s,o,a),Ny.max.set(l,u,c),Ny.getCenter(n),Ny.getSize(r).multiplyScalar(.5)}var fW=new Me,pW=new Wi,Vt=class extends gd{constructor(t,e){super(fW,pW),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?Vf(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var Hf=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var or=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ve.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let r={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),r}build(t,e,n){e=e??this.getType(t,e);let r=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,r,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,r,s,o){return""}generate(t,e,n,r,s){return""}parse(t,e,n,r){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let r=t.getTypeLength(n);(r>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=r,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof or&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)e=this.hashProperties[r],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Yw=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Xn=new Yw;var Ge=class extends or{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,r,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Ve.generateUUID()),r=e.getUUID(r??this.getUUID(),!o);let a=e.getNodeData(r),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,r)):super.build(e,n,r);if(o)return a.name=a.name||super.build(e,n,r),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,r);r=this.getUUID(!1);let u=this.getTemp(e,r);if(u)return e.format(u,l,n);{u=super.generate(e,n,r,a.output,s);let c=this.generate(e,l,r);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,r)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let r=e.getVars()[n];return r?r.name:void 0}generate(e,n,r,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),r=r??this.uuid,e.getTempVar(r,s??this.getType(e),o,this.getLabel()).name}};var Bt=class extends Ge{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,r,s,o,a){r=e.getUUID(r??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,r,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var ln=class extends Bt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(e,n)}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,n,r,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var vr=class extends Bt{constructor(e=0,n,r){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,r,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var sn=class extends Re{constructor(e,n,r,s){super(e,n,r);this.isColorA=!0;this.a=s}setRGBA(e,n,r,s){super.setRGB(e,n,r),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let r;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(r=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Zr=class extends Bt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof sn?e:new sn(e.r,e.g,e.b,e.a)}generateReadonly(e,n,r,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var mW=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,l2=/[a-z_0-9]+/gi,pe=class extends Ge{constructor(e,n,r,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,r,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,r,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=l2.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&Xn.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=Xn.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||Xn.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}p=g.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&Xn.contains(p)&&e.include(Xn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,r,s){if(this.src=e||"",this.includes=n??[],this.extensions=r??{},this.keywords=s??{},this.isMethod){let o=mW.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(l2);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var gW=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Xw=class extends Ge{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Xw.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,r,s,o){this.src=e||"";let a,l,u="",c=gW.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="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),n)}generate(e,n,r,s,o){return e.format(this.name,this.getType(e),n)}},Mt=Xw;Mt.PI="PI",Mt.PI2="PI2",Mt.RECIPROCAL_PI="RECIPROCAL_PI",Mt.RECIPROCAL_PI2="RECIPROCAL_PI2",Mt.LOG2="LOG2",Mt.EPSILON="EPSILON";var yW=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
3141
  )*?)}`,"gim"),vW=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),yd=class extends Ge{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}generate(e,n,r,s,o){return n==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),n)}parse(e=""){this.src=e,this.inputs=[];let n=yW.exec(e);if(n){let r=n[2],s;for(;s=vW.exec(r);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var vd=class extends Ge{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,n){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(s,this.getType(e),n)}};Xn.addKeyword("uv",function(){return new vd});Xn.addKeyword("uv2",function(){return new vd(1)});var Fl=class extends Ge{constructor(e,n){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=n??Fl.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case li:return["Linear"];case Ze:return["sRGB"];default:return[]}}generate(e,n){let r=this.input.build(e,"v4"),s=this.getType(e),o=Fl.Nodes[this.method],a=e.include(o);if(a===Fl.LINEAR_TO_LINEAR)return e.format(r,s,n);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+r+", "+l+" )",s,n)}else return e.format(a+"( "+r+" )",s,n)}fromEncoding(e){let n=Fl.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(e){let n=Fl.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}},zr=Fl;zr.Nodes={LinearToLinear:new pe(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3142
3142
  `)),sRGBToLinear:new pe(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
3143
3143
  `)),LinearTosRGB:new pe(["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(`
@@ -6232,9 +6232,9 @@ void main() {
6232
6232
 
6233
6233
  }
6234
6234
  }
6235
- `,R8=[],mv=class extends Bi{constructor(){super(new rt({vertexShader:D8,fragmentShader:O8,uniforms:{toScene:new se(null),fromScene:new se(null),uResolution:new se(new F),uDPR:new se(1),mixRatio:new se(0),threshold:new se(.1),useTexture:new se(0),tMixTexture:{value:R8[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(t){this.uniforms.fromScene.value=t}};function OI(i,t){return t&&t.enabled&&i.push(t.effect),i}var L8=i=>Object.values(ut).includes(i)?i:ut.NORMAL,lp=class extends Ut{constructor(e){super();this.postprocessingState=Ou.defaultData;this._scene=new mr;this._camera=new Xt;this.effects=new Map;this.blueNoiseTexture=new mo;this._renderToScreen=!0;this.clock=new Cm,this.renderer=e,this.debug=!1,this.effects.set("bloom",new qd),this.effects.set("chromaticAberration",new Xd),this.effects.set("vignette",new Jd),this.effects.set("noise",new Zd),this.effects.set("colorAverage",new Qd),this.effects.set("hueSaturation",new Kd),this.effects.set("brightnessContrast",new Yd),this.effects.set("depthOfField",new $d),this.effects.set("pixelation",new eh),this.effectComposer=new uv(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Ql(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new cv(this.scene,this.camera,this.renderer),this.aoPass=new fv(this.scene,this.camera),this.taaPass=new lv,this.taaPass.renderToScreen=!1,this.helperPass=new dv(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new pv,this.overlayPass.enabled=!1,this.sceneTransitionPass=new mv,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let n=this.effectComposer.passes.length-1;n>=0;n--){let r=this.effectComposer.passes[n];if(r.enabled===!0&&!e&&this._renderToScreen){r.renderToScreen=!0,e=!0;continue}r.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new mo(e,128,128),this.blueNoiseTexture.wrapS=Hi,this.blueNoiseTexture.wrapT=Hi,this.blueNoiseTexture.minFilter=Dt,this.blueNoiseTexture.magFilter=Dt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,n,r,s,o,a,l,u){this.aoPass.enabled=e,this.aoPass.radius=n,this.aoPass.bias=r,this.aoPass.aoColor=s,this.aoPass.fogEnabled=o,this.aoPass.fogNear=a,this.aoPass.fogFar=l,this.aoPass.runHalfRes!==!u&&(this.aoPass.runHalfRes=!u)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(OI,[]);e.length>0&&(this.uvEffectPass=new Xl(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(OI,[]);n.length>0&&(this.effectPass=new Xl(this.camera,...n),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new ot(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Hi,wrapT:Hi}),this._rt.samples=0,this._savePass=new ap(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new ap(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?n.removePass(this._savePass):n.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(e!==null?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...r}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(r)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=L8(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,r,s){e instanceof We?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,r,s),this.effectComposer.outputBuffer.scissor.set(e,n,r,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,r,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,r,s){e instanceof We?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,r,s),this.effectComposer.outputBuffer.viewport.set(e,n,r,s))}resize(e,n,r){if(this.effectComposer.setSize(e,n,r),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var RI=new qt,gv=class extends qx{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new lp(this);this.dummyCamra=new Xt;this.sceneTransitionDuration=0;this.sceneTransitionTimeRemaining=-1;this.isXRCopyPassSet=!1;this.clear=(e=!0,n=!0,r=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),n&&(o|=s.DEPTH_BUFFER_BIT),r&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.autoClear=!1;let n=this.setPixelRatio.bind(this),r=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Nm;let s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio!==o&&(this._pixelRatio=o,n(o))},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,r(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new ot(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Xe,magFilter:Xe,wrapS:Wt,wrapT:Wt,depthBuffer:!1}))}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,n*this._pixelRatio/1)}get hdTransmission(){return Fe.transmissionLod.value===1}set hdTransmission(e){Fe.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ot(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:sl,magFilter:Xe,wrapS:Wt,wrapT:Wt,depthBuffer:!1}),this.transmissionDepthTarget=new ot(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Dt,magFilter:Dt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ot(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Dt,magFilter:Dt,type:pr,depthTexture:new bi(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n,r){this.normalRenderTarget&&(this.setClearColor(0),r.layers.enable(8),r.layers.disable(0),r.layers.disable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),r instanceof Xt?iv.uniforms.depthContrast.value=(r.far-r.near)/1e4:iv.uniforms.depthContrast.value=1,n.overrideMaterial=iv,this.render(n,r),this.setClearColor(n.bgColor,n.bgColor.a),this.setRenderTarget(null),n.overrideMaterial=e.wireframeState?yv:null,r.layers.enable(0),r.layers.enable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,n,r=1){this.dummyCamra.updateCameraState(n.dataPatched);let s=n.height,o=n.width,a=this.viewportWidth/this.viewportHeight;o<s?o=s*a:s=o/a,this.dummyCamra.setViewplaneSize(o,s);for(let l=0;l<r;l++)this.renderSplineScene(e,this.dummyCamra)}renderSplineScene(e,n,{sceneHelpers:r=void 0,sceneHelpersOnTop:s=void 0,overrideTransmission:o=void 0,overrideNormal:a=void 0}={}){let l=e instanceof Ga?e.activePage:e,u=l.visible;l.visible=!0;let c=l.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(n)),this.setClearColor(l.bgColor,l.bgColor.a),l.penumbraSizeArray.forEach((m,p)=>{Fe.penumbraSize.value[p]=m}),Fe.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Fe.resolution.value.set(this.resolution.x,this.resolution.y):Fe.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(Fe.normalRenderTarget.value=a,Fe.normalRenderTargetDepth.value=RI):c.needsNormal()&&(this.createNormalRenderTarget(),Fe.normalRenderTarget.value=this.normalRenderTarget.texture,Fe.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(c,l,n));let d=l.data.ao,h=d.occlusion;h&&(this.createAORenderTarget(),Fe.aoRenderTarget.value=this.aoRenderTarget.texture),Fe.aoEnabled.value=h,this.pipeline.setAmbientOcclusionParams(d.occlusion,d.radius,d.bias,l.aoColor,l.fog!==null,l.backupFog.near,l.backupFog.far,d.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let f=!1;if(o!==void 0)Fe.transmissionRenderTarget.value=o,Fe.transmissionRenderTargetDepth.value=RI,this.pipeline.setTransmissionPassEnabled(!1);else{let m=c.needsTransmission();m&&(this.transmissionRenderTarget===void 0&&(f=!0),this.createTransmissionRenderTarget(),Fe.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Fe.aspectRatio.value=g2(this.viewportWidth,this.viewportHeight),Fe.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(m)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=l,this.pipeline.camera=n,f&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==l.postprocessing&&(this.pipeline.updatePostprocessing(l.postprocessing),!r&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.overrideMaterial=c.wireframeState?yv:null,this.pipeline.render(),Fe.frameIndex.value=(Fe.frameIndex.value+1)%16,n instanceof Xt&&n.copyHistory(),l.visible=u}renderFromSceneForSceneTransitionPass(e,n,r){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,n),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=r,this.sceneTransitionTimeRemaining=r,this.pipeline.renderToScreen=!0;let s=this.pipeline.sceneTransitionPass.uniforms;s.uDPR.value=window.devicePixelRatio,s.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var rh=class extends Vs(Rm){constructor(e,n=15,r=10066329){super(e,n,r);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,n){Hs(this.object,rh.geometryHelper,e,n)}};var ih=class extends Vs(Om){constructor(e,n=15,r=6710886){super(e,n,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,n){Hs(this.object,ih.geometryHelper,e,n)}};var vv=class extends Vs(Dm){constructor(e,n=6710886){super(e,n);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,n){Hs(this.object,vv.geometryHelper,e,n)}update(){if(this.object!==void 0){let e=vv._vector,n=this.object.distance?this.object.distance:1e3,r=n*Math.tan(this.object.angle);this.cone.scale.set(r,r,n),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},cp=vv;cp._vector=new A;function N8(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var sh=class extends jd(Tm,rh){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.top=1250,s.bottom=-1250,s.right=1250,s.left=-1250,s.near=-1e4,s.far=2500;let o=new la(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof la&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let n=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&N8(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),n&&this.update()}};var LI=new A,NI=new A,BI=new qe,oh=class extends jd(Mm,cp){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=Ve.RAD2DEG*2*this.angle,s.aspect=1,s.near=100,s.far=2500;let o=new la(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof la&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),NI.setFromMatrixPosition(this.matrixWorld),BI.setFromRotationMatrix(this.matrixWorld),LI.copy(this.up).applyQuaternion(BI).negate().multiplyScalar(this.distance),this.target.position.copy(NI).add(LI),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ti=class extends ed(mr){constructor(e,n){super();this.data=n;this.bgColor=new sn(1,1,1,1);this.fog=null;this.backupFog=new Ec(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Re;this.penumbraSizeArrayCache=null;this.super_Entity(e,n),this.personalCamera=new Xt(Ei,{...Pl.defaultData,...n.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new _m(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,n){e.color!==void 0&&(this.ambientLight.color=br(e.color,n)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Oi)if(Array.isArray(e.material))for(let n of e.material)n.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&J2(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,n){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let r=this.scene;r.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=br(e.color,n),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,n){e.aoColor!==void 0&&(this.aoColor=br(e.aoColor,n))}updateByOp(e,n,r,s){super.updateByOp(e,n,r,s);let o=n;Tr(e.path,["fog"])?this.updateFog(o.fog,r.shared):Tr(e.path,["ao"])?this.updateAo(o.ao,r.shared):Tr(e.path,["ambient"])?this.updateAmbientLight(o.ambient,r.shared):Tr(e.path,["shadow"])&&this.updateShadow(o.shadow)}updateState(e,n){this.updateState_Entity(e,n),e.backgroundColor!==void 0&&this.setBackgroundColor(br(e.backgroundColor,n.shared)),e.fog!==void 0&&this.updateFog(e.fog,n.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,n.shared),e.ao!==void 0&&this.updateAo(e.ao,n.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,n){super.raycast(e,n)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,n=0;this.traverseEntity(r=>{if(!r.visible)return!0;r instanceof sh&&r.visible&&e<3&&(this.penumbraSizeArrayCache[e]=r.data.penumbraSize,e+=1),r instanceof oh&&r.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+n]=r.data.penumbraSize,n+=1)})}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Pr(o)||sp(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),up(o,e,n,!0)),r(o))}};return r(this),n}};var xv=class extends jd(Em,ih){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=90,s.aspect=1,s.near=100,s.far=2500;let o=new A(-s.far+this.position.x,-s.far+this.position.y,-s.far+this.position.z),a=new A(s.far+this.position.x,s.far+this.position.y,s.far+this.position.z),l=new _t(o,a),u=new ca(l,new Re(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof ca){let n=this.shadow.camera,r=new A(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new A(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z);e.box.set(r,s),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var bv=class extends Ht{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?Vf(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var Va=class extends Ht{constructor(e,n,r){super(e,n,r);this._shapeId=null;this._context=r}updateState(e,n){super.updateState(e,n),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,n;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let o=this._context.scene.find(s);o?.data&&(o.attachedPaths.add(this),n=o.geometry.userData?.shape),n||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=Py;break;case"Ellipse":s=cd;break;case"Polygon":s=Cy;break;case"Star":s=Iy;break;default:throw new Error(`Unknown shape type: ${e.type}`)}n=s.create({parameters:e}).userData.shape}let r=this.geometry;n&&r.inputs&&(r.inputs.shapeData=n,r.build(),this.attachedSurfaceCloners.forEach(s=>s.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,n){super.updateGeometryInteractions(e,n),this.updateShape()}updateEntityBoxSize(e,n){let r=this.geometry.getAttribute("position");r!==void 0?Vf(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,e,n):super.updateEntityBoxSize(e,n)}};var ds=class extends js(xs,Ws){constructor(e,n,r){super();n.type==="Instance"&&typeof e=="string"&&(n=this.transformAssignData(n,r)),this.super_Entity(e,n),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,n){let r=n.scene.data.objects.get(e.component);if(r){let s,o;for(let a of Mo.rootOverrideProps)e[a]===void 0?(s===void 0&&(s={...e}),s[a]=r.data[a]):(o===void 0&&(o={}),o[a]=e[a],s===void 0&&(s={...e}),s[a]=As.apply(r.data[a],e[a]));return this.overrideData=o,s}else return{...Cr.defaultData,...e}}updateByOp(e,n,r,s){let o;if(this.isInstanceRoot&&!s){if(n=this.transformAssignData(n,r),e.type===0&&e.path.length===0&&this.component)for(let a of Mo.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(o===void 0&&(o={...e,props:{...e.props}}),o.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Mo.rootOverrideProps.includes(e.path[0])){let a=e.path[0];o===void 0&&(o={...e,path:[],props:{[a]:n[a]}})}}super.updateByOp(o??e,n,r,s)}updateState(e,n){this.updateState_Entity(e,n)}expandInstanceChildren(e){let n=this.data;if(this.component===void 0){let r=e.scene.find(n.component)??null,s=!1;if(r!==this.oldComponent){if(this.oldComponent){let o=0;for(let a of this.children)if(lt.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),wv(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(r){let o={};UI(e,[this.uuid],n.overrides,this,r,r,0,s,o);for(let a of this.children)if(lt.is(a)){let l=a.data;l.type==="Empty"&&l.animations&&a.traverseEntity(u=>{if(u instanceof Ht&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let d=c.bones.map(m=>e.scene.find(o[m])),h=c.boneInverses.map(m=>new ie().fromArray(m)),f=new ra(d,h);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function wv(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)lt.is(e)&&wv(e)}}function FI(i,t,e,n){return i.component===t&&Sl(i.identity,n)?i.overrideData===e?2:1:0}function UI(i,t,e,n,r,s,o,a,l){if(o>50)return!1;if(n.component!==r){if(n.component){let c=n.component.instances.indexOf(n);c>=0&&n.component.instances.splice(c,1)}r.instances.push(n),n.component=r}r instanceof ds&&r.isInstanceRoot&&r.expandInstanceChildren(i);let u=0;for(let c of r.children)if(lt.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],h=Lu.resolve(e,d,1),f=null,m;if(!a){let p=n.children[u];if(f=lt.is(p)?p:null,f!==null){let g=FI(f,c,h,d);m=g>=1?f.stateSelection:void 0,g!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(d)??null,f!==null)){let g=FI(f,c,h,d);if(m=g>=1?f.stateSelection:void 0,g!==2)f=null;else{let y=f.parent.children.indexOf(f);f.parent.children.splice(y,1),n.children.splice(u,0,f),f.parent===n?(y<=u&&console.error("not possible"),void 0):(f.parent=n,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let p=h?As.apply(c.data,h):c.data;Ji.is(p.type)&&(p={...p,type:"Empty"}),f=ts.createEntity(d,p,i),f.overrideData=h,n.add(f),n.children.splice(n.children.length-1,1),n.children.splice(u,0,f),f.updateState(f.data,i),m&&f.changeSelectedState(m,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let p=f.identity[f.identity.length-1];l[p]=f.uuid}u+=1,UI(i,t,e,f,c,s,o+1,a,l)}if(!a){let c=u;for(;;){let d=n.children[u];if(lt.is(d))i.pendingDeletes.add(d);else break;u+=1}n.children.splice(c,u-c)}return!0}var Sv=class extends js(jh,Ws){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};function B8(i,t,e){let n;return t.geometry.type==="TextGeometry"?new zd(i,t,e):(t.geometry.type==="SubdivGeometry"?n=new ls(i,t,e):t.geometry.type==="PathGeometry"?n=new Va(i,t,e):t.geometry.type==="VectorGeometry"?n=new bv(i,t,e):t.geometry.type==="BooleanGeometry"?n=new Ni(i,t,e):n=new Ht(i,t,e),n)}function Av(i,t,e){return t.type==="Mesh"?B8(i,t,e):t.type==="Empty"?new No(i,t):t.type==="Bone"?new Sv(i,t):t.type==="Page"?new ti(i,t):t.type==="PointLight"?new xv(i,t,e):t.type==="SpotLight"?new oh(i,t,e):t.type==="DirectionalLight"?new sh(i,t,e):t.type==="Component"||t.type==="Instance"?new ds(i,t,e):Ji.is(t.type)?new Xt(i,t):(console.error(t),new No(i,t))}ts.createEntity=Av;function F8(i,t,e){let n=Av(i.identity,t,e),r=i.children,s=i.attachedPaths,o=i.parent,a=i.component,l=i.instances,u=i.overrideData,c=i.uuid,d=i.stateSelection;i.dispose();for(let h of Object.keys(i))delete i[h];Object.setPrototypeOf(i,Object.getPrototypeOf(n));for(let h of Object.keys(n))i[h]=n[h];i.children=[...i.children,...r],i.attachedPaths=s,i.parent=o,i.component=a,i.instances=l,i.uuid=c,i.overrideData=u,i.updateState(i.data,e),d&&i.changeSelectedState(d,e),i.resetBBoxNeedsUpdate()}ts.changeEntityProptotype=F8;ts.Cloner=ur;function kI(i,t,e,n){i.updateByOp(t,e,n,!1)}function zI(i,t){let e=!1,n=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(i.layers.set(8),n.length>0&&i.layers.enable(3),e=!0,Ud(i),Fd(i)),n.length===0&&r.length===0&&i.layers.set(0),i instanceof Oi&&i.needsAO&&i.layers.enable(5),e}function GI(i,t){if(!t.layers)return!1;let e=!1,n=t.getLayersOfType("transmission").filter(s=>s.data.visible),r=t.getLayersOfType("outline").filter(s=>s.data.visible);return n.length>0&&(i.layers.set(3),r.length>0&&i.layers.enable(8),e=!0),n.length===0&&r.length===0&&i.layers.set(0),i.needsAO&&i.layers.enable(5),e}function VI(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Oi)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)zI(e,e.material[n])&&(t=!0);else zI(e,e.material)&&(t=!0)}),t}function HI(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Oi)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)GI(e,e.material[n])&&(t=!0);else GI(e,e.material)&&(t=!0)}),t}var U8=new Vc,k8=new ie,z8=new ji;function up(i,t,e,n=!1){let r=i.cloner;if(r)for(let s of r.children){let o=k8.copy(s.matrixWorld).invert(),a=z8.copy(t.ray).applyMatrix4(o),l=i.matrixWorld;a.applyMatrix4(l);let u=U8;u.set(a.origin,a.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(i,!1);c.length>0&&e.push({...c[0],object:n?s:i})}}var _v=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((n,r)=>{let s=[r,n],o=n;for(;this._constraints.has(o);)o=this._constraints.get(o),e.has(o)||s.push(o);for(let a=s.length-2;a>=0;a--)if(!e.has(s[a])){let l=t.find(s[a]);l?l.applyPathSnapping(t):console.warn(`missing entity ${s[a]}`),e.add(s[a])}})}findDependency(t,e){let n=t;for(;this._constraints.has(n);)if(n=this._constraints.get(n),n===e)return!0;return!1}};var yv=new Wi;yv.wireframe=!0;var jI=new A,Ga=class extends mr{constructor(e,n){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new _v;this.errorPage=new ti("fdasfa",{...Eo.defaultData,name:""});this.needsRecomputeInstances=!1;this.init(e,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=HI(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=VI(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let n=e.identity.join("-"),r=this.entityIdentityToEntity[n];r&&(e.uuid=r.uuid),this.entityIdentityToEntity[n]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof ti&&(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 n=this.find(e);if(n===void 0)return;let r=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);r.splice(0,0,a)}return{entity:n,sortKey:r}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push(s)}return n.sort((r,s)=>pT(r.sortKey,s.sortKey)),n.map(r=>r.entity)}nonExistOrDescendantOf(e,n){let r=this.find(e);if(r===void 0)return!0;for(;r;){if(r.uuid===n)return!0;r=r.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===Ei)return this.activePage.personalCamera}if(e===""||e===void 0)return;let n=this.entityByUuid[e];return n===void 0?this.getObjectByProperty("uuid",e):n}debugEnsureEntity(e){let n=this.find(e);if(n){if(Array.isArray(n.identity)&&this.findInstance(n.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(n=>{this.toExpandCloner.add(n)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,n){if(e.path.length===0&&e.type===7){let r=e.parent===null?this:this.find(e.parent);if(r===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,r,e.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),Pr(s)&&Hr(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(r),this.markPenumbraSizeDirty(),r.parent.remove(r),Hr(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Pr(r)&&(r.freeBooleanPointer(),s instanceof Ni&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r instanceof Va&&r.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),this.pathConstraints.removeDependencies(r.uuid)}else if(e.path.length===0&&e.type===9){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(r),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Pr(r)&&(r.invalidateUpstreamBooleanData(),Hr(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Ni&&s.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let n of this.children)n instanceof ti&&(n.visible=n.uuid===e,n.visible&&(this.activePage=n,this.activePage.onActive(this)))}updateEntityByOp(e,n,r,s){if(n.type===0){if(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),"visible"in n.props&&this.markPenumbraSizeDirty(),n.path.includes("overrides")&&"states"in n.props){let{rest:a}=n.props;n={...n,props:a},this.markNeedsRecomputeInstances()}n.path[0]==="pathSnapping"&&n.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,n.props.pathId)}let o=this.find(e);if(o)try{kI(o,n,r,{scene:this,shared:s}),o instanceof Ht&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}init(e,n){this.createChildrenObjects(e.objects,this,n),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(n,!0),this.traverseEntity(r=>{Hr(r)&&r.recomputeBoolean(),r instanceof Xt&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(n=>{(n.data.type==="Component"||n.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){lt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(n=>{lt.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,n,r,s,o,a,l){if(e){let u=s.find(e);u&&u!==s&&o.forInstancesRec(c=>{c.data=Tu(c.data,d=>{let h=d.events.data(l.id),f=c.goUp(a);if(f){let m=[...hg(f.identity),e].join("-"),p=this.entityIdentityToEntity[m];if(p){let g=p.uuid,y=Br.zoom(h,n);y[r]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,n,r,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ds&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((n,r)=>{n.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(n.forInstancesRec(a=>{a.data=Tu(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of ty.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,n,r,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,n,r,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,n,r,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,n,r,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,n,r,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,n,r,s)),this.rewriteActions(s.data.inActions,["inActions"],e,n,r,s),this.rewriteActions(s.data.outActions,["outActions"],e,n,r,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,n,r,s)})}),!0})}expandInstances(e,n,r){let s=new Set;this.traverseEntity(o=>{if(o instanceof ds&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),n||o.resetBBoxNeedsUpdate(),r&&o.traverseEntity(a=>{r.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),wv(o)}recomputeInstances(e,n){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(r=>{r instanceof ds&&r.isInstanceRoot&&(r.component=void 0)}),this.expandInstances(e,!1,n))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(n=>{let r=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[r]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[r]),n.dispose()})}clearScene(){for(let e of this.children)lt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,n){this.init(e,n)}raycast(e){return this.raycast1(e,!1)}raycast1(e,n){let r=[],s=o=>{for(let a of o.children){let l=a.cloner;if(lt.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(n===!0&&a.isInstanceRoot){let u=[];if(e.intersectObject(a,!0,u),u.length){let c=u[0];c.object=a,c.point.applyMatrix4(c.object.matrixWorld);let d=a.matrixWorld.clone().invert();c.point.applyMatrix4(d),r.push(c)}}else(Pr(a)||sp(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),up(a,e,r)),s(a)}};return s(this),r}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Pr(o)||sp(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),up(o,e,n,!0)),r(o))}};return r(this),n}forEachEntity(e){for(let n of this.children)lt.is(n)&&e(n)}traverseConcreteEntity(e){for(let n of this.children)lt.is(n)&&n.isConcreteEntity&&n.traverseEntity(e)}traverseEntity(e){for(let n of this.children)lt.is(n)&&n.traverseEntity(e)}traverseObject(e){for(let n of this.children)Zu.is(n)&&n.traverseObject(e)}traverseVisibleEntity(e){for(let n of this.children)lt.is(n)&&n.visible&&n.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,n,r){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,n,s,r),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let n of e.children)this.unregisterObject(n)}createObject(e,n,r,s,o,a){let l={scene:this,shared:a},u=Av(e,n,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),r.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,u,a)),u.updateState(n,l),u instanceof Ht&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),n.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,n.pathSnapping.pathId)),n.type==="Empty"&&n.animations&&u.traverseEntity(c=>{if(c instanceof Ht&&c.isSkinnedMesh){let d=c.dataPatched;if(d.bones&&d.boneInverses){let h=d.bones.map(p=>this.find(p)),f=d.boneInverses.map(p=>new ie().fromArray(p)),m=new ra(h,f);c.bind(m,c.bindMatrix)}}else c.matrixAutoUpdate=!0}),u}getCenter(e){let n=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;n.push(...c.vertices)}let r=new _t;return r.setFromPoints(n),r.getCenter(jI),jI}copyMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e);r?n.copy(r.matrixWorld):n.identity()}copyParentMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e)?.parent;r?n.copy(r.matrixWorld):n.identity()}traverseMaterial(e){this.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let r=0;r<n.material.length;r++)n.material[r]instanceof $r&&e(n.material[r]);else n.material instanceof $r&&e(n.material)})}updateCanvasSize(e,n,r=!1){this.activeCamera.setViewplaneSize(e,n,r)}};var dp=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return Math.sqrt(e*e+n*n)},WI=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return G8(Math.atan2(n,e))},qI=(i,t,e)=>{let n={x:0,y:0};return e=Mv(e),n.x=i.x-t*Math.cos(e),n.y=i.y-t*Math.sin(e),n},Mv=i=>i*(Math.PI/180),G8=i=>i*(180/Math.PI),YI=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,FS=new Map,US=i=>{FS.has(i)&&clearTimeout(FS.get(i)),FS.set(i,setTimeout(i,100))},ah=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.addEventListener?i.addEventListener(r,e,!1):i.attachEvent&&i.attachEvent(r,e)},kS=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.removeEventListener?i.removeEventListener(r,e):i.detachEvent&&i.detachEvent(r,e)};var Ev=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),zS=()=>{if(typeof window>"u")return;let i=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:i,y:t}},Tv=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},Cv=(i,t,e)=>{let n=QI(i);for(let r in n)if(n.hasOwnProperty(r))if(typeof t=="string")n[r]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";n[r]=s.slice(0,-2)}return n},XI=(i,t)=>{let e=QI(i);for(let n in e)e.hasOwnProperty(n)&&(e[n]=t);return e},QI=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(n){t[n+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},Pv=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},KI=(i,t)=>{let e={};for(let n in i)i.hasOwnProperty(n)&&t.hasOwnProperty(n)?e[n]=t[n]:i.hasOwnProperty(n)&&(e[n]=i[n]);return e},hp=(i,t)=>{if(i.length)for(let e=0,n=i.length;e<n;e+=1)t(i[e]);else t(i)},ZI=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(JI="ontouchstart"in window,$I=!!window.PointerEvent,eD=!!window.MSPointerEvent);var JI,$I,eD,fp={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"}},lh,pp={};$I?lh=fp.pointer:eD?lh=fp.MSPointer:JI?(lh=fp.touch,pp=fp.mouse):lh=fp.mouse;function Zl(){}Zl.prototype.on=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]=e._handlers_[r]||[],e._handlers_[r].push(t);return e};Zl.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};Zl.prototype.trigger=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]&&e._handlers_[r].length&&e._handlers_[r].forEach(function(o){o.call(e,{type:r,target:e},t)})};Zl.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=KI(t.options,i))};Zl.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},ah(i,lh[t],e._domHandlers_[t]),pp[t]&&ah(i,pp[t],e._domHandlers_[t]),e};Zl.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},kS(i,lh[t],e._domHandlers_[t]),pp[t]&&kS(i,pp[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var ch=Zl;function Qn(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,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=Qn.id,Qn.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}Qn.prototype=new ch;Qn.constructor=Qn;Qn.id=0;Qn.prototype.buildEl=function(i){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)};Qn.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=XI("borderRadius","50%"),e=Cv("transition","opacity",i),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.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)"},n.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)"},Pv(n.el,e),this.options.shape==="circle"&&Pv(n.back,t),Pv(n.front,t),this.applyStyles(n),this};Qn.prototype.applyStyles=function(i){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};Qn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Qn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Qn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Qn.prototype.show=function(i){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 i=="function"&&i.call(this)},t.options.fadeTime)),t};Qn.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,n={};n.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,n.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,n)}return t};Qn.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var n=e.options.fadeTime+"ms",r={};r.front=Cv("transition",["top","left"],n);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(r),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};Qn.prototype.restCallback=function(){var i=this,t={};t.front=Cv("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};Qn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Qn.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,n=Math.PI/2,r,s,o;if(t>e&&t<e*3&&!i.lockX?r="up":t>-e&&t<=e&&!i.lockY?r="left":t>-e*3&&t<=-e&&!i.lockX?r="down":i.lockY||(r="right"),i.lockY||(t>-n&&t<n?s="left":s="right"),i.lockX||(t>0?o="up":o="down"),i.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:r},i.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return i;(!u.x||!u.y)&&this.trigger("plain",i),u.x||this.trigger("plain:"+s,i),u.y||this.trigger("plain:"+o,i),u.angle||this.trigger("dir dir:"+r,i)}else this.resetDirection();return i};var tD=Qn;function Sn(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Sn.id,Sn.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let n=getComputedStyle(e.options.zone.parentElement);return n&&n.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Sn.prototype=new ch;Sn.constructor=Sn;Sn.id=0;Sn.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var n=0,r=t.length;n<r;n+=1)if(t[n].identifier===e)return t[n];return!1}};Sn.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Sn.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Sn.prototype.createNipple=function(i,t){var e=this,n=e.manager.scroll,r={},s=e.options,o={x:e.parentIsFlex?n.x:n.x+e.box.left,y:e.parentIsFlex?n.y:n.y+e.box.top};if(i.x&&i.y)r={x:i.x-o.x,y:i.y-o.y};else if(i.top||i.right||i.bottom||i.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=i.top,a.style.right=i.right,a.style.bottom=i.bottom,a.style.left=i.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),r=i,i={x:l.left+n.x,y:l.top+n.y}}var u=new tD(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:i,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Tv(u.ui.el,r),Tv(u.ui.front,u.frontPosition)),e.nipples.push(u),e.trigger("added "+u.identifier+":added",u),e.manager.trigger("added "+u.identifier+":added",u),e.bindNipple(u),u};Sn.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Sn.prototype.bindNipple=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};Sn.prototype.pressureFn=function(i,t,e){var n=this,r=0;clearInterval(n.pressureIntervals[e]),n.pressureIntervals[e]=setInterval(function(){var s=i.force||i.pressure||i.webkitForce||0;s!==r&&(t.trigger("pressure",s),n.trigger("pressure "+t.identifier+":pressure",s),r=s)}.bind(n),100)};Sn.prototype.onstart=function(i){var t=this,e=t.options,n=i;i=Ev(i),t.updateBox();var r=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(n.touches).findIndex(function(l){return l.identifier===o})<0){var a=[i[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return hp(i,r),t.manager.bindDocument(),!1};Sn.prototype.processOnStart=function(i){var t=this,e=t.options,n,r=t.manager.getIdentifier(i),s=i.force||i.pressure||i.webkitForce||0,o={x:i.pageX,y:i.pageY},a=t.getOrCreate(r,o);a.identifier!==r&&t.manager.removeIdentifier(a.identifier),a.identifier=r;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(i,c,c.identifier),t.processOnMove(i)};if((n=t.idles.indexOf(a))>=0&&t.idles.splice(n,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var u=dp(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(i);return}}return a};Sn.prototype.getOrCreate=function(i,t){var e=this,n=e.options,r;return/(semi|static)/.test(n.mode)?(r=e.idles[0],r?(e.idles.splice(0,1),r):n.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(r=e.createNipple(t,i),r)};Sn.prototype.processOnMove=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.scroll;if(!YI(i)){this.processOnEnd(i);return}if(!r){console.error("Found zombie joystick with ID "+n),t.manager.removeIdentifier(n);return}if(e.dynamicPage){var o=r.el.getBoundingClientRect();r.position={x:s.x+o.left,y:s.y+o.top}}r.identifier=n;var a=r.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=r.position.y),e.lockY&&(l.x=r.position.x);var u=dp(l,r.position),c=WI(l,r.position),d=Mv(c),h=u/a,f={distance:u,position:l},m,p;if(r.options.shape==="circle"?(m=Math.min(u,a),p=qI(r.position,m,c)):(p=ZI(l,r.position,a),m=dp(p,r.position)),e.follow){if(u>a){let x=l.x-p.x,w=l.y-p.y;r.position.x+=x,r.position.y+=w,r.el.style.top=r.position.y-(t.box.top+s.y)+"px",r.el.style.left=r.position.x-(t.box.left+s.x)+"px",u=dp(l,r.position)}}else l=p,u=m;var g=l.x-r.position.x,y=l.y-r.position.y;r.frontPosition={x:g,y},e.dataOnly||Tv(r.ui.front,r.frontPosition);var v={identifier:r.identifier,position:l,force:h,pressure:i.force||i.pressure||i.webkitForce||0,distance:u,angle:{radian:d,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:r,lockX:e.lockX,lockY:e.lockY};v=r.computeDirection(v),v.angle={radian:Mv(180-c),degree:180-c},r.trigger("move",v),t.trigger("move "+r.id+":move",v)};Sn.prototype.processOnEnd=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.removeIdentifier(r.identifier);!r||(e.dataOnly||r.hide(function(){e.mode==="dynamic"&&(r.trigger("removed",r),t.trigger("removed "+r.id+":removed",r),t.manager.trigger("removed "+r.id+":removed",r),r.destroy())}),clearInterval(t.pressureIntervals[r.identifier]),r.resetDirection(),r.trigger("end",r),t.trigger("end "+r.id+":end",r),t.ids.indexOf(r.identifier)>=0&&t.ids.splice(t.ids.indexOf(r.identifier),1),t.actives.indexOf(r)>=0&&t.actives.splice(t.actives.indexOf(r),1),/(semi|static)/.test(e.mode)?t.idles.push(r):t.nipples.indexOf(r)>=0&&t.nipples.splice(t.nipples.indexOf(r),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};Sn.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Sn.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)i.pressureIntervals.hasOwnProperty(t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off()};var nD=Sn;function dr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=zS(),t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(s){s.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};if(typeof window>"u")return t.collections;ah(window,"resize",function(){US(e)});var n=function(){t.scroll=zS()};return ah(window,"scroll",function(){US(n)}),t.collections}dr.prototype=new ch;dr.constructor=dr;dr.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(n){return e=n.get(t),!e}),e}};dr.prototype.create=function(i){return this.createCollection(i)};dr.prototype.createCollection=function(i){var t=this,e=new nD(t,i);return t.bindCollection(e),t.collections.push(e),e};dr.prototype.bindCollection=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};dr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};dr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};dr.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.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]};dr.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};dr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};dr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};dr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};dr.prototype.onAny=function(i,t){var e=this,n,r="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=Ev(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[r](a),a._found_=!0)},o=function(a){n=e.getIdentifier(a),hp(e.collections,s.bind(null,a,n)),a._found_||e.removeIdentifier(n)};return hp(t,o),!1};dr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.off()};dr.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var rD=dr;var iD=new rD,sD={create:function(i){return iD.create(i)},factory:iD};var oD=new Map,mp=new Map,Xs=class{constructor(t,e,n,r){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let u=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Ro({src:u,volume:o,delay:a,loop:l}),mp.has(n.uuid)?mp.get(n.uuid).push(this):mp.set(n.uuid,[this]),oD.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},uh=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=oD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=mp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...mp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Fo=class{constructor(t,e,n,r){this.data=e;if(e.interaction==="play")this.interaction=new Xs(t,e,n,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new uh(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Xs?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Xs?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){this.interaction instanceof Xs&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var V8="text/plain",H8="us-ascii",aD=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),j8=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:n,data:r,hash:s}=e.groups,o=n.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(d=>{let[h,f=""]=d.split("=").map(m=>m.trim());return h==="charset"&&(f=f.toLowerCase(),f===H8)?"":`${h}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==V8)&&c.unshift(l),`data:${c.join(";")},${a?r.trim():r}${s?`#${s}`:""}`};function GS(i,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},i=i.trim(),/^data:/i.test(i))return j8(i,t);if(/^view-source:/i.test(i))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=i.startsWith("//");!e&&/^\.*\//.test(i)||(i=i.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(i);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 o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(r.pathname);if(!c)break;let d=c[0],h=c.index,f=r.pathname.slice(a,h);l+=f.replace(/\/{2,}/g,"/"),l+=d,a=h+d.length}let u=r.pathname.slice(a,r.pathname.length);l+=u.replace(/\/{2,}/g,"/"),r.pathname=l}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 o=r.pathname.split("/"),a=o[o.length-1];aD(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),r.pathname=o.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 o of[...r.searchParams.keys()])aD(o,t.removeQueryParameters)&&r.searchParams.delete(o);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=i;return i=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var Dv=class{constructor({url:t,context:e},n){this.eventManager=n;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:GS(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){dg?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.eventManager.controlsManager.orbitControls?.onPointerUp(ke[0]),gT())}};var gp=class{constructor(t,e,n){this.data=t;this.page=e;this.eventManager=n;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let n=this.controlsManager.sharedGameControlGlobals.rapierWorld,r=n?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)r?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(r||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;n===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),this.eventManager.requestRender()};this.objects=[...t.objects],this.controlsManager=n.controlsManager}dispatch(t){this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var Ov=class{constructor(t,e,n){this.page=t;this.eventManager=n;this.sharedAssets=e}dispatch(){dh(this.page,this.sharedAssets,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender()}};var fD={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},WS={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},W8=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Lv={CSS:{},springs:{}};function hs(i,t,e){return Math.min(Math.max(i,t),e)}function yp(i,t){return i.indexOf(t)>-1}function VS(i,t){return i.apply(null,t)}var et={arr:function(i){return Array.isArray(i)},obj:function(i){return yp(Object.prototype.toString.call(i),"Object")},pth:function(i){return et.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||et.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i>"u"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return et.hex(i)||et.rgb(i)||et.hsl(i)},key:function(i){return!fD.hasOwnProperty(i)&&!WS.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function pD(i){var t=/\(([^)]+)\)/.exec(i);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function mD(i,t){var e=pD(i),n=hs(et.und(e[0])?1:e[0],.1,100),r=hs(et.und(e[1])?100:e[1],.1,100),s=hs(et.und(e[2])?10:e[2],.1,100),o=hs(et.und(e[3])?0:e[3],.1,100),a=Math.sqrt(r/n),l=s/(2*Math.sqrt(r*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*a+-o)/u:-o+a;function h(m){var p=t?t*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(c*Math.cos(u*p)+d*Math.sin(u*p)):p=(c+d*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=Lv.springs[i];if(m)return m;for(var p=1/6,g=0,y=0;;)if(g+=p,h(g)===1){if(y++,y>=16)break}else y=0;var v=g*p*1e3;return Lv.springs[i]=v,v}return t?h:f}function q8(i){return i===void 0&&(i=10),function(t){return Math.ceil(hs(t,1e-6,1)*i)*(1/i)}}var Y8=function(){var i=11,t=1/(i-1);function e(c,d){return 1-3*d+3*c}function n(c,d){return 3*d-6*c}function r(c){return 3*c}function s(c,d,h){return((e(d,h)*c+n(d,h))*c+r(d))*c}function o(c,d,h){return 3*e(d,h)*c*c+2*n(d,h)*c+r(d)}function a(c,d,h,f,m){var p,g,y=0;do g=d+(h-d)/2,p=s(g,f,m)-c,p>0?h=g:d=g;while(Math.abs(p)>1e-7&&++y<10);return g}function l(c,d,h,f){for(var m=0;m<4;++m){var p=o(d,h,f);if(p===0)return d;var g=s(d,h,f)-c;d-=g/p}return d}function u(c,d,h,f){if(!(0<=c&&c<=1&&0<=h&&h<=1))return;var m=new Float32Array(i);if(c!==d||h!==f)for(var p=0;p<i;++p)m[p]=s(p*t,c,h);function g(y){for(var v=0,x=1,w=i-1;x!==w&&m[x]<=y;++x)v+=t;--x;var S=(y-m[x])/(m[x+1]-m[x]),_=v+S*t,M=o(_,c,h);return M>=.001?l(y,_,c,h):M===0?_:a(y,v,v+t,c,h)}return function(y){return c===d&&h===f||y===0||y===1?y:s(g(y),d,f)}}return u}(),gD=function(){var i={linear:function(){return function(n){return n}}},t={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var r,s=4;n<((r=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((r*3-2)/22-n,2)}},Elastic:function(n,r){n===void 0&&(n=1),r===void 0&&(r=.5);var s=hs(n,1,10),o=hs(r,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(n,r){t[n]=function(){return function(s){return Math.pow(s,r+2)}}}),Object.keys(t).forEach(function(n){var r=t[n];i["easeIn"+n]=r,i["easeOut"+n]=function(s,o){return function(a){return 1-r(s,o)(1-a)}},i["easeInOut"+n]=function(s,o){return function(a){return a<.5?r(s,o)(a*2)/2:1-r(s,o)(a*-2+2)/2}}}),i}();function qS(i,t){if(et.fnc(i))return i;var e=i.split("(")[0],n=gD[e],r=pD(i);switch(e){case"spring":return mD(i,t);case"cubicBezier":return VS(Y8,r);case"steps":return VS(q8,r);default:return VS(n,r)}}function yD(i){try{var t=document.querySelectorAll(i);return t}catch{return}}function Nv(i,t){for(var e=i.length,n=arguments.length>=2?arguments[1]:void 0,r=[],s=0;s<e;s++)if(s in i){var o=i[s];t.call(n,o,s,i)&&r.push(o)}return r}function Bv(i){return i.reduce(function(t,e){return t.concat(et.arr(e)?Bv(e):e)},[])}function lD(i){return et.arr(i)?i:(et.str(i)&&(i=yD(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function YS(i,t){return i.some(function(e){return e===t})}function XS(i){var t={};for(var e in i)t[e]=i[e];return t}function HS(i,t){var e=XS(i);for(var n in i)e[n]=t.hasOwnProperty(n)?t[n]:i[n];return e}function Fv(i,t){var e=XS(i);for(var n in t)e[n]=et.und(i[n])?t[n]:i[n];return e}function X8(i){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return t?"rgba("+t[1]+",1)":i}function Q8(i){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=i.replace(t,function(a,l,u,c){return l+l+u+u+c+c}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),r=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+r+","+s+","+o+",1)"}function K8(i){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),e=parseInt(t[1],10)/360,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100,s=t[4]||1;function o(h,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?h+(f-h)*6*m:m<1/2?f:m<2/3?h+(f-h)*(2/3-m)*6:h}var a,l,u;if(n==0)a=l=u=r;else{var c=r<.5?r*(1+n):r+n-r*n,d=2*r-c;a=o(d,c,e+1/3),l=o(d,c,e),u=o(d,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function Z8(i){if(et.rgb(i))return X8(i);if(et.hex(i))return Q8(i);if(et.hsl(i))return K8(i)}function Uo(i){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(i);if(t)return t[1]}function J8(i){if(yp(i,"translate")||i==="perspective")return"px";if(yp(i,"rotate")||yp(i,"skew"))return"deg"}function jS(i,t){return et.fnc(i)?i(t.target,t.id,t.total):i}function Qs(i,t){return i.getAttribute(t)}function QS(i,t,e){var n=Uo(t);if(YS([e,"deg","rad","turn"],n))return t;var r=Lv.CSS[t+e];if(!et.und(r))return r;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return Lv.CSS[t+e]=u,u}function vD(i,t,e){if(t in i.style){var n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=i.style[t]||getComputedStyle(i).getPropertyValue(n)||"0";return e?QS(i,r,e):r}}function KS(i,t){if(et.dom(i)&&!et.inp(i)&&(Qs(i,t)||et.svg(i)&&i[t]))return"attribute";if(et.dom(i)&&YS(W8,t))return"transform";if(et.dom(i)&&t!=="transform"&&vD(i,t))return"css";if(i[t]!=null)return"object"}function xD(i){if(!!et.dom(i)){for(var t=i.style.transform||"",e=/(\w+)\(([^)]*)\)/g,n=new Map,r;r=e.exec(t);)n.set(r[1],r[2]);return n}}function $8(i,t,e,n){var r=yp(t,"scale")?1:0+J8(t),s=xD(i).get(t)||r;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),n?QS(i,s,n):s}function ZS(i,t,e,n){switch(KS(i,t)){case"transform":return $8(i,t,n,e);case"css":return vD(i,t,e);case"attribute":return Qs(i,t);default:return i[t]||0}}function JS(i,t){var e=/^(\*=|\+=|-=)/.exec(i);if(!e)return i;var n=Uo(i)||0,r=parseFloat(t),s=parseFloat(i.replace(e[0],""));switch(e[0][0]){case"+":return r+s+n;case"-":return r-s+n;case"*":return r*s+n}}function bD(i,t){if(et.col(i))return Z8(i);if(/\s/g.test(i))return i;var e=Uo(i),n=e?i.substr(0,i.length-e.length):i;return t?n+t:n}function $S(i,t){return Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))}function eq(i){return Math.PI*2*Qs(i,"r")}function tq(i){return Qs(i,"width")*2+Qs(i,"height")*2}function nq(i){return $S({x:Qs(i,"x1"),y:Qs(i,"y1")},{x:Qs(i,"x2"),y:Qs(i,"y2")})}function wD(i){for(var t=i.points,e=0,n,r=0;r<t.numberOfItems;r++){var s=t.getItem(r);r>0&&(e+=$S(n,s)),n=s}return e}function rq(i){var t=i.points;return wD(i)+$S(t.getItem(t.numberOfItems-1),t.getItem(0))}function SD(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return eq(i);case"rect":return tq(i);case"line":return nq(i);case"polyline":return wD(i);case"polygon":return rq(i)}}function iq(i){var t=SD(i);return i.setAttribute("stroke-dasharray",t),t}function sq(i){for(var t=i.parentNode;et.svg(t)&&et.svg(t.parentNode);)t=t.parentNode;return t}function AD(i,t){var e=t||{},n=e.el||sq(i),r=n.getBoundingClientRect(),s=Qs(n,"viewBox"),o=r.width,a=r.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function oq(i,t){var e=et.str(i)?yD(i)[0]:i,n=t||100;return function(r){return{property:r,el:e,svg:AD(e),totalLength:SD(e)*(n/100)}}}function aq(i,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return i.el.getPointAtLength(l)}var n=AD(i.el,i.svg),r=e(),s=e(-1),o=e(1);switch(i.property){case"x":return(r.x-n.x)*n.w;case"y":return(r.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function cD(i,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=bD(et.pth(i)?i.totalLength:i,t)+"";return{original:n,numbers:n.match(e)?n.match(e).map(Number):[0],strings:et.str(i)||t?n.split(e):[]}}function _D(i){var t=i?Bv(et.arr(i)?i.map(lD):lD(i)):[];return Nv(t,function(e,n,r){return r.indexOf(e)===n})}function MD(i){var t=_D(i);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:xD(e)}}})}function lq(i,t){var e=XS(t);if(/^spring/.test(e.easing)&&(e.duration=mD(e.easing)),et.arr(i)){var n=i.length,r=n===2&&!et.obj(i[0]);r?i={value:i}:et.fnc(t.duration)||(e.duration=t.duration/n)}var s=et.arr(i)?i:[i];return s.map(function(o,a){var l=et.obj(o)&&!et.pth(o)?o:{value:o};return et.und(l.delay)&&(l.delay=a?0:t.delay),et.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return Fv(o,e)})}function cq(i){for(var t=Nv(Bv(i.map(function(s){return Object.keys(s)})),function(s){return et.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},n=function(s){var o=t[s];e[o]=i.map(function(a){var l={};for(var u in a)et.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},r=0;r<t.length;r++)n(r);return e}function uq(i,t){var e=[],n=t.keyframes;n&&(t=Fv(cq(n),t));for(var r in t)et.key(r)&&e.push({name:r,tweens:lq(t[r],i)});return e}function dq(i,t){var e={};for(var n in i){var r=jS(i[n],t);et.arr(r)&&(r=r.map(function(s){return jS(s,t)}),r.length===1&&(r=r[0])),e[n]=r}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function hq(i,t){var e;return i.tweens.map(function(n){var r=dq(n,t),s=r.value,o=et.arr(s)?s[1]:s,a=Uo(o),l=ZS(t.target,i.name,a,t),u=e?e.to.original:l,c=et.arr(s)?s[0]:u,d=Uo(c)||Uo(l),h=a||d;return et.und(o)&&(o=u),r.from=cD(c,h),r.to=cD(JS(o,c),h),r.start=e?e.end:0,r.end=r.start+r.delay+r.duration+r.endDelay,r.easing=qS(r.easing,r.duration),r.isPath=et.pth(s),r.isColor=et.col(r.from.original),r.isColor&&(r.round=1),e=r,r})}var ED={css:function(i,t,e){return i.style[t]=e},attribute:function(i,t,e){return i.setAttribute(t,e)},object:function(i,t,e){return i[t]=e},transform:function(i,t,e,n,r){if(n.list.set(t,e),t===n.last||r){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function TD(i,t){var e=MD(i);e.forEach(function(n){for(var r in t){var s=jS(t[r],n),o=n.target,a=Uo(s),l=ZS(o,r,a,n),u=a||Uo(l),c=JS(bD(s,u),l),d=KS(o,r);ED[d](o,r,c,n.transforms,!0)}})}function fq(i,t){var e=KS(i.target,t.name);if(e){var n=hq(t,i),r=n[n.length-1];return{type:e,property:t.name,animatable:i,tweens:n,duration:r.end,delay:n[0].delay,endDelay:r.endDelay}}}function pq(i,t){return Nv(Bv(i.map(function(e){return t.map(function(n){return fq(e,n)})})),function(e){return!et.und(e)})}function CD(i,t){var e=i.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},r={};return r.duration=e?Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,r.delay=e?Math.min.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):t.delay,r.endDelay=e?r.duration-Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,r}var uD=0;function mq(i){var t=HS(fD,i),e=HS(WS,i),n=uq(e,i),r=MD(i.targets),s=pq(r,n),o=CD(s,e),a=uD;return uD++,Fv(t,{id:a,children:[],animatables:r,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Fi=[],dD=[],Rv,gq=function(){function i(){Rv=requestAnimationFrame(t)}function t(e){var n=Fi.length;if(n){for(var r=0;r<n;){var s=Fi[r];s.paused?(Fi.splice(r,1),n-=1):(s.tick(e),r++)}i()}else Rv=cancelAnimationFrame(Rv)}return i}();function yq(i){document.hidden?(Fi.forEach(function(t){return t.pause(i.timeStamp)}),dD=Fi.slice(0),An.running=Fi=[]):dD.forEach(function(t){return t.play(i.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",yq);function An(i){i===void 0&&(i={});var t=0,e=0,n=0,r,s,o=0,a=null;function l(M){var b=window.Promise&&new Promise(function(E){return a=E});return M.finished=b,b}var u=mq(i),c=l(u);function d(){var M=u.direction;M!=="alternate"&&(u.direction=M!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=u.reversed)})}function h(){u.direction="normal",u.reversed=!1,s.forEach(function(M){return M.reversed=!1})}function f(M){return u.reversed?u.duration-M:M}function m(){t=0,e=f(u.currentTime)*(1/An.speed)}function p(M,b){b&&(u.reversed?b.seek(b.duration*b.loop-(M-b.timelineOffset-b.pingPongDelayCorrection)):b.seek(M-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection))}function g(M){if(u.reversed)for(var E=o;E--;)p(M,s[E]);else for(var b=0;b<o;b++)p(M,s[b])}function y(M){var b=0,E=u.animations,T=E.length;for(u.direction!=="alternate"&&u.parent?.direction==="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1&&(u.parent?.reversed&&u.direction==="alternate"?M=u.duration-u.delay+u.endDelay-M:M=u.duration+u.delay-u.endDelay-M):S(!1,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)&&(u.parent?.reversed&&u.direction==="alternate"?M=u.duration-u.delay+u.endDelay-M:M=u.duration+u.delay-u.endDelay-M);b<T;){var I=E[b],C=I.animatable,P=I.tweens,O=P.length-1,B=P[O];O&&(B=Nv(P,function(k){return M<k.end})[0]||B);let Z;u.parent?.reversed&&u.direction==="alternate"?Z=hs(M-B.start-B.endDelay,0,B.duration)/B.duration:Z=hs(M-B.start-B.delay,0,B.duration)/B.duration;for(var j=isNaN(Z)?1:B.easing(Z),Q=B.to.strings,V=B.round,q=[],W=B.to.numbers.length,X=void 0,L=0;L<W;L++){var U=void 0;let k,he;u.direction!=="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1?(k=B.to.numbers[L],he=B.from.numbers[L]||0):(he=B.to.numbers[L],k=B.from.numbers[L]||0):S(!0,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)?(k=B.to.numbers[L],he=B.from.numbers[L]||0):(he=B.to.numbers[L],k=B.from.numbers[L]||0),B.isPath?U=aq(B.value,j*he):U=k+j*(he-k),V&&(B.isColor&&L>2||(U=Math.round(U*V)/V)),q.push(U)}var G=Q.length;if(!G)X=q[0];else{X=Q[0];for(var H=0;H<G;H++){var z=Q[H],re=Q[H+1],K=q[H];isNaN(K)||(re?X+=K+re:X+=K+" ")}}ED[I.type](C.target,I.property,X,C.transforms),I.currentValue=X,b++}}function v(M){u[M]&&!u.passThrough&&u[M](u)}function x(){u.remaining&&u.remaining!==!0&&u.remaining--}let w={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(M,b,E,T,I){return w[M<<4|b<<3|E<<2|T<<1|I]}function _(M){var b=u.duration;let E=u.delay,T=b-u.endDelay;u.parent?.reversed&&u.direction==="alternate"&&(E=u.endDelay,T=b-u.delay);var I=f(M);if(u.progress=hs(I/b*100,0,100),u.reversePlayback=I<u.currentTime,o&&g(I),!u.began&&u.currentTime>=0&&(u.began=!0,v("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,v("loopBegin")),(u.reversed||I>=0)&&I<=E&&u.currentTime!==0&&(y(0),v("change")),(I>=T&&u.currentTime!==b+u.pingPongDelayCorrection||!b)&&(y(b),v("change")),I>E&&I<T?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,v("changeBegin")),y(I),v("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):u.began&&I>T&&v("changeComplete"),u.currentTime=hs(I,0,b+u.pingPongDelayCorrection),u.began&&v("update"),M>=b)if(x(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,v("loopComplete"),v("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/An.speed:t+=u.duration;for(let C of s)C.setStartTime(0),C.remaining=C.loop;v("loopComplete"),u.loopBegan=!1,u.direction==="alternate"?d():o&&h()}}return u.reset=function(){var M=u.direction;u.passThrough=!1,u.currentTime=0,u.progress=0,u.paused=!0,u.began=!1,u.loopBegan=!1,u.changeBegan=!1,u.completed=!1,u.changeCompleted=!1,u.reversePlayback=!1,u.reversed=M==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var b=o;b--;)u.children[b].reset();(u.reversed&&u.loop!==!0||M==="alternate"&&u.loop===1)&&u.remaining++,y(u.reversed?u.duration:0)},u.setStartTime=function(M){t=M},u.set=function(M,b){return TD(M,b),u},u.tick=function(M){n=M,t||(t=n),_((n+(e-t))*An.speed)},u.seek=function(M){_(M-t)},u.pause=function(M){u.paused=!0,o&&(r=M??performance.now())},u.play=function(M){!u.paused||(u.completed&&u.reset(),u.paused=!1,Fi.push(u),o&&r!==void 0&&(t+=(M??performance.now())-r),Rv||gq())},u.reverse=function(){d(),u.completed=!u.reversed,m()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function hD(i,t){for(var e=t.length;e--;)YS(i,t[e].animatable.target)&&t.splice(e,1)}function vq(i){for(var t=_D(i),e=Fi.length;e--;){var n=Fi[e],r=n.animations,s=n.children;hD(t,r);for(var o=s.length;o--;){var a=s[o],l=a.animations;hD(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!r.length&&!s.length&&n.pause()}}function xq(i,t){t===void 0&&(t={});var e=t.direction||"normal",n=t.easing?qS(t.easing):null,r=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=et.arr(i),d=parseFloat(c?i[0]:i),h=c?parseFloat(i[1]):0,f=Uo(c?i[1]:i)||0,m=t.start||0+(c?d:0),p=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!p.length){for(var w=0;w<x;w++){if(!r)p.push(Math.abs(o-w));else{var S=l?(r[0]-1)/2:o%r[0],_=l?(r[1]-1)/2:Math.floor(o/r[0]),M=w%r[0],b=Math.floor(w/r[0]),E=S-M,T=_-b,I=Math.sqrt(E*E+T*T);s==="x"&&(I=-E),s==="y"&&(I=-T),p.push(I)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(P){return n(P/g)*g})),e==="reverse"&&(p=p.map(function(P){return s?P<0?P*-1:-P:Math.abs(g-P)}))}var C=c?(h-d)/g:d;return m+C*(Math.round(p[v]*100)/100)+f}}function bq(i){i===void 0&&(i={});var t=An(i);return t.duration=0,t.add=function(e,n){var r=Fi.indexOf(t),s=t.children;r>-1&&Fi.splice(r,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Fv(e,HS(WS,i));l.targets=l.targets||i.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=et.und(n)?u:JS(n,u),o(t);var c=An(l);o(c),s.push(c),c.parent=t;var d=CD(s,i);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}An.version="3.2.0";An.speed=1;An.running=Fi;An.remove=vq;An.get=ZS;An.set=TD;An.convertPx=QS;An.path=oq;An.setDashoffset=iq;An.stagger=xq;An.timeline=bq;An.easing=qS;An.penner=gD;An.random=function(i,t){return Math.floor(Math.random()*(t-i+1))+i};var Uv=An;var PD=new A,ID=new A,DD=new qe;function OD(i,t,e,n){if(n===0)return e.copy(i);if(n===1)return e.copy(t);let r=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(r>=1)return e.copy(i);let s=1-r*r;if(s<=Number.EPSILON){let c=1-n;return e.w=c*i.w+n*t.w,e.x=c*i.x+n*t.x,e.y=c*i.y+n*t.y,e.z=c*i.z+n*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,r),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return e.w=i.w*l+t.w*u,e.x=i.x*l+t.x*u,e.y=i.y*l+t.y*u,e.z=i.z*l+t.z*u,e}function fs(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(o==null)return;let a=s??t[i],l=o;if(a!==l)return{update:u=>{let c=Ve.lerp(a,l,u);r?t[i]=Math.trunc(c):t[i]=c},start:()=>{t[i]=a},end:()=>{t[i]=l}}}function e1(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=[...s??a],u=[...o];if(!(l.length!==u.length||Sl(l,u)))return{update:c=>{l.forEach((d,h)=>{let f=Ve.lerp(d,u[h],c);t[i][h]=r?Math.trunc(f):f})},start:()=>{Object.assign(t[i],l)},end:()=>{Object.assign(t[i],u)}}}function t1(i,t,e,n){let r=e[i]?e[i]:void 0,s=n[i];if(!s)return;let o=t[i],a=r?new A().fromArray(r):o.clone(),l=new A().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function RD(i,t,e,n){let r=e[i]?e[i]:void 0,s=n[i];if(!s)return;let o=t[i],a=r?new ie().fromArray(r):o.clone(),l=new A,u=new qe,c=new A;a.decompose(l,u,c);let d=new ie().fromArray(s),h=new A,f=new qe,m=new A;if(d.decompose(h,f,m),!a.equals(d))return{update:p=>{DD.slerpQuaternions(u,f,p),PD.lerpVectors(l,h,p),ID.lerpVectors(c,m,p),o.compose(PD,DD,ID)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(h,f,m)}}}function LD(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=s?typeof s=="string"?r.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[i]=c,{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Ks(i,t,e,n){if(typeof t[i]=="number")return fs(i,t,e??{},n);if(Array.isArray(t[i]))return e1(i,t,e??{},n)}function ND(i,t,e){let n=[],r=i.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,s=i.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(s!==void 0){let o=r??i.zoom,a=s;o!==a&&n.push({update:l=>{i.zoom=Ve.lerp(o,a,l),i.updateProjectionMatrix()},start:()=>{i.zoom=o,i.updateProjectionMatrix()},end:()=>{i.zoom=a,i.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let o=fs("targetOffset",i,t,e);o&&n.push(o)}return n}function wq(i,t,e,n){if(e.scaleBaked===void 0)return;let r=t.scaleBaked??i.data.geometry.scaleBaked,s=e.scaleBaked;if(Cs.isEqual(r,s))return;let o=[];return o.push({update:a=>{i.updateGeometryInteractions({scaleBaked:[Ve.lerp(r[0],s[0],a),Ve.lerp(r[1],s[1],a),Ve.lerp(r[2],s[2],a)]},n),i.invalidateDownstreamBooleanData()},start:()=>{i.updateGeometryInteractions({scaleBaked:r},n),i.invalidateDownstreamBooleanData()},end:()=>{i.updateGeometryInteractions({scaleBaked:s},n),i.invalidateDownstreamBooleanData()}}),o}function Sq(i,t,e){if(!e.extrusion)return;let n=i.extrusion,r=t.extrusion??{},s=e.extrusion,o=[];return jb.forEach(a=>{let l=Ks(a,n,r,s);l&&o.push(l)}),o}function BD(i,t,e,n){let r=[];if(!("geometry"in e))return r;let s=i.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(i instanceof ls){let l=wq(i,o,a,n);l&&r.push(...l)}else{let l={};if(Object.assign(l,Qi(s,Wb)),Wb.forEach(u=>{let c=Ks(u,l,o,a);c&&r.push(c)}),i instanceof Va){Object.assign(l,{extrusion:{...s.extrusion}});let u=Sq(l,o,a);u&&r.push(...u)}r.length&&r.push({update:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},start:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},end:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()}})}return r}function FD(i,t,e,n){let r=[];if(e.intensity!==void 0){let s=fs("intensity",i,t,e);s&&r.push(s)}if(e.color!==void 0){let s=LD("color",i,t,e,n);s&&r.push(s)}return r}function kD(i,t,e,n){let r=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return r;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;i.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||r.push(...UD(a,u,c,n))})}else{if(!("material"in e&&e.material))return r;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return r;r.push(...UD(i.material,s,o,n))}return r}function UD(i,t,e,n){let r=[],s=Jf(e,n)||!!t.layers&&Jf(t,n);r.push(Dq(i,s));for(let o of i.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||!(o.visible??!0)||!(l.visible??!0))continue;let u=o.getNames().filter(c=>!Wg.some(d=>c.includes(d)));for(let c of u)try{let d=o.getValue(c),h;if(c==="colors")h=Pq(o,a,l,c);else if(Array.isArray(d))c==="steps"&&(h=Cq(o,a,l,c));else if(typeof d=="number")h=Aq(o,a,l,c);else{if(typeof d=="boolean")continue;d instanceof F?h=_q(o,a,l,c):d instanceof A?h=Mq(o,a,l,c):d instanceof sn?h=Tq(o,a,l,c,n):d instanceof Re?h=Eq(o,a,l,c,n):"isTexture"in d&&(h=Iq(o,a,l,c))}h&&(Array.isArray(h)?r.push(...h):r.push(h))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${c}`,d)}}return r}function Aq(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=t?t[n]:i.getValue(n),s=e[n];if(r!==s)return{update:o=>{i.setValue(n,Ve.lerp(r,s,o))},start:()=>{i.setValue(n,r)},end:()=>{i.setValue(n,s)}}}function _q(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=i.getValue(n),s=t?new F().fromArray(t[n]):r.clone(),o=new F().fromArray(e[n]);if(!s.equals(o))return{update:a=>{r.lerpVectors(s,o,a)},start:()=>{r.copy(s)},end:()=>{r.copy(o)}}}function Mq(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=i.getValue(n),s=t?new A().fromArray(t[n]):r.clone(),o=new A().fromArray(e[n]);if(!s.equals(o))return{update:a=>{r.lerpVectors(s,o,a)},start:()=>{r.copy(s)},end:()=>{r.copy(o)}}}function Eq(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return{update:d=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Tq(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new sn(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return{update:d=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Cq(i,t,e,n="steps"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s,a=e[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&r.push({update:d=>{s[l]=Ve.lerp(u,c,d)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return r.length?r:void 0}function Pq(i,t,e,n="colors"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s.map(l=>l.toArray()),a=e[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];xf.isEqual(u,c)||r.push({update:d=>{s[l].fromArray(xf.lerp(u,c,d))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return r.length?r:void 0}function Iq(i,t,e,n="texture"){if(!i.hasValue(n)||!(n in e))return;let r=i.getNode("mat");if(!r)return;let s=t?t[n]:r,o=e[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!Tl.isEqual(a,u)||!Tl.isEqual(l,c))return{update:d=>{r.repeat=Tl.lerp(a,u,d),r.offset=Tl.lerp(l,c,d),r.updateMatrix()},start:()=>{r.repeat=[...a],r.offset=[...l],r.updateMatrix()},end:()=>{r.repeat=[...u],r.offset=[...c],r.updateMatrix()}}}function Dq(i,t){return{update:()=>{i.transparent=t}}}var n1=new A,zD=new Gt;function GD(i,t,e,n){let r=[],s,o,a,l,u,c,d={slide:(t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping).offset};if(u=fs("slide",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping),u&&r.push(u),c=fs("offset",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping),c&&r.push(c),!u&&!c&&(s=t1("position",i,t,e),s&&r.push(s),o=t1("scale",i,t,e),o&&r.push(o),a=Oq(i,t,e,n),a&&r.push(a),l=RD("hiddenMatrix",i,t,e),l&&r.push(l)),s||o||a||l||u||c){let h=()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),Pr(i)&&Hr(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,d))};r.push({update:h,start:h,end:h})}return r}function Oq(i,t,e,n){let r=t?.rotation?t.rotation:void 0,s=e.rotation;if(!s)return;let o=r?new A().fromArray(r):new A().setFromEuler(i.rotation),a=new A().fromArray(s);if(o.equals(a))return;let l=n1.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new qe().setFromEuler(zD.setFromVector3(o)),c=new qe().setFromEuler(zD.setFromVector3(a));return{update:d=>{OD(u,c,i.quaternion,d)},start:()=>{i.rotation.setFromVector3(o)},end:()=>{i.rotation.setFromVector3(a)}}}else return{update:u=>{n1.lerpVectors(o,a,u),i.rotation.setFromVector3(n1)},start:()=>{i.rotation.setFromVector3(o)},end:()=>{i.rotation.setFromVector3(a)}}}function VD(i,t,e){let n=[];if(!("cloner"in e)||!i.cloner)return n;let r=i.cloner,s="cloner"in t?t.cloner:{},o=e.cloner;Nb.forEach(h=>{let f;h==="count"?f=fs("count",r.parameters,s,o,!0):f=Ks(h,r.parameters,s??{},o),f&&n.push(f)});let a=Rq(r,s,o);a?.length&&n.push(...a);let l=Lq(r,s,o);l?.length&&n.push(...l);let u=Nq(r,s,o);u?.length&&n.push(...u);let c=Bq(r,s,o);c?.length&&n.push(...c);let d=Fq(r,s,o);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{r.update()}}),n}function Rq(i,t,e){if(i.parameters.type!=="radial")return;let n=t.radial,r=e.radial;if(!r)return;let s=i.parameters.radial,o=[];return Bb.forEach(a=>{let l=Ks(a,s,n??{},r);l&&o.push(l)}),o}function Lq(i,t,e){if(i.parameters.type!=="linear")return;let n=t.linear,r=e.linear;if(!r)return;let s=[],o=i.parameters.linear;return Fb.forEach(a=>{let l=Ks(a,o,n??{},r);l&&s.push(l)}),s}function Nq(i,t,e){if(i.parameters.type!=="grid")return;let n=t.grid,r=e.grid;if(!r)return;let s=[],o=i.parameters.grid;return Ub.forEach(a=>{let l;a==="count"?l=e1(a,o,n??{},r,!0):l=Ks(a,o,n??{},r),l&&s.push(l)}),s}function Bq(i,t,e){if(i.parameters.type!=="toObject")return;let n=t.toObject,r=e.toObject;if(!r)return;let s=[],o=i.parameters.toObject;return kb.forEach(a=>{let l;a==="count"?l=fs(a,o,n??{},r,!0):l=Ks(a,o,n??{},r),l&&s.push(l)}),s}function Fq(i,t,e){if(!i.parameters.randomness)return;let n=t.randomnessObject,r=e.randomnessObject;if(!r)return;let s=[],o=i.parameters.randomnessObject;return zb.forEach(a=>{let l=Ks(a,o,n??{},r);l&&s.push(l)}),s}function r1(i,t,e,n,r){let s=[];return i.data.visible&&s.push(...GD(i,t,e,r)),i.data.visible&&s.push(...VD(i,t,e)),Pr(i)?(i instanceof Ht&&i.data.visible&&s.push(...BD(i,t,e,n)),i.data.visible&&s.push(...kD(i,t,e,n))):K2(i)?i.data.visible&&s.push(...FD(i,t,e,n)):Q2(i)&&s.push(...ND(i,t,e)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var HD=new A;function dh(i,t,e=!1){let n=[];i.traverseChildren(r=>{if(e&&(r.rigidBody?.setTranslation(r.position0,!0),r.rigidBody?.setRotation(r.rotation0,!0),r.rigidBody?.setLinvel(HD,!0),r.rigidBody?.setAngvel(HD,!0)),!lt.is(r))return;let s=r.uuid,o=r.data;if(delete r.states,r.uuid===Ei)return;let a=!1;n.some(l=>i.scene.find(s)?.isDescendantOf(l))?a=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&n.push(s),r.data=o,r.currentState=null,r.reversibleToState=null,r.currentTransitionEvent=null;for(let l of o.states){let u={...l.data};i.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||a)&&(l.data.position!==void 0&&delete u.position,l.data.rotation!==void 0&&delete u.rotation,l.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),r.states||(r.states={}),r.states[l.id]=To.patch(o,u)}kq(i.scene,r,null,t,o.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),Uq(i)})}function Uq(i){i.traverseEntity(t=>{for(let e of t.data.events){let n=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":n.push(...e.data.actions);break;case"GameControl":for(let r of Object.values(e.data.gameActions))n.push(...r);break;case"DragDrop":n.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":n.push(...e.data.inActions,...e.data.outActions);break}for(let r of n)r.data.type==="Create"&&r.data.hideBase==="Yes"&&(i.scene.find(r.data.object).visible=!1)}})}function kq(i,t,e,n,r=!1){if(t instanceof Ht&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:i,shared:n},r),t instanceof Ht&&t.updateGeometryGroupsIfNeeded(),t instanceof Xt&&t.updateCameraState(t.dataPatched,{scene:i,shared:n}),t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}function i1(i){let t;if(i.easing===5){let{control1:e,control2:n}=i;t=`cubicBezier(
6235
+ `,R8=[],mv=class extends Bi{constructor(){super(new rt({vertexShader:D8,fragmentShader:O8,uniforms:{toScene:new se(null),fromScene:new se(null),uResolution:new se(new F),uDPR:new se(1),mixRatio:new se(0),threshold:new se(.1),useTexture:new se(0),tMixTexture:{value:R8[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(t){this.uniforms.fromScene.value=t}};function OI(i,t){return t&&t.enabled&&i.push(t.effect),i}var L8=i=>Object.values(ut).includes(i)?i:ut.NORMAL,lp=class extends Ut{constructor(e){super();this.postprocessingState=Ou.defaultData;this._scene=new mr;this._camera=new Xt;this.effects=new Map;this.blueNoiseTexture=new mo;this._renderToScreen=!0;this.clock=new Cm,this.renderer=e,this.debug=!1,this.effects.set("bloom",new qd),this.effects.set("chromaticAberration",new Xd),this.effects.set("vignette",new Jd),this.effects.set("noise",new Zd),this.effects.set("colorAverage",new Qd),this.effects.set("hueSaturation",new Kd),this.effects.set("brightnessContrast",new Yd),this.effects.set("depthOfField",new $d),this.effects.set("pixelation",new eh),this.effectComposer=new uv(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Ql(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new cv(this.scene,this.camera,this.renderer),this.aoPass=new fv(this.scene,this.camera),this.taaPass=new lv,this.taaPass.renderToScreen=!1,this.helperPass=new dv(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new pv,this.overlayPass.enabled=!1,this.sceneTransitionPass=new mv,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let n=this.effectComposer.passes.length-1;n>=0;n--){let r=this.effectComposer.passes[n];if(r.enabled===!0&&!e&&this._renderToScreen){r.renderToScreen=!0,e=!0;continue}r.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new mo(e,128,128),this.blueNoiseTexture.wrapS=Hi,this.blueNoiseTexture.wrapT=Hi,this.blueNoiseTexture.minFilter=Dt,this.blueNoiseTexture.magFilter=Dt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,n,r,s,o,a,l,u){this.aoPass.enabled=e,this.aoPass.radius=n,this.aoPass.bias=r,this.aoPass.aoColor=s,this.aoPass.fogEnabled=o,this.aoPass.fogNear=a,this.aoPass.fogFar=l,this.aoPass.runHalfRes!==!u&&(this.aoPass.runHalfRes=!u)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(OI,[]);e.length>0&&(this.uvEffectPass=new Xl(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(OI,[]);n.length>0&&(this.effectPass=new Xl(this.camera,...n),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new ot(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Hi,wrapT:Hi}),this._rt.samples=0,this._savePass=new ap(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new ap(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?n.removePass(this._savePass):n.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(e!==null?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...r}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(r)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=L8(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,r,s){e instanceof We?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,r,s),this.effectComposer.outputBuffer.scissor.set(e,n,r,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,r,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,r,s){e instanceof We?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,r,s),this.effectComposer.outputBuffer.viewport.set(e,n,r,s))}resize(e,n,r){if(this.effectComposer.setSize(e,n,r),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var RI=new qt,gv=class extends qx{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new lp(this);this.dummyCamra=new Xt;this.sceneTransitionDuration=0;this.sceneTransitionTimeRemaining=-1;this.isXRCopyPassSet=!1;this.clear=(e=!0,n=!0,r=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),n&&(o|=s.DEPTH_BUFFER_BIT),r&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.autoClear=!1;let n=this.setPixelRatio.bind(this),r=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Nm;let s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio!==o&&(this._pixelRatio=o,n(o))},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,r(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new ot(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Xe,magFilter:Xe,wrapS:Wt,wrapT:Wt,depthBuffer:!1}))}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,n*this._pixelRatio/1)}get hdTransmission(){return Fe.transmissionLod.value===1}set hdTransmission(e){Fe.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ot(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:sl,magFilter:Xe,wrapS:Wt,wrapT:Wt,depthBuffer:!1}),this.transmissionDepthTarget=new ot(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Dt,magFilter:Dt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ot(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Dt,magFilter:Dt,type:pr,depthTexture:new bi(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n,r){this.normalRenderTarget&&(this.setClearColor(0),r.layers.enable(8),r.layers.disable(0),r.layers.disable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),r instanceof Xt?iv.uniforms.depthContrast.value=(r.far-r.near)/1e4:iv.uniforms.depthContrast.value=1,n.overrideMaterial=iv,this.render(n,r),this.setClearColor(n.bgColor,n.bgColor.a),this.setRenderTarget(null),n.overrideMaterial=e.wireframeState?yv:null,r.layers.enable(0),r.layers.enable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,n,r=1){this.dummyCamra.updateCameraState(n.dataPatched);let s=n.height,o=n.width,a=this.viewportWidth/this.viewportHeight;o<s?o=s*a:s=o/a,this.dummyCamra.setViewplaneSize(o,s);for(let l=0;l<r;l++)this.renderSplineScene(e,this.dummyCamra)}renderSplineScene(e,n,{sceneHelpers:r=void 0,sceneHelpersOnTop:s=void 0,overrideTransmission:o=void 0,overrideNormal:a=void 0}={}){let l=e instanceof Ga?e.activePage:e,u=l.visible;l.visible=!0;let c=l.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(n)),this.setClearColor(l.bgColor,l.bgColor.a),l.penumbraSizeArray.forEach((m,p)=>{Fe.penumbraSize.value[p]=m}),Fe.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Fe.resolution.value.set(this.resolution.x,this.resolution.y):Fe.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(Fe.normalRenderTarget.value=a,Fe.normalRenderTargetDepth.value=RI):c.needsNormal()&&(this.createNormalRenderTarget(),Fe.normalRenderTarget.value=this.normalRenderTarget.texture,Fe.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(c,l,n));let d=l.data.ao,h=d.occlusion;h&&(this.createAORenderTarget(),Fe.aoRenderTarget.value=this.aoRenderTarget.texture),Fe.aoEnabled.value=h,this.pipeline.setAmbientOcclusionParams(d.occlusion,d.radius,d.bias,l.aoColor,l.fog!==null,l.backupFog.near,l.backupFog.far,d.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let f=!1;if(o!==void 0)Fe.transmissionRenderTarget.value=o,Fe.transmissionRenderTargetDepth.value=RI,this.pipeline.setTransmissionPassEnabled(!1);else{let m=c.needsTransmission();m&&(this.transmissionRenderTarget===void 0&&(f=!0),this.createTransmissionRenderTarget(),Fe.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Fe.aspectRatio.value=g2(this.viewportWidth,this.viewportHeight),Fe.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(m)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=l,this.pipeline.camera=n,f&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==l.postprocessing&&(this.pipeline.updatePostprocessing(l.postprocessing),!r&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.overrideMaterial=c.wireframeState?yv:null,this.pipeline.render(),Fe.frameIndex.value=(Fe.frameIndex.value+1)%16,n instanceof Xt&&n.copyHistory(),l.visible=u}renderFromSceneForSceneTransitionPass(e,n,r){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,n),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=r,this.sceneTransitionTimeRemaining=r,this.pipeline.renderToScreen=!0;let s=this.pipeline.sceneTransitionPass.uniforms;s.uDPR.value=window.devicePixelRatio,s.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var rh=class extends Vs(Rm){constructor(e,n=15,r=10066329){super(e,n,r);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,n){Hs(this.object,rh.geometryHelper,e,n)}};var ih=class extends Vs(Om){constructor(e,n=15,r=6710886){super(e,n,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,n){Hs(this.object,ih.geometryHelper,e,n)}};var vv=class extends Vs(Dm){constructor(e,n=6710886){super(e,n);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,n){Hs(this.object,vv.geometryHelper,e,n)}update(){if(this.object!==void 0){let e=vv._vector,n=this.object.distance?this.object.distance:1e3,r=n*Math.tan(this.object.angle);this.cone.scale.set(r,r,n),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},cp=vv;cp._vector=new A;function N8(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var sh=class extends jd(Tm,rh){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.top=1250,s.bottom=-1250,s.right=1250,s.left=-1250,s.near=-1e4,s.far=2500;let o=new la(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof la&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let n=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&N8(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),n&&this.update()}};var LI=new A,NI=new A,BI=new qe,oh=class extends jd(Mm,cp){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=Ve.RAD2DEG*2*this.angle,s.aspect=1,s.near=100,s.far=2500;let o=new la(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof la&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),NI.setFromMatrixPosition(this.matrixWorld),BI.setFromRotationMatrix(this.matrixWorld),LI.copy(this.up).applyQuaternion(BI).negate().multiplyScalar(this.distance),this.target.position.copy(NI).add(LI),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ti=class extends ed(mr){constructor(e,n){super();this.data=n;this.bgColor=new sn(1,1,1,1);this.fog=null;this.backupFog=new Ec(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Re;this.penumbraSizeArrayCache=null;this.super_Entity(e,n),this.personalCamera=new Xt(Ei,{...Pl.defaultData,...n.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new _m(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,n){e.color!==void 0&&(this.ambientLight.color=br(e.color,n)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Oi)if(Array.isArray(e.material))for(let n of e.material)n.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&J2(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,n){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let r=this.scene;r.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=br(e.color,n),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,n){e.aoColor!==void 0&&(this.aoColor=br(e.aoColor,n))}updateByOp(e,n,r,s){super.updateByOp(e,n,r,s);let o=n;Tr(e.path,["fog"])?this.updateFog(o.fog,r.shared):Tr(e.path,["ao"])?this.updateAo(o.ao,r.shared):Tr(e.path,["ambient"])?this.updateAmbientLight(o.ambient,r.shared):Tr(e.path,["shadow"])&&this.updateShadow(o.shadow)}updateState(e,n){this.updateState_Entity(e,n),e.backgroundColor!==void 0&&this.setBackgroundColor(br(e.backgroundColor,n.shared)),e.fog!==void 0&&this.updateFog(e.fog,n.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,n.shared),e.ao!==void 0&&this.updateAo(e.ao,n.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,n){super.raycast(e,n)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,n=0;this.traverseEntity(r=>{if(!r.visible)return!0;r instanceof sh&&r.visible&&e<3&&(this.penumbraSizeArrayCache[e]=r.data.penumbraSize,e+=1),r instanceof oh&&r.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+n]=r.data.penumbraSize,n+=1)})}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Pr(o)||sp(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),up(o,e,n,!0)),r(o))}};return r(this),n}};var xv=class extends jd(Em,ih){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=90,s.aspect=1,s.near=100,s.far=2500;let o=new A(-s.far+this.position.x,-s.far+this.position.y,-s.far+this.position.z),a=new A(s.far+this.position.x,s.far+this.position.y,s.far+this.position.z),l=new _t(o,a),u=new ca(l,new Re(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof ca){let n=this.shadow.camera,r=new A(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new A(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z);e.box.set(r,s),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var bv=class extends Ht{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?Vf(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var Va=class extends Ht{constructor(e,n,r){super(e,n,r);this._shapeId=null;this._context=r}updateState(e,n){super.updateState(e,n),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,n;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let o=this._context.scene.find(s);o?.data&&(o.attachedPaths.add(this),n=o.geometry.userData?.shape),n||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=Py;break;case"Ellipse":s=cd;break;case"Polygon":s=Cy;break;case"Star":s=Iy;break;default:throw new Error(`Unknown shape type: ${e.type}`)}n=s.create({parameters:e}).userData.shape}let r=this.geometry;n&&r.inputs&&(r.inputs.shapeData=n,r.build(),this.attachedSurfaceCloners.forEach(s=>s.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,n){super.updateGeometryInteractions(e,n),this.updateShape()}updateEntityBoxSize(e,n){let r=this.geometry.getAttribute("position");r!==void 0?Vf(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,e,n):super.updateEntityBoxSize(e,n)}};var ds=class extends js(xs,Ws){constructor(e,n,r){super();n.type==="Instance"&&typeof e=="string"&&(n=this.transformAssignData(n,r)),this.super_Entity(e,n),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,n){let r=n.scene.data.objects.get(e.component);if(r){let s,o;for(let a of Mo.rootOverrideProps)e[a]===void 0?(s===void 0&&(s={...e}),s[a]=r.data[a]):(o===void 0&&(o={}),o[a]=e[a],s===void 0&&(s={...e}),s[a]=As.apply(r.data[a],e[a]));return this.overrideData=o,s}else return{...Cr.defaultData,...e}}updateByOp(e,n,r,s){let o;if(this.isInstanceRoot&&!s){if(n=this.transformAssignData(n,r),e.type===0&&e.path.length===0&&this.component)for(let a of Mo.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(o===void 0&&(o={...e,props:{...e.props}}),o.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Mo.rootOverrideProps.includes(e.path[0])){let a=e.path[0];o===void 0&&(o={...e,path:[],props:{[a]:n[a]}})}}super.updateByOp(o??e,n,r,s)}updateState(e,n){this.updateState_Entity(e,n)}expandInstanceChildren(e){let n=this.data;if(this.component===void 0){let r=e.scene.find(n.component)??null,s=!1;if(r!==this.oldComponent){if(this.oldComponent){let o=0;for(let a of this.children)if(lt.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),wv(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(r){let o={};UI(e,[this.uuid],n.overrides,this,r,r,0,s,o);for(let a of this.children)if(lt.is(a)){let l=a.data;l.type==="Empty"&&l.animations&&a.traverseEntity(u=>{if(u instanceof Ht&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let d=c.bones.map(m=>e.scene.find(o[m])),h=c.boneInverses.map(m=>new ie().fromArray(m)),f=new ra(d,h);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function wv(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)lt.is(e)&&wv(e)}}function FI(i,t,e,n){return i.component===t&&Sl(i.identity,n)?i.overrideData===e?2:1:0}function UI(i,t,e,n,r,s,o,a,l){if(o>50)return!1;if(n.component!==r){if(n.component){let c=n.component.instances.indexOf(n);c>=0&&n.component.instances.splice(c,1)}r.instances.push(n),n.component=r}r instanceof ds&&r.isInstanceRoot&&r.expandInstanceChildren(i);let u=0;for(let c of r.children)if(lt.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],h=Lu.resolve(e,d,1),f=null,m;if(!a){let p=n.children[u];if(f=lt.is(p)?p:null,f!==null){let g=FI(f,c,h,d);m=g>=1?f.stateSelection:void 0,g!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(d)??null,f!==null)){let g=FI(f,c,h,d);if(m=g>=1?f.stateSelection:void 0,g!==2)f=null;else{let y=f.parent.children.indexOf(f);f.parent.children.splice(y,1),n.children.splice(u,0,f),f.parent===n?(y<=u&&console.error("not possible"),void 0):(f.parent=n,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let p=h?As.apply(c.data,h):c.data;Ji.is(p.type)&&(p={...p,type:"Empty"}),f=ts.createEntity(d,p,i),f.overrideData=h,n.add(f),n.children.splice(n.children.length-1,1),n.children.splice(u,0,f),f.updateState(f.data,i),m&&f.changeSelectedState(m,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let p=f.identity[f.identity.length-1];l[p]=f.uuid}u+=1,UI(i,t,e,f,c,s,o+1,a,l)}if(!a){let c=u;for(;;){let d=n.children[u];if(lt.is(d))i.pendingDeletes.add(d);else break;u+=1}n.children.splice(c,u-c)}return!0}var Sv=class extends js(jh,Ws){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};function B8(i,t,e){let n;return t.geometry.type==="TextGeometry"?new zd(i,t,e):(t.geometry.type==="SubdivGeometry"?n=new ls(i,t,e):t.geometry.type==="PathGeometry"?n=new Va(i,t,e):t.geometry.type==="VectorGeometry"?n=new bv(i,t,e):t.geometry.type==="BooleanGeometry"?n=new Ni(i,t,e):n=new Ht(i,t,e),n)}function Av(i,t,e){return t.type==="Mesh"?B8(i,t,e):t.type==="Empty"?new No(i,t):t.type==="Bone"?new Sv(i,t):t.type==="Page"?new ti(i,t):t.type==="PointLight"?new xv(i,t,e):t.type==="SpotLight"?new oh(i,t,e):t.type==="DirectionalLight"?new sh(i,t,e):t.type==="Component"||t.type==="Instance"?new ds(i,t,e):Ji.is(t.type)?new Xt(i,t):(console.error(t),new No(i,t))}ts.createEntity=Av;function F8(i,t,e){let n=Av(i.identity,t,e),r=i.children,s=i.attachedPaths,o=i.parent,a=i.component,l=i.instances,u=i.overrideData,c=i.uuid,d=i.stateSelection;i.dispose();for(let h of Object.keys(i))delete i[h];Object.setPrototypeOf(i,Object.getPrototypeOf(n));for(let h of Object.keys(n))i[h]=n[h];i.children=[...i.children,...r],i.attachedPaths=s,i.parent=o,i.component=a,i.instances=l,i.uuid=c,i.overrideData=u,i.updateState(i.data,e),d&&i.changeSelectedState(d,e),i.resetBBoxNeedsUpdate()}ts.changeEntityProptotype=F8;ts.Cloner=ur;function kI(i,t,e,n){i.updateByOp(t,e,n,!1)}function zI(i,t){let e=!1,n=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(i.layers.set(8),n.length>0&&i.layers.enable(3),e=!0,Ud(i),Fd(i)),n.length===0&&r.length===0&&i.layers.set(0),i instanceof Oi&&i.needsAO&&i.layers.enable(5),e}function GI(i,t){if(!t.layers)return!1;let e=!1,n=t.getLayersOfType("transmission").filter(s=>s.data.visible),r=t.getLayersOfType("outline").filter(s=>s.data.visible);return n.length>0&&(i.layers.set(3),r.length>0&&i.layers.enable(8),e=!0),n.length===0&&r.length===0&&i.layers.set(0),i.needsAO&&i.layers.enable(5),e}function VI(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Oi)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)zI(e,e.material[n])&&(t=!0);else zI(e,e.material)&&(t=!0)}),t}function HI(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Oi)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)GI(e,e.material[n])&&(t=!0);else GI(e,e.material)&&(t=!0)}),t}var U8=new Vc,k8=new ie,z8=new ji;function up(i,t,e,n=!1){let r=i.cloner;if(r)for(let s of r.children){let o=k8.copy(s.matrixWorld).invert(),a=z8.copy(t.ray).applyMatrix4(o),l=i.matrixWorld;a.applyMatrix4(l);let u=U8;u.set(a.origin,a.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(i,!1);c.length>0&&e.push({...c[0],object:n?s:i})}}var _v=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((n,r)=>{let s=[r,n],o=n;for(;this._constraints.has(o);)o=this._constraints.get(o),e.has(o)||s.push(o);for(let a=s.length-2;a>=0;a--)if(!e.has(s[a])){let l=t.find(s[a]);l?l.applyPathSnapping(t):console.warn(`missing entity ${s[a]}`),e.add(s[a])}})}findDependency(t,e){let n=t;for(;this._constraints.has(n);)if(n=this._constraints.get(n),n===e)return!0;return!1}};var yv=new Wi;yv.wireframe=!0;var jI=new A,Ga=class extends mr{constructor(e,n){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new _v;this.errorPage=new ti("fdasfa",{...Eo.defaultData,name:""});this.needsRecomputeInstances=!1;this.init(e,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=HI(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=VI(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let n=e.identity.join("-"),r=this.entityIdentityToEntity[n];r&&(e.uuid=r.uuid),this.entityIdentityToEntity[n]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof ti&&(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 n=this.find(e);if(n===void 0)return;let r=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);r.splice(0,0,a)}return{entity:n,sortKey:r}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push(s)}return n.sort((r,s)=>pT(r.sortKey,s.sortKey)),n.map(r=>r.entity)}nonExistOrDescendantOf(e,n){let r=this.find(e);if(r===void 0)return!0;for(;r;){if(r.uuid===n)return!0;r=r.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===Ei)return this.activePage.personalCamera}if(e===""||e===void 0)return;let n=this.entityByUuid[e];return n===void 0?this.getObjectByProperty("uuid",e):n}debugEnsureEntity(e){let n=this.find(e);if(n){if(Array.isArray(n.identity)&&this.findInstance(n.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(n=>{this.toExpandCloner.add(n)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,n){if(e.path.length===0&&e.type===7){let r=e.parent===null?this:this.find(e.parent);if(r===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,r,e.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),Pr(s)&&Hr(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(r),this.markPenumbraSizeDirty(),r.parent.remove(r),Hr(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Pr(r)&&(r.freeBooleanPointer(),s instanceof Ni&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r instanceof Va&&r.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),this.pathConstraints.removeDependencies(r.uuid)}else if(e.path.length===0&&e.type===9){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(r),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Pr(r)&&(r.invalidateUpstreamBooleanData(),Hr(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Ni&&s.invalidateDownstreamBooleanData().recomputeBoolean())}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 n of this.children)n instanceof ti&&(n.visible=n.uuid===e,n.visible&&(this.activePage=n,this.activePage.onActive(this)))}updateEntityByOp(e,n,r,s){if(n.type===0){if(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),"visible"in n.props&&this.markPenumbraSizeDirty(),n.path.includes("overrides")&&"states"in n.props){let{rest:a}=n.props;n={...n,props:a},this.markNeedsRecomputeInstances()}n.path[0]==="pathSnapping"&&n.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,n.props.pathId)}let o=this.find(e);if(o)try{kI(o,n,r,{scene:this,shared:s}),o instanceof Ht&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}init(e,n){this.createChildrenObjects(e.objects,this,n),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(n,!0),this.traverseEntity(r=>{Hr(r)&&r.recomputeBoolean(),r instanceof Xt&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(n=>{(n.data.type==="Component"||n.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){lt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(n=>{lt.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,n,r,s,o,a,l){if(e){let u=s.find(e);u&&u!==s&&o.forInstancesRec(c=>{c.data=Tu(c.data,d=>{let h=d.events.data(l.id),f=c.goUp(a);if(f){let m=[...hg(f.identity),e].join("-"),p=this.entityIdentityToEntity[m];if(p){let g=p.uuid,y=Br.zoom(h,n);y[r]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,n,r,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ds&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((n,r)=>{n.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(n.forInstancesRec(a=>{a.data=Tu(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of ty.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,n,r,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,n,r,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,n,r,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,n,r,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,n,r,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,n,r,s)),this.rewriteActions(s.data.inActions,["inActions"],e,n,r,s),this.rewriteActions(s.data.outActions,["outActions"],e,n,r,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,n,r,s)})}),!0})}expandInstances(e,n,r){let s=new Set;this.traverseEntity(o=>{if(o instanceof ds&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),n||o.resetBBoxNeedsUpdate(),r&&o.traverseEntity(a=>{r.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),wv(o)}recomputeInstances(e,n){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(r=>{r instanceof ds&&r.isInstanceRoot&&(r.component=void 0)}),this.expandInstances(e,!1,n))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(n=>{let r=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[r]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[r]),n.dispose()})}clearScene(){for(let e of this.children)lt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,n){this.init(e,n)}raycast(e){return this.raycast1(e,!1)}raycast1(e,n){let r=[],s=o=>{for(let a of o.children){let l=a.cloner;if(lt.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(n===!0&&a.isInstanceRoot){let u=[];if(e.intersectObject(a,!0,u),u.length){let c=u[0];c.object=a,c.point.applyMatrix4(c.object.matrixWorld);let d=a.matrixWorld.clone().invert();c.point.applyMatrix4(d),r.push(c)}}else(Pr(a)||sp(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),up(a,e,r)),s(a)}};return s(this),r}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Pr(o)||sp(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),up(o,e,n,!0)),r(o))}};return r(this),n}forEachEntity(e){for(let n of this.children)lt.is(n)&&e(n)}traverseConcreteEntity(e){for(let n of this.children)lt.is(n)&&n.isConcreteEntity&&n.traverseEntity(e)}traverseEntity(e){for(let n of this.children)lt.is(n)&&n.traverseEntity(e)}traverseObject(e){for(let n of this.children)Zu.is(n)&&n.traverseObject(e)}traverseVisibleEntity(e){for(let n of this.children)lt.is(n)&&n.visible&&n.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,n,r){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,n,s,r),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let n of e.children)this.unregisterObject(n)}createObject(e,n,r,s,o,a){let l={scene:this,shared:a},u=Av(e,n,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),r.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,u,a)),u.updateState(n,l),u instanceof Ht&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),n.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,n.pathSnapping.pathId)),n.type==="Empty"&&n.animations&&u.traverseEntity(c=>{if(c instanceof Ht&&c.isSkinnedMesh){let d=c.dataPatched;if(d.bones&&d.boneInverses){let h=d.bones.map(p=>this.find(p)),f=d.boneInverses.map(p=>new ie().fromArray(p)),m=new ra(h,f);c.bind(m,c.bindMatrix)}}else c.matrixAutoUpdate=!0}),u}getCenter(e){let n=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;n.push(...c.vertices)}let r=new _t;return r.setFromPoints(n),r.getCenter(jI),jI}copyMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e);r?n.copy(r.matrixWorld):n.identity()}copyParentMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e)?.parent;r?n.copy(r.matrixWorld):n.identity()}traverseMaterial(e){this.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let r=0;r<n.material.length;r++)n.material[r]instanceof $r&&e(n.material[r]);else n.material instanceof $r&&e(n.material)})}updateCanvasSize(e,n,r=!1){this.activeCamera.setViewplaneSize(e,n,r)}};var dp=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return Math.sqrt(e*e+n*n)},WI=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return G8(Math.atan2(n,e))},qI=(i,t,e)=>{let n={x:0,y:0};return e=Mv(e),n.x=i.x-t*Math.cos(e),n.y=i.y-t*Math.sin(e),n},Mv=i=>i*(Math.PI/180),G8=i=>i*(180/Math.PI),YI=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,FS=new Map,US=i=>{FS.has(i)&&clearTimeout(FS.get(i)),FS.set(i,setTimeout(i,100))},ah=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.addEventListener?i.addEventListener(r,e,!1):i.attachEvent&&i.attachEvent(r,e)},kS=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.removeEventListener?i.removeEventListener(r,e):i.detachEvent&&i.detachEvent(r,e)};var Ev=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),zS=()=>{if(typeof window>"u")return;let i=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:i,y:t}},Tv=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},Cv=(i,t,e)=>{let n=QI(i);for(let r in n)if(n.hasOwnProperty(r))if(typeof t=="string")n[r]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";n[r]=s.slice(0,-2)}return n},XI=(i,t)=>{let e=QI(i);for(let n in e)e.hasOwnProperty(n)&&(e[n]=t);return e},QI=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(n){t[n+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},Pv=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},KI=(i,t)=>{let e={};for(let n in i)i.hasOwnProperty(n)&&t.hasOwnProperty(n)?e[n]=t[n]:i.hasOwnProperty(n)&&(e[n]=i[n]);return e},hp=(i,t)=>{if(i.length)for(let e=0,n=i.length;e<n;e+=1)t(i[e]);else t(i)},ZI=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(JI="ontouchstart"in window,$I=!!window.PointerEvent,eD=!!window.MSPointerEvent);var JI,$I,eD,fp={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"}},lh,pp={};$I?lh=fp.pointer:eD?lh=fp.MSPointer:JI?(lh=fp.touch,pp=fp.mouse):lh=fp.mouse;function Zl(){}Zl.prototype.on=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]=e._handlers_[r]||[],e._handlers_[r].push(t);return e};Zl.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};Zl.prototype.trigger=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]&&e._handlers_[r].length&&e._handlers_[r].forEach(function(o){o.call(e,{type:r,target:e},t)})};Zl.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=KI(t.options,i))};Zl.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},ah(i,lh[t],e._domHandlers_[t]),pp[t]&&ah(i,pp[t],e._domHandlers_[t]),e};Zl.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},kS(i,lh[t],e._domHandlers_[t]),pp[t]&&kS(i,pp[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var ch=Zl;function Qn(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,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=Qn.id,Qn.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}Qn.prototype=new ch;Qn.constructor=Qn;Qn.id=0;Qn.prototype.buildEl=function(i){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)};Qn.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=XI("borderRadius","50%"),e=Cv("transition","opacity",i),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.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)"},n.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)"},Pv(n.el,e),this.options.shape==="circle"&&Pv(n.back,t),Pv(n.front,t),this.applyStyles(n),this};Qn.prototype.applyStyles=function(i){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};Qn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Qn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Qn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Qn.prototype.show=function(i){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 i=="function"&&i.call(this)},t.options.fadeTime)),t};Qn.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,n={};n.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,n.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,n)}return t};Qn.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var n=e.options.fadeTime+"ms",r={};r.front=Cv("transition",["top","left"],n);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(r),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};Qn.prototype.restCallback=function(){var i=this,t={};t.front=Cv("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};Qn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Qn.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,n=Math.PI/2,r,s,o;if(t>e&&t<e*3&&!i.lockX?r="up":t>-e&&t<=e&&!i.lockY?r="left":t>-e*3&&t<=-e&&!i.lockX?r="down":i.lockY||(r="right"),i.lockY||(t>-n&&t<n?s="left":s="right"),i.lockX||(t>0?o="up":o="down"),i.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:r},i.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return i;(!u.x||!u.y)&&this.trigger("plain",i),u.x||this.trigger("plain:"+s,i),u.y||this.trigger("plain:"+o,i),u.angle||this.trigger("dir dir:"+r,i)}else this.resetDirection();return i};var tD=Qn;function Sn(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Sn.id,Sn.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let n=getComputedStyle(e.options.zone.parentElement);return n&&n.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Sn.prototype=new ch;Sn.constructor=Sn;Sn.id=0;Sn.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var n=0,r=t.length;n<r;n+=1)if(t[n].identifier===e)return t[n];return!1}};Sn.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Sn.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Sn.prototype.createNipple=function(i,t){var e=this,n=e.manager.scroll,r={},s=e.options,o={x:e.parentIsFlex?n.x:n.x+e.box.left,y:e.parentIsFlex?n.y:n.y+e.box.top};if(i.x&&i.y)r={x:i.x-o.x,y:i.y-o.y};else if(i.top||i.right||i.bottom||i.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=i.top,a.style.right=i.right,a.style.bottom=i.bottom,a.style.left=i.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),r=i,i={x:l.left+n.x,y:l.top+n.y}}var u=new tD(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:i,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Tv(u.ui.el,r),Tv(u.ui.front,u.frontPosition)),e.nipples.push(u),e.trigger("added "+u.identifier+":added",u),e.manager.trigger("added "+u.identifier+":added",u),e.bindNipple(u),u};Sn.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Sn.prototype.bindNipple=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};Sn.prototype.pressureFn=function(i,t,e){var n=this,r=0;clearInterval(n.pressureIntervals[e]),n.pressureIntervals[e]=setInterval(function(){var s=i.force||i.pressure||i.webkitForce||0;s!==r&&(t.trigger("pressure",s),n.trigger("pressure "+t.identifier+":pressure",s),r=s)}.bind(n),100)};Sn.prototype.onstart=function(i){var t=this,e=t.options,n=i;i=Ev(i),t.updateBox();var r=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(n.touches).findIndex(function(l){return l.identifier===o})<0){var a=[i[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return hp(i,r),t.manager.bindDocument(),!1};Sn.prototype.processOnStart=function(i){var t=this,e=t.options,n,r=t.manager.getIdentifier(i),s=i.force||i.pressure||i.webkitForce||0,o={x:i.pageX,y:i.pageY},a=t.getOrCreate(r,o);a.identifier!==r&&t.manager.removeIdentifier(a.identifier),a.identifier=r;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(i,c,c.identifier),t.processOnMove(i)};if((n=t.idles.indexOf(a))>=0&&t.idles.splice(n,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var u=dp(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(i);return}}return a};Sn.prototype.getOrCreate=function(i,t){var e=this,n=e.options,r;return/(semi|static)/.test(n.mode)?(r=e.idles[0],r?(e.idles.splice(0,1),r):n.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(r=e.createNipple(t,i),r)};Sn.prototype.processOnMove=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.scroll;if(!YI(i)){this.processOnEnd(i);return}if(!r){console.error("Found zombie joystick with ID "+n),t.manager.removeIdentifier(n);return}if(e.dynamicPage){var o=r.el.getBoundingClientRect();r.position={x:s.x+o.left,y:s.y+o.top}}r.identifier=n;var a=r.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=r.position.y),e.lockY&&(l.x=r.position.x);var u=dp(l,r.position),c=WI(l,r.position),d=Mv(c),h=u/a,f={distance:u,position:l},m,p;if(r.options.shape==="circle"?(m=Math.min(u,a),p=qI(r.position,m,c)):(p=ZI(l,r.position,a),m=dp(p,r.position)),e.follow){if(u>a){let x=l.x-p.x,w=l.y-p.y;r.position.x+=x,r.position.y+=w,r.el.style.top=r.position.y-(t.box.top+s.y)+"px",r.el.style.left=r.position.x-(t.box.left+s.x)+"px",u=dp(l,r.position)}}else l=p,u=m;var g=l.x-r.position.x,y=l.y-r.position.y;r.frontPosition={x:g,y},e.dataOnly||Tv(r.ui.front,r.frontPosition);var v={identifier:r.identifier,position:l,force:h,pressure:i.force||i.pressure||i.webkitForce||0,distance:u,angle:{radian:d,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:r,lockX:e.lockX,lockY:e.lockY};v=r.computeDirection(v),v.angle={radian:Mv(180-c),degree:180-c},r.trigger("move",v),t.trigger("move "+r.id+":move",v)};Sn.prototype.processOnEnd=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.removeIdentifier(r.identifier);!r||(e.dataOnly||r.hide(function(){e.mode==="dynamic"&&(r.trigger("removed",r),t.trigger("removed "+r.id+":removed",r),t.manager.trigger("removed "+r.id+":removed",r),r.destroy())}),clearInterval(t.pressureIntervals[r.identifier]),r.resetDirection(),r.trigger("end",r),t.trigger("end "+r.id+":end",r),t.ids.indexOf(r.identifier)>=0&&t.ids.splice(t.ids.indexOf(r.identifier),1),t.actives.indexOf(r)>=0&&t.actives.splice(t.actives.indexOf(r),1),/(semi|static)/.test(e.mode)?t.idles.push(r):t.nipples.indexOf(r)>=0&&t.nipples.splice(t.nipples.indexOf(r),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};Sn.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Sn.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)i.pressureIntervals.hasOwnProperty(t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off()};var nD=Sn;function dr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=zS(),t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(s){s.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};if(typeof window>"u")return t.collections;ah(window,"resize",function(){US(e)});var n=function(){t.scroll=zS()};return ah(window,"scroll",function(){US(n)}),t.collections}dr.prototype=new ch;dr.constructor=dr;dr.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(n){return e=n.get(t),!e}),e}};dr.prototype.create=function(i){return this.createCollection(i)};dr.prototype.createCollection=function(i){var t=this,e=new nD(t,i);return t.bindCollection(e),t.collections.push(e),e};dr.prototype.bindCollection=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};dr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};dr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};dr.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.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]};dr.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};dr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};dr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};dr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};dr.prototype.onAny=function(i,t){var e=this,n,r="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=Ev(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[r](a),a._found_=!0)},o=function(a){n=e.getIdentifier(a),hp(e.collections,s.bind(null,a,n)),a._found_||e.removeIdentifier(n)};return hp(t,o),!1};dr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.off()};dr.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var rD=dr;var iD=new rD,sD={create:function(i){return iD.create(i)},factory:iD};var oD=new Map,mp=new Map,Xs=class{constructor(t,e,n,r){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let u=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Ro({src:u,volume:o,delay:a,loop:l}),mp.has(n.uuid)?mp.get(n.uuid).push(this):mp.set(n.uuid,[this]),oD.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},uh=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=oD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=mp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...mp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Fo=class{constructor(t,e,n,r){this.data=e;if(e.interaction==="play")this.interaction=new Xs(t,e,n,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new uh(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Xs?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Xs?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){this.interaction instanceof Xs&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var V8="text/plain",H8="us-ascii",aD=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),j8=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:n,data:r,hash:s}=e.groups,o=n.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(d=>{let[h,f=""]=d.split("=").map(m=>m.trim());return h==="charset"&&(f=f.toLowerCase(),f===H8)?"":`${h}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==V8)&&c.unshift(l),`data:${c.join(";")},${a?r.trim():r}${s?`#${s}`:""}`};function GS(i,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},i=i.trim(),/^data:/i.test(i))return j8(i,t);if(/^view-source:/i.test(i))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=i.startsWith("//");!e&&/^\.*\//.test(i)||(i=i.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(i);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 o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(r.pathname);if(!c)break;let d=c[0],h=c.index,f=r.pathname.slice(a,h);l+=f.replace(/\/{2,}/g,"/"),l+=d,a=h+d.length}let u=r.pathname.slice(a,r.pathname.length);l+=u.replace(/\/{2,}/g,"/"),r.pathname=l}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 o=r.pathname.split("/"),a=o[o.length-1];aD(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),r.pathname=o.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 o of[...r.searchParams.keys()])aD(o,t.removeQueryParameters)&&r.searchParams.delete(o);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=i;return i=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var Dv=class{constructor({url:t,context:e},n){this.eventManager=n;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:GS(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){dg?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.eventManager.controlsManager.orbitControls?.onPointerUp(ke[0]),gT())}};var gp=class{constructor(t,e,n){this.data=t;this.page=e;this.eventManager=n;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let n=this.controlsManager.sharedGameControlGlobals.rapierWorld,r=n?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)r?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(r||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;n===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),this.eventManager.requestRender()};this.objects=[...t.objects],this.controlsManager=n.controlsManager}dispatch(t){this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var Ov=class{constructor(t,e,n){this.page=t;this.eventManager=n;this.sharedAssets=e}dispatch(){dh(this.page,this.sharedAssets,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender()}};var fD={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},WS={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},W8=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Lv={CSS:{},springs:{}};function hs(i,t,e){return Math.min(Math.max(i,t),e)}function yp(i,t){return i.indexOf(t)>-1}function VS(i,t){return i.apply(null,t)}var et={arr:function(i){return Array.isArray(i)},obj:function(i){return yp(Object.prototype.toString.call(i),"Object")},pth:function(i){return et.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||et.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i>"u"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return et.hex(i)||et.rgb(i)||et.hsl(i)},key:function(i){return!fD.hasOwnProperty(i)&&!WS.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function pD(i){var t=/\(([^)]+)\)/.exec(i);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function mD(i,t){var e=pD(i),n=hs(et.und(e[0])?1:e[0],.1,100),r=hs(et.und(e[1])?100:e[1],.1,100),s=hs(et.und(e[2])?10:e[2],.1,100),o=hs(et.und(e[3])?0:e[3],.1,100),a=Math.sqrt(r/n),l=s/(2*Math.sqrt(r*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*a+-o)/u:-o+a;function h(m){var p=t?t*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(c*Math.cos(u*p)+d*Math.sin(u*p)):p=(c+d*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=Lv.springs[i];if(m)return m;for(var p=1/6,g=0,y=0;;)if(g+=p,h(g)===1){if(y++,y>=16)break}else y=0;var v=g*p*1e3;return Lv.springs[i]=v,v}return t?h:f}function q8(i){return i===void 0&&(i=10),function(t){return Math.ceil(hs(t,1e-6,1)*i)*(1/i)}}var Y8=function(){var i=11,t=1/(i-1);function e(c,d){return 1-3*d+3*c}function n(c,d){return 3*d-6*c}function r(c){return 3*c}function s(c,d,h){return((e(d,h)*c+n(d,h))*c+r(d))*c}function o(c,d,h){return 3*e(d,h)*c*c+2*n(d,h)*c+r(d)}function a(c,d,h,f,m){var p,g,y=0;do g=d+(h-d)/2,p=s(g,f,m)-c,p>0?h=g:d=g;while(Math.abs(p)>1e-7&&++y<10);return g}function l(c,d,h,f){for(var m=0;m<4;++m){var p=o(d,h,f);if(p===0)return d;var g=s(d,h,f)-c;d-=g/p}return d}function u(c,d,h,f){if(!(0<=c&&c<=1&&0<=h&&h<=1))return;var m=new Float32Array(i);if(c!==d||h!==f)for(var p=0;p<i;++p)m[p]=s(p*t,c,h);function g(y){for(var v=0,x=1,w=i-1;x!==w&&m[x]<=y;++x)v+=t;--x;var S=(y-m[x])/(m[x+1]-m[x]),_=v+S*t,M=o(_,c,h);return M>=.001?l(y,_,c,h):M===0?_:a(y,v,v+t,c,h)}return function(y){return c===d&&h===f||y===0||y===1?y:s(g(y),d,f)}}return u}(),gD=function(){var i={linear:function(){return function(n){return n}}},t={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var r,s=4;n<((r=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((r*3-2)/22-n,2)}},Elastic:function(n,r){n===void 0&&(n=1),r===void 0&&(r=.5);var s=hs(n,1,10),o=hs(r,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(n,r){t[n]=function(){return function(s){return Math.pow(s,r+2)}}}),Object.keys(t).forEach(function(n){var r=t[n];i["easeIn"+n]=r,i["easeOut"+n]=function(s,o){return function(a){return 1-r(s,o)(1-a)}},i["easeInOut"+n]=function(s,o){return function(a){return a<.5?r(s,o)(a*2)/2:1-r(s,o)(a*-2+2)/2}}}),i}();function qS(i,t){if(et.fnc(i))return i;var e=i.split("(")[0],n=gD[e],r=pD(i);switch(e){case"spring":return mD(i,t);case"cubicBezier":return VS(Y8,r);case"steps":return VS(q8,r);default:return VS(n,r)}}function yD(i){try{var t=document.querySelectorAll(i);return t}catch{return}}function Nv(i,t){for(var e=i.length,n=arguments.length>=2?arguments[1]:void 0,r=[],s=0;s<e;s++)if(s in i){var o=i[s];t.call(n,o,s,i)&&r.push(o)}return r}function Bv(i){return i.reduce(function(t,e){return t.concat(et.arr(e)?Bv(e):e)},[])}function lD(i){return et.arr(i)?i:(et.str(i)&&(i=yD(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function YS(i,t){return i.some(function(e){return e===t})}function XS(i){var t={};for(var e in i)t[e]=i[e];return t}function HS(i,t){var e=XS(i);for(var n in i)e[n]=t.hasOwnProperty(n)?t[n]:i[n];return e}function Fv(i,t){var e=XS(i);for(var n in t)e[n]=et.und(i[n])?t[n]:i[n];return e}function X8(i){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return t?"rgba("+t[1]+",1)":i}function Q8(i){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=i.replace(t,function(a,l,u,c){return l+l+u+u+c+c}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),r=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+r+","+s+","+o+",1)"}function K8(i){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),e=parseInt(t[1],10)/360,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100,s=t[4]||1;function o(h,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?h+(f-h)*6*m:m<1/2?f:m<2/3?h+(f-h)*(2/3-m)*6:h}var a,l,u;if(n==0)a=l=u=r;else{var c=r<.5?r*(1+n):r+n-r*n,d=2*r-c;a=o(d,c,e+1/3),l=o(d,c,e),u=o(d,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function Z8(i){if(et.rgb(i))return X8(i);if(et.hex(i))return Q8(i);if(et.hsl(i))return K8(i)}function Uo(i){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(i);if(t)return t[1]}function J8(i){if(yp(i,"translate")||i==="perspective")return"px";if(yp(i,"rotate")||yp(i,"skew"))return"deg"}function jS(i,t){return et.fnc(i)?i(t.target,t.id,t.total):i}function Qs(i,t){return i.getAttribute(t)}function QS(i,t,e){var n=Uo(t);if(YS([e,"deg","rad","turn"],n))return t;var r=Lv.CSS[t+e];if(!et.und(r))return r;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return Lv.CSS[t+e]=u,u}function vD(i,t,e){if(t in i.style){var n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=i.style[t]||getComputedStyle(i).getPropertyValue(n)||"0";return e?QS(i,r,e):r}}function KS(i,t){if(et.dom(i)&&!et.inp(i)&&(Qs(i,t)||et.svg(i)&&i[t]))return"attribute";if(et.dom(i)&&YS(W8,t))return"transform";if(et.dom(i)&&t!=="transform"&&vD(i,t))return"css";if(i[t]!=null)return"object"}function xD(i){if(!!et.dom(i)){for(var t=i.style.transform||"",e=/(\w+)\(([^)]*)\)/g,n=new Map,r;r=e.exec(t);)n.set(r[1],r[2]);return n}}function $8(i,t,e,n){var r=yp(t,"scale")?1:0+J8(t),s=xD(i).get(t)||r;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),n?QS(i,s,n):s}function ZS(i,t,e,n){switch(KS(i,t)){case"transform":return $8(i,t,n,e);case"css":return vD(i,t,e);case"attribute":return Qs(i,t);default:return i[t]||0}}function JS(i,t){var e=/^(\*=|\+=|-=)/.exec(i);if(!e)return i;var n=Uo(i)||0,r=parseFloat(t),s=parseFloat(i.replace(e[0],""));switch(e[0][0]){case"+":return r+s+n;case"-":return r-s+n;case"*":return r*s+n}}function bD(i,t){if(et.col(i))return Z8(i);if(/\s/g.test(i))return i;var e=Uo(i),n=e?i.substr(0,i.length-e.length):i;return t?n+t:n}function $S(i,t){return Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))}function eq(i){return Math.PI*2*Qs(i,"r")}function tq(i){return Qs(i,"width")*2+Qs(i,"height")*2}function nq(i){return $S({x:Qs(i,"x1"),y:Qs(i,"y1")},{x:Qs(i,"x2"),y:Qs(i,"y2")})}function wD(i){for(var t=i.points,e=0,n,r=0;r<t.numberOfItems;r++){var s=t.getItem(r);r>0&&(e+=$S(n,s)),n=s}return e}function rq(i){var t=i.points;return wD(i)+$S(t.getItem(t.numberOfItems-1),t.getItem(0))}function SD(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return eq(i);case"rect":return tq(i);case"line":return nq(i);case"polyline":return wD(i);case"polygon":return rq(i)}}function iq(i){var t=SD(i);return i.setAttribute("stroke-dasharray",t),t}function sq(i){for(var t=i.parentNode;et.svg(t)&&et.svg(t.parentNode);)t=t.parentNode;return t}function AD(i,t){var e=t||{},n=e.el||sq(i),r=n.getBoundingClientRect(),s=Qs(n,"viewBox"),o=r.width,a=r.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function oq(i,t){var e=et.str(i)?yD(i)[0]:i,n=t||100;return function(r){return{property:r,el:e,svg:AD(e),totalLength:SD(e)*(n/100)}}}function aq(i,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return i.el.getPointAtLength(l)}var n=AD(i.el,i.svg),r=e(),s=e(-1),o=e(1);switch(i.property){case"x":return(r.x-n.x)*n.w;case"y":return(r.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function cD(i,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=bD(et.pth(i)?i.totalLength:i,t)+"";return{original:n,numbers:n.match(e)?n.match(e).map(Number):[0],strings:et.str(i)||t?n.split(e):[]}}function _D(i){var t=i?Bv(et.arr(i)?i.map(lD):lD(i)):[];return Nv(t,function(e,n,r){return r.indexOf(e)===n})}function MD(i){var t=_D(i);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:xD(e)}}})}function lq(i,t){var e=XS(t);if(/^spring/.test(e.easing)&&(e.duration=mD(e.easing)),et.arr(i)){var n=i.length,r=n===2&&!et.obj(i[0]);r?i={value:i}:et.fnc(t.duration)||(e.duration=t.duration/n)}var s=et.arr(i)?i:[i];return s.map(function(o,a){var l=et.obj(o)&&!et.pth(o)?o:{value:o};return et.und(l.delay)&&(l.delay=a?0:t.delay),et.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return Fv(o,e)})}function cq(i){for(var t=Nv(Bv(i.map(function(s){return Object.keys(s)})),function(s){return et.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},n=function(s){var o=t[s];e[o]=i.map(function(a){var l={};for(var u in a)et.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},r=0;r<t.length;r++)n(r);return e}function uq(i,t){var e=[],n=t.keyframes;n&&(t=Fv(cq(n),t));for(var r in t)et.key(r)&&e.push({name:r,tweens:lq(t[r],i)});return e}function dq(i,t){var e={};for(var n in i){var r=jS(i[n],t);et.arr(r)&&(r=r.map(function(s){return jS(s,t)}),r.length===1&&(r=r[0])),e[n]=r}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function hq(i,t){var e;return i.tweens.map(function(n){var r=dq(n,t),s=r.value,o=et.arr(s)?s[1]:s,a=Uo(o),l=ZS(t.target,i.name,a,t),u=e?e.to.original:l,c=et.arr(s)?s[0]:u,d=Uo(c)||Uo(l),h=a||d;return et.und(o)&&(o=u),r.from=cD(c,h),r.to=cD(JS(o,c),h),r.start=e?e.end:0,r.end=r.start+r.delay+r.duration+r.endDelay,r.easing=qS(r.easing,r.duration),r.isPath=et.pth(s),r.isColor=et.col(r.from.original),r.isColor&&(r.round=1),e=r,r})}var ED={css:function(i,t,e){return i.style[t]=e},attribute:function(i,t,e){return i.setAttribute(t,e)},object:function(i,t,e){return i[t]=e},transform:function(i,t,e,n,r){if(n.list.set(t,e),t===n.last||r){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function TD(i,t){var e=MD(i);e.forEach(function(n){for(var r in t){var s=jS(t[r],n),o=n.target,a=Uo(s),l=ZS(o,r,a,n),u=a||Uo(l),c=JS(bD(s,u),l),d=KS(o,r);ED[d](o,r,c,n.transforms,!0)}})}function fq(i,t){var e=KS(i.target,t.name);if(e){var n=hq(t,i),r=n[n.length-1];return{type:e,property:t.name,animatable:i,tweens:n,duration:r.end,delay:n[0].delay,endDelay:r.endDelay}}}function pq(i,t){return Nv(Bv(i.map(function(e){return t.map(function(n){return fq(e,n)})})),function(e){return!et.und(e)})}function CD(i,t){var e=i.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},r={};return r.duration=e?Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,r.delay=e?Math.min.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):t.delay,r.endDelay=e?r.duration-Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,r}var uD=0;function mq(i){var t=HS(fD,i),e=HS(WS,i),n=uq(e,i),r=MD(i.targets),s=pq(r,n),o=CD(s,e),a=uD;return uD++,Fv(t,{id:a,children:[],animatables:r,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Fi=[],dD=[],Rv,gq=function(){function i(){Rv=requestAnimationFrame(t)}function t(e){var n=Fi.length;if(n){for(var r=0;r<n;){var s=Fi[r];s.paused?(Fi.splice(r,1),n-=1):(s.tick(e),r++)}i()}else Rv=cancelAnimationFrame(Rv)}return i}();function yq(i){document.hidden?(Fi.forEach(function(t){return t.pause(i.timeStamp)}),dD=Fi.slice(0),An.running=Fi=[]):dD.forEach(function(t){return t.play(i.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",yq);function An(i){i===void 0&&(i={});var t=0,e=0,n=0,r,s,o=0,a=null;function l(M){var b=window.Promise&&new Promise(function(E){return a=E});return M.finished=b,b}var u=mq(i),c=l(u);function d(){var M=u.direction;M!=="alternate"&&(u.direction=M!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=u.reversed)})}function h(){u.direction="normal",u.reversed=!1,s.forEach(function(M){return M.reversed=!1})}function f(M){return u.reversed?u.duration-M:M}function m(){t=0,e=f(u.currentTime)*(1/An.speed)}function p(M,b){b&&(u.reversed?b.seek(b.duration*b.loop-(M-b.timelineOffset-b.pingPongDelayCorrection)):b.seek(M-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection))}function g(M){if(u.reversed)for(var E=o;E--;)p(M,s[E]);else for(var b=0;b<o;b++)p(M,s[b])}function y(M){var b=0,E=u.animations,T=E.length;for(u.direction!=="alternate"&&u.parent?.direction==="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1&&(u.parent?.reversed&&u.direction==="alternate"?M=u.duration-u.delay+u.endDelay-M:M=u.duration+u.delay-u.endDelay-M):S(!1,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)&&(u.parent?.reversed&&u.direction==="alternate"?M=u.duration-u.delay+u.endDelay-M:M=u.duration+u.delay-u.endDelay-M);b<T;){var I=E[b],C=I.animatable,P=I.tweens,O=P.length-1,B=P[O];O&&(B=Nv(P,function(k){return M<k.end})[0]||B);let Z;u.parent?.reversed&&u.direction==="alternate"?Z=hs(M-B.start-B.endDelay,0,B.duration)/B.duration:Z=hs(M-B.start-B.delay,0,B.duration)/B.duration;for(var j=isNaN(Z)?1:B.easing(Z),Q=B.to.strings,V=B.round,q=[],W=B.to.numbers.length,X=void 0,L=0;L<W;L++){var U=void 0;let k,he;u.direction!=="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1?(k=B.to.numbers[L],he=B.from.numbers[L]||0):(he=B.to.numbers[L],k=B.from.numbers[L]||0):S(!0,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)?(k=B.to.numbers[L],he=B.from.numbers[L]||0):(he=B.to.numbers[L],k=B.from.numbers[L]||0),B.isPath?U=aq(B.value,j*he):U=k+j*(he-k),V&&(B.isColor&&L>2||(U=Math.round(U*V)/V)),q.push(U)}var G=Q.length;if(!G)X=q[0];else{X=Q[0];for(var H=0;H<G;H++){var z=Q[H],re=Q[H+1],K=q[H];isNaN(K)||(re?X+=K+re:X+=K+" ")}}ED[I.type](C.target,I.property,X,C.transforms),I.currentValue=X,b++}}function v(M){u[M]&&!u.passThrough&&u[M](u)}function x(){u.remaining&&u.remaining!==!0&&u.remaining--}let w={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(M,b,E,T,I){return w[M<<4|b<<3|E<<2|T<<1|I]}function _(M){var b=u.duration;let E=u.delay,T=b-u.endDelay;u.parent?.reversed&&u.direction==="alternate"&&(E=u.endDelay,T=b-u.delay);var I=f(M);if(u.progress=hs(I/b*100,0,100),u.reversePlayback=I<u.currentTime,o&&g(I),!u.began&&u.currentTime>=0&&(u.began=!0,v("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,v("loopBegin")),(u.reversed||I>=0)&&I<=E&&u.currentTime!==0&&(y(0),v("change")),(I>=T&&u.currentTime!==b+u.pingPongDelayCorrection||!b)&&(y(b),v("change")),I>E&&I<T?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,v("changeBegin")),y(I),v("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):u.began&&I>T&&v("changeComplete"),u.currentTime=hs(I,0,b+u.pingPongDelayCorrection),u.began&&v("update"),M>=b)if(x(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,v("loopComplete"),v("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/An.speed:t+=u.duration;for(let C of s)C.setStartTime(0),C.remaining=C.loop;v("loopComplete"),u.loopBegan=!1,u.direction==="alternate"?d():o&&h()}}return u.reset=function(){var M=u.direction;u.passThrough=!1,u.currentTime=0,u.progress=0,u.paused=!0,u.began=!1,u.loopBegan=!1,u.changeBegan=!1,u.completed=!1,u.changeCompleted=!1,u.reversePlayback=!1,u.reversed=M==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var b=o;b--;)u.children[b].reset();(u.reversed&&u.loop!==!0||M==="alternate"&&u.loop===1)&&u.remaining++,y(u.reversed?u.duration:0)},u.setStartTime=function(M){t=M},u.set=function(M,b){return TD(M,b),u},u.tick=function(M){n=M,t||(t=n),_((n+(e-t))*An.speed)},u.seek=function(M){_(M-t)},u.pause=function(M){u.paused=!0,o&&(r=M??performance.now())},u.play=function(M){!u.paused||(u.completed&&u.reset(),u.paused=!1,Fi.push(u),o&&r!==void 0&&(t+=(M??performance.now())-r),Rv||gq())},u.reverse=function(){d(),u.completed=!u.reversed,m()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function hD(i,t){for(var e=t.length;e--;)YS(i,t[e].animatable.target)&&t.splice(e,1)}function vq(i){for(var t=_D(i),e=Fi.length;e--;){var n=Fi[e],r=n.animations,s=n.children;hD(t,r);for(var o=s.length;o--;){var a=s[o],l=a.animations;hD(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!r.length&&!s.length&&n.pause()}}function xq(i,t){t===void 0&&(t={});var e=t.direction||"normal",n=t.easing?qS(t.easing):null,r=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=et.arr(i),d=parseFloat(c?i[0]:i),h=c?parseFloat(i[1]):0,f=Uo(c?i[1]:i)||0,m=t.start||0+(c?d:0),p=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!p.length){for(var w=0;w<x;w++){if(!r)p.push(Math.abs(o-w));else{var S=l?(r[0]-1)/2:o%r[0],_=l?(r[1]-1)/2:Math.floor(o/r[0]),M=w%r[0],b=Math.floor(w/r[0]),E=S-M,T=_-b,I=Math.sqrt(E*E+T*T);s==="x"&&(I=-E),s==="y"&&(I=-T),p.push(I)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(P){return n(P/g)*g})),e==="reverse"&&(p=p.map(function(P){return s?P<0?P*-1:-P:Math.abs(g-P)}))}var C=c?(h-d)/g:d;return m+C*(Math.round(p[v]*100)/100)+f}}function bq(i){i===void 0&&(i={});var t=An(i);return t.duration=0,t.add=function(e,n){var r=Fi.indexOf(t),s=t.children;r>-1&&Fi.splice(r,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Fv(e,HS(WS,i));l.targets=l.targets||i.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=et.und(n)?u:JS(n,u),o(t);var c=An(l);o(c),s.push(c),c.parent=t;var d=CD(s,i);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}An.version="3.2.0";An.speed=1;An.running=Fi;An.remove=vq;An.get=ZS;An.set=TD;An.convertPx=QS;An.path=oq;An.setDashoffset=iq;An.stagger=xq;An.timeline=bq;An.easing=qS;An.penner=gD;An.random=function(i,t){return Math.floor(Math.random()*(t-i+1))+i};var Uv=An;var PD=new A,ID=new A,DD=new qe;function OD(i,t,e,n){if(n===0)return e.copy(i);if(n===1)return e.copy(t);let r=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(r>=1)return e.copy(i);let s=1-r*r;if(s<=Number.EPSILON){let c=1-n;return e.w=c*i.w+n*t.w,e.x=c*i.x+n*t.x,e.y=c*i.y+n*t.y,e.z=c*i.z+n*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,r),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return e.w=i.w*l+t.w*u,e.x=i.x*l+t.x*u,e.y=i.y*l+t.y*u,e.z=i.z*l+t.z*u,e}function fs(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(o==null)return;let a=s??t[i],l=o;if(a!==l)return{update:u=>{let c=Ve.lerp(a,l,u);r?t[i]=Math.trunc(c):t[i]=c},start:()=>{t[i]=a},end:()=>{t[i]=l}}}function e1(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=[...s??a],u=[...o];if(!(l.length!==u.length||Sl(l,u)))return{update:c=>{l.forEach((d,h)=>{let f=Ve.lerp(d,u[h],c);t[i][h]=r?Math.trunc(f):f})},start:()=>{Object.assign(t[i],l)},end:()=>{Object.assign(t[i],u)}}}function t1(i,t,e,n){let r=e[i]?e[i]:void 0,s=n[i];if(!s)return;let o=t[i],a=r?new A().fromArray(r):o.clone(),l=new A().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function RD(i,t,e,n){let r=e[i]?e[i]:void 0,s=n[i];if(!s)return;let o=t[i],a=r?new ie().fromArray(r):o.clone(),l=new A,u=new qe,c=new A;a.decompose(l,u,c);let d=new ie().fromArray(s),h=new A,f=new qe,m=new A;if(d.decompose(h,f,m),!a.equals(d))return{update:p=>{DD.slerpQuaternions(u,f,p),PD.lerpVectors(l,h,p),ID.lerpVectors(c,m,p),o.compose(PD,DD,ID)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(h,f,m)}}}function LD(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=s?typeof s=="string"?r.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[i]=c,{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Ks(i,t,e,n){if(typeof t[i]=="number")return fs(i,t,e??{},n);if(Array.isArray(t[i]))return e1(i,t,e??{},n)}function ND(i,t,e){let n=[],r=i.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,s=i.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(s!==void 0){let o=r??i.zoom,a=s;o!==a&&n.push({update:l=>{i.zoom=Ve.lerp(o,a,l),i.updateProjectionMatrix()},start:()=>{i.zoom=o,i.updateProjectionMatrix()},end:()=>{i.zoom=a,i.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let o=fs("targetOffset",i,t,e);o&&n.push(o)}return n}function wq(i,t,e,n){if(e.scaleBaked===void 0)return;let r=t.scaleBaked??i.data.geometry.scaleBaked,s=e.scaleBaked;if(Cs.isEqual(r,s))return;let o=[];return o.push({update:a=>{i.updateGeometryInteractions({scaleBaked:[Ve.lerp(r[0],s[0],a),Ve.lerp(r[1],s[1],a),Ve.lerp(r[2],s[2],a)]},n),i.invalidateDownstreamBooleanData()},start:()=>{i.updateGeometryInteractions({scaleBaked:r},n),i.invalidateDownstreamBooleanData()},end:()=>{i.updateGeometryInteractions({scaleBaked:s},n),i.invalidateDownstreamBooleanData()}}),o}function Sq(i,t,e){if(!e.extrusion)return;let n=i.extrusion,r=t.extrusion??{},s=e.extrusion,o=[];return jb.forEach(a=>{let l=Ks(a,n,r,s);l&&o.push(l)}),o}function BD(i,t,e,n){let r=[];if(!("geometry"in e))return r;let s=i.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(i instanceof ls){let l=wq(i,o,a,n);l&&r.push(...l)}else{let l={};if(Object.assign(l,Qi(s,Wb)),Wb.forEach(u=>{let c=Ks(u,l,o,a);c&&r.push(c)}),i instanceof Va){Object.assign(l,{extrusion:{...s.extrusion}});let u=Sq(l,o,a);u&&r.push(...u)}r.length&&r.push({update:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},start:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},end:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()}})}return r}function FD(i,t,e,n){let r=[];if(e.intensity!==void 0){let s=fs("intensity",i,t,e);s&&r.push(s)}if(e.color!==void 0){let s=LD("color",i,t,e,n);s&&r.push(s)}return r}function kD(i,t,e,n){let r=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return r;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;i.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||r.push(...UD(a,u,c,n))})}else{if(!("material"in e&&e.material))return r;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return r;r.push(...UD(i.material,s,o,n))}return r}function UD(i,t,e,n){let r=[],s=Jf(e,n)||!!t.layers&&Jf(t,n);r.push(Dq(i,s));for(let o of i.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||!(o.visible??!0)||!(l.visible??!0))continue;let u=o.getNames().filter(c=>!Wg.some(d=>c.includes(d)));for(let c of u)try{let d=o.getValue(c),h;if(c==="colors")h=Pq(o,a,l,c);else if(Array.isArray(d))c==="steps"&&(h=Cq(o,a,l,c));else if(typeof d=="number")h=Aq(o,a,l,c);else{if(typeof d=="boolean")continue;d instanceof F?h=_q(o,a,l,c):d instanceof A?h=Mq(o,a,l,c):d instanceof sn?h=Tq(o,a,l,c,n):d instanceof Re?h=Eq(o,a,l,c,n):"isTexture"in d&&(h=Iq(o,a,l,c))}h&&(Array.isArray(h)?r.push(...h):r.push(h))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${c}`,d)}}return r}function Aq(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=t?t[n]:i.getValue(n),s=e[n];if(r!==s)return{update:o=>{i.setValue(n,Ve.lerp(r,s,o))},start:()=>{i.setValue(n,r)},end:()=>{i.setValue(n,s)}}}function _q(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=i.getValue(n),s=t?new F().fromArray(t[n]):r.clone(),o=new F().fromArray(e[n]);if(!s.equals(o))return{update:a=>{r.lerpVectors(s,o,a)},start:()=>{r.copy(s)},end:()=>{r.copy(o)}}}function Mq(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=i.getValue(n),s=t?new A().fromArray(t[n]):r.clone(),o=new A().fromArray(e[n]);if(!s.equals(o))return{update:a=>{r.lerpVectors(s,o,a)},start:()=>{r.copy(s)},end:()=>{r.copy(o)}}}function Eq(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return{update:d=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Tq(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new sn(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return{update:d=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function Cq(i,t,e,n="steps"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s,a=e[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&r.push({update:d=>{s[l]=Ve.lerp(u,c,d)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return r.length?r:void 0}function Pq(i,t,e,n="colors"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s.map(l=>l.toArray()),a=e[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];xf.isEqual(u,c)||r.push({update:d=>{s[l].fromArray(xf.lerp(u,c,d))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return r.length?r:void 0}function Iq(i,t,e,n="texture"){if(!i.hasValue(n)||!(n in e))return;let r=i.getNode("mat");if(!r)return;let s=t?t[n]:r,o=e[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!Tl.isEqual(a,u)||!Tl.isEqual(l,c))return{update:d=>{r.repeat=Tl.lerp(a,u,d),r.offset=Tl.lerp(l,c,d),r.updateMatrix()},start:()=>{r.repeat=[...a],r.offset=[...l],r.updateMatrix()},end:()=>{r.repeat=[...u],r.offset=[...c],r.updateMatrix()}}}function Dq(i,t){return{update:()=>{i.transparent=t}}}var n1=new A,zD=new Gt;function GD(i,t,e,n){let r=[],s,o,a,l,u,c,d={slide:(t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping).offset};if(u=fs("slide",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping),u&&r.push(u),c=fs("offset",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping),c&&r.push(c),!u&&!c&&(s=t1("position",i,t,e),s&&r.push(s),o=t1("scale",i,t,e),o&&r.push(o),a=Oq(i,t,e,n),a&&r.push(a),l=RD("hiddenMatrix",i,t,e),l&&r.push(l)),s||o||a||l||u||c){let h=()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),Pr(i)&&Hr(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,d))};r.push({update:h,start:h,end:h})}return r}function Oq(i,t,e,n){let r=t?.rotation?t.rotation:void 0,s=e.rotation;if(!s)return;let o=r?new A().fromArray(r):new A().setFromEuler(i.rotation),a=new A().fromArray(s);if(o.equals(a))return;let l=n1.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new qe().setFromEuler(zD.setFromVector3(o)),c=new qe().setFromEuler(zD.setFromVector3(a));return{update:d=>{OD(u,c,i.quaternion,d)},start:()=>{i.rotation.setFromVector3(o)},end:()=>{i.rotation.setFromVector3(a)}}}else return{update:u=>{n1.lerpVectors(o,a,u),i.rotation.setFromVector3(n1)},start:()=>{i.rotation.setFromVector3(o)},end:()=>{i.rotation.setFromVector3(a)}}}function VD(i,t,e){let n=[];if(!("cloner"in e)||!i.cloner)return n;let r=i.cloner,s="cloner"in t?t.cloner:{},o=e.cloner;Nb.forEach(h=>{let f;h==="count"?f=fs("count",r.parameters,s,o,!0):f=Ks(h,r.parameters,s??{},o),f&&n.push(f)});let a=Rq(r,s,o);a?.length&&n.push(...a);let l=Lq(r,s,o);l?.length&&n.push(...l);let u=Nq(r,s,o);u?.length&&n.push(...u);let c=Bq(r,s,o);c?.length&&n.push(...c);let d=Fq(r,s,o);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{r.update()}}),n}function Rq(i,t,e){if(i.parameters.type!=="radial")return;let n=t.radial,r=e.radial;if(!r)return;let s=i.parameters.radial,o=[];return Bb.forEach(a=>{let l=Ks(a,s,n??{},r);l&&o.push(l)}),o}function Lq(i,t,e){if(i.parameters.type!=="linear")return;let n=t.linear,r=e.linear;if(!r)return;let s=[],o=i.parameters.linear;return Fb.forEach(a=>{let l=Ks(a,o,n??{},r);l&&s.push(l)}),s}function Nq(i,t,e){if(i.parameters.type!=="grid")return;let n=t.grid,r=e.grid;if(!r)return;let s=[],o=i.parameters.grid;return Ub.forEach(a=>{let l;a==="count"?l=e1(a,o,n??{},r,!0):l=Ks(a,o,n??{},r),l&&s.push(l)}),s}function Bq(i,t,e){if(i.parameters.type!=="toObject")return;let n=t.toObject,r=e.toObject;if(!r)return;let s=[],o=i.parameters.toObject;return kb.forEach(a=>{let l;a==="count"?l=fs(a,o,n??{},r,!0):l=Ks(a,o,n??{},r),l&&s.push(l)}),s}function Fq(i,t,e){if(!i.parameters.randomness)return;let n=t.randomnessObject,r=e.randomnessObject;if(!r)return;let s=[],o=i.parameters.randomnessObject;return zb.forEach(a=>{let l=Ks(a,o,n??{},r);l&&s.push(l)}),s}function r1(i,t,e,n,r){let s=[];return i.data.visible&&s.push(...GD(i,t,e,r)),i.data.visible&&s.push(...VD(i,t,e)),Pr(i)?(i instanceof Ht&&i.data.visible&&s.push(...BD(i,t,e,n)),i.data.visible&&s.push(...kD(i,t,e,n))):K2(i)?i.data.visible&&s.push(...FD(i,t,e,n)):Q2(i)&&s.push(...ND(i,t,e)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var HD=new A;function dh(i,t,e=!1){let n=[];i.traverseChildren(r=>{if(e&&(r.rigidBody?.setTranslation(r.position0,!0),r.rigidBody?.setRotation(r.rotation0,!0),r.rigidBody?.setLinvel(HD,!0),r.rigidBody?.setAngvel(HD,!0)),!lt.is(r))return;let s=r.uuid,o=r.data;if(delete r.states,r.uuid===Ei)return;let a=!1;n.some(l=>i.scene.find(s)?.isDescendantOf(l))?a=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&n.push(s),r.data=o,r.currentState=null,r.reversibleToState=null,r.currentTransitionEvent=null;for(let l of o.states){let u={...l.data};i.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||a)&&(l.data.position!==void 0&&delete u.position,l.data.rotation!==void 0&&delete u.rotation,l.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),r.states||(r.states={}),r.states[l.id]=To.patch(o,u)}kq(i.scene,r,null,t,o.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),Uq(i)})}function Uq(i){i.traverseEntity(t=>{for(let e of t.data.events){let n=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":n.push(...e.data.actions);break;case"GameControl":for(let r of Object.values(e.data.gameActions))n.push(...r);break;case"DragDrop":n.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":n.push(...e.data.inActions,...e.data.outActions);break}for(let r of n)r.data.type==="Create"&&r.data.hideBase==="Yes"&&(i.scene.find(r.data.object).visible=!1)}})}function kq(i,t,e,n,r=!1){if(t instanceof Ht&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:i,shared:n},r),t instanceof Ht&&t.updateGeometryGroupsIfNeeded(),t instanceof Xt&&t.updateCameraState(t.dataPatched,{scene:i,shared:n}),t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}function i1(i){let t;if(i.easing===5){let{control1:e,control2:n}=i;t=`cubicBezier(
6236
6236
  ${e[0]}, ${e[1]}, ${n[0]}, ${n[1]}
6237
- )`}else if(i.easing===6){let{mass:e,stiffness:n,damping:r,velocity:s}=i;t=`spring( ${e}, ${n}, ${r}, ${s} )`}else{let e;switch(i.easing){case 0:e=_o.linear;break;case 1:e=_o.ease;break;case 2:e=_o.easeIn;break;case 3:e=_o.easeOut;break;case 4:e=_o.easeInOut;break;default:e=_o.linear}let[n,r,s,o]=e;t=`cubicBezier( ${n}, ${r}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function jD(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.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,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var zq={type:"beginState"},Gq={type:"completeState",isfromEntity:!1},Gv=class{constructor(t,e,n,r,s,o){this.object=t;this.data=r;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Xt&&e.dispatchEvent(zq)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Xt&&e.dispatchEvent(Gq)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=r1(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=zv(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=zv(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=zv(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...jD(r),...i1(r),change:this.onChange},this.callback=r1(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},ko=class extends Ut{constructor(e,n,r){super();this.data=e;this.page=n;this.sharedAssets=r;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=zv(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:n=!1}={}){try{let r=jD(this.data.tweens[0].data),s=r.loop;n&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=Uv.timeline({autoplay:!1,...r,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),r.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Xt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new Gv(this.object,d,c.data.state===void 0?this.currentState:c.data.state,c.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?r.delay:0)+(l===a&&!n?r.pingPongDelayCorrection:0))}this.timeline.duration+=r.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Xt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new Gv(this.object,d,c.data.state===void 0?this.currentState:c.data.state,u.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l-1]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?r.endDelay:0))}this.timeline.duration+=r.delay+(n?0:r.pingPongDelayCorrection)}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function zv(i,t){let e,n;if(typeof t=="string"?(e=t,n=i.states?.[e]):t===null&&(e=null,n=i.data),!(e===void 0||n===void 0))return{id:e,data:n}}var Vq={type:"beginState"},WD={type:"completeState",isfromEntity:!1},qD={type:"requestRender"},vp=class extends Ut{constructor(e,n){super();this.data=e;this.page=n;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new qe;this.qEnd=new qe;this.zoomStart=1;this.zoomEnd=1;this.toCamera=this.page.scene.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let n={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=Uv({targets:n,t:1,...i1(this.data),update:()=>{n.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)),this.page.activeCamera.dispatchEvent(Vq));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,n.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(qD),n.t===1&&r.dispatchEvent(WD)}})}switchCamera(e){this.page.switchActiveCamera(e),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:e})}play(){this.playing||this.page.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.page.activeCamera.dispatchEvent(WD),this.page.activeCamera.dispatchEvent(qD))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var zo=class extends Ut{constructor(e,n,r){super();this.page=n;this.animationControls=r;this.startOnceDelay=0;this.toggleIsForward=!1;let s=e.object,o=n.scene.find(e.object);o&&Array.isArray(o.identity)&&(s=o.identity[0]),this.data={...e,object:s};let a=this.animationControls.clipIdToAction[e.clipId+"/"+s];this.duration=a?.getClip()?.duration??1;let l=a?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){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 n=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let o=r.split("/")[1];this.threeAnimAction!==s&&o===n&&s.isRunning()&&(e?s.fadeOut(.2):s.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Ve.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,n=!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 r=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===r&&o.isRunning()&&(n?o.fadeOut(.2):o.stop())}),n&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var xp=class{constructor(t,e,n,r){this.data=t;this.page=e;this.eventManager=n;this.shared=r;this.timeOutId=-1;this.scene=e.scene}dispatch(){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(n=>n.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),dh(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function _n(i,t,e,n,r,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[]};return t.forEach(({id:a,data:l})=>{try{l.type==="Audio"?Zi[i.type].includes("Audio")&&o.Audio.push(new Fo(a,l,s,n)):l.type==="Video"?Zi[i.type].includes("Video")&&o.Video.push(new Jl(a,l,s)):l.type==="Link"?Zi[i.type].includes("Link")&&o.Link.push(new Dv(l,r)):l.type==="Create"?Zi[i.type].includes("Create")&&o.Create.push(new Go(l,e,r.controlsManager)):l.type==="Destroy"?Zi[i.type].includes("Destroy")&&o.Destroy.push(new gp(l,e,r)):l.type==="Reset"?Zi[i.type].includes("Reset")&&o.Reset.push(new Ov(e,n,r)):l.type==="Transition"?Zi[i.type].includes("Transition")&&o.Transition.push(new ko(l,e,n)):l.type==="SwitchCamera"?Zi[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new vp(l,e)):l.type==="SceneTransition"?Zi[i.type].includes("SceneTransition")&&o.SceneTransition.push(new xp(l,e,r,n)):l.type==="Animation"&&Zi[i.type].includes("Animation")&&o.Animation.push(new zo(l,e,r.animationControls))}catch(u){!1&&console.log(u)}}),o}function cn(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Fo||e instanceof Jl||e instanceof zo||e instanceof ko||e instanceof Go||e instanceof gp||e instanceof vp||e instanceof xp)&&e.dispose()})})}function YD(i,t){let e;if("material"in i){let n=i.material;Array.isArray(n)?e=i.material[0].layers.find(r=>r.uuid===t):e=i.material.layers.find(r=>r.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var XD=new Map,bp=new Map,Vo=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:r,loop:s,volume:o,delay:a}=e;if(this.object=n,r===void 0)throw new Error("Missing property");let l=YD(n,r);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),bp.has(n.uuid)?bp.get(n.uuid).push(this):bp.set(n.uuid,[this]),XD.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let n=this.videoElement.play();n!==void 0&&n.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},hh=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=XD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=bp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let t=[...bp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Jl=class{constructor(t,e,n){this.data=e;if(e.interaction==="play")this.interaction=new Vo(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new hh(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Vo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Vo?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var QD=(()=>{let i,t,e,n;function r(a){!i&&!KD()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,n=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,d=u.length,h=0;for(;h<d;){let f=u[h];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),n()),h++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(h,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(m=>m.bvhGeometry!==void 0)),d--,n())}i=h>0?requestAnimationFrame(s):void 0,e=h>0?a:void 0}function o(){KD()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):r()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),r})();function KD(){return!!document&&document.hidden}var ZD=new qe,Hq=new A,jq=new A,Go=class{constructor(t,e,n){this.data=t;this.page=e;this.controlsManager=n;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Ve.generateUUID();this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=hb(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=()=>{if(this.timeoutIdQueue.shift(),this.object===void 0)return;let t=new rn(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem,r=this.page.scene.find(n);r&&(r.updateMatrixWorldSVD(),t.hiddenMatrix.copy(r.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),QD(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof ur)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof rn)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof ur)return;t instanceof rn?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let n=new A().fromArray(this.data.velocity),r=e.dataPatched;if(!(r.physics.enabled==="visibility"?!r.visible:!r.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(Hq,ZD,jq),n.applyQuaternion(ZD),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(n.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=n)),e.dataPatched.physics?.fusedBody===!0))return!0};this.object=this.page.scene.find(this.data.object),QD(n)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var u1=200,s1=.02,o1=.3,Wq=65,sDe=new A,JD=new A,$D=new A,qq=new A,wr=new A,jr=new A,Ha=new A,Vv=new ie,a1=new ie,Yq=new ie,oDe=new ie,gi=new qe,Ho=new qe,Zs=new Gt(0,0,0,"YXZ"),Xq=new A(1,0,0),ps=new A(0,1,0),Qq=new A(0,0,1),l1=new A(1,1,1),c1=new dn,Kq=1,Zq=.025,Jq=16e-6,eO=12,$q=20,hr=new Hn,Ui=new _t,e9={type:"requestRender"},t9={type:"updateMatrix"},tO=Math.PI/6,Hv=class extends Ut{constructor(e,n,r,s,o,a,l,u,c){super();this.object=e;this.domElement=n;this.data=r;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new ie;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=u1;this.euler0=new Gt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new qe;this.scale0Cam=new A;this.hiddenMatrix0Cam=new ie;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Hn(new A(0,-40,0),new A(0,40,0)),matrix:new ie,position:new A,rotation:new qe};this.euler=new Gt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastPosition=new A;this.lastCameraQuaternion=new qe;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new F;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.nonColliderRotOffset=new ie;this.nonColliderPosOffset=new ie;this.firstPointerId=-1;this.rot=new A;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 ie;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new qe;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new qe;this.objXZQuatInv=new qe;this.objXZRotMat=new ie;this.isFirstPerson=!1;this.actions={};this.didHit=!1;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new qe;this.colliderWorldQuat=new qe;this.groundNormal=new A;this.groundTilt=new qe;this.groundTiltInv=new qe;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new A;this.quaternion=new qe;this.scale=new A;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Wn&&(!fb||pb>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let n=e.clientX-this.prevMouse.x,r=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(fb&&pb<15.5&&!Wn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-r*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-r*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Hv.isLocked=!0:Hv.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]){this.movementState[n[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]||e.code.slice(3,e.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.copyVRGamePadValues=(e,n)=>{for(let r=2;r<4;r++){let s=e.axes[r];n===0?r===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,r===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let d=this.euler0.clone(),h=d.y;if(this.objectRealQuat.copy(this.quaternion),d.y=0,this.quaternion.setFromEuler(d),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),d.set(0,h,0),this.quaternion.setFromEuler(d),this.rot.setFromEuler(d),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let g=new A(0,0,-1).applyQuaternion(this.camera.quaternion),y=new A().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let w=new Gt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-w.x,w.x=0,w.z=0,w.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(w)}if(this.object instanceof Xt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=r.rotByTouch??"joystick",this.rotBy=r.rotBy??"keys",this.rotationMode=r.rotationMode??"normal",this.moveMode=r.moveMode??"walk",this.collisionEnabled=r.collisionEnabled,this.speedTranslate=(r.speedTranslate??250)*Kq,this.speedOrbit=(r.speedRotate??100)*Zq,this.mouseOrbitSensitivity=(r.speedRotate??100)*Jq,this.keyAssignments=r.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),r.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((r.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((r.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((r.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((r.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((r.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((r.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Ma.defaultData.gravity)*eO,this.usePhysics=this.gloabalPhysics.usePhysics??Ma.defaultData.usePhysics,this.jumpPower=r.jumpPower*$q,this.resetYPosition=this.position.y+Math.abs(r.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=r.alignToGround??!1,this.orientMode=r.autoOrientMove?r.orientMode:"none",this.orientWith=r.orientWith??Fu.defaultDataThirdPerson.orientWith,this.slopeThresh=Wq*Math.PI/180,r.collider.type==="capsule"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=r.collider.height/2-r.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=r.collider.height*s1/this.pixelsPerMeter,this.stepThresh=r.collider.height*o1/this.pixelsPerMeter,this.colliderHeight=r.collider.height):r.collider.type==="sphere"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*r.collider.radius*s1/this.pixelsPerMeter,this.stepThresh=2*r.collider.radius*o1/this.pixelsPerMeter,this.colliderHeight=r.collider.radius*2):(this.offset=r.collider.height*s1/this.pixelsPerMeter,this.stepThresh=r.collider.height*o1/this.pixelsPerMeter,this.colliderHeight=r.collider.height),this.collider.type=r.collider.type;let f=new A().fromArray(r.collider.position),m=new qe().setFromEuler(new Gt().fromArray([...r.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(m),this.collider.matrix.compose(f,m,l1),r.cameraXAxis!==void 0&&(this.cameraXAxis=r.cameraXAxis,this.cameraYAxis=r.cameraYAxis,this.minPolarAngle=r.cameraRotXLimits[0],this.maxPolarAngle=r.cameraRotXLimits[1],this.minAzimuthAngleRel=r.cameraRotYLimits[0],this.maxAzimuthAngleRel=r.cameraRotYLimits[1]),this.forwardDir=r.forwardDirection??"-z",this.runMultiplier=r.runMultiplier??2;let p=r.navmesh.destinationHelperRadius*2;p>0&&(this.navMeshPathDest=new Dn(vy.create({parameters:{width:p,height:p/10,hollow:.7}}),new Wi({color:Nn.toHex(r.navmesh.destinationHelperColor),transparent:!0,opacity:r.navmesh.destinationHelperColor.a})),this.navMeshPathDest.material.userData.opacity0=r.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 n=new Gt().setFromQuaternion(this.quaternion,"YXZ"),r=n.y;this.objectRealQuat.copy(this.quaternion),n.y=0,this.quaternion.setFromEuler(n),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),n.set(0,r,0),this.quaternion.setFromEuler(n),this.rot.setFromEuler(n),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Xt?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,n=this.page,r=this.sharedAssets,s=this.object;e.gameActions!==void 0&&Object.entries(e.gameActions).forEach(([o,a],l)=>{a.forEach(({id:u,data:c})=>{try{this.actions[o]===void 0&&(this.actions[o]=[]),c.type==="Transition"?this.actions[o].push(new ko(c,n,r)):c.type==="Animation"?this.actions[o].push(new zo(c,n,this.controlsManager.eventManager.animationControls)):c.type==="Audio"?this.actions[o].push(new Fo(u,c,s,r)):c.type==="Video"?this.actions[o].push(new Jl(u,c,s)):c.type==="Create"&&this.actions[o].push(new Go(c,n,this.controlsManager))}catch{}})}),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"),cn(this.actions)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].forEach(n=>{n instanceof ko?n.play():n instanceof zo?n.play(this.initialAction===!1):n instanceof Go?n.dispatchStart():n instanceof Fo&&n.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].forEach(n=>{n instanceof ko?(n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})):n instanceof zo||(n instanceof Go?n.dispatchStop():n instanceof Fo&&n.dispatchGameControl("stop"))})))}get colliderWorldPosition(){return wr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,n,r){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let u=jr.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*eO),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(c){this.onObject=!0,this.groundNormal.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),c.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let d=c.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let h of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(h.rigidBody===d&&h.userData.isFollowingObj!==this.object.uuid){(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(wr,Ho,jr),this.groundVelocity.subVectors(wr,h.prevT),this.object.getWorldPosition(jr).add(this.collider.position).sub(wr),this.groundYRotation=Zs.setFromQuaternion(Ho).y-h.prevR.y,Ha.copy(jr).applyAxisAngle(ps,this.groundYRotation),this.groundVelocity.add(Ha.sub(jr)).divideScalar(s);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*o),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let u=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 c=wr.subVectors(this.path[1],this.position),d=jr.subVectors(this.path[1],this.path[0]);c.dot(d)<0?this.path.shift():(this.directionXZ.x=d.x,this.directionXZ.z=d.z),u.opacity=u.userData.opacity0}else u.opacity-=.05*u.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=qq.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=jr.copy(l);u.y=0,l.set(0,l.y,u.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let u=wr;this.camera.getWorldDirection(u);let c=Ha.copy(ps).multiplyScalar(u.dot(ps));u.sub(c);let d=jr.copy(this.directionXZ);d.x*=-1,this.rot.y=u.angleTo(d)*(u.cross(d).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(Zs.setFromVector3(this.rot),this.moveMode==="walk"&&(Zs.x=0),l.applyEuler(Zs),a&&(Ho.setFromUnitVectors(ps,this.groundNormal),l.applyQuaternion(Ho)),r){let u=Zs.set(0,this.vrEulerYOffset*tO,0);r.applyEuler(u),l.x+=r.x,l.z+=r.z,this.nonColliderPosOffset.elements[13]+=r.y*s}if(this.usePhysics===!0){let u=jr;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let d=Ha.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),h=c.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),wr.copy(l).divideScalar(this.pixelsPerMeter),s,!1);d.multiplyScalar(this.pixelsPerMeter);let f=lt.is(c)?c:c.object;if(h!==null&&this.lastHitObj!==f){let m;c instanceof rn&&(m=c);let p=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(p)for(let g of p)g.data.target==="character"&&(g.dispatch(m),f.dispatchEvent(jv));this.lastHitObj=f}if(h!==null){this.pushedVelocity.copy(d),u.copy(h.normal1).applyQuaternion(c.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let c=u.dot(l);c<0&&l.addScaledVector(u,-c),l.add(this.pushedVelocity)}else l.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ps,this.euler.y-this.euler0.y);let u=jr.copy(this.objectToCamXZ).normalize(),c=Ha.copy(l).multiplyScalar(s);c.y=0;let d=c.sub(wr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(d,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Ve.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Ve.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Ve.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n?(Zs.copy(n),Zs.y=0):(Zs.copy(this.euler),Zs.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Zs)),n&&(this.moveMode==="walk"?(this.rot.y=n.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(n),this.rot.y+=this.vrEulerYOffset*tO),gi.setFromAxisAngle(Xq,this.rot.x),Ho.setFromAxisAngle(ps,this.rot.y),Ho.multiply(gi),gi.setFromAxisAngle(Qq,this.rot.z),Ho.multiply(gi),this.quaternion.copy(Ho),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let u=jr.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let d=new A;for(let h=0;h<5;h++){let f=u.length(),m=Ha.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),this.colliderWorldQuat,m,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),c!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(c.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let x=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(x){for(let w of x)if(w.data.target==="character"){let S=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,_;if(p.cloner){for(let M of p.cloner.children)if(M.rigidBody===S){_=M;break}}w.dispatch(_),p.dispatchEvent(jv)}}}let g=JD.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=$D.copy(m).multiplyScalar(c.toi).dot(g),v=c.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=c.toi*(y-this.offset)/y,d.addScaledVector(m,v)),u.copy(m).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),w=Ha.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);w.y=0;let S=x.add(w);S.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(S,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),d.add(u);break}}this.position.addScaledVector(d,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(wr.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(gi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let d=0;d<u;d++)this.position.add(c),d===0&&this.checkTrigger(),this.collisionAdjustment(s/u)}else this.position.addScaledVector(l,s);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let u=this.objectToTarget.add(this.position),c=this.targetToCamera.add(u);Vv.lookAt(c,u,ps).setPosition(c),Vv.decompose(this.targetPos,this.targetQuat,wr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Ve.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Ve.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(t9),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?.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(e9),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=gi.setFromAxisAngle(ps,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Ve.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 n;this.cameraXAxis==="Limit"?n=Ve.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=Ve.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let r=wr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&r.applyQuaternion(e);let s=Ho.setFromAxisAngle(r,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){ps.angleTo(e)*180/Math.PI<15||ps.angleTo(e)*180/Math.PI>85?gi.identity():gi.setFromUnitVectors(ps,e),this.groundTilt.slerp(gi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}checkTrigger(){let e;for(let n=0;n<this.sharedGameControlGlobals.triggers.length;n++){let[r,s,o,a]=this.sharedGameControlGlobals.triggers[n];for(let l=0;l<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;l++){let u=this.sharedGameControlGlobals.entitiesWithTransformAnim[l];if(o===u||a.isValidTriggeringObject(lt.is(u)?u:u.object)===!1)continue;let c=a1.copy(o.matrixWorld).decompose(wr,gi,jr).compose(wr,gi,l1).multiply(s),d=Vv.copy(u.matrixWorld).invert().multiply(c);r instanceof _t?e=u.bvhGeometry.boundsTree.intersectsBox(r,d):(c1.radius=r,c1.center.setFromMatrixPosition(d),e=u.bvhGeometry.boundsTree.intersectsSphere(c1)),e?a.currentIntersectedObjects.indexOf(u)===-1&&(a.currentIntersectedObjects.push(u),a.dispatch(),o.dispatchEvent(nO)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(h=>h!==u)}}}collisionAdjustment(e){let n=$D.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let r=Vv.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(wr,gi,jr).compose(wr,gi,l1);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;Ui.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=a1.copy(a).invert(),u=Yq.copy(a1).multiply(r);hr.copy(this.collider.segment),hr.start.applyMatrix4(u),hr.end.applyMatrix4(u);let c=JD.copy(this.position).applyMatrix4(l);Ui.expandByPoint(hr.start),Ui.expandByPoint(hr.end),Ui.min.addScalar(-this.collider.radius),Ui.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(d){return d.distanceToPoint(hr.end)},intersectsBounds:d=>d.intersectsBox(Ui),intersectsTriangle:d=>{let h=wr,f=jr,m=d.closestPointToSegment(hr,h,f);if(m<this.collider.radius){let p=this.collider.radius-m,g=f.sub(h).normalize(),y=Ha.copy(c);y.addScaledVector(g,p);let v=y.applyMatrix4(a).sub(this.position);n.add(v),hr.start.addScaledVector(g,p),hr.end.addScaledVector(g,p)}}})}),Ui.makeEmpty(),hr.copy(this.collider.segment),hr.start.applyMatrix4(r),hr.end.applyMatrix4(r),Ui.expandByPoint(hr.start),Ui.expandByPoint(hr.end),Ui.min.addScalar(-this.collider.radius),Ui.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(hr.end)},intersectsBounds:o=>o.intersectsBox(Ui),intersectsTriangle:o=>{let a=wr,l=jr,u=o.closestPointToSegment(hr,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,d=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(d),n.addScaledVector(d,c),hr.start.addScaledVector(d,c),hr.end.addScaledVector(d,c)}}}),this.onObject=Math.abs(n.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.position.add(n)}},wp=Hv;wp.isLocked=!1;var rO=Ah(fw());function ms(i,t){let e=new Me;if(!i.getAttribute("position"))return e.setAttribute("position",new Ae([],3)),e.setIndex([]),e;let{positions:n,triIndices:r}=Bl(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Ae(n,3)),e.setIndex(r),t&&e.applyMatrix4(t),e}var n9=new ie,r9=new ie,Js=[[0,0,0],[0,0,0],[0,0,0]];function d1(i){let t=i.elements;Js[0][0]=t[0],Js[0][1]=t[4],Js[0][2]=t[8],Js[1][0]=t[1],Js[1][1]=t[5],Js[1][2]=t[9],Js[2][0]=t[2],Js[2][1]=t[6],Js[2][2]=t[10];let{u:e,v:n}=(0,rO.SVD)(Js),r=n9.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=r9.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return r.multiply(s.transpose())}var Wv=class extends Vc{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,n=[]){return t.forEach(r=>{r.visible&&this.intersectObject(r,e,n)}),n}createRaycastLineHelper(){let t=new wi({color:65280,linewidth:10}),e=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new A().addVectors(e,n.multiplyScalar(r)),o=new Me;return o.setFromPoints([e,s]),new cl(o,t)}};var iO=i=>i instanceof No||i instanceof ds;function i9(i,t){return i.distance-t.distance}function sO(i,t,e){if(!(!Ls(t)||!t.visible)){Pr(t)&&t.raycast(i,e);for(let n of t.children)sO(i,n,e)}}function Sp(i,t,e){if(!e.some(r=>fh(i,r)!==void 0))return[];let n=[];return t.children.forEach(r=>sO(i,r,n)),n.sort(i9),n}function Ap(i){let t=[];if(i.length){let e=i[0].object;Ls(e)&&t.push(e);let n=e.parent;for(;n;)iO(n)&&t.push(n),n=n.parent}return t}function fh(i,t){if(Pr(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(iO(t))return oO(i,t)}function oO(i,t){if(!(!Ls(t)||!t.visible)){if(Pr(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let n=oO(i,e);if(n)return n}}}function s9(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var qv=class{constructor(t,e,n,r,s,o,a){this.renderer=t;this.publish=e;this.scene=n;this.getCamera=r;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.raycaster=new Wv;this.raycasterNeedsUpdate=!0;this._useWindowEvents=!1;this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:n}=t.touches?.length>0?t.touches[0]:t,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(s9(e,n,r),this.getCamera())}};var h1=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))(h1||{}),Fn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var f1=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],aO=i=>f1.find(([t,e])=>e===i)?.[0],$s=i=>f1.find(([t])=>t===i)?.[1],o9=(i,t)=>{let e=aO(i);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},Yv=class extends Fn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[aO(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:r}=this.eventContext;r.dispatchEvent(n)};let{page:n}=this.eventContext;n.traverseEntity(r=>{if(!!r.data?.events.length){for(let[s,o]of f1)if(r.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(r):this.objectsPerEvents.set(s,[r]);let a={id:r.uuid,name:r.name},l=o9(o,a),u=this.splineEvents[s];u?u[r.uuid]=l:this.splineEvents[s]={[r.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var p1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.toggle,(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=_n(e,e.actions,r,s,o,n)}disconnect(){cn(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.useToggle===!1&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(r=>r.playing)||this.actions.Transition.forEach(r=>{this.alreadyPlayedNonTogglingActions.has(r)===!1&&r.play()}),this.actions.SwitchCamera.some(r=>r.playing)||this.actions.SwitchCamera.forEach(r=>{r.play()}),this.actions.Animation.forEach(r=>{r.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}},Xv=class extends Fn{constructor(e,n){super(e);this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.windowMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.onWindowMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})};this.onWindowMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(r)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!o.data?.events.length)return;let a=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let l of a){let u=this.eventsPerObjects[l];o.data.events.filter(({data:c})=>c.type===l&&c.disabled!==!0).forEach(({id:c,data:d})=>{try{let h=new p1(c,d,o,r,s,n);h.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?d.mode==="Canvas"&&this.canvasMouseEvents.push(h):u[o.uuid]?u[o.uuid].push(h):u[o.uuid]=[h]}catch(h){!1&&console.log(h)}}),u[o.uuid]?.length&&this.objectsPerTypes[l].push(o)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),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(n=>{Object.values(n).forEach(r=>{r.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:r,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!!o.length)if(n){let a=Sp(r,s,o);Ap(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}else o.forEach(a=>{fh(r,a)&&this.handleObjectMouseEventDispatch(a,e)})}handleMousePressEvent(e=!1){let n="MousePress",r=this.objectsPerTypes[n],s=[];if(!!r.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=Sp(a,l,r);s=Ap(u)}else r.forEach(u=>{fh(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatchRelease()})}handleKeyEvent(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(r?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(r)})})}};var a9=new A,l9=new A;var Qv=class{constructor(t,e,n,r,s){this.actionsIn=_n(t,t.inActions,n,r,s,e),this.actionsOut=_n(t,t.outActions,n,r,s,e)}disconnect(){cn(this.actionsIn),cn(this.actionsOut)}};var m1=class extends Qv{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{let e=a9.setFromMatrixPosition(this.objects[0].matrixWorld),n=l9.setFromMatrixPosition(this.objects[1].matrixWorld),r=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==r){let s=r==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),this.stage=r}};let{distance:l,fromObject:u,toObject:c}=n.condition;this.distance=l;for(let d of[u,c]){if(!d)throw new Error("Missing property");let h=s.find(d);if(!h)throw new Error("Missing property");this.objects.push(h)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},g1=class extends Qv{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(r=>r.dispatchConditional()),this.actionsOut.Video.forEach(r=>r.dispatchConditional()),this.actionsOut.Link.forEach(r=>r.dispatch()),this.actionsOut.Create.forEach(r=>r.dispatch()),this.actionsOut.Destroy.forEach(r=>r.dispatch()),this.actionsOut.Reset.forEach(r=>r.dispatch()),this.actionsIn.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(r=>r.play()),this.actionsOut.Animation.forEach(r=>r.play()),this.actionsIn.SwitchCamera.forEach(r=>r.pause()),this.actionsOut.SwitchCamera.forEach(r=>r.play()),this.actionsOut.SceneTransition.forEach(r=>r.dispatch()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(r=>r.dispatchConditional()),this.actionsIn.Video.forEach(r=>r.dispatchConditional()),this.actionsIn.Link.forEach(r=>r.dispatch()),this.actionsIn.Create.forEach(r=>r.dispatch()),this.actionsIn.Destroy.forEach(r=>r.dispatch()),this.actionsIn.Reset.forEach(r=>r.dispatch()),this.actionsOut.Transition.forEach(r=>r.pause()),this.actionsOut.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(r=>r.play()),this.actionsIn.Animation.forEach(r=>r.play()),this.actionsOut.SwitchCamera.forEach(r=>r.pause()),this.actionsIn.SwitchCamera.forEach(r=>r.play()),this.actionsIn.SceneTransition.forEach(r=>r.dispatch()))};let{condition:l}=n;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Kv=class extends Fn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new m1(a,l,o,r,s,n):l.condition.type==="State"&&(u=new g1(a,l,o,r,s,n))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var _p=new A,ja=new A,$l=new A,lO=new vn,c9=.01,Lt=new A,Kn=new A,cO=new A,ec=new qe,y1=new Gt,u9=new ie,v1=new en,ph=new A,eo=new A,mh=.2;function x1(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var d9=function(){let i=new ie;return(t,e,n)=>{let r=t.obj;i.copy(r.hiddenMatrix),r.parent!==null&&i.premultiply(r.parent.matrixWorld),i.invert(),r.position.copy(e),t.reference==="global"&&x1(r.position,t.limits),r.position.applyMatrix4(i),t.reference==="parent"?x1(r.position,t.limits):t.reference==="local"&&(ec.copy(t.quat0).invert(),r.position.sub(t.position0),r.position.applyQuaternion(ec),x1(r.position,t.limits),ec.invert(),r.position.applyQuaternion(ec),r.position.add(t.position0)),i.multiply(n??r.matrixWorld).decompose(Lt,r.quaternion,Kn),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r instanceof Vt&&Hr(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),b1=class{constructor(t,e,n,r,s,o){this.object=t;this.data=e;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=_n(e,e.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=_n(e,e.dragDropActions.drop,n,r,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new qe().copy(l.quaternion),snapped:!1,orientationMatrix:new ie,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){cn(this.actionsDrag),cn(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Zv=class extends Fn{constructor(e,n){super(e);this.eventManager=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||lt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Lt,ec,Kn),y1.setFromQuaternion(ec),d.prevR===void 0?(d.prevR=y1.clone(),d.prevT=Lt.clone()):(d.prevR.copy(y1),d.prevT.copy(Lt)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(ke.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||lt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof No)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||r.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=cO.copy(a.face.normal).applyMatrix3(v1.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Lt.copy(l).applyMatrix3(v1.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Lt.x>mh?Kn.x=-u.recursiveBBox.min.x:Lt.x<-mh&&(Kn.x=-u.recursiveBBox.max.x),Lt.y>mh?Kn.y=-u.recursiveBBox.min.y:Lt.y<-mh&&(Kn.y=-u.recursiveBBox.max.y),Lt.z>mh?Kn.z=-u.recursiveBBox.min.z:Lt.z<-mh&&(Kn.z=-u.recursiveBBox.max.z),Kn.applyMatrix3(v1.invert())}else Kn.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Kn)}this.activeEvent.data.autoOrient&&(Lt.set(0,1,0).cross(l),Lt.length()<1e-4&&Lt.set(-1,0,0).cross(l),Kn.crossVectors(cO,Lt),o.orientationMatrix.makeBasis(Lt,Kn,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(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.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),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.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.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=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||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(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(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")})),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let r={};e.page.traverseEntity(s=>{s.component&&(r[s.component.uuid]?r[s.component.uuid].push(s.uuid):r[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new b1(s,o.data,e.page,e.sharedAssets,n,r))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,r,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(ja),ja.negate();let l=ec.identity();switch(s==="parent"?u9.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Lt,l,Kn):s==="local"&&e.matrixWorld.decompose(Lt,l,Kn),r){case"x":Lt.set(1,0,0).applyQuaternion(l),ph.copy(ja).cross(Lt),eo.copy(Lt).cross(ph);break;case"y":Lt.set(0,1,0).applyQuaternion(l),ph.copy(ja).cross(Lt),eo.copy(Lt).cross(ph);break;case"z":Lt.set(0,0,1).applyQuaternion(l),ph.copy(ja).cross(Lt),eo.copy(Lt).cross(ph);break;case"xy":eo.set(0,0,1).applyQuaternion(l);break;case"yz":eo.set(1,0,0).applyQuaternion(l);break;case"xz":eo.set(0,1,0).applyQuaternion(l);break;case"adaptive":ja.angleTo(Kn.set(0,1,0))>Math.PI/6?(Lt.crossVectors(Kn.set(0,1,0),ja),eo.crossVectors(Lt,Kn)):eo.set(0,1,0);break;default:eo.copy(ja);break}$l.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:$l;if(lO.setFromNormalAndCoplanarPoint(eo,u),!!a.ray.intersectPlane(lO,n)&&(r==="x"||r==="y"||r==="z")){let c=Kn.subVectors(n,u).dot(Lt);n.copy(u).addScaledVector(Lt,c)}}updateDragItem(e,n=!1){$l.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?_p.subVectors(e.fromPosition,$l).divideScalar(e.currentDampingFactor):e.reset==="original"?(_p.subVectors(e.obj.userData.worldPosition0,$l).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):_p.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub($l).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?_p.length()<c9:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&d9(e,_p.add($l),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var gh=new A,w1=new A,jo=new A,Wo=new A,uO=new vn,h9=.01,f9={type:"requestRender"},p9=function(){let i=new A,t=new A;return(e,n,r)=>r>0?(i.subVectors(e,n),i.length()<=r?e:t.copy(n).add(i.normalize().multiplyScalar(r))):n}(),dO=function(){let i=new ie;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Vt&&Hr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),S1=class{constructor(t,e,n,r,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Ug.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=_n(t,t.actions,n,r,s,e)}},Jv=class extends Fn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!r.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new S1(o.data,s,r,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,o=this.onTargetChange(r);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let r of this.events)r.paused=!0,r.isReset=!1,cn(r.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:r,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(jo),e.isReset)Wo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Wo);else{let{getCamera:l,raycaster:u}=this.eventContext;if(r==="custom"?(l().getWorldDirection(w1),w1.negate(),gh.copy(w1)):r==="xy"?gh.set(0,0,1):r==="xz"?gh.set(0,1,0):r==="yz"&&gh.set(1,0,0),uO.setFromNormalAndCoplanarPoint(gh,jo),!u.ray.intersectPlane(uO,Wo))return}if(!e.isReset){if(Wo.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Wo.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&&(Wo.x=jo.x),e.data.enabledTranslation[1]===!1&&(Wo.y=jo.y),e.data.enabledTranslation[2]===!1&&(Wo.z=jo.z);let a=p9(jo,Wo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=gh.subVectors(a,jo).divideScalar(e.currentDampingFactor);jo.add(l),n&&dO(e.object,jo),e.paused=l.length()<h9}else dO(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(f9)}};var Mp=new A,$v=new A,Ep=new ie,yh=new qe,Wa=new qe,Tp=new A,Cp=new A,tc=new A,qo=new A,A1=new vn,m9=1e-6,g9={type:"requestRender"},y9={type:"changeRotation"},hO=function(){let i=new ie;return function(e,n){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),n.premultiply(d1(i).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof Vt&&Hr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),_1=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new qe;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...kg.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},e0=class extends Fn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:r})=>{if(!n||!r)return;let s=$s(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(r=>{let s=r.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new _1(s.data,r,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let a=this.onTargetChange(r),l=r.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(r),o=r.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let[r,s]of this.pairOfUserEventListeners)r.removeEventListener("userEvent",s);for(let r of this.events)r.paused=!0,r.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:r,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:d}=this.eventContext,{object:h,target:f}=e;if(h.getWorldPosition(Tp),!e.isReset)if(e.target)e.target.getWorldPosition(Cp);else{if(o==="custom"?(c().getWorldDirection($v),$v.negate(),A1.setFromNormalAndCoplanarPoint($v,Tp)):(o==="xy"?Mp.set(0,0,1):o==="xz"?Mp.set(0,1,0):o==="yz"&&Mp.set(1,0,0),A1.setFromNormalAndCoplanarPoint(Mp,Tp)),!d.ray.intersectPlane(A1,Cp))return;s>0&&(o==="custom"||o===void 0)&&Cp.addScaledVector($v,s)}if(e.isReset||(f?n==="target"?tc.copy(f.up).applyMatrix4(Ep.extractRotation(f.matrixWorld)).normalize():l.some(m=>m===!1)?(r==="x"?(qo.set(0,0,1),l[2]===!1&&qo.set(0,1,0)):r==="y"?(qo.set(1,0,0),l[0]===!1&&qo.set(0,0,1)):(qo.set(0,1,0),l[1]===!1&&qo.set(1,0,0)),tc.copy(qo).applyQuaternion(e.worldQuaternion0).normalize()):tc.set(0,1,0):o==="custom"?tc.set(0,1,0):tc.copy(Mp)),e.isReset)Wa.copy(e.worldQuaternion0);else if(Tp.distanceTo(Cp)>a&&u&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Wa.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;v9(Ep,Cp,Tp,tc,r,qo),Wa.setFromRotationMatrix(Ep),yh.setFromUnitVectors(qo.applyQuaternion(Wa),tc),l.some(m=>m===!1)&&n!=="target"&&Wa.premultiply(yh).normalize()}e.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),yh.setFromRotationMatrix(d1(h.matrixWorld)),yh.slerp(Wa,1/e.currentDampingFactor),hO(h,Ep.makeRotationFromQuaternion(yh)),e.paused=8*(1-yh.dot(Wa))<m9):(hO(h,Ep.makeRotationFromQuaternion(Wa)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(g9),h.dispatchEvent(y9)}},ki=new A,Zn=new A,Mn=new A;function v9(i,t,e,n,r,s){let o=i.elements;Mn.subVectors(t,e),Mn.lengthSq()===0&&(Mn.z=1),Mn.normalize(),Zn.crossVectors(n,Mn),Zn.lengthSq()===0&&(Math.abs(n.z)===1?Mn.x+=1e-4:Mn.z+=1e-4,Mn.normalize(),Zn.crossVectors(n,Mn)),Zn.normalize(),ki.crossVectors(Mn,Zn),r==="x"?s.z===1?[Zn,ki,Mn]=[Mn,Zn,ki]:(Zn.negate(),[Zn,Mn]=[Mn,Zn]):r==="y"?s.x===1?[Zn,ki,Mn]=[ki,Mn,Zn]:(Zn.negate(),[ki,Mn]=[Mn,ki]):s.x===1&&(Zn.negate(),[Zn,ki]=[ki,Zn]),o[0]=Zn.x,o[4]=ki.x,o[8]=Mn.x,o[1]=Zn.y,o[5]=ki.y,o[9]=Mn.y,o[2]=Zn.z,o[6]=ki.z,o[10]=Mn.z}var M1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=_n(e,e.actions,r,s,o,n)}disconnect(){cn(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch())}},t0=class extends Fn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{ke.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(r)))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new M1(a,l,o,r,s,n);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(r=>{r.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:r,raycaster:s,page:o}=this.eventContext;if(r){let a=Sp(s,o,this.objects);n=Ap(a)}else this.objects.forEach(a=>{fh(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(r=>{n.includes(r)||(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(r=>{r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var E1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=_n(e,e.actions,r,s,o,n)}connect(){this.scrollCounter=0}disconnect(){cn(this.actions)}dispatch(t){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(n)),this.actions.Animation.forEach(r=>r.seek(e)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled())}},T1=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=_n(e,e.actions,r,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,r=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){cn(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let n=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled())}},n0=class extends Fn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),r.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))};let{page:r,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;r.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let d=new E1(u,c,l,r,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(d):this.wheelEventsPerObject.set(l,[d])}else{let d=new T1(u,c,l,r,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(d):this.scrollEventsPerObject.set(l,[d])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var C1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=_n(e,e.actions,r,s,o,n)}disconnect(){cn(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof Xs?e.interaction.audioPlayer.play():e.interaction instanceof uh&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof Vo?e.interaction.play(n==="autoplay"):e.interaction instanceof hh&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof Xs?e.interaction.audioPlayer.play():e.interaction instanceof uh&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Vo?e.interaction.play():e.interaction instanceof hh&&e.interaction.dispatch()})}},r0=class extends Fn{constructor(e,n){super(e);this.eventManager=n;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.actions.Audio.forEach(s=>{s.interaction instanceof Xs&&s.interaction.audioPlayer.play()}),r.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Vo&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))}}connect(){let{sharedAssets:e,page:n}=this.eventContext;if(n.traverseEntity(r=>{if(!!r.data?.events.length)for(let{id:s,data:o}of r.data.events){if(o.disabled||o.type!=="Start")continue;let a=new C1(s,o,r,n,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,o=s?document:r;o.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),o.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,l])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,r=n?document:e;r.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),r.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(r=>r.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var i0=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!1;this.actions=_n(e,e.actions,r,s,o,n),this.target=e.target,this.useToggle=e.toggle}disconnect(){cn(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var pO=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.400/build/",x9=!1?pO:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.400/build/",b9=`
6237
+ )`}else if(i.easing===6){let{mass:e,stiffness:n,damping:r,velocity:s}=i;t=`spring( ${e}, ${n}, ${r}, ${s} )`}else{let e;switch(i.easing){case 0:e=_o.linear;break;case 1:e=_o.ease;break;case 2:e=_o.easeIn;break;case 3:e=_o.easeOut;break;case 4:e=_o.easeInOut;break;default:e=_o.linear}let[n,r,s,o]=e;t=`cubicBezier( ${n}, ${r}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function jD(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.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,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var zq={type:"beginState"},Gq={type:"completeState",isfromEntity:!1},Gv=class{constructor(t,e,n,r,s,o){this.object=t;this.data=r;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Xt&&e.dispatchEvent(zq)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Xt&&e.dispatchEvent(Gq)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=r1(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=zv(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=zv(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=zv(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...jD(r),...i1(r),change:this.onChange},this.callback=r1(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},ko=class extends Ut{constructor(e,n,r){super();this.data=e;this.page=n;this.sharedAssets=r;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=zv(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:n=!1}={}){try{let r=jD(this.data.tweens[0].data),s=r.loop;n&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=Uv.timeline({autoplay:!1,...r,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),r.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Xt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new Gv(this.object,d,c.data.state===void 0?this.currentState:c.data.state,c.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?r.delay:0)+(l===a&&!n?r.pingPongDelayCorrection:0))}this.timeline.duration+=r.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Xt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new Gv(this.object,d,c.data.state===void 0?this.currentState:c.data.state,u.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l-1]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?r.endDelay:0))}this.timeline.duration+=r.delay+(n?0:r.pingPongDelayCorrection)}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function zv(i,t){let e,n;if(typeof t=="string"?(e=t,n=i.states?.[e]):t===null&&(e=null,n=i.data),!(e===void 0||n===void 0))return{id:e,data:n}}var Vq={type:"beginState"},WD={type:"completeState",isfromEntity:!1},qD={type:"requestRender"},vp=class extends Ut{constructor(e,n){super();this.data=e;this.page=n;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new qe;this.qEnd=new qe;this.zoomStart=1;this.zoomEnd=1;this.toCamera=this.page.scene.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let n={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=Uv({targets:n,t:1,...i1(this.data),update:()=>{n.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)),this.page.activeCamera.dispatchEvent(Vq));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,n.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(qD),n.t===1&&r.dispatchEvent(WD)}})}switchCamera(e){this.page.switchActiveCamera(e),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:e})}play(){this.playing||this.page.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.page.activeCamera.dispatchEvent(WD),this.page.activeCamera.dispatchEvent(qD))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var zo=class extends Ut{constructor(e,n,r){super();this.page=n;this.animationControls=r;this.startOnceDelay=0;this.toggleIsForward=!1;let s=e.object,o=n.scene.find(e.object);o&&Array.isArray(o.identity)&&(s=o.identity[0]),this.data={...e,object:s};let a=this.animationControls.clipIdToAction[e.clipId+"/"+s];this.duration=a?.getClip()?.duration??1;let l=a?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){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 n=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let o=r.split("/")[1];this.threeAnimAction!==s&&o===n&&s.isRunning()&&(e?s.fadeOut(.2):s.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Ve.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,n=!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 r=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===r&&o.isRunning()&&(n?o.fadeOut(.2):o.stop())}),n&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var xp=class{constructor(t,e,n,r){this.data=t;this.page=e;this.eventManager=n;this.shared=r;this.timeOutId=-1;this.scene=e.scene}dispatch(){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(n=>n.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),dh(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function _n(i,t,e,n,r,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[]};return t.forEach(({id:a,data:l})=>{try{l.type==="Audio"?Zi[i.type].includes("Audio")&&o.Audio.push(new Fo(a,l,s,n)):l.type==="Video"?Zi[i.type].includes("Video")&&o.Video.push(new Jl(a,l,s)):l.type==="Link"?Zi[i.type].includes("Link")&&o.Link.push(new Dv(l,r)):l.type==="Create"?Zi[i.type].includes("Create")&&o.Create.push(new Go(l,e,r.controlsManager)):l.type==="Destroy"?Zi[i.type].includes("Destroy")&&o.Destroy.push(new gp(l,e,r)):l.type==="Reset"?Zi[i.type].includes("Reset")&&o.Reset.push(new Ov(e,n,r)):l.type==="Transition"?Zi[i.type].includes("Transition")&&o.Transition.push(new ko(l,e,n)):l.type==="SwitchCamera"?Zi[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new vp(l,e)):l.type==="SceneTransition"?Zi[i.type].includes("SceneTransition")&&o.SceneTransition.push(new xp(l,e,r,n)):l.type==="Animation"&&Zi[i.type].includes("Animation")&&o.Animation.push(new zo(l,e,r.animationControls))}catch(u){!1&&console.log(u)}}),o}function cn(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Fo||e instanceof Jl||e instanceof zo||e instanceof ko||e instanceof Go||e instanceof gp||e instanceof vp||e instanceof xp)&&e.dispose()})})}function YD(i,t){let e;if("material"in i){let n=i.material;Array.isArray(n)?e=i.material[0].layers.find(r=>r.uuid===t):e=i.material.layers.find(r=>r.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var XD=new Map,bp=new Map,Vo=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:r,loop:s,volume:o,delay:a}=e;if(this.object=n,r===void 0)throw new Error("Missing property");let l=YD(n,r);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),bp.has(n.uuid)?bp.get(n.uuid).push(this):bp.set(n.uuid,[this]),XD.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let n=this.videoElement.play();n!==void 0&&n.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},hh=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=XD.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=bp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let t=[...bp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Jl=class{constructor(t,e,n){this.data=e;if(e.interaction==="play")this.interaction=new Vo(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new hh(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Vo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Vo?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var QD=(()=>{let i,t,e,n;function r(a){!i&&!KD()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,n=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,d=u.length,h=0;for(;h<d;){let f=u[h];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),n()),h++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(h,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(m=>m.bvhGeometry!==void 0)),d--,n())}i=h>0?requestAnimationFrame(s):void 0,e=h>0?a:void 0}function o(){KD()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):r()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),r})();function KD(){return!!document&&document.hidden}var ZD=new qe,Hq=new A,jq=new A,Go=class{constructor(t,e,n){this.data=t;this.page=e;this.controlsManager=n;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Ve.generateUUID();this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=hb(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=()=>{if(this.timeoutIdQueue.shift(),this.object===void 0)return;let t=new rn(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem,r=this.page.scene.find(n);r&&(r.updateMatrixWorldSVD(),t.hiddenMatrix.copy(r.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),QD(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof ur)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof rn)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof ur)return;t instanceof rn?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let n=new A().fromArray(this.data.velocity),r=e.dataPatched;if(!(r.physics.enabled==="visibility"?!r.visible:!r.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(Hq,ZD,jq),n.applyQuaternion(ZD),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(n.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=n)),e.dataPatched.physics?.fusedBody===!0))return!0};this.object=this.page.scene.find(this.data.object),QD(n)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var u1=200,s1=.02,o1=.3,Wq=65,sDe=new A,JD=new A,$D=new A,qq=new A,wr=new A,jr=new A,Ha=new A,Vv=new ie,a1=new ie,Yq=new ie,oDe=new ie,gi=new qe,Ho=new qe,Zs=new Gt(0,0,0,"YXZ"),Xq=new A(1,0,0),ps=new A(0,1,0),Qq=new A(0,0,1),l1=new A(1,1,1),c1=new dn,Kq=1,Zq=.025,Jq=16e-6,eO=12,$q=20,hr=new Hn,Ui=new _t,e9={type:"requestRender"},t9={type:"updateMatrix"},tO=Math.PI/6,Hv=class extends Ut{constructor(e,n,r,s,o,a,l,u,c){super();this.object=e;this.domElement=n;this.data=r;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new ie;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=u1;this.euler0=new Gt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new qe;this.scale0Cam=new A;this.hiddenMatrix0Cam=new ie;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Hn(new A(0,-40,0),new A(0,40,0)),matrix:new ie,position:new A,rotation:new qe};this.euler=new Gt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastPosition=new A;this.lastCameraQuaternion=new qe;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new F;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.nonColliderRotOffset=new ie;this.nonColliderPosOffset=new ie;this.firstPointerId=-1;this.rot=new A;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 ie;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new qe;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new qe;this.objXZQuatInv=new qe;this.objXZRotMat=new ie;this.isFirstPerson=!1;this.actions={};this.didHit=!1;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new qe;this.colliderWorldQuat=new qe;this.groundNormal=new A;this.groundTilt=new qe;this.groundTiltInv=new qe;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new A;this.quaternion=new qe;this.scale=new A;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Wn&&(!fb||pb>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let n=e.clientX-this.prevMouse.x,r=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(fb&&pb<15.5&&!Wn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-r*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-r*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Hv.isLocked=!0:Hv.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]){this.movementState[n[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]||e.code.slice(3,e.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.copyVRGamePadValues=(e,n)=>{for(let r=2;r<4;r++){let s=e.axes[r];n===0?r===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,r===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let d=this.euler0.clone(),h=d.y;if(this.objectRealQuat.copy(this.quaternion),d.y=0,this.quaternion.setFromEuler(d),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),d.set(0,h,0),this.quaternion.setFromEuler(d),this.rot.setFromEuler(d),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let g=new A(0,0,-1).applyQuaternion(this.camera.quaternion),y=new A().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let w=new Gt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-w.x,w.x=0,w.z=0,w.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(w)}if(this.object instanceof Xt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=r.rotByTouch??"joystick",this.rotBy=r.rotBy??"keys",this.rotationMode=r.rotationMode??"normal",this.moveMode=r.moveMode??"walk",this.collisionEnabled=r.collisionEnabled,this.speedTranslate=(r.speedTranslate??250)*Kq,this.speedOrbit=(r.speedRotate??100)*Zq,this.mouseOrbitSensitivity=(r.speedRotate??100)*Jq,this.keyAssignments=r.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),r.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((r.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((r.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((r.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((r.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((r.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((r.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Ma.defaultData.gravity)*eO,this.usePhysics=this.gloabalPhysics.usePhysics??Ma.defaultData.usePhysics,this.jumpPower=r.jumpPower*$q,this.resetYPosition=this.position.y+Math.abs(r.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=r.alignToGround??!1,this.orientMode=r.autoOrientMove?r.orientMode:"none",this.orientWith=r.orientWith??Fu.defaultDataThirdPerson.orientWith,this.slopeThresh=Wq*Math.PI/180,r.collider.type==="capsule"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=r.collider.height/2-r.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=r.collider.height*s1/this.pixelsPerMeter,this.stepThresh=r.collider.height*o1/this.pixelsPerMeter,this.colliderHeight=r.collider.height):r.collider.type==="sphere"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*r.collider.radius*s1/this.pixelsPerMeter,this.stepThresh=2*r.collider.radius*o1/this.pixelsPerMeter,this.colliderHeight=r.collider.radius*2):(this.offset=r.collider.height*s1/this.pixelsPerMeter,this.stepThresh=r.collider.height*o1/this.pixelsPerMeter,this.colliderHeight=r.collider.height),this.collider.type=r.collider.type;let f=new A().fromArray(r.collider.position),m=new qe().setFromEuler(new Gt().fromArray([...r.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(m),this.collider.matrix.compose(f,m,l1),r.cameraXAxis!==void 0&&(this.cameraXAxis=r.cameraXAxis,this.cameraYAxis=r.cameraYAxis,this.minPolarAngle=r.cameraRotXLimits[0],this.maxPolarAngle=r.cameraRotXLimits[1],this.minAzimuthAngleRel=r.cameraRotYLimits[0],this.maxAzimuthAngleRel=r.cameraRotYLimits[1]),this.forwardDir=r.forwardDirection??"-z",this.runMultiplier=r.runMultiplier??2;let p=r.navmesh.destinationHelperRadius*2;p>0&&(this.navMeshPathDest=new Dn(vy.create({parameters:{width:p,height:p/10,hollow:.7}}),new Wi({color:Nn.toHex(r.navmesh.destinationHelperColor),transparent:!0,opacity:r.navmesh.destinationHelperColor.a})),this.navMeshPathDest.material.userData.opacity0=r.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 n=new Gt().setFromQuaternion(this.quaternion,"YXZ"),r=n.y;this.objectRealQuat.copy(this.quaternion),n.y=0,this.quaternion.setFromEuler(n),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),n.set(0,r,0),this.quaternion.setFromEuler(n),this.rot.setFromEuler(n),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Xt?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,n=this.page,r=this.sharedAssets,s=this.object;e.gameActions!==void 0&&Object.entries(e.gameActions).forEach(([o,a],l)=>{a.forEach(({id:u,data:c})=>{try{this.actions[o]===void 0&&(this.actions[o]=[]),c.type==="Transition"?this.actions[o].push(new ko(c,n,r)):c.type==="Animation"?this.actions[o].push(new zo(c,n,this.controlsManager.eventManager.animationControls)):c.type==="Audio"?this.actions[o].push(new Fo(u,c,s,r)):c.type==="Video"?this.actions[o].push(new Jl(u,c,s)):c.type==="Create"&&this.actions[o].push(new Go(c,n,this.controlsManager))}catch{}})}),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"),cn(this.actions)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].forEach(n=>{n instanceof ko?n.play():n instanceof zo?n.play(this.initialAction===!1):n instanceof Go?n.dispatchStart():n instanceof Fo&&n.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].forEach(n=>{n instanceof ko?(n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})):n instanceof zo||(n instanceof Go?n.dispatchStop():n instanceof Fo&&n.dispatchGameControl("stop"))})))}get colliderWorldPosition(){return wr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,n,r){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let u=jr.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*eO),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(c){this.onObject=!0,this.groundNormal.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),c.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let d=c.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let h of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(h.rigidBody===d&&h.userData.isFollowingObj!==this.object.uuid){(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(wr,Ho,jr),this.groundVelocity.subVectors(wr,h.prevT),this.object.getWorldPosition(jr).add(this.collider.position).sub(wr),this.groundYRotation=Zs.setFromQuaternion(Ho).y-h.prevR.y,Ha.copy(jr).applyAxisAngle(ps,this.groundYRotation),this.groundVelocity.add(Ha.sub(jr)).divideScalar(s);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*o),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let u=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 c=wr.subVectors(this.path[1],this.position),d=jr.subVectors(this.path[1],this.path[0]);c.dot(d)<0?this.path.shift():(this.directionXZ.x=d.x,this.directionXZ.z=d.z),u.opacity=u.userData.opacity0}else u.opacity-=.05*u.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=qq.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=jr.copy(l);u.y=0,l.set(0,l.y,u.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let u=wr;this.camera.getWorldDirection(u);let c=Ha.copy(ps).multiplyScalar(u.dot(ps));u.sub(c);let d=jr.copy(this.directionXZ);d.x*=-1,this.rot.y=u.angleTo(d)*(u.cross(d).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(Zs.setFromVector3(this.rot),this.moveMode==="walk"&&(Zs.x=0),l.applyEuler(Zs),a&&(Ho.setFromUnitVectors(ps,this.groundNormal),l.applyQuaternion(Ho)),r){let u=Zs.set(0,this.vrEulerYOffset*tO,0);r.applyEuler(u),l.x+=r.x,l.z+=r.z,this.nonColliderPosOffset.elements[13]+=r.y*s}if(this.usePhysics===!0){let u=jr;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let d=Ha.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),h=c.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),wr.copy(l).divideScalar(this.pixelsPerMeter),s,!1);d.multiplyScalar(this.pixelsPerMeter);let f=lt.is(c)?c:c.object;if(h!==null&&this.lastHitObj!==f){let m;c instanceof rn&&(m=c);let p=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(p)for(let g of p)g.data.target==="character"&&(g.dispatch(m),f.dispatchEvent(jv));this.lastHitObj=f}if(h!==null){this.pushedVelocity.copy(d),u.copy(h.normal1).applyQuaternion(c.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let c=u.dot(l);c<0&&l.addScaledVector(u,-c),l.add(this.pushedVelocity)}else l.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ps,this.euler.y-this.euler0.y);let u=jr.copy(this.objectToCamXZ).normalize(),c=Ha.copy(l).multiplyScalar(s);c.y=0;let d=c.sub(wr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(d,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Ve.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Ve.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Ve.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n?(Zs.copy(n),Zs.y=0):(Zs.copy(this.euler),Zs.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Zs)),n&&(this.moveMode==="walk"?(this.rot.y=n.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(n),this.rot.y+=this.vrEulerYOffset*tO),gi.setFromAxisAngle(Xq,this.rot.x),Ho.setFromAxisAngle(ps,this.rot.y),Ho.multiply(gi),gi.setFromAxisAngle(Qq,this.rot.z),Ho.multiply(gi),this.quaternion.copy(Ho),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let u=jr.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let d=new A;for(let h=0;h<5;h++){let f=u.length(),m=Ha.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),this.colliderWorldQuat,m,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),c!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(c.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let x=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(x){for(let w of x)if(w.data.target==="character"){let S=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,_;if(p.cloner){for(let M of p.cloner.children)if(M.rigidBody===S){_=M;break}}w.dispatch(_),p.dispatchEvent(jv)}}}let g=JD.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=$D.copy(m).multiplyScalar(c.toi).dot(g),v=c.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=c.toi*(y-this.offset)/y,d.addScaledVector(m,v)),u.copy(m).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(d),w=Ha.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);w.y=0;let S=x.add(w);S.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(S,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),d.add(u);break}}this.position.addScaledVector(d,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(wr.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(gi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let d=0;d<u;d++)this.position.add(c),d===0&&this.checkTrigger(),this.collisionAdjustment(s/u)}else this.position.addScaledVector(l,s);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let u=this.objectToTarget.add(this.position),c=this.targetToCamera.add(u);Vv.lookAt(c,u,ps).setPosition(c),Vv.decompose(this.targetPos,this.targetQuat,wr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Ve.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Ve.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(t9),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?.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(e9),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=gi.setFromAxisAngle(ps,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Ve.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 n;this.cameraXAxis==="Limit"?n=Ve.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=Ve.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let r=wr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&r.applyQuaternion(e);let s=Ho.setFromAxisAngle(r,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){ps.angleTo(e)*180/Math.PI<15||ps.angleTo(e)*180/Math.PI>85?gi.identity():gi.setFromUnitVectors(ps,e),this.groundTilt.slerp(gi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}checkTrigger(){let e;for(let n=0;n<this.sharedGameControlGlobals.triggers.length;n++){let[r,s,o,a]=this.sharedGameControlGlobals.triggers[n];for(let l=0;l<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;l++){let u=this.sharedGameControlGlobals.entitiesWithTransformAnim[l];if(o===u||a.isValidTriggeringObject(lt.is(u)?u:u.object)===!1)continue;let c=a1.copy(o.matrixWorld).decompose(wr,gi,jr).compose(wr,gi,l1).multiply(s),d=Vv.copy(u.matrixWorld).invert().multiply(c);r instanceof _t?e=u.bvhGeometry.boundsTree.intersectsBox(r,d):(c1.radius=r,c1.center.setFromMatrixPosition(d),e=u.bvhGeometry.boundsTree.intersectsSphere(c1)),e?a.currentIntersectedObjects.indexOf(u)===-1&&(a.currentIntersectedObjects.push(u),a.dispatch(),o.dispatchEvent(nO)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(h=>h!==u)}}}collisionAdjustment(e){let n=$D.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let r=Vv.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(wr,gi,jr).compose(wr,gi,l1);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;Ui.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=a1.copy(a).invert(),u=Yq.copy(a1).multiply(r);hr.copy(this.collider.segment),hr.start.applyMatrix4(u),hr.end.applyMatrix4(u);let c=JD.copy(this.position).applyMatrix4(l);Ui.expandByPoint(hr.start),Ui.expandByPoint(hr.end),Ui.min.addScalar(-this.collider.radius),Ui.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(d){return d.distanceToPoint(hr.end)},intersectsBounds:d=>d.intersectsBox(Ui),intersectsTriangle:d=>{let h=wr,f=jr,m=d.closestPointToSegment(hr,h,f);if(m<this.collider.radius){let p=this.collider.radius-m,g=f.sub(h).normalize(),y=Ha.copy(c);y.addScaledVector(g,p);let v=y.applyMatrix4(a).sub(this.position);n.add(v),hr.start.addScaledVector(g,p),hr.end.addScaledVector(g,p)}}})}),Ui.makeEmpty(),hr.copy(this.collider.segment),hr.start.applyMatrix4(r),hr.end.applyMatrix4(r),Ui.expandByPoint(hr.start),Ui.expandByPoint(hr.end),Ui.min.addScalar(-this.collider.radius),Ui.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(hr.end)},intersectsBounds:o=>o.intersectsBox(Ui),intersectsTriangle:o=>{let a=wr,l=jr,u=o.closestPointToSegment(hr,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,d=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(d),n.addScaledVector(d,c),hr.start.addScaledVector(d,c),hr.end.addScaledVector(d,c)}}}),this.onObject=Math.abs(n.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.position.add(n)}},wp=Hv;wp.isLocked=!1;var rO=Ah(fw());function ms(i,t){let e=new Me;if(!i.getAttribute("position"))return e.setAttribute("position",new Ae([],3)),e.setIndex([]),e;let{positions:n,triIndices:r}=Bl(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Ae(n,3)),e.setIndex(r),t&&e.applyMatrix4(t),e}var n9=new ie,r9=new ie,Js=[[0,0,0],[0,0,0],[0,0,0]];function d1(i){let t=i.elements;Js[0][0]=t[0],Js[0][1]=t[4],Js[0][2]=t[8],Js[1][0]=t[1],Js[1][1]=t[5],Js[1][2]=t[9],Js[2][0]=t[2],Js[2][1]=t[6],Js[2][2]=t[10];let{u:e,v:n}=(0,rO.SVD)(Js),r=n9.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=r9.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return r.multiply(s.transpose())}var Wv=class extends Vc{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,n=[]){return t.forEach(r=>{r.visible&&this.intersectObject(r,e,n)}),n}createRaycastLineHelper(){let t=new wi({color:65280,linewidth:10}),e=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new A().addVectors(e,n.multiplyScalar(r)),o=new Me;return o.setFromPoints([e,s]),new cl(o,t)}};var iO=i=>i instanceof No||i instanceof ds;function i9(i,t){return i.distance-t.distance}function sO(i,t,e){if(!(!Ls(t)||!t.visible)){Pr(t)&&t.raycast(i,e);for(let n of t.children)sO(i,n,e)}}function Sp(i,t,e){if(!e.some(r=>fh(i,r)!==void 0))return[];let n=[];return t.children.forEach(r=>sO(i,r,n)),n.sort(i9),n}function Ap(i){let t=[];if(i.length){let e=i[0].object;Ls(e)&&t.push(e);let n=e.parent;for(;n;)iO(n)&&t.push(n),n=n.parent}return t}function fh(i,t){if(Pr(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(iO(t))return oO(i,t)}function oO(i,t){if(!(!Ls(t)||!t.visible)){if(Pr(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let n=oO(i,e);if(n)return n}}}function s9(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var qv=class{constructor(t,e,n,r,s,o,a){this.renderer=t;this.publish=e;this.scene=n;this.getCamera=r;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.raycaster=new Wv;this.raycasterNeedsUpdate=!0;this._useWindowEvents=!1;this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:n}=t.touches?.length>0?t.touches[0]:t,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(s9(e,n,r),this.getCamera())}};var h1=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))(h1||{}),Fn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var f1=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],aO=i=>f1.find(([t,e])=>e===i)?.[0],$s=i=>f1.find(([t])=>t===i)?.[1],o9=(i,t)=>{let e=aO(i);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},Yv=class extends Fn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[aO(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:r}=this.eventContext;r.dispatchEvent(n)};let{page:n}=this.eventContext;n.traverseEntity(r=>{if(!!r.data?.events.length){for(let[s,o]of f1)if(r.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(r):this.objectsPerEvents.set(s,[r]);let a={id:r.uuid,name:r.name},l=o9(o,a),u=this.splineEvents[s];u?u[r.uuid]=l:this.splineEvents[s]={[r.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var p1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.toggle,(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=_n(e,e.actions,r,s,o,n)}disconnect(){cn(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.useToggle===!1&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(r=>r.playing)||this.actions.Transition.forEach(r=>{this.alreadyPlayedNonTogglingActions.has(r)===!1&&r.play()}),this.actions.SwitchCamera.some(r=>r.playing)||this.actions.SwitchCamera.forEach(r=>{r.play()}),this.actions.Animation.forEach(r=>{r.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}},Xv=class extends Fn{constructor(e,n){super(e);this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.windowMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.onWindowMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})};this.onWindowMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(r)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!o.data?.events.length)return;let a=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let l of a){let u=this.eventsPerObjects[l];o.data.events.filter(({data:c})=>c.type===l&&c.disabled!==!0).forEach(({id:c,data:d})=>{try{let h=new p1(c,d,o,r,s,n);h.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?d.mode==="Canvas"&&this.canvasMouseEvents.push(h):u[o.uuid]?u[o.uuid].push(h):u[o.uuid]=[h]}catch(h){!1&&console.log(h)}}),u[o.uuid]?.length&&this.objectsPerTypes[l].push(o)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),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(n=>{Object.values(n).forEach(r=>{r.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:r,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!!o.length)if(n){let a=Sp(r,s,o);Ap(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}else o.forEach(a=>{fh(r,a)&&this.handleObjectMouseEventDispatch(a,e)})}handleMousePressEvent(e=!1){let n="MousePress",r=this.objectsPerTypes[n],s=[];if(!!r.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=Sp(a,l,r);s=Ap(u)}else r.forEach(u=>{fh(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatchRelease()})}handleKeyEvent(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(r?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(r)})})}};var a9=new A,l9=new A;var Qv=class{constructor(t,e,n,r,s){this.actionsIn=_n(t,t.inActions,n,r,s,e),this.actionsOut=_n(t,t.outActions,n,r,s,e)}disconnect(){cn(this.actionsIn),cn(this.actionsOut)}};var m1=class extends Qv{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{let e=a9.setFromMatrixPosition(this.objects[0].matrixWorld),n=l9.setFromMatrixPosition(this.objects[1].matrixWorld),r=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==r){let s=r==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),this.stage=r}};let{distance:l,fromObject:u,toObject:c}=n.condition;this.distance=l;for(let d of[u,c]){if(!d)throw new Error("Missing property");let h=s.find(d);if(!h)throw new Error("Missing property");this.objects.push(h)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},g1=class extends Qv{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(r=>r.dispatchConditional()),this.actionsOut.Video.forEach(r=>r.dispatchConditional()),this.actionsOut.Link.forEach(r=>r.dispatch()),this.actionsOut.Create.forEach(r=>r.dispatch()),this.actionsOut.Destroy.forEach(r=>r.dispatch()),this.actionsOut.Reset.forEach(r=>r.dispatch()),this.actionsIn.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(r=>r.play()),this.actionsOut.Animation.forEach(r=>r.play()),this.actionsIn.SwitchCamera.forEach(r=>r.pause()),this.actionsOut.SwitchCamera.forEach(r=>r.play()),this.actionsOut.SceneTransition.forEach(r=>r.dispatch()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(r=>r.dispatchConditional()),this.actionsIn.Video.forEach(r=>r.dispatchConditional()),this.actionsIn.Link.forEach(r=>r.dispatch()),this.actionsIn.Create.forEach(r=>r.dispatch()),this.actionsIn.Destroy.forEach(r=>r.dispatch()),this.actionsIn.Reset.forEach(r=>r.dispatch()),this.actionsOut.Transition.forEach(r=>r.pause()),this.actionsOut.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(r=>r.play()),this.actionsIn.Animation.forEach(r=>r.play()),this.actionsOut.SwitchCamera.forEach(r=>r.pause()),this.actionsIn.SwitchCamera.forEach(r=>r.play()),this.actionsIn.SceneTransition.forEach(r=>r.dispatch()))};let{condition:l}=n;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Kv=class extends Fn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new m1(a,l,o,r,s,n):l.condition.type==="State"&&(u=new g1(a,l,o,r,s,n))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var _p=new A,ja=new A,$l=new A,lO=new vn,c9=.01,Lt=new A,Kn=new A,cO=new A,ec=new qe,y1=new Gt,u9=new ie,v1=new en,ph=new A,eo=new A,mh=.2;function x1(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var d9=function(){let i=new ie;return(t,e,n)=>{let r=t.obj;i.copy(r.hiddenMatrix),r.parent!==null&&i.premultiply(r.parent.matrixWorld),i.invert(),r.position.copy(e),t.reference==="global"&&x1(r.position,t.limits),r.position.applyMatrix4(i),t.reference==="parent"?x1(r.position,t.limits):t.reference==="local"&&(ec.copy(t.quat0).invert(),r.position.sub(t.position0),r.position.applyQuaternion(ec),x1(r.position,t.limits),ec.invert(),r.position.applyQuaternion(ec),r.position.add(t.position0)),i.multiply(n??r.matrixWorld).decompose(Lt,r.quaternion,Kn),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r instanceof Vt&&Hr(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),b1=class{constructor(t,e,n,r,s,o){this.object=t;this.data=e;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=_n(e,e.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=_n(e,e.dragDropActions.drop,n,r,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let d=n.find(c);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new qe().copy(l.quaternion),snapped:!1,orientationMatrix:new ie,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){cn(this.actionsDrag),cn(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Zv=class extends Fn{constructor(e,n){super(e);this.eventManager=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||lt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Lt,ec,Kn),y1.setFromQuaternion(ec),d.prevR===void 0?(d.prevR=y1.clone(),d.prevT=Lt.clone()):(d.prevR.copy(y1),d.prevT.copy(Lt)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(ke.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(ke.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||lt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof No)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||r.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=cO.copy(a.face.normal).applyMatrix3(v1.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Lt.copy(l).applyMatrix3(v1.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Lt.x>mh?Kn.x=-u.recursiveBBox.min.x:Lt.x<-mh&&(Kn.x=-u.recursiveBBox.max.x),Lt.y>mh?Kn.y=-u.recursiveBBox.min.y:Lt.y<-mh&&(Kn.y=-u.recursiveBBox.max.y),Lt.z>mh?Kn.z=-u.recursiveBBox.min.z:Lt.z<-mh&&(Kn.z=-u.recursiveBBox.max.z),Kn.applyMatrix3(v1.invert())}else Kn.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Kn)}this.activeEvent.data.autoOrient&&(Lt.set(0,1,0).cross(l),Lt.length()<1e-4&&Lt.set(-1,0,0).cross(l),Kn.crossVectors(cO,Lt),o.orientationMatrix.makeBasis(Lt,Kn,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(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.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),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.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.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=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||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(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(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")})),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let r={};e.page.traverseEntity(s=>{s.component&&(r[s.component.uuid]?r[s.component.uuid].push(s.uuid):r[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new b1(s,o.data,e.page,e.sharedAssets,n,r))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,r,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(ja),ja.negate();let l=ec.identity();switch(s==="parent"?u9.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Lt,l,Kn):s==="local"&&e.matrixWorld.decompose(Lt,l,Kn),r){case"x":Lt.set(1,0,0).applyQuaternion(l),ph.copy(ja).cross(Lt),eo.copy(Lt).cross(ph);break;case"y":Lt.set(0,1,0).applyQuaternion(l),ph.copy(ja).cross(Lt),eo.copy(Lt).cross(ph);break;case"z":Lt.set(0,0,1).applyQuaternion(l),ph.copy(ja).cross(Lt),eo.copy(Lt).cross(ph);break;case"xy":eo.set(0,0,1).applyQuaternion(l);break;case"yz":eo.set(1,0,0).applyQuaternion(l);break;case"xz":eo.set(0,1,0).applyQuaternion(l);break;case"adaptive":ja.angleTo(Kn.set(0,1,0))>Math.PI/6?(Lt.crossVectors(Kn.set(0,1,0),ja),eo.crossVectors(Lt,Kn)):eo.set(0,1,0);break;default:eo.copy(ja);break}$l.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:$l;if(lO.setFromNormalAndCoplanarPoint(eo,u),!!a.ray.intersectPlane(lO,n)&&(r==="x"||r==="y"||r==="z")){let c=Kn.subVectors(n,u).dot(Lt);n.copy(u).addScaledVector(Lt,c)}}updateDragItem(e,n=!1){$l.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?_p.subVectors(e.fromPosition,$l).divideScalar(e.currentDampingFactor):e.reset==="original"?(_p.subVectors(e.obj.userData.worldPosition0,$l).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):_p.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub($l).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?_p.length()<c9:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&d9(e,_p.add($l),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var gh=new A,w1=new A,jo=new A,Wo=new A,uO=new vn,h9=.01,f9={type:"requestRender"},p9=function(){let i=new A,t=new A;return(e,n,r)=>r>0?(i.subVectors(e,n),i.length()<=r?e:t.copy(n).add(i.normalize().multiplyScalar(r))):n}(),dO=function(){let i=new ie;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Vt&&Hr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),S1=class{constructor(t,e,n,r,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Ug.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=_n(t,t.actions,n,r,s,e)}},Jv=class extends Fn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!r.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new S1(o.data,s,r,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,o=this.onTargetChange(r);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let r of this.events)r.paused=!0,r.isReset=!1,cn(r.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:r,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(jo),e.isReset)Wo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Wo);else{let{getCamera:l,raycaster:u}=this.eventContext;if(r==="custom"?(l().getWorldDirection(w1),w1.negate(),gh.copy(w1)):r==="xy"?gh.set(0,0,1):r==="xz"?gh.set(0,1,0):r==="yz"&&gh.set(1,0,0),uO.setFromNormalAndCoplanarPoint(gh,jo),!u.ray.intersectPlane(uO,Wo))return}if(!e.isReset){if(Wo.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Wo.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&&(Wo.x=jo.x),e.data.enabledTranslation[1]===!1&&(Wo.y=jo.y),e.data.enabledTranslation[2]===!1&&(Wo.z=jo.z);let a=p9(jo,Wo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=gh.subVectors(a,jo).divideScalar(e.currentDampingFactor);jo.add(l),n&&dO(e.object,jo),e.paused=l.length()<h9}else dO(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(f9)}};var Mp=new A,$v=new A,Ep=new ie,yh=new qe,Wa=new qe,Tp=new A,Cp=new A,tc=new A,qo=new A,A1=new vn,m9=1e-6,g9={type:"requestRender"},y9={type:"changeRotation"},hO=function(){let i=new ie;return function(e,n){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),n.premultiply(d1(i).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof Vt&&Hr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),_1=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new qe;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...kg.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},e0=class extends Fn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(ke.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:r})=>{if(!n||!r)return;let s=$s(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(r=>{let s=r.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new _1(s.data,r,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let a=this.onTargetChange(r),l=r.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(r),o=r.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Wn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let[r,s]of this.pairOfUserEventListeners)r.removeEventListener("userEvent",s);for(let r of this.events)r.paused=!0,r.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:r,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:d}=this.eventContext,{object:h,target:f}=e;if(h.getWorldPosition(Tp),!e.isReset)if(e.target)e.target.getWorldPosition(Cp);else{if(o==="custom"?(c().getWorldDirection($v),$v.negate(),A1.setFromNormalAndCoplanarPoint($v,Tp)):(o==="xy"?Mp.set(0,0,1):o==="xz"?Mp.set(0,1,0):o==="yz"&&Mp.set(1,0,0),A1.setFromNormalAndCoplanarPoint(Mp,Tp)),!d.ray.intersectPlane(A1,Cp))return;s>0&&(o==="custom"||o===void 0)&&Cp.addScaledVector($v,s)}if(e.isReset||(f?n==="target"?tc.copy(f.up).applyMatrix4(Ep.extractRotation(f.matrixWorld)).normalize():l.some(m=>m===!1)?(r==="x"?(qo.set(0,0,1),l[2]===!1&&qo.set(0,1,0)):r==="y"?(qo.set(1,0,0),l[0]===!1&&qo.set(0,0,1)):(qo.set(0,1,0),l[1]===!1&&qo.set(1,0,0)),tc.copy(qo).applyQuaternion(e.worldQuaternion0).normalize()):tc.set(0,1,0):o==="custom"?tc.set(0,1,0):tc.copy(Mp)),e.isReset)Wa.copy(e.worldQuaternion0);else if(Tp.distanceTo(Cp)>a&&u&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Wa.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;v9(Ep,Cp,Tp,tc,r,qo),Wa.setFromRotationMatrix(Ep),yh.setFromUnitVectors(qo.applyQuaternion(Wa),tc),l.some(m=>m===!1)&&n!=="target"&&Wa.premultiply(yh).normalize()}e.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),yh.setFromRotationMatrix(d1(h.matrixWorld)),yh.slerp(Wa,1/e.currentDampingFactor),hO(h,Ep.makeRotationFromQuaternion(yh)),e.paused=8*(1-yh.dot(Wa))<m9):(hO(h,Ep.makeRotationFromQuaternion(Wa)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(g9),h.dispatchEvent(y9)}},ki=new A,Zn=new A,Mn=new A;function v9(i,t,e,n,r,s){let o=i.elements;Mn.subVectors(t,e),Mn.lengthSq()===0&&(Mn.z=1),Mn.normalize(),Zn.crossVectors(n,Mn),Zn.lengthSq()===0&&(Math.abs(n.z)===1?Mn.x+=1e-4:Mn.z+=1e-4,Mn.normalize(),Zn.crossVectors(n,Mn)),Zn.normalize(),ki.crossVectors(Mn,Zn),r==="x"?s.z===1?[Zn,ki,Mn]=[Mn,Zn,ki]:(Zn.negate(),[Zn,Mn]=[Mn,Zn]):r==="y"?s.x===1?[Zn,ki,Mn]=[ki,Mn,Zn]:(Zn.negate(),[ki,Mn]=[Mn,ki]):s.x===1&&(Zn.negate(),[Zn,ki]=[ki,Zn]),o[0]=Zn.x,o[4]=ki.x,o[8]=Mn.x,o[1]=Zn.y,o[5]=ki.y,o[9]=Mn.y,o[2]=Zn.z,o[6]=ki.z,o[10]=Mn.z}var M1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=_n(e,e.actions,r,s,o,n)}disconnect(){cn(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch())}},t0=class extends Fn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{ke.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{ke.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(r)))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new M1(a,l,o,r,s,n);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Wn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(r=>{r.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:r,raycaster:s,page:o}=this.eventContext;if(r){let a=Sp(s,o,this.objects);n=Ap(a)}else this.objects.forEach(a=>{fh(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(r=>{n.includes(r)||(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(r=>{r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var E1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=_n(e,e.actions,r,s,o,n)}connect(){this.scrollCounter=0}disconnect(){cn(this.actions)}dispatch(t){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(n)),this.actions.Animation.forEach(r=>r.seek(e)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled())}},T1=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=_n(e,e.actions,r,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,r=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){cn(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let n=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled())}},n0=class extends Fn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),r.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))};let{page:r,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;r.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let d=new E1(u,c,l,r,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(d):this.wheelEventsPerObject.set(l,[d])}else{let d=new T1(u,c,l,r,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(d):this.scrollEventsPerObject.set(l,[d])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var C1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=_n(e,e.actions,r,s,o,n)}disconnect(){cn(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof Xs?e.interaction.audioPlayer.play():e.interaction instanceof uh&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof Vo?e.interaction.play(n==="autoplay"):e.interaction instanceof hh&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof Xs?e.interaction.audioPlayer.play():e.interaction instanceof uh&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Vo?e.interaction.play():e.interaction instanceof hh&&e.interaction.dispatch()})}},r0=class extends Fn{constructor(e,n){super(e);this.eventManager=n;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.actions.Audio.forEach(s=>{s.interaction instanceof Xs&&s.interaction.audioPlayer.play()}),r.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Vo&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=$s(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))}}connect(){let{sharedAssets:e,page:n}=this.eventContext;if(n.traverseEntity(r=>{if(!!r.data?.events.length)for(let{id:s,data:o}of r.data.events){if(o.disabled||o.type!=="Start")continue;let a=new C1(s,o,r,n,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,o=s?document:r;o.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),o.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,l])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,r=n?document:e;r.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),r.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(r=>r.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var i0=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!1;this.actions=_n(e,e.actions,r,s,o,n),this.target=e.target,this.useToggle=e.toggle}disconnect(){cn(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var pO=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.402/build/",x9=!1?pO:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.402/build/",b9=`
6238
6238
  (async function() {
6239
6239
  const [wasmImport, wasmBinary] = await Promise.all([
6240
6240
  import('${pO}' + 'navmesh.js'),
@@ -6300,4 +6300,4 @@ onmessage = function(messageEvent) {
6300
6300
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6301
6301
  </svg>
6302
6302
  `),T.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),T.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,g];return}let b={zone:g,mode:"static",position:S,size:y};x==="hide"&&(b.restOpacity=0);let E=sD.create(b);E.on("move",(T,I)=>{let C=this.gameControl;m==="pos"?I.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-I.angle.radian),C.movementState.movePosX=Math.cos(-I.angle.radian),I.force>1.2?C.movementState.run=1:C.movementState.run=0,I.force<.3?C.moveForce=(I.force-.2)/.1:C.moveForce=1):m==="rot"&&(I.force<.2?C.rotForce=0:(C.movementState.rotPosX=I.vector.y,C.movementState.rotPosY=-I.vector.x,I.force<.3?C.rotForce=(I.force-.2)/.1:C.rotForce=1)),this.requestRender()}),E.on("end",(T,I)=>{let C=this.gameControl;m==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):m==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[E,g]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(m=>m.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new yt.World(new yt.Vector3(0,this.gravity,0)),this.events=new yt.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof ur)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;l=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof rn)l=a.object;else if(l=a,l.dataPatched.cloner?.disabled===!1&&l.dataPatched.cloner?.hideBase&&l.dataPatched.physics?.fusedBody!==!0)return!0;let u=l.dataPatched,c;for(let y of u.events)y.data.disabled!==!0&&y.data.type==="GameControl"&&(c=y.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldSVD();let d=Pp(u),h=!1,f=l.userData.hasDestroy,m=l.userData.hasDrag,p=!1;for(let y of u.events)if(y.data.disabled!==!0){if(y.data.type==="Collision"){h=!0;let v=new i0(y.id,y.data,l,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(x=>x.id!==y.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[v]}else if(y.data.type==="Follow"){p=!0;let v=y.data.target;a.traverseVisible(x=>{x.userData.isFollowingObj=v})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(c!==void 0){let y=yt.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Un,gs,qa),a.position0=Un.clone().divideScalar(this.pixelsPerMeter),a.rotation0=gs.clone(),Un.divideScalar(this.pixelsPerMeter),y.setTranslation(Un.x,Un.y,Un.z).setRotation(gs);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=v;let x;c.collider.type==="sphere"?x=yt.ColliderDesc.ball(c.collider.radius/this.pixelsPerMeter):c.collider.type==="capsule"?x=yt.ColliderDesc.capsule((c.collider.height/2-c.collider.radius)/this.pixelsPerMeter,c.collider.radius/this.pixelsPerMeter):x=yt.ColliderDesc.cuboid(c.collider.width/this.pixelsPerMeter/2,c.collider.height/this.pixelsPerMeter/2,c.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(yt.CoefficientCombineRule.Average).setRestitutionCombineRule(yt.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(u.physics.restitution);let w=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(w.handle,l),Un.fromArray(c.collider.position).multiply(qa.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),w.setTranslationWrtParent(Un);let S=new qe().setFromEuler(new Gt().setFromVector3(new A().fromArray(c.collider.rotation)));w.setRotationWrtParent(S),w.setActiveEvents(yt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else u.physics.rigidBody==="dynamic"||d||p||f||m||h?(this.addRigidBody(a,l,{hasFollow:p,hasTransformAnim:d,hasDrag:m}),this.generateSensorColliderDescs(l,u.physics.fusedBody)):(g&&t.push(ms(g,a.matrixWorld)),u.physics.fusedBody&&a.traverseObject((y,v)=>{if(v===0)return;let x;if(y instanceof ur)if(y.objectForSample){if(y.objectForSample.dataPatched.physics.fusedBody)return;x=y.object}else return y.object.dataPatched.physics.fusedBody===!0&&y.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(y instanceof rn)x=y.object;else if(x=y,x.dataPatched.cloner?.hideBase)return!0;let w=x.dataPatched;if(w.physics.enabled==="visibility"?!w.visible:!w.physics.enabled)return!0;let S=y.geometry;S?.getAttribute("position")!==void 0&&t.push(ms(S,y.matrixWorld))}),this.generateSensorColliderDescs(l,u.physics.fusedBody,e));if(u.physics?.fusedBody===!0||c)return!0}),t.length===0)return;let n=$i(t);n.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=yt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),o=yt.ColliderDesc.trimesh(n.getAttribute("position").array,n.getIndex().array).setFrictionCombineRule(yt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(yt.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);for(let[a,l]of e){let u=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[u.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?(this.gameControl===null||this.needsCollisionDetection)&&this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let n=new Ip(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new ie().compose(Yo.fromArray(e.data.position),wh.setFromEuler(bO.fromArray(e.data.rotation)),SO);if(e.data.triggerZone==="box"){let s=new _t;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,n])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,t,n])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}update(t,e,n){let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(t,e,n)&&r),this.usePhysics){for(let s of this.sharedGameControlGlobals.entitiesWithTransformAnim){(s.hasNonUniformScale?s.matrixWorldRigid:s.matrixWorld).decompose(Un,gs,qa),L1.setFromQuaternion(gs);let o=s;o.prevR===void 0?(o.prevR=L1.clone(),o.prevT=Un.clone()):(o.prevR.copy(L1),o.prevT.copy(Un)),s.rigidBody.setNextKinematicTranslation(Un.divideScalar(this.pixelsPerMeter)),s.rigidBody.setNextKinematicRotation(gs)}this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),r=!this.updatePositions()&&r}return r}dispatchCollisionEvent(t,e,n){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(n))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===r){s=o;break}}t.dispatch(s),e.dispatchEvent(jv)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,n){let r=R9.copy(t.matrixWorld).invert();t.traverseEntity((s,o)=>{if(e===!1&&o===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let l=new Ip(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),u;if(a.data.triggerZone==="box"?u=yt.ColliderDesc.cuboid(...a.data.size.map(c=>c/(2*this.pixelsPerMeter))):u=yt.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),u.setDensity(0).setSensor(!0).setActiveEvents(yt.ActiveEvents.COLLISION_EVENTS),Yo.fromArray(a.data.position),wh.setFromEuler(bO.fromArray(a.data.rotation)),N1.compose(Yo,wh,SO).premultiply(s.matrixWorld),n?(N1.decompose(Yo,wh,wO),u.setActiveCollisionTypes(yt.ActiveCollisionTypes.KINEMATIC_FIXED|yt.ActiveCollisionTypes.DYNAMIC_FIXED)):(N1.premultiply(r).decompose(Yo,wh,wO),t.rigidBody.bodyType()===yt.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===yt.RigidBodyType.Fixed?u.setActiveCollisionTypes(yt.ActiveCollisionTypes.KINEMATIC_FIXED|yt.ActiveCollisionTypes.DYNAMIC_FIXED):u.setActiveCollisionTypes(yt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|yt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Yo.divideScalar(this.pixelsPerMeter),u.setTranslation(Yo.x,Yo.y,Yo.z),u.setRotation(wh),n)n.push([u,l]);else{let c=this.sharedGameControlGlobals.rapierWorld.createCollider(u,t.rigidBody);this.sensorToTriggerEvent[c.handle]=l}}})}};function _O(i){let t=this._clip.duration,e=this._clip.start??0,n=this.loop,r=this.time+i,s=this._loopCount,o=n===$h;if(i===0)return s===-1?r:o&&(s&1)===1?t-(r-e):r;if(n===zx){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:i<0?-1:1})}}else{if(s===-1&&(i>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<e){let a=Math.floor((r-e)/(t-e));r-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(r=i>0?t:e,this.repetitions===1&&(r=t)),this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:i>0?1:-1});else{if(l===1){let u=i<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-(r-e)}return r}var MO=!1,c0=class{constructor(t,e,n,r){this.scene=t;this.requestRender=e;this.updateDisplayProgress=n;this.animationInspectorState=r;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,n)=>{let r=e[0]+"/";if(Array.isArray(t.identity)?r+=t.identity[0]:r+=t.uuid,this.clipIdToAction[r])return;let s=Uc.parse(JSON.parse(e[2]));t.animations[n]=s;let o=this.mixer.clipAction(s,t);MO===!1&&(Object.getPrototypeOf(o)._updateTime=_O,MO=!0),o.clampWhenFinished=!0,this.clipIdToAction[r]=o})};this.mixer=new Pm(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let n=this.scene.find(e);if(!n)return;let r=n.animations.find(o=>o.uuid===t);if(!r)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[t],n.animations=n.animations.filter(o=>o.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=Gx}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,n=this.clipIdToAction[e];if(!!n)return t&&(t.repeat>=0&&(n.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(n.loop=$h)),n.play(),n.paused=!1,this.requestRender(),n}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let n=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?t/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),n&&(this.clipIdToAction[e].paused=!0)}};var B1=new WeakMap,u0=class extends kc{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,n,r){let s=new zc(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,o=>{this.decodeDracoFile(o,e).catch(r)},n,r)}decodeDracoFile(t,e,n,r){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){let n=JSON.stringify(e);if(B1.has(t)){let l=B1.get(t);if(l.key===n)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(r=l,new Promise((u,c)=>{r._callbacks[s]={resolve:u,reject:c},r.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),B1.set(t,{key:n,promise:a}),a}_createGeometry(t){let e=new Me;t.index&&e.setIndex(new Be(t.index.array,1));for(let n=0;n<t.attributes.length;n++){let r=t.attributes[n],s=r.name,o=r.array,a=r.itemSize;e.setAttribute(s,new Be(o,a))}return e}_loadLibrary(t,e){let n=new zc(this.manager);return n.setPath(this.decoderPath),n.setResponseType(e),n.setWithCredentials(this.withCredentials),new Promise((r,s)=>{n.load(t,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(n=>{let r=n[0];t||(this.decoderConfig.wasmBinary=n[1]);let s=N9.toString(),o=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
6303
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let o=s.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function N9(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(c){i.onModuleLoaded=function(d){c({draco:d})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let d=c.draco,h=new d.Decoder,f=new d.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let m=e(d,h,f,u),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{d.destroy(f),d.destroy(h)}});break}};function e(o,a,l,u){let c=u.attributeIDs,d=u.attributeTypes,h,f,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)h=new o.Mesh,f=a.DecodeBufferToMesh(l,h);else if(m===o.POINT_CLOUD)h=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||h.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let g in c){let y=self[d[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(h,x);else{if(x=a.GetAttributeId(h,o[c[g]]),x===-1)continue;v=a.GetAttribute(h,x)}p.attributes.push(r(o,a,h,g,y,v))}return m===o.TRIANGULAR_MESH&&(p.index=n(o,a,h)),o.destroy(h),p}function n(o,a,l){let c=l.num_faces()*3,d=c*4,h=o._malloc(d);a.GetTrianglesUInt32Array(l,d,h);let f=new Uint32Array(o.HEAPF32.buffer,h,c).slice();return o._free(h),{array:f,itemSize:1}}function r(o,a,l,u,c,d){let h=d.num_components(),m=l.num_points()*h,p=m*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,d,g,p,y);let v=new c(o.HEAPF32.buffer,y,m).slice();return o._free(y),{name:u,array:v,itemSize:h}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Ya;function B9(){return Ya||(Ya=new u0,Ya.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Ya.decoderPending}async function F9(i){if(Ya){let t={attributeIDs:Ya.defaultAttributeIDs,attributeTypes:Ya.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Ya.decodeGeometry(new Int8Array(i).buffer,t)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function EO(i,t){let[e,n]=wb(Bg.deserialize(new Uint8Array(i)));RC(e);let r=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await B9();for(let s of r){let o=await F9(Ln(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return t&&t(e),n.result().data}var TO=Object.keys(h1).filter(i=>isNaN(Number(i))),d0=class{constructor(t,e,n,r){this.publish=t;this.controlsManager=e;this.animationControls=n;this.eventContext=r;this.isEnable=!1;this._isPaused=!1;this.activateCount=0;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=t=>{(t.touches.length>1||this.preventTouchScroll)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}activate(){if(this.handlers={Spline:new Yv(this.eventContext),["Conditional"]:new Kv(this.eventContext,this),["Start"]:new r0(this.eventContext,this),Basic:new Xv(this.eventContext,this),["MouseHover"]:new t0(this.eventContext,this),["Scroll"]:new n0(this.eventContext,this),["Follow"]:new Jv(this.eventContext,this),["DragDrop"]:new Zv(this.eventContext,this),["LookAt"]:new e0(this.eventContext)},this.isPaused)return;let{page:t,domElement:e,eventElement:n}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),this.isEnable=!0,t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),TO.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(e.addEventListener(r,this.onResetRaycaster),n.addEventListener(r,this.onResetRaycaster))}),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){let{page:t,domElement:e}=this.eventContext;this.isEnable=!1,e.style.cursor="",Object.values(this.handlers).forEach(n=>n.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender)}),TO.forEach(n=>{e.removeEventListener(n,this.onResetRaycaster)}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this._isPaused}pause(){this._isPaused=!0,this.deactivate()}resume(){this._isPaused=!1,this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnable;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}};var h0=class{constructor(t,e,n,r,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new F().copy(n),this._editorSize=new F().copy(r),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,n=this._editorSize.y;this._aspect=t/e,e<=n&&(this._camera.zoom*=n/e),this._renderer.setViewport(0,0,t,e)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,e=this._editorSize.y,n=this._fov;if(t>e){let r=U9(t,1080,2160,1,15)/100;n*=t/e,n*=1-r}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function U9(i,t,e,n,r){return(i-t)/(e-t)*(r-n)+n}var f0=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Wl(t.shared,e),this.scene=new Ga(t.scene,this.sharedAssets)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof ti&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Ht&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var p0=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function k9(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Dp(i){return i instanceof ls?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function z9(i,t){let e={};return i.traverseEntity(n=>{if(!n.visible||!(n instanceof Vt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let r=n.parent;for(;r;){if(r instanceof Vt&&n.states&&Object.keys(n.states).length)return;r=r.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!sr.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!sr.isMergable(u.material))return;s=sr.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Dp(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Dp(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Dp(n)].push(u)}),e}function G9(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(n=>{let r=n.length;r>t&&(t=r)})}),t}function CO(i,t){let e=z9(t,i),n=G9(e),r=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let m of Object.values(f)){if(a=0,u=0,m.forEach(g=>{g instanceof Vt&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&k9(o[g]);let p=$i(o.slice(0,a),!1);if(p){let g;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Dn(p,l[0].material);break}default:{g=new Dn(p,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Vt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Dp(x)]&&e[x.material.uuid][Dp(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),r[s++]=x}}}for(let h=0;h<s;h++)r[h].removeFromParent()}var OO=Ah(IO(),1);var H9=new F;function j9(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var DO=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this._lastTime=performance.now();this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),(this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=H9.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderAutoMode())};this._debouncedResize=wl(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new p0({x:10,y:10})),xT(t)}async load(t,e){j9(t),this.disposed=!1;let r=await(await fetch(t,e)).arrayBuffer();await this.start(r)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await EO(t);this._data=n,n.version&&(0,OO.default)(n.version,"0.9.400")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([ES(n)&&s2(),O2(n)&&JP(),Ta.physicsEnabled(n.scene.objects)&&ET(),vS(n)&&E2(),I1(n)&&AT()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new f0(n);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();CO(n,r.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}ES(n)&&this._scene.traverse(o=>{Hr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof ur&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),vS(n)&&AO(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),dh(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new gv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];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 h0(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"}if(e){let o=new qv(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new l0(o),this._animationControls=new c0(this._scene,this._requestRenderAutoMode),this._eventManager=new d0(n.scene.publish,this._controls,this._animationControls,o),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),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)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==Ei&&!(e instanceof ti)){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof bh&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:r,a:s}={r:0,g:0,b:0,a:1},o=new sn(e,n,r,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{sb.unsubscribe(t)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),bT(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof ti&&(e=s.name)});let n={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof ti||t instanceof Ga?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=sb(n,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,r),r}};export{DO as Application};
6303
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let o=s.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function N9(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(c){i.onModuleLoaded=function(d){c({draco:d})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let d=c.draco,h=new d.Decoder,f=new d.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let m=e(d,h,f,u),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{d.destroy(f),d.destroy(h)}});break}};function e(o,a,l,u){let c=u.attributeIDs,d=u.attributeTypes,h,f,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)h=new o.Mesh,f=a.DecodeBufferToMesh(l,h);else if(m===o.POINT_CLOUD)h=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||h.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let g in c){let y=self[d[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(h,x);else{if(x=a.GetAttributeId(h,o[c[g]]),x===-1)continue;v=a.GetAttribute(h,x)}p.attributes.push(r(o,a,h,g,y,v))}return m===o.TRIANGULAR_MESH&&(p.index=n(o,a,h)),o.destroy(h),p}function n(o,a,l){let c=l.num_faces()*3,d=c*4,h=o._malloc(d);a.GetTrianglesUInt32Array(l,d,h);let f=new Uint32Array(o.HEAPF32.buffer,h,c).slice();return o._free(h),{array:f,itemSize:1}}function r(o,a,l,u,c,d){let h=d.num_components(),m=l.num_points()*h,p=m*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,d,g,p,y);let v=new c(o.HEAPF32.buffer,y,m).slice();return o._free(y),{name:u,array:v,itemSize:h}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Ya;function B9(){return Ya||(Ya=new u0,Ya.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Ya.decoderPending}async function F9(i){if(Ya){let t={attributeIDs:Ya.defaultAttributeIDs,attributeTypes:Ya.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Ya.decodeGeometry(new Int8Array(i).buffer,t)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function EO(i,t){let[e,n]=wb(Bg.deserialize(new Uint8Array(i)));RC(e);let r=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await B9();for(let s of r){let o=await F9(Ln(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return t&&t(e),n.result().data}var TO=Object.keys(h1).filter(i=>isNaN(Number(i))),d0=class{constructor(t,e,n,r){this.publish=t;this.controlsManager=e;this.animationControls=n;this.eventContext=r;this.isEnable=!1;this._isPaused=!1;this.activateCount=0;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=t=>{(t.touches.length>1||this.preventTouchScroll)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}activate(){if(this.handlers={Spline:new Yv(this.eventContext),["Conditional"]:new Kv(this.eventContext,this),["Start"]:new r0(this.eventContext,this),Basic:new Xv(this.eventContext,this),["MouseHover"]:new t0(this.eventContext,this),["Scroll"]:new n0(this.eventContext,this),["Follow"]:new Jv(this.eventContext,this),["DragDrop"]:new Zv(this.eventContext,this),["LookAt"]:new e0(this.eventContext)},this.isPaused)return;let{page:t,domElement:e,eventElement:n}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),this.isEnable=!0,t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),TO.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(e.addEventListener(r,this.onResetRaycaster),n.addEventListener(r,this.onResetRaycaster))}),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){let{page:t,domElement:e}=this.eventContext;this.isEnable=!1,e.style.cursor="",Object.values(this.handlers).forEach(n=>n.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender)}),TO.forEach(n=>{e.removeEventListener(n,this.onResetRaycaster)}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this._isPaused}pause(){this._isPaused=!0,this.deactivate()}resume(){this._isPaused=!1,this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnable;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}};var h0=class{constructor(t,e,n,r,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new F().copy(n),this._editorSize=new F().copy(r),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,n=this._editorSize.y;this._aspect=t/e,e<=n&&(this._camera.zoom*=n/e),this._renderer.setViewport(0,0,t,e)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,e=this._editorSize.y,n=this._fov;if(t>e){let r=U9(t,1080,2160,1,15)/100;n*=t/e,n*=1-r}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function U9(i,t,e,n,r){return(i-t)/(e-t)*(r-n)+n}var f0=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Wl(t.shared,e),this.scene=new Ga(t.scene,this.sharedAssets)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof ti&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Ht&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var p0=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function k9(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Dp(i){return i instanceof ls?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function z9(i,t){let e={};return i.traverseEntity(n=>{if(!n.visible||!(n instanceof Vt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let r=n.parent;for(;r;){if(r instanceof Vt&&n.states&&Object.keys(n.states).length)return;r=r.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!sr.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!sr.isMergable(u.material))return;s=sr.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Dp(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Dp(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Dp(n)].push(u)}),e}function G9(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(n=>{let r=n.length;r>t&&(t=r)})}),t}function CO(i,t){let e=z9(t,i),n=G9(e),r=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let m of Object.values(f)){if(a=0,u=0,m.forEach(g=>{g instanceof Vt&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&k9(o[g]);let p=$i(o.slice(0,a),!1);if(p){let g;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Dn(p,l[0].material);break}default:{g=new Dn(p,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Vt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Dp(x)]&&e[x.material.uuid][Dp(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),r[s++]=x}}}for(let h=0;h<s;h++)r[h].removeFromParent()}var OO=Ah(IO(),1);var H9=new F;function j9(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var DO=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this._lastTime=performance.now();this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),(this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=H9.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._requestRenderAutoMode())};this._debouncedResize=wl(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new p0({x:10,y:10})),xT(t)}async load(t,e){j9(t),this.disposed=!1;let r=await(await fetch(t,e)).arrayBuffer();await this.start(r)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await EO(t);this._data=n,n.version&&(0,OO.default)(n.version,"0.9.402")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([ES(n)&&s2(),O2(n)&&JP(),Ta.physicsEnabled(n.scene.objects)&&ET(),vS(n)&&E2(),I1(n)&&AT()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new f0(n);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();CO(n,r.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}ES(n)&&this._scene.traverse(o=>{Hr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof ur&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),vS(n)&&AO(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),dh(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new gv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];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 h0(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"}if(e){let o=new qv(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new l0(o),this._animationControls=new c0(this._scene,this._requestRenderAutoMode),this._eventManager=new d0(n.scene.publish,this._controls,this._animationControls,o),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),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)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==Ei&&!(e instanceof ti)){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof bh&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:r,a:s}={r:0,g:0,b:0,a:1},o=new sn(e,n,r,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{sb.unsubscribe(t)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),bT(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof ti&&(e=s.name)});let n={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof ti||t instanceof Ga?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=sb(n,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,r),r}};export{DO as Application};