@splinetool/runtime 0.9.217 → 0.9.218

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.cjs CHANGED
@@ -3136,7 +3136,7 @@ void main() {
3136
3136
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3137
3137
  }`;function v3(r,e,t){let n=new fd,i=new U,s=new U,o=new Xe,a=new pd({depthPacking:jv}),l=new bv,u={},c=t.maxTextureSize,d={0:Pn,1:Gi,2:Lr},h=new yt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new U},radius:{value:4}},vertexShader:g3,fragmentShader:y3}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new Ce;m.setAttribute("position",new Be(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Cn(m,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=lp,this.render=function(w,S,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let T=r.getRenderTarget(),x=r.getActiveCubeFace(),M=r.getActiveMipmapLevel(),E=r.state;E.setBlending(Lt),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,P=w.length;C<P;C++){let O=w[C],I=O.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;i.copy(I.mapSize);let N=I.getFrameExtents();if(i.multiply(N),s.copy(I.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/N.x),i.x=s.x*N.x,I.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/N.y),i.y=s.y*N.y,I.mapSize.y=s.y)),I.map===null){let W=this.type!==rd?{minFilter:Bt,magFilter:Bt}:{};I.map=new ft(i.x,i.y,W),I.map.texture.name=O.name+".shadowMap",I.camera.updateProjectionMatrix()}r.setRenderTarget(I.map),r.clear();let B=I.getViewportCount();for(let W=0;W<B;W++){let X=I.getViewport(W);o.set(s.x*X.x,s.y*X.y,s.x*X.z,s.y*X.w),E.viewport(o),I.updateMatrices(O,W),n=I.getFrustum(),b(S,_,I.camera,O,this.type)}I.isPointLightShadow!==!0&&this.type===rd&&y(I,_),I.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(T,x,M)};function y(w,S){let _=e.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 ft(i.x,i.y)),h.uniforms.shadow_pass.value=w.map.texture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.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,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(S,null,_,f,p,null)}function v(w,S,_,T,x,M){let E=null,C=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0?E=C:E=_.isPointLight===!0?l:a,r.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0){let P=E.uuid,O=S.uuid,I=u[P];I===void 0&&(I={},u[P]=I);let N=I[O];N===void 0&&(N=E.clone(),I[O]=N),E=N}return E.visible=S.visible,E.wireframe=S.wireframe,M===rd?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:d[S.side],E.alphaMap=S.alphaMap,E.alphaTest=S.alphaTest,E.clipShadows=S.clipShadows,E.clippingPlanes=S.clippingPlanes,E.clipIntersection=S.clipIntersection,E.displacementMap=S.displacementMap,E.displacementScale=S.displacementScale,E.displacementBias=S.displacementBias,E.wireframeLinewidth=S.wireframeLinewidth,E.linewidth=S.linewidth,_.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(_.matrixWorld),E.nearDistance=T,E.farDistance=x),E}function b(w,S,_,T,x){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&x===rd)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let C=e.update(w),P=w.material;if(Array.isArray(P)){let O=C.groups;for(let I=0,N=O.length;I<N;I++){let B=O[I],W=P[B.materialIndex];if(W&&W.visible){let X=v(w,W,T,_.near,_.far,x);r.renderBufferDirect(_,null,C,X,w,B)}}}else if(P.visible){let O=v(w,P,T,_.near,_.far,x);r.renderBufferDirect(_,null,C,O,w,null)}}let E=w.children;for(let C=0,P=E.length;C<P;C++)b(E[C],S,_,T,x)}}function x3(r,e,t){let n=t.isWebGL2;function i(){let V=!1,ye=new Xe,ve=null,Qe=new Xe(0,0,0,0);return{setMask:function(Re){ve!==Re&&!V&&(r.colorMask(Re,Re,Re,Re),ve=Re)},setLocked:function(Re){V=Re},setClear:function(Re,Je,we,$e,St){St===!0&&(Re*=$e,Je*=$e,we*=$e),ye.set(Re,Je,we,$e),Qe.equals(ye)===!1&&(r.clearColor(Re,Je,we,$e),Qe.copy(ye))},reset:function(){V=!1,ve=null,Qe.set(-1,0,0,0)}}}function s(){let V=!1,ye=null,ve=null,Qe=null;return{setTest:function(Re){Re?Y(2929):G(2929)},setMask:function(Re){ye!==Re&&!V&&(r.depthMask(Re),ye=Re)},setFunc:function(Re){if(ve!==Re){if(Re)switch(Re){case X2:r.depthFunc(512);break;case K2:r.depthFunc(519);break;case Z2:r.depthFunc(513);break;case iv:r.depthFunc(515);break;case Q2:r.depthFunc(514);break;case J2:r.depthFunc(518);break;case $2:r.depthFunc(516);break;case eI:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);ve=Re}},setLocked:function(Re){V=Re},setClear:function(Re){Qe!==Re&&(r.clearDepth(Re),Qe=Re)},reset:function(){V=!1,ye=null,ve=null,Qe=null}}}function o(){let V=!1,ye=null,ve=null,Qe=null,Re=null,Je=null,we=null,$e=null,St=null;return{setTest:function(ot){V||(ot?Y(2960):G(2960))},setMask:function(ot){ye!==ot&&!V&&(r.stencilMask(ot),ye=ot)},setFunc:function(ot,Mn,Nt){(ve!==ot||Qe!==Mn||Re!==Nt)&&(r.stencilFunc(ot,Mn,Nt),ve=ot,Qe=Mn,Re=Nt)},setOp:function(ot,Mn,Nt){(Je!==ot||we!==Mn||$e!==Nt)&&(r.stencilOp(ot,Mn,Nt),Je=ot,we=Mn,$e=Nt)},setLocked:function(ot){V=ot},setClear:function(ot){St!==ot&&(r.clearStencil(ot),St=ot)},reset:function(){V=!1,ye=null,ve=null,Qe=null,Re=null,Je=null,we=null,$e=null,St=null}}}let a=new i,l=new s,u=new o,c={},d={},h=new WeakMap,f=[],m=null,p=!1,g=null,y=null,v=null,b=null,w=null,S=null,_=null,T=!1,x=null,M=null,E=null,C=null,P=null,O=r.getParameter(35661),I=!1,N=0,B=r.getParameter(7938);B.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(B)[1]),I=N>=1):B.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),I=N>=2);let W=null,X={},F=r.getParameter(3088),k=r.getParameter(2978),K=new Xe().fromArray(F),H=new Xe().fromArray(k);function z(V,ye,ve){let Qe=new Uint8Array(4),Re=r.createTexture();r.bindTexture(V,Re),r.texParameteri(V,10241,9728),r.texParameteri(V,10240,9728);for(let Je=0;Je<ve;Je++)r.texImage2D(ye+Je,0,6408,1,1,0,6408,5121,Qe);return Re}let j={};j[3553]=z(3553,3553,1),j[34067]=z(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),Y(2929),l.setFunc(iv),_e(!1),me(pw),Y(2884),oe(Lt);function Y(V){c[V]!==!0&&(r.enable(V),c[V]=!0)}function G(V){c[V]!==!1&&(r.disable(V),c[V]=!1)}function de(V,ye){return d[V]!==ye?(r.bindFramebuffer(V,ye),d[V]=ye,n&&(V===36009&&(d[36160]=ye),V===36160&&(d[36009]=ye)),!0):!1}function te(V,ye){let ve=f,Qe=!1;if(V)if(ve=h.get(ye),ve===void 0&&(ve=[],h.set(ye,ve)),V.isWebGLMultipleRenderTargets){let Re=V.texture;if(ve.length!==Re.length||ve[0]!==36064){for(let Je=0,we=Re.length;Je<we;Je++)ve[Je]=36064+Je;ve.length=Re.length,Qe=!0}}else ve[0]!==36064&&(ve[0]=36064,Qe=!0);else ve[0]!==1029&&(ve[0]=1029,Qe=!0);Qe&&(t.isWebGL2?r.drawBuffers(ve):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function Q(V){return m!==V?(r.useProgram(V),m=V,!0):!1}let q={[bl]:32774,[F2]:32778,[U2]:32779};if(n)q[vw]=32775,q[xw]=32776;else{let V=e.get("EXT_blend_minmax");V!==null&&(q[vw]=V.MIN_EXT,q[xw]=V.MAX_EXT)}let se={[G2]:0,[k2]:1,[z2]:768,[YS]:770,[Y2]:776,[j2]:774,[H2]:772,[V2]:769,[XS]:771,[q2]:775,[W2]:773};function oe(V,ye,ve,Qe,Re,Je,we,$e){if(V===Lt){p===!0&&(G(3042),p=!1);return}if(p===!1&&(Y(3042),p=!0),V!==B2){if(V!==g||$e!==T){if((y!==bl||w!==bl)&&(r.blendEquation(32774),y=bl,w=bl),$e)switch(V){case Al:r.blendFuncSeparate(1,771,1,771);break;case mw:r.blendFunc(1,1);break;case gw:r.blendFuncSeparate(0,769,0,1);break;case yw:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",V);break}else switch(V){case Al:r.blendFuncSeparate(770,771,1,771);break;case mw:r.blendFunc(770,1);break;case gw:r.blendFuncSeparate(0,769,0,1);break;case yw:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",V);break}v=null,b=null,S=null,_=null,g=V,T=$e}return}Re=Re||ye,Je=Je||ve,we=we||Qe,(ye!==y||Re!==w)&&(r.blendEquationSeparate(q[ye],q[Re]),y=ye,w=Re),(ve!==v||Qe!==b||Je!==S||we!==_)&&(r.blendFuncSeparate(se[ve],se[Qe],se[Je],se[we]),v=ve,b=Qe,S=Je,_=we),g=V,T=null}function ae(V,ye){V.side===Lr?G(2884):Y(2884);let ve=V.side===Pn;ye&&(ve=!ve),_e(ve),V.blending===Al&&V.transparent===!1?oe(Lt):oe(V.blending,V.blendEquation,V.blendSrc,V.blendDst,V.blendEquationAlpha,V.blendSrcAlpha,V.blendDstAlpha,V.premultipliedAlpha),l.setFunc(V.depthFunc),l.setTest(V.depthTest),l.setMask(V.depthWrite),a.setMask(V.colorWrite);let Qe=V.stencilWrite;u.setTest(Qe),Qe&&(u.setMask(V.stencilWriteMask),u.setFunc(V.stencilFunc,V.stencilRef,V.stencilFuncMask),u.setOp(V.stencilFail,V.stencilZFail,V.stencilZPass)),be(V.polygonOffset,V.polygonOffsetFactor,V.polygonOffsetUnits),V.alphaToCoverage===!0?Y(32926):G(32926)}function _e(V){x!==V&&(V?r.frontFace(2304):r.frontFace(2305),x=V)}function me(V){V!==L2?(Y(2884),V!==M&&(V===pw?r.cullFace(1029):V===R2?r.cullFace(1028):r.cullFace(1032))):G(2884),M=V}function xe(V){V!==E&&(I&&r.lineWidth(V),E=V)}function be(V,ye,ve){V?(Y(32823),(C!==ye||P!==ve)&&(r.polygonOffset(ye,ve),C=ye,P=ve)):G(32823)}function fe(V){V?Y(3089):G(3089)}function Pe(V){V===void 0&&(V=33984+O-1),W!==V&&(r.activeTexture(V),W=V)}function Ne(V,ye){W===null&&Pe();let ve=X[W];ve===void 0&&(ve={type:void 0,texture:void 0},X[W]=ve),(ve.type!==V||ve.texture!==ye)&&(r.bindTexture(V,ye||j[V]),ve.type=V,ve.texture=ye)}function Ke(){let V=X[W];V!==void 0&&V.type!==void 0&&(r.bindTexture(V.type,null),V.type=void 0,V.texture=void 0)}function R(){try{r.compressedTexImage2D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function D(){try{r.texSubImage2D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function ce(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function pe(){try{r.texStorage2D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Me(){try{r.texStorage3D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function ke(){try{r.texImage2D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function re(){try{r.texImage3D.apply(r,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Fe(V){K.equals(V)===!1&&(r.scissor(V.x,V.y,V.z,V.w),K.copy(V))}function Le(V){H.equals(V)===!1&&(r.viewport(V.x,V.y,V.z,V.w),H.copy(V))}function De(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),c={},W=null,X={},d={},h=new WeakMap,f=[],m=null,p=!1,g=null,y=null,v=null,b=null,w=null,S=null,_=null,T=!1,x=null,M=null,E=null,C=null,P=null,K.set(0,0,r.canvas.width,r.canvas.height),H.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:Y,disable:G,bindFramebuffer:de,drawBuffers:te,useProgram:Q,setBlending:oe,setMaterial:ae,setFlipSided:_e,setCullFace:me,setLineWidth:xe,setPolygonOffset:be,setScissorTest:fe,activeTexture:Pe,bindTexture:Ne,unbindTexture:Ke,compressedTexImage2D:R,texImage2D:ke,texImage3D:re,texStorage2D:pe,texStorage3D:Me,texSubImage2D:D,texSubImage3D:J,compressedTexSubImage2D:ce,scissor:Fe,viewport:Le,reset:De}}function b3(r,e,t,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,d=i.maxSamples,h=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=/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):zf("canvas")}function b(R,D,J,ce){let pe=1;if((R.width>ce||R.height>ce)&&(pe=ce/Math.max(R.width,R.height)),pe<1||D===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Me=D?kf:Math.floor,ke=Me(pe*R.width),re=Me(pe*R.height);p===void 0&&(p=v(ke,re));let Fe=J?v(ke,re):p;return Fe.width=ke,Fe.height=re,Fe.getContext("2d").drawImage(R,0,0,ke,re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+ke+"x"+re+")."),Fe}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 uv(R.width)&&uv(R.height)}function S(R){return a?!1:R.wrapS!==rr||R.wrapT!==rr||R.minFilter!==Bt&&R.minFilter!==st}function _(R,D){return R.generateMipmaps&&D&&R.minFilter!==Bt&&R.minFilter!==st}function T(R){r.generateMipmap(R)}function x(R,D,J,ce,pe=!1){if(a===!1)return D;if(R!==null){if(r[R]!==void 0)return r[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Me=D;return D===6403&&(J===5126&&(Me=33326),J===5131&&(Me=33325),J===5121&&(Me=33321)),D===33319&&(J===5126&&(Me=33328),J===5131&&(Me=33327),J===5121&&(Me=33323)),D===6408&&(J===5126&&(Me=34836),J===5131&&(Me=34842),J===5121&&(Me=ce===Ye&&pe===!1?35907:32856),J===32819&&(Me=32854),J===32820&&(Me=32855)),(Me===33325||Me===33326||Me===33327||Me===33328||Me===34842||Me===34836)&&e.get("EXT_color_buffer_float"),Me}function M(R,D,J){return _(R,J)===!0||R.isFramebufferTexture&&R.minFilter!==Bt&&R.minFilter!==st?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 E(R){return R===Bt||R===bw||R===ww?9728:9729}function C(R){let D=R.target;D.removeEventListener("dispose",C),O(D),D.isVideoTexture&&m.delete(D)}function P(R){let D=R.target;D.removeEventListener("dispose",P),N(D)}function O(R){let D=n.get(R);if(D.__webglInit===void 0)return;let J=R.source,ce=g.get(J);if(ce){let pe=ce[D.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&I(R),Object.keys(ce).length===0&&g.delete(J)}n.remove(R)}function I(R){let D=n.get(R);r.deleteTexture(D.__webglTexture);let J=R.source,ce=g.get(J);delete ce[D.__cacheKey],o.memory.textures--}function N(R){let D=R.texture,J=n.get(R),ce=n.get(D);if(ce.__webglTexture!==void 0&&(r.deleteTexture(ce.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++)r.deleteFramebuffer(J.__webglFramebuffer[pe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[pe]);else{if(r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let pe=0;pe<J.__webglColorRenderbuffer.length;pe++)J.__webglColorRenderbuffer[pe]&&r.deleteRenderbuffer(J.__webglColorRenderbuffer[pe]);J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let pe=0,Me=D.length;pe<Me;pe++){let ke=n.get(D[pe]);ke.__webglTexture&&(r.deleteTexture(ke.__webglTexture),o.memory.textures--),n.remove(D[pe])}n.remove(D),n.remove(R)}let B=0;function W(){B=0}function X(){let R=B;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),B+=1,R}function F(R){let D=[];return D.push(R.wrapS),D.push(R.wrapT),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 k(R,D){let J=n.get(R);if(R.isVideoTexture&&Ne(R),R.isRenderTargetTexture===!1&&R.version>0&&J.__version!==R.version){let ce=R.image;if(ce===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ce.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{te(J,R,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,J.__webglTexture)}function K(R,D){let J=n.get(R);if(R.version>0&&J.__version!==R.version){te(J,R,D);return}t.activeTexture(33984+D),t.bindTexture(35866,J.__webglTexture)}function H(R,D){let J=n.get(R);if(R.version>0&&J.__version!==R.version){te(J,R,D);return}t.activeTexture(33984+D),t.bindTexture(32879,J.__webglTexture)}function z(R,D){let J=n.get(R);if(R.version>0&&J.__version!==R.version){Q(J,R,D);return}t.activeTexture(33984+D),t.bindTexture(34067,J.__webglTexture)}let j={[Tl]:10497,[rr]:33071,[av]:33648},Y={[Bt]:9728,[bw]:9984,[ww]:9986,[st]:9729,[lI]:9985,[Hl]:9987};function G(R,D,J){if(J?(r.texParameteri(R,10242,j[D.wrapS]),r.texParameteri(R,10243,j[D.wrapT]),(R===32879||R===35866)&&r.texParameteri(R,32882,j[D.wrapR]),r.texParameteri(R,10240,Y[D.magFilter]),r.texParameteri(R,10241,Y[D.minFilter])):(r.texParameteri(R,10242,33071),r.texParameteri(R,10243,33071),(R===32879||R===35866)&&r.texParameteri(R,32882,33071),(D.wrapS!==rr||D.wrapT!==rr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(R,10240,E(D.magFilter)),r.texParameteri(R,10241,E(D.minFilter)),D.minFilter!==Bt&&D.minFilter!==st&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let ce=e.get("EXT_texture_filter_anisotropic");if(D.type===Bi&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===ud&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(r.texParameterf(R,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function de(R,D){let J=!1;R.__webglInit===void 0&&(R.__webglInit=!0,D.addEventListener("dispose",C));let ce=D.source,pe=g.get(ce);pe===void 0&&(pe={},g.set(ce,pe));let Me=F(D);if(Me!==R.__cacheKey){pe[Me]===void 0&&(pe[Me]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,J=!0),pe[Me].usedTimes++;let ke=pe[R.__cacheKey];ke!==void 0&&(pe[R.__cacheKey].usedTimes--,ke.usedTimes===0&&I(D)),R.__cacheKey=Me,R.__webglTexture=pe[Me].texture}return J}function te(R,D,J){let ce=3553;D.isDataArrayTexture&&(ce=35866),D.isData3DTexture&&(ce=32879);let pe=de(R,D),Me=D.source;if(t.activeTexture(33984+J),t.bindTexture(ce,R.__webglTexture),Me.version!==Me.__currentVersion||pe===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let ke=S(D)&&w(D.image)===!1,re=b(D.image,ke,!1,c);re=Ke(D,re);let Fe=w(re)||a,Le=s.convert(D.format,D.encoding),De=s.convert(D.type),V=x(D.internalFormat,Le,De,D.encoding,D.isVideoTexture);G(ce,D,Fe);let ye,ve=D.mipmaps,Qe=a&&D.isVideoTexture!==!0,Re=Me.__currentVersion===void 0||pe===!0,Je=M(D,re,Fe);if(D.isDepthTexture)V=6402,a?D.type===Bi?V=36012:D.type===Ts?V=33190:D.type===so?V=35056:V=33189:D.type===Bi&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===aa&&V===6402&&D.type!==QS&&D.type!==Ts&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Ts,De=s.convert(D.type)),D.format===lo&&V===6402&&(V=34041,D.type!==so&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=so,De=s.convert(D.type))),Re&&(Qe?t.texStorage2D(3553,1,V,re.width,re.height):t.texImage2D(3553,0,V,re.width,re.height,0,Le,De,null));else if(D.isDataTexture)if(ve.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Je,V,ve[0].width,ve[0].height);for(let we=0,$e=ve.length;we<$e;we++)ye=ve[we],Qe?t.texSubImage2D(3553,we,0,0,ye.width,ye.height,Le,De,ye.data):t.texImage2D(3553,we,V,ye.width,ye.height,0,Le,De,ye.data);D.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Je,V,re.width,re.height),t.texSubImage2D(3553,0,0,0,re.width,re.height,Le,De,re.data)):t.texImage2D(3553,0,V,re.width,re.height,0,Le,De,re.data);else if(D.isCompressedTexture){Qe&&Re&&t.texStorage2D(3553,Je,V,ve[0].width,ve[0].height);for(let we=0,$e=ve.length;we<$e;we++)ye=ve[we],D.format!==hi?Le!==null?Qe?t.compressedTexSubImage2D(3553,we,0,0,ye.width,ye.height,Le,ye.data):t.compressedTexImage2D(3553,we,V,ye.width,ye.height,0,ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?t.texSubImage2D(3553,we,0,0,ye.width,ye.height,Le,De,ye.data):t.texImage2D(3553,we,V,ye.width,ye.height,0,Le,De,ye.data)}else if(D.isDataArrayTexture)Qe?(Re&&t.texStorage3D(35866,Je,V,re.width,re.height,re.depth),t.texSubImage3D(35866,0,0,0,0,re.width,re.height,re.depth,Le,De,re.data)):t.texImage3D(35866,0,V,re.width,re.height,re.depth,0,Le,De,re.data);else if(D.isData3DTexture)Qe?(Re&&t.texStorage3D(32879,Je,V,re.width,re.height,re.depth),t.texSubImage3D(32879,0,0,0,0,re.width,re.height,re.depth,Le,De,re.data)):t.texImage3D(32879,0,V,re.width,re.height,re.depth,0,Le,De,re.data);else if(D.isFramebufferTexture){if(Re)if(Qe)t.texStorage2D(3553,Je,V,re.width,re.height);else{let we=re.width,$e=re.height;for(let St=0;St<Je;St++)t.texImage2D(3553,St,V,we,$e,0,Le,De,null),we>>=1,$e>>=1}}else if(ve.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Je,V,ve[0].width,ve[0].height);for(let we=0,$e=ve.length;we<$e;we++)ye=ve[we],Qe?t.texSubImage2D(3553,we,0,0,Le,De,ye):t.texImage2D(3553,we,V,Le,De,ye);D.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Je,V,re.width,re.height),t.texSubImage2D(3553,0,0,0,Le,De,re)):t.texImage2D(3553,0,V,Le,De,re);_(D,Fe)&&T(ce),Me.__currentVersion=Me.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function Q(R,D,J){if(D.image.length!==6)return;let ce=de(R,D),pe=D.source;if(t.activeTexture(33984+J),t.bindTexture(34067,R.__webglTexture),pe.version!==pe.__currentVersion||ce===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let Me=D.isCompressedTexture||D.image[0].isCompressedTexture,ke=D.image[0]&&D.image[0].isDataTexture,re=[];for(let we=0;we<6;we++)!Me&&!ke?re[we]=b(D.image[we],!1,!0,u):re[we]=ke?D.image[we].image:D.image[we],re[we]=Ke(D,re[we]);let Fe=re[0],Le=w(Fe)||a,De=s.convert(D.format,D.encoding),V=s.convert(D.type),ye=x(D.internalFormat,De,V,D.encoding),ve=a&&D.isVideoTexture!==!0,Qe=pe.__currentVersion===void 0||ce===!0,Re=M(D,Fe,Le);G(34067,D,Le);let Je;if(Me){ve&&Qe&&t.texStorage2D(34067,Re,ye,Fe.width,Fe.height);for(let we=0;we<6;we++){Je=re[we].mipmaps;for(let $e=0;$e<Je.length;$e++){let St=Je[$e];D.format!==hi?De!==null?ve?t.compressedTexSubImage2D(34069+we,$e,0,0,St.width,St.height,De,St.data):t.compressedTexImage2D(34069+we,$e,ye,St.width,St.height,0,St.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ve?t.texSubImage2D(34069+we,$e,0,0,St.width,St.height,De,V,St.data):t.texImage2D(34069+we,$e,ye,St.width,St.height,0,De,V,St.data)}}}else{Je=D.mipmaps,ve&&Qe&&(Je.length>0&&Re++,t.texStorage2D(34067,Re,ye,re[0].width,re[0].height));for(let we=0;we<6;we++)if(ke){ve?t.texSubImage2D(34069+we,0,0,0,re[we].width,re[we].height,De,V,re[we].data):t.texImage2D(34069+we,0,ye,re[we].width,re[we].height,0,De,V,re[we].data);for(let $e=0;$e<Je.length;$e++){let ot=Je[$e].image[we].image;ve?t.texSubImage2D(34069+we,$e+1,0,0,ot.width,ot.height,De,V,ot.data):t.texImage2D(34069+we,$e+1,ye,ot.width,ot.height,0,De,V,ot.data)}}else{ve?t.texSubImage2D(34069+we,0,0,0,De,V,re[we]):t.texImage2D(34069+we,0,ye,De,V,re[we]);for(let $e=0;$e<Je.length;$e++){let St=Je[$e];ve?t.texSubImage2D(34069+we,$e+1,0,0,De,V,St.image[we]):t.texImage2D(34069+we,$e+1,ye,De,V,St.image[we])}}}_(D,Le)&&T(34067),pe.__currentVersion=pe.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function q(R,D,J,ce,pe){let Me=s.convert(J.format,J.encoding),ke=s.convert(J.type),re=x(J.internalFormat,Me,ke,J.encoding);n.get(D).__hasExternalTextures||(pe===32879||pe===35866?t.texImage3D(pe,0,re,D.width,D.height,D.depth,0,Me,ke,null):t.texImage2D(pe,0,re,D.width,D.height,0,Me,ke,null)),t.bindFramebuffer(36160,R),Pe(D)?h.framebufferTexture2DMultisampleEXT(36160,ce,pe,n.get(J).__webglTexture,0,fe(D)):r.framebufferTexture2D(36160,ce,pe,n.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function se(R,D,J){if(r.bindRenderbuffer(36161,R),D.depthBuffer&&!D.stencilBuffer){let ce=33189;if(J||Pe(D)){let pe=D.depthTexture;pe&&pe.isDepthTexture&&(pe.type===Bi?ce=36012:pe.type===Ts&&(ce=33190));let Me=fe(D);Pe(D)?h.renderbufferStorageMultisampleEXT(36161,Me,ce,D.width,D.height):r.renderbufferStorageMultisample(36161,Me,ce,D.width,D.height)}else r.renderbufferStorage(36161,ce,D.width,D.height);r.framebufferRenderbuffer(36160,36096,36161,R)}else if(D.depthBuffer&&D.stencilBuffer){let ce=fe(D);J&&Pe(D)===!1?r.renderbufferStorageMultisample(36161,ce,35056,D.width,D.height):Pe(D)?h.renderbufferStorageMultisampleEXT(36161,ce,35056,D.width,D.height):r.renderbufferStorage(36161,34041,D.width,D.height),r.framebufferRenderbuffer(36160,33306,36161,R)}else{let ce=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let pe=0;pe<ce.length;pe++){let Me=ce[pe],ke=s.convert(Me.format,Me.encoding),re=s.convert(Me.type),Fe=x(Me.internalFormat,ke,re,Me.encoding),Le=fe(D);J&&Pe(D)===!1?r.renderbufferStorageMultisample(36161,Le,Fe,D.width,D.height):Pe(D)?h.renderbufferStorageMultisampleEXT(36161,Le,Fe,D.width,D.height):r.renderbufferStorage(36161,Fe,D.width,D.height)}}r.bindRenderbuffer(36161,null)}function oe(R,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.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),k(D.depthTexture,0);let ce=n.get(D.depthTexture).__webglTexture,pe=fe(D);if(D.depthTexture.format===aa)Pe(D)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,ce,0,pe):r.framebufferTexture2D(36160,36096,3553,ce,0);else if(D.depthTexture.format===lo)Pe(D)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,ce,0,pe):r.framebufferTexture2D(36160,33306,3553,ce,0);else throw new Error("Unknown depthTexture format")}function ae(R){let D=n.get(R),J=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!D.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");oe(D.__webglFramebuffer,R)}else if(J){D.__webglDepthbuffer=[];for(let ce=0;ce<6;ce++)t.bindFramebuffer(36160,D.__webglFramebuffer[ce]),D.__webglDepthbuffer[ce]=r.createRenderbuffer(),se(D.__webglDepthbuffer[ce],R,!1)}else t.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=r.createRenderbuffer(),se(D.__webglDepthbuffer,R,!1);t.bindFramebuffer(36160,null)}function _e(R,D,J){let ce=n.get(R);D!==void 0&&q(ce.__webglFramebuffer,R,R.texture,36064,3553),J!==void 0&&ae(R)}function me(R){let D=R.texture,J=n.get(R),ce=n.get(D);R.addEventListener("dispose",P),R.isWebGLMultipleRenderTargets!==!0&&(ce.__webglTexture===void 0&&(ce.__webglTexture=r.createTexture()),ce.__version=D.version,o.memory.textures++);let pe=R.isWebGLCubeRenderTarget===!0,Me=R.isWebGLMultipleRenderTargets===!0,ke=w(R)||a;if(pe){J.__webglFramebuffer=[];for(let re=0;re<6;re++)J.__webglFramebuffer[re]=r.createFramebuffer()}else{if(J.__webglFramebuffer=r.createFramebuffer(),Me)if(i.drawBuffers){let re=R.texture;for(let Fe=0,Le=re.length;Fe<Le;Fe++){let De=n.get(re[Fe]);De.__webglTexture===void 0&&(De.__webglTexture=r.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&&Pe(R)===!1){let re=Me?D:[D];J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer);for(let Fe=0;Fe<re.length;Fe++){let Le=re[Fe];J.__webglColorRenderbuffer[Fe]=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer[Fe]);let De=s.convert(Le.format,Le.encoding),V=s.convert(Le.type),ye=x(Le.internalFormat,De,V,Le.encoding),ve=fe(R);r.renderbufferStorageMultisample(36161,ve,ye,R.width,R.height),r.framebufferRenderbuffer(36160,36064+Fe,36161,J.__webglColorRenderbuffer[Fe])}r.bindRenderbuffer(36161,null),R.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),se(J.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(36160,null)}}if(pe){t.bindTexture(34067,ce.__webglTexture),G(34067,D,ke);for(let re=0;re<6;re++)q(J.__webglFramebuffer[re],R,D,36064,34069+re);_(D,ke)&&T(34067),t.unbindTexture()}else if(Me){let re=R.texture;for(let Fe=0,Le=re.length;Fe<Le;Fe++){let De=re[Fe],V=n.get(De);t.bindTexture(3553,V.__webglTexture),G(3553,De,ke),q(J.__webglFramebuffer,R,De,36064+Fe,3553),_(De,ke)&&T(3553)}t.unbindTexture()}else{let re=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?re=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(re,ce.__webglTexture),G(re,D,ke),q(J.__webglFramebuffer,R,D,36064,re),_(D,ke)&&T(re),t.unbindTexture()}R.depthBuffer&&ae(R)}function xe(R){let D=w(R)||a,J=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ce=0,pe=J.length;ce<pe;ce++){let Me=J[ce];if(_(Me,D)){let ke=R.isWebGLCubeRenderTarget?34067:3553,re=n.get(Me).__webglTexture;t.bindTexture(ke,re),T(ke),t.unbindTexture()}}}function be(R){if(a&&R.samples>0&&Pe(R)===!1){let D=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],J=R.width,ce=R.height,pe=16384,Me=[],ke=R.stencilBuffer?33306:36096,re=n.get(R),Fe=R.isWebGLMultipleRenderTargets===!0;if(Fe)for(let Le=0;Le<D.length;Le++)t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Le,36161,null),t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Le,3553,null,0);t.bindFramebuffer(36008,re.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,re.__webglFramebuffer);for(let Le=0;Le<D.length;Le++){Me.push(36064+Le),R.depthBuffer&&Me.push(ke);let De=re.__ignoreDepthValues!==void 0?re.__ignoreDepthValues:!1;if(De===!1&&(R.depthBuffer&&(pe|=256),R.stencilBuffer&&(pe|=1024)),Fe&&r.framebufferRenderbuffer(36008,36064,36161,re.__webglColorRenderbuffer[Le]),De===!0&&(r.invalidateFramebuffer(36008,[ke]),r.invalidateFramebuffer(36009,[ke])),Fe){let V=n.get(D[Le]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,V,0)}r.blitFramebuffer(0,0,J,ce,0,0,J,ce,pe,9728),f&&r.invalidateFramebuffer(36008,Me)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Fe)for(let Le=0;Le<D.length;Le++){t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Le,36161,re.__webglColorRenderbuffer[Le]);let De=n.get(D[Le]).__webglTexture;t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Le,3553,De,0)}t.bindFramebuffer(36009,re.__webglMultisampledFramebuffer)}}function fe(R){return Math.min(d,R.samples)}function Pe(R){let D=n.get(R);return a&&R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function Ne(R){let D=o.render.frame;m.get(R)!==D&&(m.set(R,D),R.update())}function Ke(R,D){let J=R.encoding,ce=R.format,pe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===cv||J!==Rr&&(J===Ye?a===!1?e.has("EXT_sRGB")===!0&&ce===hi?(R.format=cv,R.minFilter=st,R.generateMipmaps=!1):D=Vf.sRGBToLinear(D):(ce!==hi||pe!==Ft)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),D}this.allocateTextureUnit=X,this.resetTextureUnits=W,this.setTexture2D=k,this.setTexture2DArray=K,this.setTexture3D=H,this.setTextureCube=z,this.rebindTextures=_e,this.setupRenderTarget=me,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=be,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=q,this.useMultisampledRTT=Pe}function w3(r,e,t){let n=t.isWebGL2;function i(s,o=null){let a;if(s===Ft)return 5121;if(s===hI)return 32819;if(s===fI)return 32820;if(s===cI)return 5120;if(s===uI)return 5122;if(s===QS)return 5123;if(s===dI)return 5124;if(s===Ts)return 5125;if(s===Bi)return 5126;if(s===ud)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===pI)return 6406;if(s===hi)return 6408;if(s===gI)return 6409;if(s===yI)return 6410;if(s===aa)return 6402;if(s===lo)return 34041;if(s===vI)return 6403;if(s===mI)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===cv)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===xI)return 36244;if(s===bI)return 33319;if(s===wI)return 33320;if(s===SI)return 36249;if(s===Sy||s===Ay||s===_y||s===Ty)if(o===Ye)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Sy)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ay)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===_y)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Ty)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Sy)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ay)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===_y)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Ty)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Sw||s===Aw||s===_w||s===Tw)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Sw)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Aw)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===_w)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Tw)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===AI)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Mw||s===Ew)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Mw)return o===Ye?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Ew)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Cw||s===Pw||s===Iw||s===Dw||s===Ow||s===Lw||s===Rw||s===Nw||s===Bw||s===Fw||s===Uw||s===Gw||s===kw||s===zw)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Cw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Pw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Iw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Dw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Ow)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Lw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Rw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Nw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Bw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Fw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Uw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Gw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===kw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===zw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Vw)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Vw)return o===Ye?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===so?n?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var wv=class extends rn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Fi=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}},S3={type:"move"},ad=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Fi,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 Fi,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 Fi,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(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,n);if(u.joints[p.jointName]===void 0){let v=new Fi;v.matrixAutoUpdate=!1,v.visible=!1,u.joints[p.jointName]=v,u.add(v)}let y=u.joints[p.jointName];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:e.handedness,target:this})):!u.inputState.pinching&&h<=f-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.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&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(S3)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}},uo=class extends jt{constructor(e,t,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:aa,c!==aa&&c!==lo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===aa&&(n=Ts),n===void 0&&c===lo&&(n=so),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Bt,this.minFilter=l!==void 0?l:Bt,this.flipY=!1,this.generateMipmaps=!1}},Sv=class extends zt{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=null,u=null,c=null,d=null,h=null,f=null,m=t.getContextAttributes(),p=null,g=null,y=[],v=[],b=new rn;b.layers.enable(1),b.viewport=new Xe;let w=new rn;w.layers.enable(2),w.viewport=new Xe;let S=[b,w],_=new wv;_.layers.enable(1),_.layers.enable(2);let T=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let k=y[F];return k===void 0&&(k=new ad,y[F]=k),k.getTargetRaySpace()},this.getControllerGrip=function(F){let k=y[F];return k===void 0&&(k=new ad,y[F]=k),k.getGripSpace()},this.getHand=function(F){let k=y[F];return k===void 0&&(k=new ad,y[F]=k),k.getHandSpace()};function M(F){let k=v.indexOf(F.inputSource);if(k===-1)return;let K=y[k];K!==void 0&&K.dispatchEvent({type:F.type,data:F.inputSource})}function E(){i.removeEventListener("select",M),i.removeEventListener("selectstart",M),i.removeEventListener("selectend",M),i.removeEventListener("squeeze",M),i.removeEventListener("squeezestart",M),i.removeEventListener("squeezeend",M),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C);for(let F=0;F<y.length;F++){let k=v[F];k!==null&&(v[F]=null,y[F].disconnect(k))}T=null,x=null,e.setRenderTarget(p),h=null,d=null,c=null,i=null,g=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(F){l=F},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(F){if(i=F,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",M),i.addEventListener("selectstart",M),i.addEventListener("selectend",M),i.addEventListener("squeeze",M),i.addEventListener("squeezestart",M),i.addEventListener("squeezeend",M),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let k={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,t,k),i.updateRenderState({baseLayer:h}),g=new ft(h.framebufferWidth,h.framebufferHeight,{format:hi,type:Ft,encoding:e.outputEncoding})}else{let k=null,K=null,H=null;m.depth&&(H=m.stencil?35056:33190,k=m.stencil?lo:aa,K=m.stencil?so:Ts);let z={colorFormat:32856,depthFormat:H,scaleFactor:s};c=new XRWebGLBinding(i,t),d=c.createProjectionLayer(z),i.updateRenderState({layers:[d]}),g=new ft(d.textureWidth,d.textureHeight,{format:hi,type:Ft,depthTexture:new uo(d.textureWidth,d.textureHeight,K,void 0,void 0,void 0,void 0,void 0,void 0,k),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let j=e.properties.get(g);j.__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),X.setContext(i),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function C(F){for(let k=0;k<F.removed.length;k++){let K=F.removed[k],H=v.indexOf(K);H>=0&&(v[H]=null,y[H].dispatchEvent({type:"disconnected",data:K}))}for(let k=0;k<F.added.length;k++){let K=F.added[k],H=v.indexOf(K);if(H===-1){for(let j=0;j<y.length;j++)if(j>=v.length){v.push(K),H=j;break}else if(v[j]===null){v[j]=K,H=j;break}if(H===-1)break}let z=y[H];z&&z.dispatchEvent({type:"connected",data:K})}}let P=new A,O=new A;function I(F,k,K){P.setFromMatrixPosition(k.matrixWorld),O.setFromMatrixPosition(K.matrixWorld);let H=P.distanceTo(O),z=k.projectionMatrix.elements,j=K.projectionMatrix.elements,Y=z[14]/(z[10]-1),G=z[14]/(z[10]+1),de=(z[9]+1)/z[5],te=(z[9]-1)/z[5],Q=(z[8]-1)/z[0],q=(j[8]+1)/j[0],se=Y*Q,oe=Y*q,ae=H/(-Q+q),_e=ae*-Q;k.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(_e),F.translateZ(ae),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let me=Y+ae,xe=G+ae,be=se-_e,fe=oe+(H-_e),Pe=de*G/xe*me,Ne=te*G/xe*me;F.projectionMatrix.makePerspective(be,fe,Pe,Ne,me,xe)}function N(F,k){k===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(k.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(i===null)return;_.near=w.near=b.near=F.near,_.far=w.far=b.far=F.far,(T!==_.near||x!==_.far)&&(i.updateRenderState({depthNear:_.near,depthFar:_.far}),T=_.near,x=_.far);let k=F.parent,K=_.cameras;N(_,k);for(let z=0;z<K.length;z++)N(K[z],k);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),F.position.copy(_.position),F.quaternion.copy(_.quaternion),F.scale.copy(_.scale),F.matrix.copy(_.matrix),F.matrixWorld.copy(_.matrixWorld);let H=F.children;for(let z=0,j=H.length;z<j;z++)H[z].updateMatrixWorld(!0);K.length===2?I(_,b,w):_.projectionMatrix.copy(b.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(d!==null)return d.fixedFoveation;if(h!==null)return h.fixedFoveation},this.setFoveation=function(F){d!==null&&(d.fixedFoveation=F),h!==null&&h.fixedFoveation!==void 0&&(h.fixedFoveation=F)};let B=null;function W(F,k){if(u=k.getViewerPose(l||o),f=k,u!==null){let K=u.views;h!==null&&(e.setRenderTargetFramebuffer(g,h.framebuffer),e.setRenderTarget(g));let H=!1;K.length!==_.cameras.length&&(_.cameras.length=0,H=!0);for(let z=0;z<K.length;z++){let j=K[z],Y=null;if(h!==null)Y=h.getViewport(j);else{let de=c.getViewSubImage(d,j);Y=de.viewport,z===0&&(e.setRenderTargetTextures(g,de.colorTexture,d.ignoreDepthValues?void 0:de.depthStencilTexture),e.setRenderTarget(g))}let G=S[z];G===void 0&&(G=new rn,G.layers.enable(z),G.viewport=new Xe,S[z]=G),G.matrix.fromArray(j.transform.matrix),G.projectionMatrix.fromArray(j.projectionMatrix),G.viewport.set(Y.x,Y.y,Y.width,Y.height),z===0&&_.matrix.copy(G.matrix),H===!0&&_.cameras.push(G)}}for(let K=0;K<y.length;K++){let H=v[K],z=y[K];H!==null&&z!==void 0&&z.update(H,k,l||o)}B&&B(F,k),f=null}let X=new e1;X.setAnimationLoop(W),this.setAnimationLoop=function(F){B=F},this.dispose=function(){}}};function A3(r,e){function t(p,g){p.fogColor.value.copy(g.color),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,b){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),c(p,g)):g.isMeshPhongMaterial?(i(p,g),u(p,g)):g.isMeshStandardMaterial?(i(p,g),d(p,g),g.isMeshPhysicalMaterial&&h(p,g,b)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,y,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 i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===Pn&&(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===Pn&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let y=e.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=r.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 b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),p.uv2Transform.value.copy(b.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 b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),p.uvTransform.value.copy(b.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),e.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===Pn&&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:t,refreshMaterialUniforms:n}}function _3(){let r=zf("canvas");return r.style.display="block",r}function Xv(r={}){this.isWebGLRenderer=!0;let e=r.canvas!==void 0?r.canvas:_3(),t=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;t!==null?c=t.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let d=null,h=null,f=[],m=[];this.domElement=e,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=Rr,this.physicallyCorrectLights=!1,this.toneMapping=Ms,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,y=0,v=0,b=null,w=-1,S=null,_=new Xe,T=new Xe,x=null,M=e.width,E=e.height,C=1,P=null,O=null,I=new Xe(0,0,M,E),N=new Xe(0,0,M,E),B=!1,W=new fd,X=!1,F=!1,k=null,K=new he,H=new U,z=new A,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return b===null?C:1}let G=t;function de(L,$){for(let ie=0;ie<L.length;ie++){let ne=L[ie],ue=e.getContext(ne,$);if(ue!==null)return ue}return null}try{let L={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${xa}`),e.addEventListener("webglcontextlost",V,!1),e.addEventListener("webglcontextrestored",ye,!1),e.addEventListener("webglcontextcreationerror",ve,!1),G===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),G=de($,L),G===null)throw de($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}G.getShaderPrecisionFormat===void 0&&(G.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let te,Q,q,se,oe,ae,_e,me,xe,be,fe,Pe,Ne,Ke,R,D,J,ce,pe,Me,ke,re,Fe;function Le(){te=new jL(G),Q=new GL(G,te,r),te.init(Q),re=new w3(G,te,Q),q=new x3(G,te,Q),se=new XL,oe=new a3,ae=new b3(G,te,q,oe,Q,re,se),_e=new zL(p),me=new WL(p),xe=new oD(G,Q),Fe=new FL(G,te,xe,Q),be=new qL(G,xe,se,Fe),fe=new JL(G,be,xe,se),pe=new QL(G,Q,ae),D=new kL(oe),Pe=new o3(p,_e,me,te,Q,Fe,D),Ne=new A3(p,oe),Ke=new c3,R=new m3(te,Q),ce=new BL(p,_e,q,fe,c,o),J=new v3(p,fe,Q),Me=new UL(G,te,se,Q),ke=new YL(G,te,se,Q),se.programs=Pe.programs,p.capabilities=Q,p.extensions=te,p.properties=oe,p.renderLists=Ke,p.shadowMap=J,p.state=q,p.info=se}Le();let De=new Sv(p,G);this.xr=De,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){let L=te.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=te.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(L){L!==void 0&&(C=L,this.setSize(M,E,!1))},this.getSize=function(L){return L.set(M,E)},this.setSize=function(L,$,ie){if(De.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=L,E=$,e.width=Math.floor(L*C),e.height=Math.floor($*C),ie!==!1&&(e.style.width=L+"px",e.style.height=$+"px"),this.setViewport(0,0,L,$)},this.getDrawingBufferSize=function(L){return L.set(M*C,E*C).floor()},this.setDrawingBufferSize=function(L,$,ie){M=L,E=$,C=ie,e.width=Math.floor(L*ie),e.height=Math.floor($*ie),this.setViewport(0,0,L,$)},this.getCurrentViewport=function(L){return L.copy(_)},this.getViewport=function(L){return L.copy(I)},this.setViewport=function(L,$,ie,ne){L.isVector4?I.set(L.x,L.y,L.z,L.w):I.set(L,$,ie,ne),q.viewport(_.copy(I).multiplyScalar(C).floor())},this.getScissor=function(L){return L.copy(N)},this.setScissor=function(L,$,ie,ne){L.isVector4?N.set(L.x,L.y,L.z,L.w):N.set(L,$,ie,ne),q.scissor(T.copy(N).multiplyScalar(C).floor())},this.getScissorTest=function(){return B},this.setScissorTest=function(L){q.setScissorTest(B=L)},this.setOpaqueSort=function(L){P=L},this.setTransparentSort=function(L){O=L},this.getClearColor=function(L){return L.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor.apply(ce,arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha.apply(ce,arguments)},this.clear=function(L=!0,$=!0,ie=!0){let ne=0;L&&(ne|=16384),$&&(ne|=256),ie&&(ne|=1024),G.clear(ne)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",V,!1),e.removeEventListener("webglcontextrestored",ye,!1),e.removeEventListener("webglcontextcreationerror",ve,!1),Ke.dispose(),R.dispose(),oe.dispose(),_e.dispose(),me.dispose(),fe.dispose(),Fe.dispose(),Pe.dispose(),De.dispose(),De.removeEventListener("sessionstart",St),De.removeEventListener("sessionend",ot),k&&(k.dispose(),k=null),Mn.stop()};function V(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=se.autoReset,$=J.enabled,ie=J.autoUpdate,ne=J.needsUpdate,ue=J.type;Le(),se.autoReset=L,J.enabled=$,J.autoUpdate=ie,J.needsUpdate=ne,J.type=ue}function ve(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function Qe(L){let $=L.target;$.removeEventListener("dispose",Qe),Re($)}function Re(L){Je(L),oe.remove(L)}function Je(L){let $=oe.get(L).programs;$!==void 0&&($.forEach(function(ie){Pe.releaseProgram(ie)}),L.isShaderMaterial&&Pe.releaseShaderCache(L))}this.renderBufferDirect=function(L,$,ie,ne,ue,tt){$===null&&($=j);let it=ue.isMesh&&ue.matrixWorld.determinant()<0,lt=_2(L,$,ie,ne,ue);q.setMaterial(ne,it);let at=ie.index,Pt=ie.attributes.position;if(at===null){if(Pt===void 0||Pt.count===0)return}else if(at.count===0)return;let mt=1;ne.wireframe===!0&&(at=be.getWireframeAttribute(ie),mt=2),Fe.setup(ue,ne,lt,ie,at);let xt,Yt=Me;at!==null&&(xt=xe.get(at),Yt=ke,Yt.setIndex(xt));let ea=at!==null?at.count:Pt.count,rl=ie.drawRange.start*mt,il=ie.drawRange.count*mt,Oi=tt!==null?tt.start*mt:0,_t=tt!==null?tt.count*mt:1/0,sl=Math.max(rl,Oi),hn=Math.min(ea,rl+il,Oi+_t)-1,Li=Math.max(0,hn-sl+1);if(Li!==0){if(ue.isMesh)ne.wireframe===!0?(q.setLineWidth(ne.wireframeLinewidth*Y()),Yt.setMode(1)):Yt.setMode(4);else if(ue.isLine){let Zs=ne.linewidth;Zs===void 0&&(Zs=1),q.setLineWidth(Zs*Y()),ue.isLineSegments?Yt.setMode(1):ue.isLineLoop?Yt.setMode(2):Yt.setMode(3)}else ue.isPoints?Yt.setMode(0):ue.isSprite&&Yt.setMode(4);if(ue.isInstancedMesh)Yt.renderInstances(sl,Li,ue.count);else if(ie.isInstancedBufferGeometry){let Zs=Math.min(ie.instanceCount,ie._maxInstanceCount);Yt.renderInstances(sl,Li,Zs)}else Yt.render(sl,Li)}},this.compile=function(L,$){h=R.get(L),h.init(),m.push(h),L.traverseVisible(function(ie){ie.isLight&&ie.layers.test($.layers)&&(h.pushLight(ie),ie.castShadow&&h.pushShadow(ie))}),h.setupLights(p.physicallyCorrectLights),L.traverse(function(ie){let ne=ie.material;if(ne)if(Array.isArray(ne))for(let ue=0;ue<ne.length;ue++){let tt=ne[ue];vy(tt,L,ie)}else vy(ne,L,ie)}),m.pop(),h=null};let we=null;function $e(L){we&&we(L)}function St(){Mn.stop()}function ot(){Mn.start()}let Mn=new e1;Mn.setAnimationLoop($e),typeof self<"u"&&Mn.setContext(self),this.setAnimationLoop=function(L){we=L,De.setAnimationLoop(L),L===null?Mn.stop():Mn.start()},De.addEventListener("sessionstart",St),De.addEventListener("sessionend",ot),this.render=function(L,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.autoUpdate===!0&&L.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),De.enabled===!0&&De.isPresenting===!0&&(De.cameraAutoUpdate===!0&&De.updateCamera($),$=De.getCamera()),L.isScene===!0&&L.onBeforeRender(p,L,$,b),h=R.get(L,m.length),h.init(),m.push(h),K.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),W.setFromProjectionMatrix(K),F=this.localClippingEnabled,X=D.init(this.clippingPlanes,F,$),d=Ke.get(L,f.length),d.init(),f.push(d),Nt(L,$,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(P,O),X===!0&&D.beginShadows();let ie=h.state.shadowsArray;if(J.render(ie,L,$),X===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),ce.render(d,L),h.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let ne=$.cameras;for(let ue=0,tt=ne.length;ue<tt;ue++){let it=ne[ue];nl(d,L,it,it.viewport)}}else nl(d,L,$);b!==null&&(ae.updateMultisampleRenderTarget(b),ae.updateRenderTargetMipmap(b)),L.isScene===!0&&L.onAfterRender(p,L,$),Fe.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 Nt(L,$,ie,ne){if(L.visible===!1)return;if(L.layers.test($.layers)){if(L.isGroup)ie=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update($);else if(L.isLight)h.pushLight(L),L.castShadow&&h.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||W.intersectsSprite(L)){ne&&z.setFromMatrixPosition(L.matrixWorld).applyMatrix4(K);let it=fe.update(L),lt=L.material;lt.visible&&d.push(L,it,lt,ie,z.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==se.render.frame&&(L.skeleton.update(),L.skeleton.frame=se.render.frame),!L.frustumCulled||W.intersectsObject(L))){ne&&z.setFromMatrixPosition(L.matrixWorld).applyMatrix4(K);let it=fe.update(L),lt=L.material;if(Array.isArray(lt)){let at=it.groups;for(let Pt=0,mt=at.length;Pt<mt;Pt++){let xt=at[Pt],Yt=lt[xt.materialIndex];Yt&&Yt.visible&&d.push(L,it,Yt,ie,z.z,xt)}}else lt.visible&&d.push(L,it,lt,ie,z.z,null)}}let tt=L.children;for(let it=0,lt=tt.length;it<lt;it++)Nt(tt[it],$,ie,ne)}function nl(L,$,ie,ne){let ue=L.opaque,tt=L.transmissive,it=L.transparent;h.setupLightsView(ie),tt.length>0&&yy(ue,$,ie),ne&&q.viewport(_.copy(ne)),ue.length>0&&ys(ue,$,ie),tt.length>0&&ys(tt,$,ie),it.length>0&&ys(it,$,ie),q.buffers.depth.setTest(!0),q.buffers.depth.setMask(!0),q.buffers.color.setMask(!0),q.setPolygonOffset(!1)}function yy(L,$,ie){let ne=Q.isWebGL2;k===null&&(k=new ft(1,1,{generateMipmaps:!0,type:te.has("EXT_color_buffer_half_float")?ud:Ft,minFilter:Hl,samples:ne&&s===!0?4:0})),p.getDrawingBufferSize(H),ne?k.setSize(H.x,H.y):k.setSize(kf(H.x),kf(H.y));let ue=p.getRenderTarget();p.setRenderTarget(k),p.clear();let tt=p.toneMapping;p.toneMapping=Ms,ys(L,$,ie),p.toneMapping=tt,ae.updateMultisampleRenderTarget(k),ae.updateRenderTargetMipmap(k),p.setRenderTarget(ue)}function ys(L,$,ie){let ne=$.isScene===!0?$.overrideMaterial:null;for(let ue=0,tt=L.length;ue<tt;ue++){let it=L[ue],lt=it.object,at=it.geometry,Pt=ne===null?it.material:ne,mt=it.group;lt.layers.test(ie.layers)&&A2(lt,$,ie,at,Pt,mt)}}function A2(L,$,ie,ne,ue,tt){L.onBeforeRender(p,$,ie,ne,ue,tt),L.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),ue.onBeforeRender(p,$,ie,ne,L,tt),ue.transparent===!0&&ue.side===Lr?(ue.side=Pn,ue.needsUpdate=!0,p.renderBufferDirect(ie,$,ne,ue,L,tt),ue.side=Gi,ue.needsUpdate=!0,p.renderBufferDirect(ie,$,ne,ue,L,tt),ue.side=Lr):p.renderBufferDirect(ie,$,ne,ue,L,tt),L.onAfterRender(p,$,ie,ne,ue,tt)}function vy(L,$,ie){$.isScene!==!0&&($=j);let ne=oe.get(L),ue=h.state.lights,tt=h.state.shadowsArray,it=ue.state.version,lt=Pe.getParameters(L,ue.state,tt,$,ie),at=Pe.getProgramCacheKey(lt),Pt=ne.programs;ne.environment=L.isMeshStandardMaterial?$.environment:null,ne.fog=$.fog,ne.envMap=(L.isMeshStandardMaterial?me:_e).get(L.envMap||ne.environment),Pt===void 0&&(L.addEventListener("dispose",Qe),Pt=new Map,ne.programs=Pt);let mt=Pt.get(at);if(mt!==void 0){if(ne.currentProgram===mt&&ne.lightsStateVersion===it)return dw(L,lt),mt}else lt.uniforms=Pe.getUniforms(L),L.onBuild(ie,lt,p),L.onBeforeCompile(lt,p),mt=Pe.acquireProgram(lt,at),Pt.set(at,mt),ne.uniforms=lt.uniforms;let xt=ne.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(xt.clippingPlanes=D.uniform),dw(L,lt),ne.needsLights=M2(L),ne.lightsStateVersion=it,ne.needsLights&&(xt.ambientLightColor.value=ue.state.ambient,xt.lightProbe.value=ue.state.probe,xt.directionalLights.value=ue.state.directional,xt.directionalLightShadows.value=ue.state.directionalShadow,xt.spotLights.value=ue.state.spot,xt.spotLightShadows.value=ue.state.spotShadow,xt.rectAreaLights.value=ue.state.rectArea,xt.ltc_1.value=ue.state.rectAreaLTC1,xt.ltc_2.value=ue.state.rectAreaLTC2,xt.pointLights.value=ue.state.point,xt.pointLightShadows.value=ue.state.pointShadow,xt.hemisphereLights.value=ue.state.hemi,xt.directionalShadowMap.value=ue.state.directionalShadowMap,xt.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,xt.spotShadowMap.value=ue.state.spotShadowMap,xt.spotShadowMatrix.value=ue.state.spotShadowMatrix,xt.pointShadowMap.value=ue.state.pointShadowMap,xt.pointShadowMatrix.value=ue.state.pointShadowMatrix);let Yt=mt.getUniforms(),ea=_l.seqWithValue(Yt.seq,xt);return ne.currentProgram=mt,ne.uniformsList=ea,mt}function dw(L,$){let ie=oe.get(L);ie.outputEncoding=$.outputEncoding,ie.instancing=$.instancing,ie.skinning=$.skinning,ie.morphTargets=$.morphTargets,ie.morphNormals=$.morphNormals,ie.morphColors=$.morphColors,ie.morphTargetsCount=$.morphTargetsCount,ie.numClippingPlanes=$.numClippingPlanes,ie.numIntersection=$.numClipIntersection,ie.vertexAlphas=$.vertexAlphas,ie.vertexTangents=$.vertexTangents,ie.toneMapping=$.toneMapping}function _2(L,$,ie,ne,ue){$.isScene!==!0&&($=j),ae.resetTextureUnits();let tt=$.fog,it=ne.isMeshStandardMaterial?$.environment:null,lt=b===null?p.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:Rr,at=(ne.isMeshStandardMaterial?me:_e).get(ne.envMap||it),Pt=ne.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,mt=!!ne.normalMap&&!!ie.attributes.tangent,xt=!!ie.morphAttributes.position,Yt=!!ie.morphAttributes.normal,ea=!!ie.morphAttributes.color,rl=ne.toneMapped?p.toneMapping:Ms,il=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,Oi=il!==void 0?il.length:0,_t=oe.get(ne),sl=h.state.lights;if(X===!0&&(F===!0||L!==S)){let Ri=L===S&&ne.id===w;D.setState(ne,L,Ri)}let hn=!1;ne.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==sl.state.version||_t.outputEncoding!==lt||ue.isInstancedMesh&&_t.instancing===!1||!ue.isInstancedMesh&&_t.instancing===!0||ue.isSkinnedMesh&&_t.skinning===!1||!ue.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==at||ne.fog===!0&&_t.fog!==tt||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==D.numPlanes||_t.numIntersection!==D.numIntersection)||_t.vertexAlphas!==Pt||_t.vertexTangents!==mt||_t.morphTargets!==xt||_t.morphNormals!==Yt||_t.morphColors!==ea||_t.toneMapping!==rl||Q.isWebGL2===!0&&_t.morphTargetsCount!==Oi)&&(hn=!0):(hn=!0,_t.__version=ne.version);let Li=_t.currentProgram;hn===!0&&(Li=vy(ne,$,ue));let Zs=!1,Qu=!1,xy=!1,tr=Li.getUniforms(),Ju=_t.uniforms;if(q.useProgram(Li.program)&&(Zs=!0,Qu=!0,xy=!0),ne.id!==w&&(w=ne.id,Qu=!0),Zs||S!==L){if(tr.setValue(G,"projectionMatrix",L.projectionMatrix),Q.logarithmicDepthBuffer&&tr.setValue(G,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),S!==L&&(S=L,Qu=!0,xy=!0),ne.isShaderMaterial||ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshStandardMaterial||ne.envMap){let Ri=tr.map.cameraPosition;Ri!==void 0&&Ri.setValue(G,z.setFromMatrixPosition(L.matrixWorld))}(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&tr.setValue(G,"isOrthographic",L.isOrthographicCamera===!0),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial||ne.isShadowMaterial||ue.isSkinnedMesh)&&tr.setValue(G,"viewMatrix",L.matrixWorldInverse)}if(ue.isSkinnedMesh){tr.setOptional(G,ue,"bindMatrix"),tr.setOptional(G,ue,"bindMatrixInverse");let Ri=ue.skeleton;Ri&&(Q.floatVertexTextures?(Ri.boneTexture===null&&Ri.computeBoneTexture(),tr.setValue(G,"boneTexture",Ri.boneTexture,ae),tr.setValue(G,"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 by=ie.morphAttributes;return(by.position!==void 0||by.normal!==void 0||by.color!==void 0&&Q.isWebGL2===!0)&&pe.update(ue,ie,ne,Li),(Qu||_t.receiveShadow!==ue.receiveShadow)&&(_t.receiveShadow=ue.receiveShadow,tr.setValue(G,"receiveShadow",ue.receiveShadow)),Qu&&(tr.setValue(G,"toneMappingExposure",p.toneMappingExposure),_t.needsLights&&T2(Ju,xy),tt&&ne.fog===!0&&Ne.refreshFogUniforms(Ju,tt),Ne.refreshMaterialUniforms(Ju,ne,C,E,k),_l.upload(G,_t.uniformsList,Ju,ae)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(_l.upload(G,_t.uniformsList,Ju,ae),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&tr.setValue(G,"center",ue.center),tr.setValue(G,"modelViewMatrix",ue.modelViewMatrix),tr.setValue(G,"normalMatrix",ue.normalMatrix),tr.setValue(G,"modelMatrix",ue.matrixWorld),Li}function T2(L,$){L.ambientLightColor.needsUpdate=$,L.lightProbe.needsUpdate=$,L.directionalLights.needsUpdate=$,L.directionalLightShadows.needsUpdate=$,L.pointLights.needsUpdate=$,L.pointLightShadows.needsUpdate=$,L.spotLights.needsUpdate=$,L.spotLightShadows.needsUpdate=$,L.rectAreaLights.needsUpdate=$,L.hemisphereLights.needsUpdate=$}function M2(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(L,$,ie){oe.get(L.texture).__webglTexture=$,oe.get(L.depthTexture).__webglTexture=ie;let ne=oe.get(L);ne.__hasExternalTextures=!0,ne.__hasExternalTextures&&(ne.__autoAllocateDepthBuffer=ie===void 0,ne.__autoAllocateDepthBuffer||te.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ne.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,$){let ie=oe.get(L);ie.__webglFramebuffer=$,ie.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(L,$=0,ie=0){b=L,y=$,v=ie;let ne=!0;if(L){let at=oe.get(L);at.__useDefaultFramebuffer!==void 0?(q.bindFramebuffer(36160,null),ne=!1):at.__webglFramebuffer===void 0?ae.setupRenderTarget(L):at.__hasExternalTextures&&ae.rebindTextures(L,oe.get(L.texture).__webglTexture,oe.get(L.depthTexture).__webglTexture)}let ue=null,tt=!1,it=!1;if(L){let at=L.texture;(at.isData3DTexture||at.isDataArrayTexture)&&(it=!0);let Pt=oe.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(ue=Pt[$],tt=!0):Q.isWebGL2&&L.samples>0&&ae.useMultisampledRTT(L)===!1?ue=oe.get(L).__webglMultisampledFramebuffer:ue=Pt,_.copy(L.viewport),T.copy(L.scissor),x=L.scissorTest}else _.copy(I).multiplyScalar(C).floor(),T.copy(N).multiplyScalar(C).floor(),x=B;if(q.bindFramebuffer(36160,ue)&&Q.drawBuffers&&ne&&q.drawBuffers(L,ue),q.viewport(_),q.scissor(T),q.setScissorTest(x),tt){let at=oe.get(L.texture);G.framebufferTexture2D(36160,36064,34069+$,at.__webglTexture,ie)}else if(it){let at=oe.get(L.texture),Pt=$||0;G.framebufferTextureLayer(36160,36064,at.__webglTexture,ie||0,Pt)}w=-1},this.readRenderTargetPixels=function(L,$,ie,ne,ue,tt,it){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let lt=oe.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&it!==void 0&&(lt=lt[it]),lt){q.bindFramebuffer(36160,lt);try{let at=L.texture,Pt=at.format,mt=at.type;if(Pt!==hi&&re.convert(Pt)!==G.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let xt=mt===ud&&(te.has("EXT_color_buffer_half_float")||Q.isWebGL2&&te.has("EXT_color_buffer_float"));if(mt!==Ft&&re.convert(mt)!==G.getParameter(35738)&&!(mt===Bi&&(Q.isWebGL2||te.has("OES_texture_float")||te.has("WEBGL_color_buffer_float")))&&!xt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=L.width-ne&&ie>=0&&ie<=L.height-ue&&G.readPixels($,ie,ne,ue,re.convert(Pt),re.convert(mt),tt)}finally{let at=b!==null?oe.get(b).__webglFramebuffer:null;q.bindFramebuffer(36160,at)}}},this.copyFramebufferToTexture=function(L,$,ie=0){let ne=Math.pow(2,-ie),ue=Math.floor($.image.width*ne),tt=Math.floor($.image.height*ne);ae.setTexture2D($,0),G.copyTexSubImage2D(3553,ie,0,0,L.x,L.y,ue,tt),q.unbindTexture()},this.copyTextureToTexture=function(L,$,ie,ne=0){let ue=$.image.width,tt=$.image.height,it=re.convert(ie.format),lt=re.convert(ie.type);ae.setTexture2D(ie,0),G.pixelStorei(37440,ie.flipY),G.pixelStorei(37441,ie.premultiplyAlpha),G.pixelStorei(3317,ie.unpackAlignment),$.isDataTexture?G.texSubImage2D(3553,ne,L.x,L.y,ue,tt,it,lt,$.image.data):$.isCompressedTexture?G.compressedTexSubImage2D(3553,ne,L.x,L.y,$.mipmaps[0].width,$.mipmaps[0].height,it,$.mipmaps[0].data):G.texSubImage2D(3553,ne,L.x,L.y,it,lt,$.image),ne===0&&ie.generateMipmaps&&G.generateMipmap(3553),q.unbindTexture()},this.copyTextureToTexture3D=function(L,$,ie,ne,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let tt=L.max.x-L.min.x+1,it=L.max.y-L.min.y+1,lt=L.max.z-L.min.z+1,at=re.convert(ne.format),Pt=re.convert(ne.type),mt;if(ne.isData3DTexture)ae.setTexture3D(ne,0),mt=32879;else if(ne.isDataArrayTexture)ae.setTexture2DArray(ne,0),mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}G.pixelStorei(37440,ne.flipY),G.pixelStorei(37441,ne.premultiplyAlpha),G.pixelStorei(3317,ne.unpackAlignment);let xt=G.getParameter(3314),Yt=G.getParameter(32878),ea=G.getParameter(3316),rl=G.getParameter(3315),il=G.getParameter(32877),Oi=ie.isCompressedTexture?ie.mipmaps[0]:ie.image;G.pixelStorei(3314,Oi.width),G.pixelStorei(32878,Oi.height),G.pixelStorei(3316,L.min.x),G.pixelStorei(3315,L.min.y),G.pixelStorei(32877,L.min.z),ie.isDataTexture||ie.isData3DTexture?G.texSubImage3D(mt,ue,$.x,$.y,$.z,tt,it,lt,at,Pt,Oi.data):ie.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),G.compressedTexSubImage3D(mt,ue,$.x,$.y,$.z,tt,it,lt,at,Oi.data)):G.texSubImage3D(mt,ue,$.x,$.y,$.z,tt,it,lt,at,Pt,Oi),G.pixelStorei(3314,xt),G.pixelStorei(32878,Yt),G.pixelStorei(3316,ea),G.pixelStorei(3315,rl),G.pixelStorei(32877,il),ue===0&&ne.generateMipmaps&&G.generateMipmap(mt),q.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?ae.setTextureCube(L,0):L.isData3DTexture?ae.setTexture3D(L,0):L.isDataArrayTexture?ae.setTexture2DArray(L,0):ae.setTexture2D(L,0),q.unbindTexture()},this.resetState=function(){y=0,v=0,b=null,q.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Av=class extends Xv{};Av.prototype.isWebGL1Renderer=!0;var Cl=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Oe(e),this.near=t,this.far=n}clone(){return new Cl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},or=class extends ht{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},Xf=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lv,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ui()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},nr=new A,da=class{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)nr.fromBufferAttribute(this,t),nr.applyMatrix4(e),this.setXYZ(t,nr.x,nr.y,nr.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)nr.fromBufferAttribute(this,t),nr.applyNormalMatrix(e),this.setXYZ(t,nr.x,nr.y,nr.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)nr.fromBufferAttribute(this,t),nr.transformDirection(e),this.setXYZ(t,nr.x,nr.y,nr.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Be(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new da(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var Kf=class extends Be{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};var Xr=class extends ca{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},MS=new A,ES=new A,CS=new he,$y=new fi,If=new pn,ha=class extends ht{constructor(e=new Ce,t=new Xr){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)MS.fromBufferAttribute(t,i-1),ES.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=MS.distanceTo(ES);e.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),If.copy(n.boundingSphere),If.applyMatrix4(i),If.radius+=s,e.ray.intersectsSphere(If)===!1)return;CS.copy(i).invert(),$y.copy(e.ray).applyMatrix4(CS);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 b=y,w=v-1;b<w;b+=f){let S=m.getX(b),_=m.getX(b+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,_),$y.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(h);x<e.near||x>e.far||t.push({distance:x,point:d.clone().applyMatrix4(this.matrixWorld),index:b,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 b=y,w=v-1;b<w;b+=f){if(u.fromBufferAttribute(g,b),c.fromBufferAttribute(g,b+1),$y.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(h);_<e.near||_>e.far||t.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},PS=new A,IS=new A,ho=class extends ha{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)PS.fromBufferAttribute(t,i),IS.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+PS.distanceTo(IS);e.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Zf=class extends jt{constructor(e,t,n,i,s,o,a,l,u){super(e,t,n,i,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:st,this.magFilter=s!==void 0?s:st,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Kr=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],h=n[i+1]-c,f=(o-c)/h;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new U:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new A,i=[],s=[],o=[],a=new A,l=new he;for(let f=0;f<=e;f++){let m=f/e;i[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),d=Math.abs(i[0].y),h=Math.abs(i[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(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(vn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(vn(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},fa=class extends Kr{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let n=t||new U,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*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(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},_v=class extends fa{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Kv(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){i(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,i(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var Df=new A,ev=new Kv,tv=new Kv,nv=new Kv,Tv=class extends Kr{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new A){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,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=i[(a-1)%s]:(Df.subVectors(i[0],i[1]).add(i[0]),u=Df);let d=i[a%s],h=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Df.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Df),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),ev.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,m,p,g),tv.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,m,p,g),nv.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(ev.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),tv.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),nv.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(ev.calc(l),tv.calc(l),nv.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function DS(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function T3(r,e){let t=1-r;return t*t*e}function M3(r,e){return 2*(1-r)*r*e}function E3(r,e){return r*r*e}function ld(r,e,t,n){return T3(r,e)+M3(r,t)+E3(r,n)}function C3(r,e){let t=1-r;return t*t*t*e}function P3(r,e){let t=1-r;return 3*t*t*r*e}function I3(r,e){return 3*(1-r)*r*r*e}function D3(r,e){return r*r*r*e}function cd(r,e,t,n,i){return C3(r,e)+P3(r,t)+I3(r,n)+D3(r,i)}var Kn=class extends Kr{constructor(e=new U,t=new U,n=new U,i=new U){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new U){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(cd(e,i.x,s.x,o.x,a.x),cd(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Mv=class extends Kr{constructor(e=new A,t=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(cd(e,i.x,s.x,o.x,a.x),cd(e,i.y,s.y,o.y,a.y),cd(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Zn=class extends Kr{constructor(e=new U,t=new U){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new U){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let n=t||new U;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},md=class extends Kr{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Nr=class extends Kr{constructor(e=new U,t=new U,n=new U){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new U){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(ld(e,i.x,s.x,o.x),ld(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ev=class extends Kr{constructor(e=new A,t=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(ld(e,i.x,s.x,o.x),ld(e,i.y,s.y,o.y),ld(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Pl=class extends Kr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new U){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],d=i[o>i.length-3?i.length-1:o+2];return n.set(DS(a,l.x,u.x,c.x,d.x),DS(a,l.y,u.y,c.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new U().fromArray(i))}return this}},O3=Object.freeze({__proto__:null,ArcCurve:_v,CatmullRomCurve3:Tv,CubicBezierCurve:Kn,CubicBezierCurve3:Mv,EllipseCurve:fa,LineCurve:Zn,LineCurve3:md,QuadraticBezierCurve:Nr,QuadraticBezierCurve3:Ev,SplineCurve:Pl}),Cv=class extends Kr{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Zn(t,e))}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(t.push(c),n=c)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new O3[i.type]().fromJSON(i))}return this}},pa=class extends Cv{constructor(e){super(),this.type="Path",this.currentPoint=new U,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new Zn(this.currentPoint.clone(),new U(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new Nr(this.currentPoint.clone(),new U(e,t),new U(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new Kn(this.currentPoint.clone(),new U(e,t),new U(n,i),new U(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new Pl(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+u,t+c,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let u=new fa(e,t,n,i,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(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Il=class extends Ce{constructor(e=[new U(0,.5),new U(.5,0),new U(0,-.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=vn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/t,d=new A,h=new U,f=new A,m=new A,p=new A,g=0,y=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,y=e[v+1].y-e[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 e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[v+1].x-e[v].x,y=e[v+1].y-e[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<=t;v++){let b=n+v*c*i,w=Math.sin(b),S=Math.cos(b);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*w,d.y=e[_].y,d.z=e[_].x*S,o.push(d.x,d.y,d.z),h.x=v/t,h.y=_/(e.length-1),a.push(h.x,h.y);let T=l[3*_+0]*w,x=l[3*_+1],M=l[3*_+0]*S;u.push(T,x,M)}}for(let v=0;v<t;v++)for(let b=0;b<e.length-1;b++){let w=b+v*e.length,S=w,_=w+e.length,T=w+e.length+1,x=w+1;s.push(S,_,x),s.push(T,x,_)}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(e){return new Il(e.points,e.segments,e.phiStart,e.phiLength)}};var ma=class extends Ce{constructor(e=1,t=1,n=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],d=[],h=[],f=[],m=0,p=[],g=n/2,y=0;v(),o===!1&&(e>0&&b(!0),t>0&&b(!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,T=(t-e)/n;for(let x=0;x<=s;x++){let M=[],E=x/s,C=E*(t-e)+e;for(let P=0;P<=i;P++){let O=P/i,I=O*l+a,N=Math.sin(I),B=Math.cos(I);S.x=C*N,S.y=-E*n+g,S.z=C*B,d.push(S.x,S.y,S.z),w.set(N,T,B).normalize(),h.push(w.x,w.y,w.z),f.push(O,1-E),M.push(m++)}p.push(M)}for(let x=0;x<i;x++)for(let M=0;M<s;M++){let E=p[M][x],C=p[M+1][x],P=p[M+1][x+1],O=p[M][x+1];c.push(E,C,O),c.push(C,P,O),_+=6}u.addGroup(y,_,0),y+=_}function b(w){let S=m,_=new U,T=new A,x=0,M=w===!0?e:t,E=w===!0?1:-1;for(let P=1;P<=i;P++)d.push(0,g*E,0),h.push(0,E,0),f.push(.5,.5),m++;let C=m;for(let P=0;P<=i;P++){let I=P/i*l+a,N=Math.cos(I),B=Math.sin(I);T.x=M*B,T.y=g*E,T.z=M*N,d.push(T.x,T.y,T.z),h.push(0,E,0),_.x=N*.5+.5,_.y=B*.5*E+.5,f.push(_.x,_.y),m++}for(let P=0;P<i;P++){let O=S+P,I=C+P;w===!0?c.push(I,I+1,O):c.push(I+1,I,O),x+=3}u.addGroup(y,x,w===!0?1:2),y+=x}}static fromJSON(e){return new ma(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Dl=class extends ma{constructor(e=1,t=1,n=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new Dl(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ol=class extends Ce{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let s=[],o=[];a(i),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)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let b=new A,w=new A,S=new A;for(let _=0;_<t.length;_+=3)f(t[_+0],b),f(t[_+1],w),f(t[_+2],S),l(b,w,S,v)}function l(v,b,w,S){let _=S+1,T=[];for(let x=0;x<=_;x++){T[x]=[];let M=v.clone().lerp(w,x/_),E=b.clone().lerp(w,x/_),C=_-x;for(let P=0;P<=C;P++)P===0&&x===_?T[x][P]=M:T[x][P]=M.clone().lerp(E,P/C)}for(let x=0;x<_;x++)for(let M=0;M<2*(_-x)-1;M++){let E=Math.floor(M/2);M%2===0?(h(T[x][E+1]),h(T[x+1][E]),h(T[x][E])):(h(T[x][E+1]),h(T[x+1][E+1]),h(T[x+1][E]))}}function u(v){let b=new A;for(let w=0;w<s.length;w+=3)b.x=s[w+0],b.y=s[w+1],b.z=s[w+2],b.normalize().multiplyScalar(v),s[w+0]=b.x,s[w+1]=b.y,s[w+2]=b.z}function c(){let v=new A;for(let b=0;b<s.length;b+=3){v.x=s[b+0],v.y=s[b+1],v.z=s[b+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 b=o[v+0],w=o[v+2],S=o[v+4],_=Math.max(b,w,S),T=Math.min(b,w,S);_>.9&&T<.1&&(b<.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,b){let w=v*3;b.x=e[w+0],b.y=e[w+1],b.z=e[w+2]}function m(){let v=new A,b=new A,w=new A,S=new A,_=new U,T=new U,x=new U;for(let M=0,E=0;M<s.length;M+=9,E+=6){v.set(s[M+0],s[M+1],s[M+2]),b.set(s[M+3],s[M+4],s[M+5]),w.set(s[M+6],s[M+7],s[M+8]),_.set(o[E+0],o[E+1]),T.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),S.copy(v).add(b).add(w).divideScalar(3);let C=g(S);p(_,E+0,v,C),p(T,E+2,b,C),p(x,E+4,w,C)}}function p(v,b,w,S){S<0&&v.x===1&&(o[b]=v.x-1),w.x===0&&w.z===0&&(o[b]=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(e){return new Ol(e.vertices,e.indices,e.radius,e.details)}},Ll=class extends Ol{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ll(e.radius,e.detail)}};var Ps=class extends pa{constructor(e){super(e),this.uuid=Ui(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new pa().fromJSON(i))}return this}},L3={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=o1(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=U3(r,e,s,t)),r.length>80*t){a=u=r[0],l=c=r[1];for(let m=t;m<i;m+=t)d=r[m],h=r[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?1/f:0}return gd(s,o,t,a,l,f),o}};function o1(r,e,t,n,i){let s,o;if(i===K3(r,e,t,n)>0)for(s=e;s<t;s+=n)o=OS(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=OS(s,r[s],r[s+1],o);return o&&up(o,o.next)&&(vd(o),o=o.next),o}function fo(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(up(t,t.next)||Wt(t.prev,t,t.next)===0)){if(vd(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function gd(r,e,t,n,i,s,o){if(!r)return;!o&&s&&H3(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?N3(r,n,i,s):R3(r)){e.push(l.i/t),e.push(r.i/t),e.push(u.i/t),vd(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=B3(fo(r),e,t),gd(r,e,t,n,i,s,2)):o===2&&F3(r,e,t,n,i,s):gd(fo(r),e,t,n,i,s,1);break}}}function R3(r){let e=r.prev,t=r,n=r.next;if(Wt(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if(Sl(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Wt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function N3(r,e,t,n){let i=r.prev,s=r,o=r.next;if(Wt(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,u=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,c=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,d=Pv(a,l,e,t,n),h=Pv(u,c,e,t,n),f=r.prevZ,m=r.nextZ;for(;f&&f.z>=d&&m&&m.z<=h;){if(f!==r.prev&&f!==r.next&&Sl(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Wt(f.prev,f,f.next)>=0||(f=f.prevZ,m!==r.prev&&m!==r.next&&Sl(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Wt(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=d;){if(f!==r.prev&&f!==r.next&&Sl(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Wt(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=h;){if(m!==r.prev&&m!==r.next&&Sl(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Wt(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function B3(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!up(i,s)&&a1(i,n,n.next,s)&&yd(i,s)&&yd(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),vd(n),vd(n.next),n=r=s),n=n.next}while(n!==r);return fo(n)}function F3(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&q3(o,a)){let l=l1(o,a);o=fo(o,o.next),l=fo(l,l.next),gd(o,e,t,n,i,s),gd(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function U3(r,e,t,n){let i=[],s,o,a,l,u;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,u=o1(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(j3(u));for(i.sort(G3),s=0;s<i.length;s++)k3(i[s],t),t=fo(t,t.next);return t}function G3(r,e){return r.x-e.x}function k3(r,e){if(e=z3(r,e),e){let t=l1(e,r);fo(e,e.next),fo(t,t.next)}}function z3(r,e){let t=e,n=r.x,i=r.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let h=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>s){if(s=h,h===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===s)return o;let a=o,l=o.x,u=o.y,c=1/0,d;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&Sl(i<u?n:s,i,l,u,i<u?s:n,i,t.x,t.y)&&(d=Math.abs(i-t.y)/(n-t.x),yd(t,r)&&(d<c||d===c&&(t.x>o.x||t.x===o.x&&V3(o,t)))&&(o=t,c=d)),t=t.next;while(t!==a);return o}function V3(r,e){return Wt(r.prev,r,e.prev)<0&&Wt(e.next,r,r.next)<0}function H3(r,e,t,n){let i=r;do i.z===null&&(i.z=Pv(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,W3(i)}function W3(r){let e,t,n,i,s,o,a,l,u=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<u&&(a++,n=n.nextZ,!!n);e++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,u*=2}while(o>1);return r}function Pv(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function j3(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Sl(r,e,t,n,i,s,o,a){return(i-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function q3(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Y3(r,e)&&(yd(r,e)&&yd(e,r)&&X3(r,e)&&(Wt(r.prev,r,e.prev)||Wt(r,e.prev,e))||up(r,e)&&Wt(r.prev,r,r.next)>0&&Wt(e.prev,e,e.next)>0)}function Wt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function up(r,e){return r.x===e.x&&r.y===e.y}function a1(r,e,t,n){let i=Lf(Wt(r,e,t)),s=Lf(Wt(r,e,n)),o=Lf(Wt(t,n,r)),a=Lf(Wt(t,n,e));return!!(i!==s&&o!==a||i===0&&Of(r,t,e)||s===0&&Of(r,n,e)||o===0&&Of(t,r,n)||a===0&&Of(t,e,n))}function Of(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Lf(r){return r>0?1:r<0?-1:0}function Y3(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&a1(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function yd(r,e){return Wt(r.prev,r,r.next)<0?Wt(r,e,r.next)>=0&&Wt(r,r.prev,e)>=0:Wt(r,e,r.prev)<0||Wt(r,r.next,e)<0}function X3(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function l1(r,e){let t=new Iv(r.i,r.x,r.y),n=new Iv(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function OS(r,e,t,n){let i=new Iv(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function vd(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Iv(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function K3(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var Rl=class{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return Rl.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];LS(e),RS(n,e);let o=e.length;t.forEach(LS);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,RS(n,t[l]);let a=L3.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function LS(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function RS(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var Nl=class extends Ol{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=[-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(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Nl(e.radius,e.detail)}};var ga=class extends Ce{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),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=[],b=y/n,w=0;y==0&&o==0?w=.5/t:y==n&&l==Math.PI&&(w=-.5/t);for(let S=0;S<=t;S++){let _=S/t;d.x=-e*Math.cos(i+_*s)*Math.sin(o+b*a),d.y=e*Math.cos(o+b*a),d.z=e*Math.sin(i+_*s)*Math.sin(o+b*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-b),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<t;v++){let b=c[y][v+1],w=c[y][v],S=c[y+1][v],_=c[y+1][v+1];(y!==0||o>0)&&f.push(b,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(e){return new ga(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var Bl=class extends Ce{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);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 b=0;b<=n;++b){let w=b/n*s*Math.PI*2;v(w,s,o,e,f),v(w+.01,s,o,e,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<=i;++S){let _=S/i*Math.PI*2,T=-t*Math.cos(_),x=t*Math.sin(_);d.x=f.x+(T*y.x+x*p.x),d.y=f.y+(T*y.y+x*p.y),d.z=f.z+(T*y.z+x*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(b/n),c.push(S/i)}}for(let b=1;b<=n;b++)for(let w=1;w<=i;w++){let S=(i+1)*(b-1)+(w-1),_=(i+1)*b+(w-1),T=(i+1)*b+w,x=(i+1)*(b-1)+w;a.push(S,_,x),a.push(_,T,x)}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(b,w,S,_,T){let x=Math.cos(b),M=Math.sin(b),E=S/w*b,C=Math.cos(E);T.x=_*(2+C)*.5*x,T.y=_*(2+C)*M*.5,T.z=_*Math.sin(E)*.5}}static fromJSON(e){return new Bl(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var yn={arraySlice:function(r,e,t){return yn.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i},flattenJSON:function(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)},subclip:function(r,e,t,n,i=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let u=s.tracks[l],c=u.getValueSize(),d=[],h=[];for(let f=0;f<u.times.length;++f){let m=u.times[f]*i;if(!(m<t||m>=n)){d.push(u.times[f]);for(let p=0;p<c;++p)h.push(u.values[f*c+p])}}d.length!==0&&(u.times=yn.convertArray(d,u.times.constructor),u.values=yn.convertArray(h,u.values.constructor),o.push(u))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,n=30){n<=0&&(n=30);let i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let u=r.tracks.find(function(y){return y.name===a.name&&y.ValueTypeName===l});if(u===void 0)continue;let c=0,d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=d/3);let h=0,f=u.getValueSize();u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=f/3);let m=a.times.length-1,p;if(s<=a.times[0]){let y=c,v=d-c;p=yn.arraySlice(a.values,y,v)}else if(s>=a.times[m]){let y=m*d+c,v=y+d-c;p=yn.arraySlice(a.values,y,v)}else{let y=a.createInterpolant(),v=c,b=d-c;y.evaluate(s),p=yn.arraySlice(y.resultBuffer,v,b)}l==="quaternion"&&new nt().fromArray(p).normalize().conjugate().toArray(p);let g=u.times.length;for(let y=0;y<g;++y){let v=y*f+h;if(l==="quaternion")nt.multiplyQuaternionsFlat(u.values,v,p,0,u.values,v);else{let b=f-h*2;for(let w=0;w<b;++w)u.values[v+w]-=p[w]}}}return r.blendMode=_I,r}},Fl=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{r:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}o=t.length;break t}if(!(e>=s)){let a=t[1];e<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(i=s,s=t[--n-1],e>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Dv=class extends Fl{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Hw,endingEnd:Hw}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Ww:s=e,a=2*t-n;break;case jw:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Ww:o=e,l=2*n-t;break;case jw:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let u=(n-t)*.5,c=this.valueSize;this._weightPrev=u/(t-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),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,b=(-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]+b*o[l+S]+w*o[d+S];return s}},Ov=class extends Fl{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=(n-t)/(i-t),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},Lv=class extends Fl{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},mi=class{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=yn.convertArray(t,this.TimeBufferType),this.values=yn.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:yn.convertArray(e.times,Array),values:yn.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Lv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ov(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Dv(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Uf:t=this.InterpolantFactoryMethodDiscrete;break;case Gf:t=this.InterpolantFactoryMethodLinear;break;case My:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Uf;case this.InterpolantFactoryMethodLinear:return Gf;case this.InterpolantFactoryMethodSmooth:return My}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=yn.arraySlice(n,s,o),this.values=yn.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!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),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&yn.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),e=!1;break}}return e}optimize(){let e=yn.arraySlice(this.times),t=yn.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===My,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=e[a],c=e[a+1];if(u!==c&&(a!==1||u!==e[0]))if(i)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let m=0;m!==n;++m){let p=t[d+m];if(p!==t[h+m]||p!==t[f+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)t[h+f]=t[d+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)t[l+u]=t[a+u];++o}return o!==e.length?(this.times=yn.arraySlice(e,0,o),this.values=yn.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=yn.arraySlice(this.times,0),t=yn.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};mi.prototype.TimeBufferType=Float32Array;mi.prototype.ValueBufferType=Float32Array;mi.prototype.DefaultInterpolation=Gf;var ya=class extends mi{};ya.prototype.ValueTypeName="bool";ya.prototype.ValueBufferType=Array;ya.prototype.DefaultInterpolation=Uf;ya.prototype.InterpolantFactoryMethodLinear=void 0;ya.prototype.InterpolantFactoryMethodSmooth=void 0;var Rv=class extends mi{};Rv.prototype.ValueTypeName="color";var Nv=class extends mi{};Nv.prototype.ValueTypeName="number";var Bv=class extends Fl{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),u=e*a;for(let c=u+a;u!==c;u+=4)nt.slerpFlat(s,0,o,u-a,o,u,l);return s}},xd=class extends mi{InterpolantFactoryMethodLinear(e){return new Bv(this.times,this.values,this.getValueSize(),e)}};xd.prototype.ValueTypeName="quaternion";xd.prototype.DefaultInterpolation=Gf;xd.prototype.InterpolantFactoryMethodSmooth=void 0;var va=class extends mi{};va.prototype.ValueTypeName="string";va.prototype.ValueBufferType=Array;va.prototype.DefaultInterpolation=Uf;va.prototype.InterpolantFactoryMethodLinear=void 0;va.prototype.InterpolantFactoryMethodSmooth=void 0;var Fv=class extends mi{};Fv.prototype.ValueTypeName="vector";var NS={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},bd=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.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}}},Z3=new bd,Ul=class{constructor(e){this.manager=e!==void 0?e:Z3,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},As={},Gl=class extends Ul{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=NS.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(As[e]!==void 0){As[e].push({onLoad:t,onProgress:n,onError:i});return}As[e]=[],As[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{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=As[e],d=u.body.getReader(),h=u.headers.get("Content-Length"),f=h?parseInt(h):0,m=f!==0,p=0,g=new ReadableStream({start(y){v();function v(){d.read().then(({done:b,value:w})=>{if(b)y.close();else{p+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let _=0,T=c.length;_<T;_++){let x=c[_];x.onProgress&&x.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw Error(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`)}).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=>{NS.add(e,u);let c=As[e];delete As[e];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=As[e];if(c===void 0)throw this.manager.itemError(e),u;delete As[e];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onError&&f.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var po=class extends ht{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},Qf=class extends po{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},BS=new he,FS=new A,US=new A,wd=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new he,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fd,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;FS.setFromMatrixPosition(e.matrixWorld),t.position.copy(FS),US.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(US),t.updateMatrixWorld(),BS.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(BS),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Uv=class extends wd{constructor(){super(new rn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=dd*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Jf=class extends po{constructor(e,t,n=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.target=new ht,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Uv}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},GS=new he,nd=new A,rv=new A,Gv=class extends wd{constructor(){super(new rn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new U(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(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(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),nd.setFromMatrixPosition(e.matrixWorld),n.position.copy(nd),rv.copy(n.position),rv.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(rv),n.updateMatrixWorld(),i.makeTranslation(-nd.x,-nd.y,-nd.z),GS.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(GS)}},$f=class extends po{constructor(e,t,n=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Gv}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},kv=class extends wd{constructor(){super(new ua(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ep=class extends po{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.target=new ht,this.shadow=new kv}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var zv=class extends Ce{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},kl=class extends Ul{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new Gl(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(f,m){if(t[m]!==void 0)return t[m];let g=f.interleavedBuffers[m],y=s(f,g.buffer),v=cf(g.type,y),b=new Xf(v,g.stride);return b.uuid=g.uuid,t[m]=b,b}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=e.isInstancedBufferGeometry?new zv:new Ce,a=e.data.index;if(a!==void 0){let f=cf(a.type,a.array);o.setIndex(new Be(f,1))}let l=e.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new da(g,m.itemSize,m.offset,m.normalized)}else{let g=cf(m.type,m.array),y=m.isInstancedBufferAttribute?Kf: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=e.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],b;if(v.isInterleavedBufferAttribute){let w=i(e.data,v.data);b=new da(w,v.itemSize,v.offset,v.normalized)}else{let w=cf(v.type,v.array);b=new Be(w,v.itemSize,v.normalized)}v.name!==void 0&&(b.name=v.name),p.push(b)}o.morphAttributes[f]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=e.data.groups||e.data.drawcalls||e.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=e.data.boundingSphere;if(h!==void 0){let f=new A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new pn(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var tp=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=kS(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=kS();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function kS(){return(typeof performance>"u"?Date:performance).now()}var Zv="\\[\\]\\.:\\/",Q3=new RegExp("["+Zv+"]","g"),Qv="[^"+Zv+"]",J3="[^"+Zv.replace("\\.","")+"]",$3=/((?:WC+[\/:])*)/.source.replace("WC",Qv),eN=/(WCOD+)?/.source.replace("WCOD",J3),tN=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qv),nN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qv),rN=new RegExp("^"+$3+eN+tN+nN+"$"),iN=["material","materials","bones"],Vv=class{constructor(e,t,n){let i=n||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Tt=class{constructor(e,t,n){this.path=t,this.parsedPath=n||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,n):new Tt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Q3,"")}static parseTrackName(e){let t=rN.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);iN.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===u){u=c;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(u!==void 0){if(e[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[u]}}let o=e[i];if(o===void 0){let u=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Tt.Composite=Vv;Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray];Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Se=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Se(this.value.clone===void 0?this.value:this.value.clone())}};var zl=class{constructor(e,t,n=0,i=1/0){this.ray=new fi(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new hd,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Hv(e,this,n,t),n.sort(zS),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Hv(e[i],this,n,t);return n.sort(zS),n}};function zS(r,e){return r.distance-e.distance}function Hv(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Hv(i[s],e,t,!0)}}var Sd=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(vn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var VS=new U,np=class{constructor(e=new U(1/0,1/0),t=new U(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=VS.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return VS.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},HS=new A,Rf=new A,bn=class{constructor(e=new A,t=new A){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){HS.subVectors(e,this.start),Rf.subVectors(this.end,this.start);let n=Rf.dot(Rf),s=Rf.dot(HS)/n;return t&&(s=vn(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},WS=new A,rp=class extends ht{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let n=new Ce,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Ae(i,3));let s=new Xr({fog:!1,toneMapped:!1});this.cone=new ho(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),WS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(WS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var ip=class extends Cn{constructor(e,t,n){let i=new ga(t,4,2),s=new Es({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),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.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var jS=new A,Nf=new A,qS=new A,sp=class extends ht{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,t===void 0&&(t=1);let i=new Ce;i.setAttribute("position",new Ae([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Xr({fog:!1,toneMapped:!1});this.lightPlane=new ha(i,s),this.add(this.lightPlane),i=new Ce,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new ha(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){jS.setFromMatrixPosition(this.light.matrixWorld),Nf.setFromMatrixPosition(this.light.target.matrixWorld),qS.subVectors(Nf,jS),this.lightPlane.lookAt(Nf),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(Nf),this.targetLine.scale.z=qS.length()}},Bf=new A,Xt=new pi,mo=class extends ho{constructor(e){let t=new Ce,n=new Xr({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Ae(i,3)),t.setAttribute("color",new Ae(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Oe(16755200),c=new Oe(16711680),d=new Oe(43775),h=new Oe(16777215),f=new Oe(3355443);this.setColors(u,c,d,h,f)}setColors(e,t,n,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,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,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,n=1,i=1;Xt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),nn("c",t,e,Xt,0,0,-1),nn("t",t,e,Xt,0,0,1),nn("n1",t,e,Xt,-n,-i,-1),nn("n2",t,e,Xt,n,-i,-1),nn("n3",t,e,Xt,-n,i,-1),nn("n4",t,e,Xt,n,i,-1),nn("f1",t,e,Xt,-n,-i,1),nn("f2",t,e,Xt,n,-i,1),nn("f3",t,e,Xt,-n,i,1),nn("f4",t,e,Xt,n,i,1),nn("u1",t,e,Xt,n*.7,i*1.1,-1),nn("u2",t,e,Xt,-n*.7,i*1.1,-1),nn("u3",t,e,Xt,0,i*2,-1),nn("cf1",t,e,Xt,-n,0,1),nn("cf2",t,e,Xt,n,0,1),nn("cf3",t,e,Xt,0,-i,1),nn("cf4",t,e,Xt,0,i,1),nn("cn1",t,e,Xt,-n,0,-1),nn("cn2",t,e,Xt,n,0,-1),nn("cn3",t,e,Xt,0,-i,-1),nn("cn4",t,e,Xt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function nn(r,e,t,n,i,s,o){Bf.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Bf.x,Bf.y,Bf.z)}}var go=class extends ho{constructor(e,t=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]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ce;s.setIndex(new Be(n,1)),s.setAttribute("position",new Ae(i,3)),super(s,new Xr({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}};var op=class extends ho{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ce;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(n,3));let s=new Xr({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new Oe,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var{floatView:Cj,uint32View:Pj,baseTable:Ij,shiftTable:Dj,mantissaTable:Oj,exponentTable:Lj,offsetTable:Rj}=sN();function sN(){let r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let u=l-127;u<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):u<-14?(n[l]=1024>>-u-14,n[l|256]=1024>>-u-14|32768,i[l]=-u-1,i[l|256]=-u-1):u<=15?(n[l]=u+15<<10,n[l|256]=u+15<<10|32768,i[l]=13,i[l|256]=13):u<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}var ap=class extends ft{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:xa}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=xa);var jl=".",Ad=Symbol("target"),Jv=Symbol("unsubscribe");function _d(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function c1(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var Fr=Array.isArray;function ba(r){return typeof r=="symbol"}var oN={after:(r,e)=>Fr(r)?r.slice(e.length):e===""?r:r.slice(e.length+1),concat:(r,e)=>Fr(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+=jl),ba(e)?r+e.toString():r+e):r,initial:r=>{if(Fr(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(jl);return e===-1?"":r.slice(0,e)},last:r=>{if(Fr(r))return r[r.length-1]||"";if(r==="")return r;let e=r.lastIndexOf(jl);return e===-1?r:r.slice(e+1)},walk:(r,e)=>{if(Fr(r))for(let t of r)e(t);else if(r!==""){let t=0,n=r.indexOf(jl);if(n===-1)e(r);else for(;t<r.length;)n===-1&&(n=r.length),e(r.slice(t,n)),t=n+1,n=r.indexOf(jl,t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r}},ar=oN;function $v(r){return typeof r=="object"&&typeof r.next=="function"}function e0(r,e,t,n,i){let s=r.next;if(e.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],n),o.value[1]=i(o.value[1],e,o.value[0],n)),o};else if(e.name==="values"){let o=t[Ad].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,n)),o};return r}function dp(r,e,t){return r.isUnsubscribed||e.ignoreSymbols&&ba(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Td=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),n=t.get(e);return n===void 0&&(n={},t.set(e,n)),n}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let n=this._getProperties(e),i=n[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),n[t]=i),i}getProxy(e,t,n,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,n):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,ar.get(t,this.getPath(e)))}defineProperty(e,t,n){return Reflect.defineProperty(e,t,n)?(this.isUnsubscribed||(this._getProperties(e)[t]=n),!0):!1}setProperty(e,t,n,i,s){if(!this._equals(s,n)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,n,i):Reflect.set(e,t,n)}return!0}deleteProperty(e,t,n){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(e,t,n){let i=this._getOwnPropertyDescriptor(t,n);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function ql(r){return toString.call(r)==="[object Object]"}function Yl(){return!0}function yo(r,e){return r.length!==e.length||r.some((t,n)=>e[n]!==t)}var hp=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var aN=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),t0={push:Yl,pop:Yl,shift:Yl,unshift:Yl,copyWithin:yo,reverse:yo,sort:yo,splice:yo,flat:yo,fill:yo},u1=new Set([...hp,...aN,...Object.keys(t0)]);function Xl(r,e){if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var n0=["keys","values","entries"],r0=new Set(["has","toString"]),i0={add:Xl,clear:Xl,delete:Xl,forEach:Xl},d1=new Set([...r0,...Object.keys(i0),...n0]);function Kl(r,e){if(r.size!==e.size)return!0;let t;for(let[n,i]of r)if(t=e.get(n),t!==i||t===void 0&&!e.has(n))return!0;return!1}var lN=new Set([...r0,"get"]),s0={set:Kl,clear:Kl,delete:Kl,forEach:Kl},h1=new Set([...lN,...Object.keys(s0),...n0]);var On=class{constructor(e,t,n,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return hp.has(e)}_shallowClone(e){let t=e;if(ql(e))t={...e};else if(Fr(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(n=>this._shallowClone(n)));else if(e instanceof Map){t=new Map;for(let[n,i]of e.entries())t.set(n,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,n,i){return e?(Fr(i)?this._onIsChanged=t0[t]:i instanceof Set?this._onIsChanged=i0[t]:i instanceof Map&&(this._onIsChanged=s0[t]),i):n}update(e,t,n){let i=ar.after(e,this._path);if(t!=="length"){let s=this.clone;ar.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:n}),s&&s[t]&&(s[t]=n)}this._isChanged=!0}undo(e){let t;for(let n=this._changes.length-1;n!==-1;n--)t=this._changes[n],ar.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var Zl=class extends On{static isHandledMethod(e){return u1.has(e)}};var Md=class extends On{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var Ql=class extends On{static isHandledMethod(e){return d1.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var Jl=class extends On{static isHandledMethod(e){return h1.has(e)}undo(e){for(let[t,n]of this.clone.entries())e.set(t,n);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Ed=class extends On{constructor(e,t,n,i){super(void 0,t,n,i),this._arg1=n[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Cd=class extends On{constructor(e,t,n,i){super(void 0,t,n,i),this._weakKey=n[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var yi=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return ql(e)||Fr(e)||_d(e)}static isHandledMethod(e,t){return ql(e)?On.isHandledMethod(t):Fr(e)?Zl.isHandledMethod(t):e instanceof Set?Ql.isHandledMethod(t):e instanceof Map?Jl.isHandledMethod(t):_d(e)}get isCloning(){return this._stack.length>0}start(e,t,n){let i=On;Fr(e)?i=Zl:e instanceof Date?i=Md:e instanceof Set?i=Ql:e instanceof Map?i=Jl:e instanceof WeakSet?i=Ed:e instanceof WeakMap&&(i=Cd),this._stack.push(new i(e,t,n,this._hasOnValidate))}update(e,t,n){this._stack[this._stack.length-1].update(e,t,n)}preferredThisArg(e,t,n){let{name:i}=e,s=yi.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,n)}isChanged(e,t,n){return this._stack[this._stack.length-1].isChanged(e,t,n)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var cN={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},o0=(r,e,t={})=>{t={...cN,...t};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new Td(i),u=typeof t.onValidate=="function",c=new yi(u),d=(v,b,w,S,_)=>!u||c.isCloning||t.onValidate(ar.concat(l.getPath(v),b),w,S,_)===!0,h=(v,b,w,S)=>{!dp(l,t,b)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),b,w,S)},f=(v,b,w,S,_)=>{c.isCloning?c.update(v,b,S):e(ar.concat(v,b),w,S,_)},m=v=>v&&(v[n]||v),p=(v,b,w,S)=>c1(v)||w==="constructor"||s&&!yi.isHandledMethod(b,w)||dp(l,t,w)||l.isGetInvariant(b,w)||o&&l.isDetached(b,r)?v:(S===void 0&&(S=l.getPath(b)),l.getProxy(v,ar.concat(S,w),g,n)),g={get(v,b,w){if(ba(b)){if(b===n||b===Ad)return v;if(b===Jv&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=_d(v)?Reflect.get(v,b):Reflect.get(v,b,w);return p(S,v,b)},set(v,b,w,S){w=m(w);let _=v[n]||v,T=_[b];if(i(T,w)&&b in v)return!0;let x=d(v,b,w,T);return x&&l.setProperty(_,b,w,S,T)?(h(v,b,v[b],T),!0):!x},defineProperty(v,b,w){if(!l.isSameDescriptor(w,v,b)){let S=v[b];d(v,b,w.value,S)&&l.defineProperty(v,b,w,S)&&h(v,b,w.value,S)}return!0},deleteProperty(v,b){if(!Reflect.has(v,b))return!0;let w=Reflect.get(v,b),S=d(v,b,void 0,w);return S&&l.deleteProperty(v,b,w)?(h(v,b,void 0,w),!0):!S},apply(v,b,w){let S=b[n]||b;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&yi.isHandledType(S)){let _=ar.initial(l.getPath(v)),T=yi.isHandledMethod(S,v.name);c.start(S,_,w);let x=Reflect.apply(v,c.preferredThisArg(v,b,S),T?w.map(C=>m(C)):w),M=c.isChanged(S,i),E=c.stop();if(yi.isHandledType(x)&&T&&(b instanceof Map&&v.name==="get"&&(_=ar.concat(_,w[0])),x=l.getProxy(x,_,g)),M){let C={name:v.name,args:w,result:x},P=c.isCloning?ar.initial(_):_,O=c.isCloning?ar.last(_):"";d(ar.get(r,P),O,S,E,C)?f(P,O,S,E,C):c.undo(S)}return(b instanceof Map||b instanceof Set)&&$v(x)?e0(x,v,b,_,p):x}return Reflect.apply(v,b,w)}},y=l.getProxy(r,t.pathAsArray?[]:"",g);return e=e.bind(y),u&&(t.onValidate=t.onValidate.bind(y)),y};o0.target=r=>r&&r[Ad]||r;o0.unsubscribe=r=>r[Jv]||r;var a0=o0;var uN=typeof global=="object"&&global&&global.Object===Object&&global,fp=uN;var dN=typeof self=="object"&&self&&self.Object===Object&&self,hN=fp||dN||Function("return this")(),Zt=hN;var fN=Zt.Symbol,Ln=fN;var f1=Object.prototype,pN=f1.hasOwnProperty,mN=f1.toString,Pd=Ln?Ln.toStringTag:void 0;function gN(r){var e=pN.call(r,Pd),t=r[Pd];try{r[Pd]=void 0;var n=!0}catch{}var i=mN.call(r);return n&&(e?r[Pd]=t:delete r[Pd]),i}var p1=gN;var yN=Object.prototype,vN=yN.toString;function xN(r){return vN.call(r)}var m1=xN;var bN="[object Null]",wN="[object Undefined]",g1=Ln?Ln.toStringTag:void 0;function SN(r){return r==null?r===void 0?wN:bN:g1&&g1 in Object(r)?p1(r):m1(r)}var Ur=SN;function AN(r){return r!=null&&typeof r=="object"}var Wn=AN;var _N="[object Symbol]";function TN(r){return typeof r=="symbol"||Wn(r)&&Ur(r)==_N}var vo=TN;function MN(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var pp=MN;var EN=Array.isArray,wn=EN;var CN=1/0,y1=Ln?Ln.prototype:void 0,v1=y1?y1.toString:void 0;function x1(r){if(typeof r=="string")return r;if(wn(r))return pp(r,x1)+"";if(vo(r))return v1?v1.call(r):"";var e=r+"";return e=="0"&&1/r==-CN?"-0":e}var b1=x1;var PN=/\s/;function IN(r){for(var e=r.length;e--&&PN.test(r.charAt(e)););return e}var w1=IN;var DN=/^\s+/;function ON(r){return r&&r.slice(0,w1(r)+1).replace(DN,"")}var S1=ON;function LN(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Rn=LN;var A1=0/0,RN=/^[-+]0x[0-9a-f]+$/i,NN=/^0b[01]+$/i,BN=/^0o[0-7]+$/i,FN=parseInt;function UN(r){if(typeof r=="number")return r;if(vo(r))return A1;if(Rn(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Rn(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=S1(r);var t=NN.test(r);return t||BN.test(r)?FN(r.slice(2),t?2:8):RN.test(r)?A1:+r}var l0=UN;function GN(r){return r}var _1=GN;var kN="[object AsyncFunction]",zN="[object Function]",VN="[object GeneratorFunction]",HN="[object Proxy]";function WN(r){if(!Rn(r))return!1;var e=Ur(r);return e==zN||e==VN||e==kN||e==HN}var mp=WN;var jN=Zt["__core-js_shared__"],gp=jN;var T1=function(){var r=/[^.]+$/.exec(gp&&gp.keys&&gp.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function qN(r){return!!T1&&T1 in r}var M1=qN;var YN=Function.prototype,XN=YN.toString;function KN(r){if(r!=null){try{return XN.call(r)}catch{}try{return r+""}catch{}}return""}var Is=KN;var ZN=/[\\^$.*+?()[\]{}|]/g,QN=/^\[object .+?Constructor\]$/,JN=Function.prototype,$N=Object.prototype,eB=JN.toString,tB=$N.hasOwnProperty,nB=RegExp("^"+eB.call(tB).replace(ZN,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rB(r){if(!Rn(r)||M1(r))return!1;var e=mp(r)?nB:QN;return e.test(Is(r))}var E1=rB;function iB(r,e){return r?.[e]}var C1=iB;function sB(r,e){var t=C1(r,e);return E1(t)?t:void 0}var vr=sB;var oB=vr(Zt,"WeakMap"),yp=oB;var P1=Object.create,aB=function(){function r(){}return function(e){if(!Rn(e))return{};if(P1)return P1(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),I1=aB;function lB(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var D1=lB;function cB(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var O1=cB;var uB=800,dB=16,hB=Date.now;function fB(r){var e=0,t=0;return function(){var n=hB(),i=dB-(n-t);if(t=n,i>0){if(++e>=uB)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var L1=fB;function pB(r){return function(){return r}}var R1=pB;var mB=function(){try{var r=vr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),$l=mB;var gB=$l?function(r,e){return $l(r,"toString",{configurable:!0,enumerable:!1,value:R1(e),writable:!0})}:_1,N1=gB;var yB=L1(N1),B1=yB;function vB(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var F1=vB;var xB=9007199254740991,bB=/^(?:0|[1-9]\d*)$/;function wB(r,e){var t=typeof r;return e=e??xB,!!e&&(t=="number"||t!="symbol"&&bB.test(r))&&r>-1&&r%1==0&&r<e}var ec=wB;function SB(r,e,t){e=="__proto__"&&$l?$l(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var vp=SB;function AB(r,e){return r===e||r!==r&&e!==e}var tc=AB;var _B=Object.prototype,TB=_B.hasOwnProperty;function MB(r,e,t){var n=r[e];(!(TB.call(r,e)&&tc(n,t))||t===void 0&&!(e in r))&&vp(r,e,t)}var nc=MB;function EB(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(t[a],r[a],a,t,r):void 0;l===void 0&&(l=r[a]),i?vp(t,a,l):nc(t,a,l)}return t}var ki=EB;var U1=Math.max;function CB(r,e,t){return e=U1(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,s=U1(n.length-e,0),o=Array(s);++i<s;)o[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=t(o),D1(r,this,a)}}var G1=CB;var PB=9007199254740991;function IB(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=PB}var rc=IB;function DB(r){return r!=null&&rc(r.length)&&!mp(r)}var xp=DB;var OB=Object.prototype;function LB(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||OB;return r===t}var ic=LB;function RB(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var k1=RB;var NB="[object Arguments]";function BB(r){return Wn(r)&&Ur(r)==NB}var c0=BB;var z1=Object.prototype,FB=z1.hasOwnProperty,UB=z1.propertyIsEnumerable,GB=c0(function(){return arguments}())?c0:function(r){return Wn(r)&&FB.call(r,"callee")&&!UB.call(r,"callee")},sc=GB;function kB(){return!1}var V1=kB;var j1=typeof exports=="object"&&exports&&!exports.nodeType&&exports,H1=j1&&typeof module=="object"&&module&&!module.nodeType&&module,zB=H1&&H1.exports===j1,W1=zB?Zt.Buffer:void 0,VB=W1?W1.isBuffer:void 0,HB=VB||V1,wa=HB;var WB="[object Arguments]",jB="[object Array]",qB="[object Boolean]",YB="[object Date]",XB="[object Error]",KB="[object Function]",ZB="[object Map]",QB="[object Number]",JB="[object Object]",$B="[object RegExp]",eF="[object Set]",tF="[object String]",nF="[object WeakMap]",rF="[object ArrayBuffer]",iF="[object DataView]",sF="[object Float32Array]",oF="[object Float64Array]",aF="[object Int8Array]",lF="[object Int16Array]",cF="[object Int32Array]",uF="[object Uint8Array]",dF="[object Uint8ClampedArray]",hF="[object Uint16Array]",fF="[object Uint32Array]",Ut={};Ut[sF]=Ut[oF]=Ut[aF]=Ut[lF]=Ut[cF]=Ut[uF]=Ut[dF]=Ut[hF]=Ut[fF]=!0;Ut[WB]=Ut[jB]=Ut[rF]=Ut[qB]=Ut[iF]=Ut[YB]=Ut[XB]=Ut[KB]=Ut[ZB]=Ut[QB]=Ut[JB]=Ut[$B]=Ut[eF]=Ut[tF]=Ut[nF]=!1;function pF(r){return Wn(r)&&rc(r.length)&&!!Ut[Ur(r)]}var q1=pF;function mF(r){return function(e){return r(e)}}var oc=mF;var Y1=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Id=Y1&&typeof module=="object"&&module&&!module.nodeType&&module,gF=Id&&Id.exports===Y1,u0=gF&&fp.process,yF=function(){try{var r=Id&&Id.require&&Id.require("util").types;return r||u0&&u0.binding&&u0.binding("util")}catch{}}(),Ds=yF;var X1=Ds&&Ds.isTypedArray,vF=X1?oc(X1):q1,bp=vF;var xF=Object.prototype,bF=xF.hasOwnProperty;function wF(r,e){var t=wn(r),n=!t&&sc(r),i=!t&&!n&&wa(r),s=!t&&!n&&!i&&bp(r),o=t||n||i||s,a=o?k1(r.length,String):[],l=a.length;for(var u in r)(e||bF.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||ec(u,l)))&&a.push(u);return a}var wp=wF;function SF(r,e){return function(t){return r(e(t))}}var Sp=SF;var AF=Sp(Object.keys,Object),K1=AF;var _F=Object.prototype,TF=_F.hasOwnProperty;function MF(r){if(!ic(r))return K1(r);var e=[];for(var t in Object(r))TF.call(r,t)&&t!="constructor"&&e.push(t);return e}var Z1=MF;function EF(r){return xp(r)?wp(r):Z1(r)}var ac=EF;function CF(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var Q1=CF;var PF=Object.prototype,IF=PF.hasOwnProperty;function DF(r){if(!Rn(r))return Q1(r);var e=ic(r),t=[];for(var n in r)n=="constructor"&&(e||!IF.call(r,n))||t.push(n);return t}var J1=DF;function OF(r){return xp(r)?wp(r,!0):J1(r)}var lc=OF;var LF=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,RF=/^\w*$/;function NF(r,e){if(wn(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||vo(r)?!0:RF.test(r)||!LF.test(r)||e!=null&&r in Object(e)}var $1=NF;var BF=vr(Object,"create"),Os=BF;function FF(){this.__data__=Os?Os(null):{},this.size=0}var eA=FF;function UF(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var tA=UF;var GF="__lodash_hash_undefined__",kF=Object.prototype,zF=kF.hasOwnProperty;function VF(r){var e=this.__data__;if(Os){var t=e[r];return t===GF?void 0:t}return zF.call(e,r)?e[r]:void 0}var nA=VF;var HF=Object.prototype,WF=HF.hasOwnProperty;function jF(r){var e=this.__data__;return Os?e[r]!==void 0:WF.call(e,r)}var rA=jF;var qF="__lodash_hash_undefined__";function YF(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Os&&e===void 0?qF:e,this}var iA=YF;function cc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}cc.prototype.clear=eA;cc.prototype.delete=tA;cc.prototype.get=nA;cc.prototype.has=rA;cc.prototype.set=iA;var d0=cc;function XF(){this.__data__=[],this.size=0}var sA=XF;function KF(r,e){for(var t=r.length;t--;)if(tc(r[t][0],e))return t;return-1}var xo=KF;var ZF=Array.prototype,QF=ZF.splice;function JF(r){var e=this.__data__,t=xo(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():QF.call(e,t,1),--this.size,!0}var oA=JF;function $F(r){var e=this.__data__,t=xo(e,r);return t<0?void 0:e[t][1]}var aA=$F;function eU(r){return xo(this.__data__,r)>-1}var lA=eU;function tU(r,e){var t=this.__data__,n=xo(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var cA=tU;function uc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}uc.prototype.clear=sA;uc.prototype.delete=oA;uc.prototype.get=aA;uc.prototype.has=lA;uc.prototype.set=cA;var bo=uc;var nU=vr(Zt,"Map"),wo=nU;function rU(){this.size=0,this.__data__={hash:new d0,map:new(wo||bo),string:new d0}}var uA=rU;function iU(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var dA=iU;function sU(r,e){var t=r.__data__;return dA(e)?t[typeof e=="string"?"string":"hash"]:t.map}var So=sU;function oU(r){var e=So(this,r).delete(r);return this.size-=e?1:0,e}var hA=oU;function aU(r){return So(this,r).get(r)}var fA=aU;function lU(r){return So(this,r).has(r)}var pA=lU;function cU(r,e){var t=So(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var mA=cU;function dc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}dc.prototype.clear=uA;dc.prototype.delete=hA;dc.prototype.get=fA;dc.prototype.has=pA;dc.prototype.set=mA;var Sa=dc;var uU="Expected a function";function h0(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(uU);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new(h0.Cache||Sa),t}h0.Cache=Sa;var gA=h0;var dU=500;function hU(r){var e=gA(r,function(n){return t.size===dU&&t.clear(),n}),t=e.cache;return e}var yA=hU;var fU=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,pU=/\\(\\)?/g,mU=yA(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(fU,function(t,n,i,s){e.push(i?s.replace(pU,"$1"):n||t)}),e}),vA=mU;function gU(r){return r==null?"":b1(r)}var xA=gU;function yU(r,e){return wn(r)?r:$1(r,e)?[r]:vA(xA(r))}var Zr=yU;var vU=1/0;function xU(r){if(typeof r=="string"||vo(r))return r;var e=r+"";return e=="0"&&1/r==-vU?"-0":e}var Ao=xU;function bU(r,e){e=Zr(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[Ao(e[t++])];return t&&t==n?r:void 0}var Ap=bU;function wU(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var hc=wU;var bA=Ln?Ln.isConcatSpreadable:void 0;function SU(r){return wn(r)||sc(r)||!!(bA&&r&&r[bA])}var wA=SU;function SA(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=wA),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?SA(a,e-1,t,n,i):hc(i,a):n||(i[i.length]=a)}return i}var AA=SA;function AU(r){var e=r==null?0:r.length;return e?AA(r,1):[]}var _A=AU;function _U(r){return B1(G1(r,void 0,_A),r+"")}var _p=_U;var TU=Sp(Object.getPrototypeOf,Object),fc=TU;var MU="[object Object]",EU=Function.prototype,CU=Object.prototype,TA=EU.toString,PU=CU.hasOwnProperty,IU=TA.call(Object);function DU(r){if(!Wn(r)||Ur(r)!=MU)return!1;var e=fc(r);if(e===null)return!0;var t=PU.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&TA.call(t)==IU}var MA=DU;function OU(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+e];return s}var EA=OU;function LU(){this.__data__=new bo,this.size=0}var CA=LU;function RU(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var PA=RU;function NU(r){return this.__data__.get(r)}var IA=NU;function BU(r){return this.__data__.has(r)}var DA=BU;var FU=200;function UU(r,e){var t=this.__data__;if(t instanceof bo){var n=t.__data__;if(!wo||n.length<FU-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new Sa(n)}return t.set(r,e),this.size=t.size,this}var OA=UU;function pc(r){var e=this.__data__=new bo(r);this.size=e.size}pc.prototype.clear=CA;pc.prototype.delete=PA;pc.prototype.get=IA;pc.prototype.has=DA;pc.prototype.set=OA;var mc=pc;function GU(r,e){return r&&ki(e,ac(e),r)}var LA=GU;function kU(r,e){return r&&ki(e,lc(e),r)}var RA=kU;var UA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,NA=UA&&typeof module=="object"&&module&&!module.nodeType&&module,zU=NA&&NA.exports===UA,BA=zU?Zt.Buffer:void 0,FA=BA?BA.allocUnsafe:void 0;function VU(r,e){if(e)return r.slice();var t=r.length,n=FA?FA(t):new r.constructor(t);return r.copy(n),n}var GA=VU;function HU(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var kA=HU;function WU(){return[]}var Tp=WU;var jU=Object.prototype,qU=jU.propertyIsEnumerable,zA=Object.getOwnPropertySymbols,YU=zA?function(r){return r==null?[]:(r=Object(r),kA(zA(r),function(e){return qU.call(r,e)}))}:Tp,gc=YU;function XU(r,e){return ki(r,gc(r),e)}var VA=XU;var KU=Object.getOwnPropertySymbols,ZU=KU?function(r){for(var e=[];r;)hc(e,gc(r)),r=fc(r);return e}:Tp,Mp=ZU;function QU(r,e){return ki(r,Mp(r),e)}var HA=QU;function JU(r,e,t){var n=e(r);return wn(r)?n:hc(n,t(r))}var Ep=JU;function $U(r){return Ep(r,ac,gc)}var Dd=$U;function eG(r){return Ep(r,lc,Mp)}var Cp=eG;var tG=vr(Zt,"DataView"),Pp=tG;var nG=vr(Zt,"Promise"),Ip=nG;var rG=vr(Zt,"Set"),Dp=rG;var WA="[object Map]",iG="[object Object]",jA="[object Promise]",qA="[object Set]",YA="[object WeakMap]",XA="[object DataView]",sG=Is(Pp),oG=Is(wo),aG=Is(Ip),lG=Is(Dp),cG=Is(yp),Aa=Ur;(Pp&&Aa(new Pp(new ArrayBuffer(1)))!=XA||wo&&Aa(new wo)!=WA||Ip&&Aa(Ip.resolve())!=jA||Dp&&Aa(new Dp)!=qA||yp&&Aa(new yp)!=YA)&&(Aa=function(r){var e=Ur(r),t=e==iG?r.constructor:void 0,n=t?Is(t):"";if(n)switch(n){case sG:return XA;case oG:return WA;case aG:return jA;case lG:return qA;case cG:return YA}return e});var Ls=Aa;var uG=Object.prototype,dG=uG.hasOwnProperty;function hG(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&dG.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var KA=hG;var fG=Zt.Uint8Array,yc=fG;function pG(r){var e=new r.constructor(r.byteLength);return new yc(e).set(new yc(r)),e}var vc=pG;function mG(r,e){var t=e?vc(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var ZA=mG;var gG=/\w*$/;function yG(r){var e=new r.constructor(r.source,gG.exec(r));return e.lastIndex=r.lastIndex,e}var QA=yG;var JA=Ln?Ln.prototype:void 0,$A=JA?JA.valueOf:void 0;function vG(r){return $A?Object($A.call(r)):{}}var e_=vG;function xG(r,e){var t=e?vc(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var t_=xG;var bG="[object Boolean]",wG="[object Date]",SG="[object Map]",AG="[object Number]",_G="[object RegExp]",TG="[object Set]",MG="[object String]",EG="[object Symbol]",CG="[object ArrayBuffer]",PG="[object DataView]",IG="[object Float32Array]",DG="[object Float64Array]",OG="[object Int8Array]",LG="[object Int16Array]",RG="[object Int32Array]",NG="[object Uint8Array]",BG="[object Uint8ClampedArray]",FG="[object Uint16Array]",UG="[object Uint32Array]";function GG(r,e,t){var n=r.constructor;switch(e){case CG:return vc(r);case bG:case wG:return new n(+r);case PG:return ZA(r,t);case IG:case DG:case OG:case LG:case RG:case NG:case BG:case FG:case UG:return t_(r,t);case SG:return new n;case AG:case MG:return new n(r);case _G:return QA(r);case TG:return new n;case EG:return e_(r)}}var n_=GG;function kG(r){return typeof r.constructor=="function"&&!ic(r)?I1(fc(r)):{}}var r_=kG;var zG="[object Map]";function VG(r){return Wn(r)&&Ls(r)==zG}var i_=VG;var s_=Ds&&Ds.isMap,HG=s_?oc(s_):i_,o_=HG;var WG="[object Set]";function jG(r){return Wn(r)&&Ls(r)==WG}var a_=jG;var l_=Ds&&Ds.isSet,qG=l_?oc(l_):a_,c_=qG;var YG=1,XG=2,KG=4,u_="[object Arguments]",ZG="[object Array]",QG="[object Boolean]",JG="[object Date]",$G="[object Error]",d_="[object Function]",ek="[object GeneratorFunction]",tk="[object Map]",nk="[object Number]",h_="[object Object]",rk="[object RegExp]",ik="[object Set]",sk="[object String]",ok="[object Symbol]",ak="[object WeakMap]",lk="[object ArrayBuffer]",ck="[object DataView]",uk="[object Float32Array]",dk="[object Float64Array]",hk="[object Int8Array]",fk="[object Int16Array]",pk="[object Int32Array]",mk="[object Uint8Array]",gk="[object Uint8ClampedArray]",yk="[object Uint16Array]",vk="[object Uint32Array]",Rt={};Rt[u_]=Rt[ZG]=Rt[lk]=Rt[ck]=Rt[QG]=Rt[JG]=Rt[uk]=Rt[dk]=Rt[hk]=Rt[fk]=Rt[pk]=Rt[tk]=Rt[nk]=Rt[h_]=Rt[rk]=Rt[ik]=Rt[sk]=Rt[ok]=Rt[mk]=Rt[gk]=Rt[yk]=Rt[vk]=!0;Rt[$G]=Rt[d_]=Rt[ak]=!1;function Op(r,e,t,n,i,s){var o,a=e&YG,l=e&XG,u=e&KG;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!Rn(r))return r;var c=wn(r);if(c){if(o=KA(r),!a)return O1(r,o)}else{var d=Ls(r),h=d==d_||d==ek;if(wa(r))return GA(r,a);if(d==h_||d==u_||h&&!i){if(o=l||h?{}:r_(r),!a)return l?HA(r,RA(o,r)):VA(r,LA(o,r))}else{if(!Rt[d])return i?r:{};o=n_(r,d,a)}}s||(s=new mc);var f=s.get(r);if(f)return f;s.set(r,o),c_(r)?r.forEach(function(g){o.add(Op(g,e,t,g,r,s))}):o_(r)&&r.forEach(function(g,y){o.set(y,Op(g,e,t,y,r,s))});var m=u?l?Cp:Dd:l?lc:ac,p=c?void 0:m(r);return F1(p||r,function(g,y){p&&(y=g,g=r[y]),nc(o,y,Op(g,e,t,y,r,s))}),o}var Lp=Op;var xk=1,bk=4;function wk(r){return Lp(r,xk|bk)}var _a=wk;var Sk="__lodash_hash_undefined__";function Ak(r){return this.__data__.set(r,Sk),this}var f_=Ak;function _k(r){return this.__data__.has(r)}var p_=_k;function Rp(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new Sa;++e<t;)this.add(r[e])}Rp.prototype.add=Rp.prototype.push=f_;Rp.prototype.has=p_;var m_=Rp;function Tk(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var g_=Tk;function Mk(r,e){return r.has(e)}var y_=Mk;var Ek=1,Ck=2;function Pk(r,e,t,n,i,s){var o=t&Ek,a=r.length,l=e.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(r),c=s.get(e);if(u&&c)return u==e&&c==r;var d=-1,h=!0,f=t&Ck?new m_:void 0;for(s.set(r,e),s.set(e,r);++d<a;){var m=r[d],p=e[d];if(n)var g=o?n(p,m,d,e,r,s):n(m,p,d,r,e,s);if(g!==void 0){if(g)continue;h=!1;break}if(f){if(!g_(e,function(y,v){if(!y_(f,v)&&(m===y||i(m,y,t,n,s)))return f.push(v)})){h=!1;break}}else if(!(m===p||i(m,p,t,n,s))){h=!1;break}}return s.delete(r),s.delete(e),h}var Np=Pk;function Ik(r){var e=-1,t=Array(r.size);return r.forEach(function(n,i){t[++e]=[i,n]}),t}var v_=Ik;function Dk(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var x_=Dk;var Ok=1,Lk=2,Rk="[object Boolean]",Nk="[object Date]",Bk="[object Error]",Fk="[object Map]",Uk="[object Number]",Gk="[object RegExp]",kk="[object Set]",zk="[object String]",Vk="[object Symbol]",Hk="[object ArrayBuffer]",Wk="[object DataView]",b_=Ln?Ln.prototype:void 0,f0=b_?b_.valueOf:void 0;function jk(r,e,t,n,i,s,o){switch(t){case Wk:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case Hk:return!(r.byteLength!=e.byteLength||!s(new yc(r),new yc(e)));case Rk:case Nk:case Uk:return tc(+r,+e);case Bk:return r.name==e.name&&r.message==e.message;case Gk:case zk:return r==e+"";case Fk:var a=v_;case kk:var l=n&Ok;if(a||(a=x_),r.size!=e.size&&!l)return!1;var u=o.get(r);if(u)return u==e;n|=Lk,o.set(r,e);var c=Np(a(r),a(e),n,i,s,o);return o.delete(r),c;case Vk:if(f0)return f0.call(r)==f0.call(e)}return!1}var w_=jk;var qk=1,Yk=Object.prototype,Xk=Yk.hasOwnProperty;function Kk(r,e,t,n,i,s){var o=t&qk,a=Dd(r),l=a.length,u=Dd(e),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in e:Xk.call(e,h)))return!1}var f=s.get(r),m=s.get(e);if(f&&m)return f==e&&m==r;var p=!0;s.set(r,e),s.set(e,r);for(var g=o;++d<l;){h=a[d];var y=r[h],v=e[h];if(n)var b=o?n(v,y,h,e,r,s):n(y,v,h,r,e,s);if(!(b===void 0?y===v||i(y,v,t,n,s):b)){p=!1;break}g||(g=h=="constructor")}if(p&&!g){var w=r.constructor,S=e.constructor;w!=S&&"constructor"in r&&"constructor"in e&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(p=!1)}return s.delete(r),s.delete(e),p}var S_=Kk;var Zk=1,A_="[object Arguments]",__="[object Array]",Bp="[object Object]",Qk=Object.prototype,T_=Qk.hasOwnProperty;function Jk(r,e,t,n,i,s){var o=wn(r),a=wn(e),l=o?__:Ls(r),u=a?__:Ls(e);l=l==A_?Bp:l,u=u==A_?Bp:u;var c=l==Bp,d=u==Bp,h=l==u;if(h&&wa(r)){if(!wa(e))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new mc),o||bp(r)?Np(r,e,t,n,i,s):w_(r,e,l,t,n,i,s);if(!(t&Zk)){var f=c&&T_.call(r,"__wrapped__"),m=d&&T_.call(e,"__wrapped__");if(f||m){var p=f?r.value():r,g=m?e.value():e;return s||(s=new mc),i(p,g,t,n,s)}}return h?(s||(s=new mc),S_(r,e,t,n,i,s)):!1}var M_=Jk;function E_(r,e,t,n,i){return r===e?!0:r==null||e==null||!Wn(r)&&!Wn(e)?r!==r&&e!==e:M_(r,e,t,n,E_,i)}var C_=E_;function $k(r,e){return r!=null&&e in Object(r)}var P_=$k;function ez(r,e,t){e=Zr(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=Ao(e[n]);if(!(s=r!=null&&t(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&rc(i)&&ec(o,i)&&(wn(r)||sc(r)))}var I_=ez;function tz(r,e){return r!=null&&I_(r,e,P_)}var D_=tz;var nz=function(){return Zt.Date.now()},Fp=nz;var rz="Expected a function",iz=Math.max,sz=Math.min;function oz(r,e,t){var n,i,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(rz);e=l0(e)||0,Rn(t)&&(c=!!t.leading,d="maxWait"in t,s=d?iz(l0(t.maxWait)||0,e):s,h="trailing"in t?!!t.trailing:h);function f(_){var T=n,x=i;return n=i=void 0,u=_,o=r.apply(x,T),o}function m(_){return u=_,a=setTimeout(y,e),c?f(_):o}function p(_){var T=_-l,x=_-u,M=e-T;return d?sz(M,s-x):M}function g(_){var T=_-l,x=_-u;return l===void 0||T>=e||T<0||d&&x>=s}function y(){var _=Fp();if(g(_))return v(_);a=setTimeout(y,p(_))}function v(_){return a=void 0,h&&n?f(_):(n=i=void 0,o)}function b(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function w(){return a===void 0?o:v(Fp())}function S(){var _=Fp(),T=g(_);if(n=arguments,i=this,l=_,T){if(a===void 0)return m(l);if(d)return clearTimeout(a),a=setTimeout(y,e),f(l)}return a===void 0&&(a=setTimeout(y,e)),o}return S.cancel=b,S.flush=w,S}var Od=oz;function az(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var O_=az;function lz(r,e){return e.length<2?r:Ap(r,EA(e,0,-1))}var L_=lz;function cz(r,e){return C_(r,e)}var Ta=cz;function uz(r,e){return e=Zr(e,r),r=L_(r,e),r==null||delete r[Ao(O_(e))]}var R_=uz;function dz(r){return MA(r)?void 0:r}var N_=dz;var hz=1,fz=2,pz=4,mz=_p(function(r,e){var t={};if(r==null)return t;var n=!1;e=pp(e,function(s){return s=Zr(s,r),n||(n=s.length>1),s}),ki(r,Cp(r),t),n&&(t=Lp(t,hz|fz|pz,N_));for(var i=e.length;i--;)R_(t,e[i]);return t}),xc=mz;function gz(r,e,t,n){if(!Rn(r))return r;e=Zr(e,r);for(var i=-1,s=e.length,o=s-1,a=r;a!=null&&++i<s;){var l=Ao(e[i]),u=t;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Rn(c)?c:ec(e[i+1])?[]:{})}nc(a,l,u),a=a[l]}return r}var B_=gz;function yz(r,e,t){for(var n=-1,i=e.length,s={};++n<i;){var o=e[n],a=Ap(r,o);t(a,o)&&B_(s,Zr(o,r),a)}return s}var F_=yz;function vz(r,e){return F_(r,e,function(t,n){return D_(r,n)})}var U_=vz;var xz=_p(function(r,e){return r==null?{}:U_(r,e)}),bc=xz;var k_,z_=new Promise(r=>{k_=r}),G_=!1;async function V_(){if(G_)return;let r=await import("./physics.js");await r.init(),k_(r),G_=!0}var Ot=class{modifyById(e,t){let n=this;if(n[e]===void 0)throw new Error("not expected");{let s={...n,[e]:t};return Object.setPrototypeOf(s,Ot.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let n=t[e.id],i;n===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:n};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,Ot.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:n}=e,i=t[n];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,Ot.prototype),delete s[n],{data:s,actual:e,reverse:{type:1,id:n,data:i}}}}return null}};function Ld(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let e=Object.getOwnPropertyNames(r);for(let t of e){let n=r[t];n&&typeof n=="object"&&Ld(n)}return Object.freeze(r)}function H_(r,e){let t=0;for(;t<r.length&&t<e.length;){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==r.length?1:0}var wc=class extends Error{};function Up(r){let e={...r};return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}function zi(r,e,t){if(r===void 0?e===void 0?(r=0,e=10):r=e-10:e===void 0&&(e=r+10),r>e){let s=r;r=e,e=s}let n=[],i=1/(t+1);for(let s=0;s<t;s++){let o=r+(e-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function Sc(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function W_(){return typeof process<"u"}function j_(r,e){for(let t of r)e(t.id,t.data)!==!0&&j_(t.children,e)}function q_(r,e){if(e(r.id,r.data)!==!0)for(let t of r.children)q_(t,e)}var Vt=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Vt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Ld(this[t]),t++}fillCaches0(t,n){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,n);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}nonExistOrDescendantOf(t,n){if(!this.has(t))return!0;for(;t;){let i=this.parent(t);if(i===n)return!0;t=i}return!1}isDescendantOf(t,n){for(;t;){let i=this.parent(t);if(i===n)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,n){if(t===null)this.traverse(n);else{let i=this.get(t);i&&q_(i,n)}}traverse(t){j_(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(c=>c.id===t);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(t,n){let i=t,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);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,Vt.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}return null}checkDuplicatedIdRec({id:t,children:n}){if(this.get(t)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:n,fi:i,id:s,data:o,children:a}=t;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=n,u=this.childrenArray(l),c={fi:i,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.fi-f.fi),t.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:n}=t;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:n,fi:i,id:s}=t;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 wc("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:i},l=[...l,c],l.sort((f,m)=>f.fi-m.fi),t.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:t,reverse:{type:9,parent:a,fi:h,id:s}}}previous(t,n){if(n===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(t){let n=this.childrenArray(t);return n.length>0?n[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let n=this.childrenArray(t);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):t}sortPrevious(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(t){let n=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>H_(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(t){var n=t;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(t,n,i){return this.insertAfterHelper(t,this.previous(t,n),i)}insertAfterHelper(t,n,i){let s=this.childrenArray(t);if(n===null){if(s.length===0)return zi(0,i,i);{let o=s[0].fi;return zi(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==t)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 zi(l,l+i,i)}else return zi(o.fi,a.fi,i)}}};var Ac;(e=>{function r(t,n){if(n.type!==0)return null;if(Array.isArray(t)){let i=n.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}e.runOp=r})(Ac||(Ac={}));var He=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,He.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Ld(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,He.prototype);let n=t;return W_()||n.fillCaches(),n}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}return null}addOp(t){let{fi:n,id:i,data:s}=t,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:n}=t,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:n,id:i}=t,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);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),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===t)return n;n=i.id}return null}insertBeforeHelper(t,n){return this.insertAfterHelper(this.previous(t),n)}insertAfterHelper(t,n){let i=this;if(t===null){if(i.length===0)return zi(0,n,n);{let s=i[0].fi;return zi(s-n,s,n)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return zi(a,a+n,n)}else return zi(s.fi,o.fi,n)}}};function _c(r){return r&&typeof r=="object"&&r instanceof Ht}var Ht=class{unusedFunOverridesTable(e){}runOp(e){let t=[],n=this,i=0,s={};for(;i<e.path.length;){if(t.push(n),n=n===void 0?void 0:n[e.path[i]],n!==void 0&&!_c(n))return null;i+=1}n=n?Up(n):new Ht;for(let[l,u]of Object.entries(e.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;i>0;){if(Object.keys(n).length===0){let l=t[i-1];l&&(n=Up(l),delete n[e.path[i-1]])}else{let l=t[i-1];if(l){let u=Up(l);u[e.path[i-1]]=n,n=u}else{let u=new Ht;u[e.path[i-1]]=n,n=u}}i-=1}let o=Object.setPrototypeOf(n,Ht.prototype),a={...e,props:s};return{data:o,actual:e,reverse:a}}},Rs;(n=>{function r(i,s){return Rd(i,s)??i}n.apply=r;function e(i,s){return m0(i,s)}n.merge=e;function t(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=lr.zoomOnce(l,a[o]),l===void 0)return s;if(!_c(l))return;o+=1}if(l===void 0)return s;if(!!_c(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=p0([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=t})(Rs||(Rs={}));function p0(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Rd(i.data,e[s]);if(t=t||o!==void 0,o===void 0&&(o=i.data),i.children){let a=p0(i.children,e);return a!==void 0?t=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(t)return n}function bz(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Rd(i.data,e[s]);return t=t||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(t)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function Rd(r,e){if(!_c(e))return e;if(r instanceof Vt){let t=p0(r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else{if(r instanceof He)return bz(r,e);if(Array.isArray(r)){let t=!1,n=r.map((i,s)=>{let o=Rd(i,e[s]);return t=t||o!==void 0,o===void 0&&(o=i),o});return t?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else{if(r instanceof Ht)return m0(r,e);if(r&&typeof r=="object"){let t={},n=!1;for(let[i,s]of Object.entries(r)){let o=Rd(s,e[i]);n=n||o!==void 0,o===void 0&&(o=s),t[i]=o}return n?(Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t):void 0}}}}function m0(r,e){if(r===void 0)return e;if(e===void 0)return r;if(!_c(e))return e;if(!_c(r))return Rs.apply(r,e);let t=new Set;for(let i of Object.keys(r))t.add(i);for(let i of Object.keys(e))t.add(i);let n=new Ht;for(let i of t){let s=m0(r===void 0?void 0:r[i],e===void 0?void 0:e[i]);n[i]=s}return n}function Y_(r,e){let t={cur:[],result:[],len:0};return r=Nd(r,e,t)??r,[r,t.result]}function Gp(r,e){return r===null?null:(r.cur[r.len]=e,r.len+=1,r)}function kp(r){r&&(r.len-=1)}function wz(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function X_(r,e,t){let n=!1,i=r.map(s=>{let o=s.id,a=e[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,t!==null))throw new Error("not supported");let l=Nd(s.data,e,Gp(t,o));kp(t),n=n||l!==void 0,l===void 0&&(l=s.data);let u=X_(s.children,e,t);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function Sz(r,e,t){let n=!1,i=r.map(s=>{let o=s.id,a=e[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,t!==null))throw new Error("not supported");let l=Nd(s.data,e,Gp(t,o));return kp(t),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function Nd(r,e,t){if(r instanceof Vt){let n=X_(r,e,t);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof He)return Sz(r,e,t);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=Nd(s,e,Gp(t,o));return kp(t),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"&&!Sc(r)){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=e[s];if(typeof a=="string"){if(t!==null)throw new Error("not supported");i=!0,s=a}let l=Nd(o,e,Gp(t,s));kp(t),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=e[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");wz(t)}return n}else return}}var zp;(e=>{function r(t,n){let i=lr.zoom(n,t.path);if(typeof i=="object"){let s={};for(let o of Object.keys(t.props))s[o]=i[o];return{...t,props:s}}else return{...t,props:{}}}e.replaceProps=r})(zp||(zp={}));var jn;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function e(l,u){return t(l,u)?.data??l}a.applySimple=e;function t(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof Ht&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),d.length===c.length&&(l instanceof Vt||l instanceof He||l instanceof Ot?h=l.runOp(u):h=Ac.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 Vt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof He){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Ot){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Ht){let b={...v,[y]:p};p=Object.setPrototypeOf(b,Ht.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 b=p;p=[...v],p[y]=b}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 Vt){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof He){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=t;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 i(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=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(jn||(jn={}));var g0;(l=>{function r(){return[]}l.empty=r;function e(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=e;function t(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=t;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(h=>!c.some(f=>jn.subsumed(h,f))),...c]}l.compress=i;function s(u,c){return u.every(d=>c.every(h=>jn.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=lr.zoom(d,[...m.path,m.id]),g=jn.apply(d,{...m,type:2});if(g!==null){d=g.data;let[y,v]=Y_(d,{[m.id]:p});d=y;for(let b of v){let w=b[b.length-1];b.splice(b.length-1,1),h.push({type:0,path:b,props:{[w]:p}}),f.push({type:0,path:b,props:{[w]:m.id}})}f.push(g.reverse),h.push(g.actual)}}else{let p=jn.apply(d,m);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof wc)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(g0||(g0={}));var K_=Symbol(),Az=Symbol(),Hp=Symbol(),Ma=class{reportOp(e,t,n=[]){let i=this;if(t===null)return;i._current=t.data;let s=n;for(;!(i instanceof Vp);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let n=t[Hp];n&&n(),delete this._children[e]}}}},v0=class extends Ma{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Ac.runOp(this._current,e),e.path)}},x0=class extends Ma{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Ot.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Z_={get(r,e){if(e===Hp)return()=>{r._parent=null};if(e===K_)return r._current;if(e===Az)return r;let{_current:t,_children:n}=r;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t[e],o=Wp(r,e,s);return o!==s?(n===void 0&&(n={},r._children=n),n[e]=o,o):s},has(r,e){return e in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,e){let t=r._current,n=Reflect.getOwnPropertyDescriptor(t,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:t[e]}}},_z={...Z_,set(r,e,t){let n={type:0,props:{[e]:Nn(t)??t}};return r.deleteChildren(e),r.runOp(n),!0},deleteProperty(r,e){let t={type:0,props:{[e]:void 0}};return r.deleteChildren(e),r.runOp(t),!0}},Tz={...Z_,set(r,e,t){return t===void 0?this.deleteProperty(r,e):(r.deleteChildren(e),r.runOp({type:1,id:e,data:t})),!0},deleteProperty(r,e){return r.runOp({type:2,id:e}),!0}},Tc=class extends Ma{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Hp]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,n)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Wp(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}add(e,t,n,i,s){this.runOp({type:7,parent:e,fi:t,id:n,data:i,children:s})}move(e,t,n){this.runOp({type:9,parent:e,fi:t,id:n})}insertAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}moveBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Mc=class extends Ma{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Hp]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id,s=this._current[n].fi;e(this.data(this._current[n].id),i,s)}}find(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id;if(e(this.data(i),i))return this.get(i)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Wp(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,n){this.runOp({type:4,fi:e,id:t,data:n})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}insertBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}moveAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}moveBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function y0(r,e,t){if(r.length>0){let n=r[r.length-1];if(n.type===0&&e.type===0&&lr.equal(n.path,t)){Object.assign(n.props,e.props);return}}r.push({...e,path:t})}var Vp=class extends Ma{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,n,i){y0(this.ts,t,e),y0(this.actual,n,e),y0(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Wp(r,e,t){return t instanceof Vt?new Tc(r,e,t):t instanceof He?new Mc(r,e,t):t instanceof Ot?new Proxy(new x0(r,e,t),Tz):t!==null&&typeof t=="object"?Sc(t)?t:new Proxy(new v0(r,e,t),_z):t}function b0(r){let e=new Vp(r);return[Wp(e,"",r),e]}function Ec(r,e){let[t,n]=b0(r);return e(t),n.result()}function Nn(r){return r instanceof Tc||r instanceof Mc?r._current:r!==null&&typeof r=="object"?r[K_]:r}var lr;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function e(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}i.removeOverridden=e;function t(s,o){if((s instanceof Vt||s instanceof Tc)&&typeof o=="string")return s.data(o);if((s instanceof He||s instanceof Mc)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=t;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=t(s,o[a]),a+=1;return s}i.zoom=n})(lr||(lr={}));function Q_(r,e){let t=[];if(e.length===r.length)for(var n=0;n<r.length;){if(e[n]==="*")t.push(r[n]);else if(r[n]!==e[n])return null;n+=1}else return null;return t}function Vi(r,e){let t=[];if(e.length<=r.length)for(var n=0;n<e.length;){if(e[n]==="*")t.push(r[n]);else if(r[n]!==e[n])return null;n+=1}else return null;return t}var jp=class{},Bd=class extends jp{constructor(t){super();this.id=t}},Fd=class extends jp{constructor(t){super();this.data=t}};var S0;try{S0=new TextDecoder}catch{}var Ie,To,Z=0;var sT=[],A0=sT,_0=0,xr={},bt,_o,Qr=0,Hi=0,Gr,Ns,cr=[],Mt,J_={useRecords:!1,mapsAsObjects:!0},Ud=class{},M0=new Ud;M0.name="MessagePack 0xC1";var Cc=!1,Wi=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Ie)return uT(()=>(Yp(),this?this.unpack(e,t):Wi.prototype.unpack.call(J_,e,t)));To=t>-1?t:e.length,Z=0,_0=0,Hi=0,_o=null,A0=sT,Gr=null,Ie=e;try{Mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Ie=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Wi){if(xr=this,this.structures)return bt=this.structures,qp();(!bt||bt.length>0)&&(bt=[])}else xr=J_,(!bt||bt.length>0)&&(bt=[]);return qp()}unpackMultiple(e,t){let n,i=0;try{Cc=!0;let s=e.length,o=this?this.unpack(e,s):Zp.unpack(e,s);if(t){for(t(o);Z<s;)if(i=Z,t(qp())===!1)return}else{for(n=[o];Z<s;)i=Z,n.push(qp());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Cc=!1,Yp()}}_mergeStructures(e,t){e=e||[];for(let n=0,i=e.length;n<i;n++){let s=e[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let i=e[n],s=t[n];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[n]=i),e[n]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function qp(){try{if(!xr.trusted&&!Cc){let e=bt.sharedLength||0;e<bt.length&&(bt.length=e)}let r=Qt();if(Z==To)bt.restoreStructures&&$_(),bt=null,Ie=null,Ns&&(Ns=null);else if(Z>To){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Cc)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw bt.restoreStructures&&$_(),Yp(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function $_(){for(let r in bt.restoreStructures)bt[r]=bt.restoreStructures[r];bt.restoreStructures=null}function Qt(){let r=Ie[Z++];if(r<160)if(r<128){if(r<64)return r;{let e=bt[r&63]||xr.getStructures&&oT()[r&63];return e?(e.read||(e.read=E0(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,xr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[lT()]=Qt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Qt(),Qt());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Qt();return e}else if(r<192){let e=r-160;if(Hi>=Z)return _o.slice(Z-Qr,(Z+=e)-Qr);if(Hi==0&&To<140){let t=e<16?C0(e):aT(e);if(t!=null)return t}return T0(e)}else{let e;switch(r){case 192:return null;case 193:return Gr?(e=Qt(),e>0?Gr[1].slice(Gr.position1,Gr.position1+=e):Gr[0].slice(Gr.position0,Gr.position0-=e)):M0;case 194:return!1;case 195:return!0;case 196:return w0(Ie[Z++]);case 197:return e=Mt.getUint16(Z),Z+=2,w0(e);case 198:return e=Mt.getUint32(Z),Z+=4,w0(e);case 199:return Ea(Ie[Z++]);case 200:return e=Mt.getUint16(Z),Z+=2,Ea(e);case 201:return e=Mt.getUint32(Z),Z+=4,Ea(e);case 202:if(e=Mt.getFloat32(Z),xr.useFloat32>2){let t=Kp[(Ie[Z]&127)<<1|Ie[Z+1]>>7];return Z+=4,(t*e+(e>0?.5:-.5)>>0)/t}return Z+=4,e;case 203:return e=Mt.getFloat64(Z),Z+=8,e;case 204:return Ie[Z++];case 205:return e=Mt.getUint16(Z),Z+=2,e;case 206:return e=Mt.getUint32(Z),Z+=4,e;case 207:return xr.int64AsNumber?(e=Mt.getUint32(Z)*4294967296,e+=Mt.getUint32(Z+4)):e=Mt.getBigUint64(Z),Z+=8,e;case 208:return Mt.getInt8(Z++);case 209:return e=Mt.getInt16(Z),Z+=2,e;case 210:return e=Mt.getInt32(Z),Z+=4,e;case 211:return xr.int64AsNumber?(e=Mt.getInt32(Z)*4294967296,e+=Mt.getUint32(Z+4)):e=Mt.getBigInt64(Z),Z+=8,e;case 212:if(e=Ie[Z++],e==114)return iT(Ie[Z++]&63);{let t=cr[e];if(t)return t.read?(Z++,t.read(Qt())):t.noBuffer?(Z++,t()):t(Ie.subarray(Z,++Z));throw new Error("Unknown extension "+e)}case 213:return e=Ie[Z],e==114?(Z++,iT(Ie[Z++]&63,Ie[Z++])):Ea(2);case 214:return Ea(4);case 215:return Ea(8);case 216:return Ea(16);case 217:return e=Ie[Z++],Hi>=Z?_o.slice(Z-Qr,(Z+=e)-Qr):Ez(e);case 218:return e=Mt.getUint16(Z),Z+=2,Hi>=Z?_o.slice(Z-Qr,(Z+=e)-Qr):Cz(e);case 219:return e=Mt.getUint32(Z),Z+=4,Hi>=Z?_o.slice(Z-Qr,(Z+=e)-Qr):Pz(e);case 220:return e=Mt.getUint16(Z),Z+=2,tT(e);case 221:return e=Mt.getUint32(Z),Z+=4,tT(e);case 222:return e=Mt.getUint16(Z),Z+=2,nT(e);case 223:return e=Mt.getUint32(Z),Z+=4,nT(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}var Mz=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function E0(r,e){function t(){if(t.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>Mz.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Qt);return r.highByte===0&&(r.read=eT(e,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=Qt()}return n}return t.count=0,r.highByte===0?eT(e,t):t}var eT=(r,e)=>function(){let t=Ie[Z++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),i=bt[n]||oT()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=E0(i,r)),i.read()};function oT(){let r=uT(()=>(Ie=null,xr.getStructures()));return bt=xr._mergeStructures(r,bt)}var T0=Xp,Ez=Xp,Cz=Xp,Pz=Xp;function Xp(r){let e;if(r<16&&(e=C0(r)))return e;if(r>64&&S0)return S0.decode(Ie.subarray(Z,Z+=r));let t=Z+r,n=[];for(e="";Z<t;){let i=Ie[Z++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Ie[Z++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Ie[Z++]&63,o=Ie[Z++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ie[Z++]&63,o=Ie[Z++]&63,a=Ie[Z++]&63,l=(i&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(i);n.length>=4096&&(e+=Bn.apply(String,n),n.length=0)}return n.length>0&&(e+=Bn.apply(String,n)),e}function tT(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Qt();return e}function nT(r){if(xr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[lT()]=Qt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Qt(),Qt());return e}}var Bn=String.fromCharCode;function aT(r){let e=Z,t=new Array(r);for(let n=0;n<r;n++){let i=Ie[Z++];if((i&128)>0){Z=e;return}t[n]=i}return Bn.apply(String,t)}function C0(r){if(r<4)if(r<2){if(r===0)return"";{let e=Ie[Z++];if((e&128)>1){Z-=1;return}return Bn(e)}}else{let e=Ie[Z++],t=Ie[Z++];if((e&128)>0||(t&128)>0){Z-=2;return}if(r<3)return Bn(e,t);let n=Ie[Z++];if((n&128)>0){Z-=3;return}return Bn(e,t,n)}else{let e=Ie[Z++],t=Ie[Z++],n=Ie[Z++],i=Ie[Z++];if((e&128)>0||(t&128)>0||(n&128)>0||(i&128)>0){Z-=4;return}if(r<6){if(r===4)return Bn(e,t,n,i);{let s=Ie[Z++];if((s&128)>0){Z-=5;return}return Bn(e,t,n,i,s)}}else if(r<8){let s=Ie[Z++],o=Ie[Z++];if((s&128)>0||(o&128)>0){Z-=6;return}if(r<7)return Bn(e,t,n,i,s,o);let a=Ie[Z++];if((a&128)>0){Z-=7;return}return Bn(e,t,n,i,s,o,a)}else{let s=Ie[Z++],o=Ie[Z++],a=Ie[Z++],l=Ie[Z++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Z-=8;return}if(r<10){if(r===8)return Bn(e,t,n,i,s,o,a,l);{let u=Ie[Z++];if((u&128)>0){Z-=9;return}return Bn(e,t,n,i,s,o,a,l,u)}}else if(r<12){let u=Ie[Z++],c=Ie[Z++];if((u&128)>0||(c&128)>0){Z-=10;return}if(r<11)return Bn(e,t,n,i,s,o,a,l,u,c);let d=Ie[Z++];if((d&128)>0){Z-=11;return}return Bn(e,t,n,i,s,o,a,l,u,c,d)}else{let u=Ie[Z++],c=Ie[Z++],d=Ie[Z++],h=Ie[Z++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){Z-=12;return}if(r<14){if(r===12)return Bn(e,t,n,i,s,o,a,l,u,c,d,h);{let f=Ie[Z++];if((f&128)>0){Z-=13;return}return Bn(e,t,n,i,s,o,a,l,u,c,d,h,f)}}else{let f=Ie[Z++],m=Ie[Z++];if((f&128)>0||(m&128)>0){Z-=14;return}if(r<15)return Bn(e,t,n,i,s,o,a,l,u,c,d,h,f,m);let p=Ie[Z++];if((p&128)>0){Z-=15;return}return Bn(e,t,n,i,s,o,a,l,u,c,d,h,f,m,p)}}}}}function w0(r){return xr.copyBuffers?Uint8Array.prototype.slice.call(Ie,Z,Z+=r):Ie.subarray(Z,Z+=r)}function Ea(r){let e=Ie[Z++];if(cr[e])return cr[e](Ie.subarray(Z,Z+=r));throw new Error("Unknown extension type "+e)}var rT=new Array(4096);function lT(){let r=Ie[Z++];if(r>=160&&r<192){if(r=r-160,Hi>=Z)return _o.slice(Z-Qr,(Z+=r)-Qr);if(!(Hi==0&&To<180))return T0(r)}else return Z--,Qt();let e=(r<<5^(r>1?Mt.getUint16(Z):r>0?Ie[Z]:0))&4095,t=rT[e],n=Z,i=Z+r-3,s,o=0;if(t&&t.bytes==r){for(;n<i;){if(s=Mt.getUint32(n),s!=t[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Ie[n++],s!=t[o++]){n=1879048192;break}if(n===i)return Z=n,t.string;i-=3,n=Z}for(t=[],rT[e]=t,t.bytes=r;n<i;)s=Mt.getUint32(n),t.push(s),n+=4;for(i+=3;n<i;)s=Ie[n++],t.push(s);let a=r<16?C0(r):aT(r);return a!=null?t.string=a:t.string=T0(r)}var iT=(r,e)=>{var t=Qt();let n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let i=bt[r];return i&&i.isShared&&((bt.restoreStructures||(bt.restoreStructures=[]))[r]=i),bt[r]=t,t.read=E0(t,n),t.read()},cT=typeof self=="object"?self:global;cr[0]=()=>{};cr[0].noBuffer=!0;cr[101]=()=>{let r=Qt();return(cT[r[0]]||Error)(r[1])};cr[105]=r=>{let e=Mt.getUint32(Z-4);Ns||(Ns=new Map);let t=Ie[Z],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let i={target:n};Ns.set(e,i);let s=Qt();return i.used?Object.assign(n,s):(i.target=s,s)};cr[112]=r=>{let e=Mt.getUint32(Z-4),t=Ns.get(e);return t.used=!0,t.target};cr[115]=()=>new Set(Qt());var P0=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");cr[116]=r=>{let e=r[0],t=P0[e];if(!t)throw new Error("Could not find typed array for code "+e);return new cT[t](Uint8Array.prototype.slice.call(r,1).buffer)};cr[120]=()=>{let r=Qt();return new RegExp(r[0],r[1])};cr[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=Z;Z+=e-4,Gr=[Qt(),Qt()],Gr.position0=0,Gr.position1=0;let n=Z;Z=t;try{return Qt()}finally{Z=n}};cr[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function uT(r){let e=To,t=Z,n=_0,i=Qr,s=Hi,o=_o,a=A0,l=Ns,u=Gr,c=new Uint8Array(Ie.slice(0,To)),d=bt,h=bt.slice(0,bt.length),f=xr,m=Cc,p=r();return To=e,Z=t,_0=n,Qr=i,Hi=s,_o=o,A0=a,Ns=l,Gr=u,Ie=c,Cc=m,bt=d,bt.splice(0,bt.length,...h),xr=f,Mt=new DataView(Ie.buffer,Ie.byteOffset,Ie.byteLength),p}function Yp(){Ie=null,Ns=null,bt=null}function dT(r){r.unpack?cr[r.type]=r.unpack:cr[r.type]=r}var Kp=new Array(147);for(let r=0;r<256;r++)Kp[r]=+("1e"+Math.floor(45.15-r*.30103));var Zp=new Wi({useRecords:!1}),Iz=Zp.unpack,Dz=Zp.unpackMultiple,Oz=Zp.unpack,Qp={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Lz=new Float32Array(1),DJ=new Uint8Array(Lz.buffer,0,4);var Jp;try{Jp=new TextEncoder}catch{}var $p,D0,em=typeof Buffer<"u",I0=em?Buffer.allocUnsafeSlow:Uint8Array,mT=em?Buffer:Uint8Array,hT=em?4294967296:2144337920,le,on,ee=0,ji,qi=null,Rz=/[\u0080-\uFFFF]/,Gd=Symbol("record-id"),Ca=class extends Wi{constructor(e){super(e),this.offset=0;let t,n,i,s,o,a,l=0,u=mT.prototype.utf8Write?function(x,M,E){return le.utf8Write(x,M,E)}:Jp&&Jp.encodeInto?function(x,M){return Jp.encodeInto(x,le.subarray(M)).written}:!1,c=this;e||(e={});let d=e&&e.sequential,h=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=h?32:64),d&&!e.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=[],b=0,w=0;this.pack=this.encode=function(x,M){if(le||(le=new I0(8192),on=new DataView(le.buffer,0,8192),ee=0),ji=le.length-10,ji-ee<2048?(le=new I0(le.length),on=new DataView(le.buffer,0,le.length),ji=le.length-10,ee=0):ee=ee+7&2147483640,n=ee,a=c.structuredClone?new Map:null,c.bundleStrings?(qi=["",""],le[ee++]=214,le[ee++]=98,qi.position=ee-n,ee+=4):qi=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let E=i.sharedLength||0;if(E>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let P=i[C];if(!P)continue;let O,I=i.transitions;for(let N=0,B=P.length;N<B;N++){let W=P[N];O=I[W],O||(O=I[W]=Object.create(null)),I=O}I[Gd]=C+64}l=E}d||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(x),qi){on.setUint32(qi.position+n,ee-qi.position-n);let E=qi;qi=null,S(E[0]),S(E[1])}if(c.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>ji&&T(ee),c.offset=ee;let E=Bz(le.subarray(n,ee),a.idsToInsert);return a=null,E}return M&yT?(le.start=n,le.end=ee,le):le.subarray(n,ee)}finally{if(i){if(w<10&&w++,b>1e4)i.transitions=null,w=0,b=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let E=0,C=v.length;E<C;E++)v[E][Gd]=0;v=[]}if(s&&c.saveStructures){let E=i.sharedLength||f;i.length>E&&(i=i.slice(0,E));let C=le.subarray(n,ee);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=E,C)}}M&Hz&&(ee=n)}};let S=x=>{ee>ji&&(le=T(ee));var M=typeof x,E;if(M==="string"){let C=x.length;if(qi&&C>=8&&C<4096){let I=Rz.test(x);qi[I?0:1]+=x,le[ee++]=193,S(I?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let O=C*3;if(ee+O>ji&&(le=T(ee+O)),C<64||!u){let I,N,B,W=ee+P;for(I=0;I<C;I++)N=x.charCodeAt(I),N<128?le[W++]=N:N<2048?(le[W++]=N>>6|192,le[W++]=N&63|128):(N&64512)===55296&&((B=x.charCodeAt(I+1))&64512)===56320?(N=65536+((N&1023)<<10)+(B&1023),I++,le[W++]=N>>18|240,le[W++]=N>>12&63|128,le[W++]=N>>6&63|128,le[W++]=N&63|128):(le[W++]=N>>12|224,le[W++]=N>>6&63|128,le[W++]=N&63|128);E=W-ee-P}else E=u(x,ee+P,O);E<32?le[ee++]=160|E:E<256?(P<2&&le.copyWithin(ee+2,ee+1,ee+1+E),le[ee++]=217,le[ee++]=E):E<65536?(P<3&&le.copyWithin(ee+3,ee+2,ee+2+E),le[ee++]=218,le[ee++]=E>>8,le[ee++]=E&255):(P<5&&le.copyWithin(ee+5,ee+3,ee+3+E),le[ee++]=219,on.setUint32(ee,E),ee+=4),ee+=E}else if(M==="number")if(x>>>0===x)x<64?le[ee++]=x:x<256?(le[ee++]=204,le[ee++]=x):x<65536?(le[ee++]=205,le[ee++]=x>>8,le[ee++]=x&255):(le[ee++]=206,on.setUint32(ee,x),ee+=4);else if(x>>0===x)x>=-32?le[ee++]=256+x:x>=-128?(le[ee++]=208,le[ee++]=x+256):x>=-32768?(le[ee++]=209,on.setInt16(ee,x),ee+=2):(le[ee++]=210,on.setInt32(ee,x),ee+=4);else{let C;if((C=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){le[ee++]=202,on.setFloat32(ee,x);let P;if(C<4||(P=x*Kp[(le[ee]&127)<<1|le[ee+1]>>7])>>0===P){ee+=4;return}else ee--}le[ee++]=203,on.setFloat64(ee,x),ee+=8}else if(M==="object")if(!x)le[ee++]=192;else{if(a){let P=a.get(x);if(P){if(!P.id){let O=a.idsToInsert||(a.idsToInsert=[]);P.id=O.push(P)}le[ee++]=214,le[ee++]=112,on.setUint32(ee,P.id),ee+=4;return}else a.set(x,{offset:ee-n})}let C=x.constructor;if(C===Object)_(x,!0);else if(C===Array){E=x.length,E<16?le[ee++]=144|E:E<65536?(le[ee++]=220,le[ee++]=E>>8,le[ee++]=E&255):(le[ee++]=221,on.setUint32(ee,E),ee+=4);for(let P=0;P<E;P++)S(x[P])}else if(C===Map){E=x.size,E<16?le[ee++]=128|E:E<65536?(le[ee++]=222,le[ee++]=E>>8,le[ee++]=E&255):(le[ee++]=223,on.setUint32(ee,E),ee+=4);for(let[P,O]of x)S(P),S(O)}else{for(let P=0,O=$p.length;P<O;P++){let I=D0[P];if(x instanceof I){let N=$p[P];if(N.write){N.type&&(le[ee++]=212,le[ee++]=N.type,le[ee++]=0),S(N.write.call(this,x));return}let B=le,W=on,X=ee;le=null;let F;try{F=N.pack.call(this,x,k=>(le=B,B=null,ee+=k,ee>ji&&T(ee),{target:le,targetView:on,position:ee-k}),S)}finally{B&&(le=B,on=W,ee=X,ji=le.length-10)}F&&(F.length+ee>ji&&T(F.length+ee),ee=Nz(F,le,ee,N.type));return}}_(x,!x.hasOwnProperty)}}else if(M==="boolean")le[ee++]=x?195:194;else if(M==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))le[ee++]=211,on.setBigInt64(ee,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)le[ee++]=207,on.setBigUint64(ee,x);else if(this.largeBigIntToFloat)le[ee++]=203,on.setFloat64(ee,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ee+=8}else if(M==="undefined")this.encodeUndefinedAsNil?le[ee++]=192:(le[ee++]=212,le[ee++]=0,le[ee++]=0);else if(M==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},_=this.useRecords===!1?this.variableMapSize?x=>{let M=Object.keys(x),E=M.length;E<16?le[ee++]=128|E:E<65536?(le[ee++]=222,le[ee++]=E>>8,le[ee++]=E&255):(le[ee++]=223,on.setUint32(ee,E),ee+=4);let C;for(let P=0;P<E;P++)S(C=M[P]),S(x[C])}:(x,M)=>{le[ee++]=222;let E=ee-n;ee+=2;let C=0;for(let P in x)(M||x.hasOwnProperty(P))&&(S(P),S(x[P]),C++);le[E+++n]=C>>8,le[E+n]=C&255}:x=>{let M=Object.keys(x),E,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let I=0,N=M.length;I<N;I++){let B=M[I];E=C[B],E||(E=C[B]=Object.create(null),P++),C=E}let O=C[Gd];if(O)O>=96&&p?(le[ee++]=((O-=96)&31)+96,le[ee++]=O>>5):le[ee++]=O;else{O=o.nextId,O||(O=64),O<g&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(O=o.nextOwnId,O<y||(O=g),o.nextOwnId=O+1):(O>=y&&(O=g),o.nextId=O+1);let I=M.highByte=O>=96&&p?O-96>>5:-1;C[Gd]=O,o[O-64]=M,O<g?(M.isShared=!0,o.sharedLength=O-63,s=!0,I>=0?(le[ee++]=(O&31)+96,le[ee++]=I):le[ee++]=O):(I>=0?(le[ee++]=213,le[ee++]=114,le[ee++]=(O&31)+96,le[ee++]=I):(le[ee++]=212,le[ee++]=114,le[ee++]=O),P&&(b+=w*P),v.length>=m&&(v.shift()[Gd]=0),v.push(C),S(M))}for(let I=0,N=M.length;I<N;I++)S(x[M[I]])},T=x=>{let M;if(x>16777216){if(x-n>hT)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(hT,Math.round(Math.max((x-n)*(x>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(x-n<<2,le.length-1)>>12)+1<<12;let E=new I0(M);return on=new DataView(E.buffer,0,M),le.copy?le.copy(E,0,n,x):E.set(le.slice(n,x)),ee-=n,n=0,ji=E.length-10,le=E}}useBuffer(e){le=e,on=new DataView(le.buffer,le.byteOffset,le.byteLength),ee=0}};D0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ud];$p=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){let n=Array.from(r),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(n)}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),t([r.source,r.flags])}},{pack(r,e){this.structuredClone?fT(r,16,e):pT(em?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==mT&&this.structuredClone?fT(r,P0.indexOf(t.name),e):pT(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function fT(r,e,t,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function pT(r,e){let t=r.byteLength;var n,i;if(t<256){var{target:n,position:i}=e(t+2);n[i++]=196,n[i++]=t}else if(t<65536){var{target:n,position:i}=e(t+3);n[i++]=197,n[i++]=t>>8,n[i++]=t&255}else{var{target:n,position:i,targetView:s}=e(t+5);n[i++]=198,s.setUint32(i,t),i+=4}n.set(r,i)}function Nz(r,e,t,n){let i=r.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=n,e.set(r,t),t+=i,t}function Bz(r,e){let t,n=e.length*6,i=r.length-n;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function Mo(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");D0.unshift(r.Class),$p.unshift(r)}dT(r)}var gT=new Ca({useRecords:!1}),Fz=gT.pack,Uz=gT.pack;var{NEVER:Gz,ALWAYS:kz,DECIMAL_ROUND:zz,DECIMAL_FIT:Vz}=Qp,yT=512,Hz=1024;var vT=new Ca({structuredClone:!0});Mo({Class:Ot.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ot.prototype),r}});Mo({Class:He.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,He.prototype),r}});Mo({Class:Vt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Vt.prototype),r}});Mo({Class:Bd.prototype.constructor,type:4,write(r){return r.id},read(r){return new Bd(r)}});Mo({Class:Fd.prototype.constructor,type:5,write(r){return r.data},read(r){return new Fd(r)}});Mo({Class:Ht.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ht.prototype),r}});function Wz(r){var e=0;if(r.length===0)return e;for(let t=0;t<r.length;t++){let n=r[t];e=(e<<5)-e+n,e=e&e}return e}function O0(r){if(Sc(r))return r;if(Array.isArray(r))return r.map(O0);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=O0(r[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else return r}var tm;(n=>{function r(i){return vT.pack(i)}n.serialize=r;function e(i){return vT.unpack(i)}n.deserialize=e;function t(i){return Wz(r(O0(i))).toString()}n.checksum=t})(tm||(tm={}));var Pc={["LookAt"]:[],["Follow"]:[],["MouseHover"]:["Transition"],["Scroll"]:["Transition"],["Start"]:["Transition","Audio","Video"],["Conditional"]:["Transition","Audio","Video"],["MouseDown"]:["Transition","Audio","Video","Link","Reset"],["MouseUp"]:["Transition","Audio","Video","Link","Reset"],["MousePress"]:["Transition","Audio","Video","Link","Reset"],["KeyDown"]:["Transition","Audio","Video","Link","Reset"],["KeyUp"]:["Transition","Audio","Video","Link","Reset"],["KeyPress"]:["Transition","Audio","Video","Link","Reset"],["GameControl"]:["Transition","Audio"],["Collision"]:["Transition","Audio"]},xT;(t=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}t.is=r;function e(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,disabled:!1,toggle:!1,actions:new He}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new He}}t.defaultData=e})(xT||(xT={}));var nm;(t=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}t.propertyDefaultData=r,t.valueDefaultData={type:"Literal",value:0}})(nm||(nm={}));var L0;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:nm.propertyDefaultData(i),rOperand:{...nm.valueDefaultData}}}n.comparisonDefaultData=r;function e(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=e;function t(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=t})(L0||(L0={}));var bT;(t=>{function r(n){return n.type==="Conditional"}t.is=r;function e(n){return{type:"Conditional",disabled:!1,inActions:new He,outActions:new He,condition:L0.distanceDefaultData(n)}}t.defaultData=e})(bT||(bT={}));var wT;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,plane:"custom",resetOnPointerLeave:!0})(wT||(wT={}));var ST;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0})(ST||(ST={}));var AT;(t=>{function r(n){return n.type==="MouseHover"}t.is=r;function e(){return{type:"MouseHover",disabled:!1,actions:new He}}t.defaultData=e})(AT||(AT={}));var _T;(t=>{function r(n){return n.type==="Scroll"}t.is=r;function e(){return{type:"Scroll",disabled:!1,steps:100,actions:new He}}t.defaultData=e})(_T||(_T={}));var TT;(t=>{function r(n){return n.type==="Start"}t.is=r;function e(){return{type:"Start",disabled:!1,actions:new He}}t.defaultData=e})(TT||(TT={}));var MT;(t=>{function r(n){return n.type==="Collision"}t.is=r;function e(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new He}}t.defaultData=e})(MT||(MT={}));var Pa;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}t.lerp=e})(Pa||(Pa={}));var Yi;(o=>{function r(a,l){return a[0]===l[0]&&a[1]===l[1]&&a[2]===l[2]}o.isEqual=r;function e(a,l){return[a[0]+l[0],a[1]+l[1],a[2]+l[2]]}o.add=e;function t(a,l){return[a[0]-l[0],a[1]-l[1],a[2]-l[2]]}o.sub=t;function n(a,l){return[a[0]/l[0],a[1]/l[1],a[2]/l[2]]}o.div=n;function i(a,l){return[a[0]*l[0],a[1]*l[1],a[2]*l[2]]}o.mul=i;function s(a,l,u){return[a[0]+(l[0]-a[0])*u,a[1]+(l[1]-a[1])*u,a[2]+(l[2]-a[2])*u]}o.lerp=s})(Yi||(Yi={}));var kd;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}t.lerp=e})(kd||(kd={}));var Eo;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;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}i.applyMatrix4=n})(Eo||(Eo={}));var Qn;(u=>{function r(c){return typeof c=="object"&&typeof c.r=="number"&&typeof c.g=="number"&&typeof c.b=="number"}u.isRGB=r,u.white={r:1,g:1,b:1},u.red={r:1,g:0,b:0},u.black={r:0,g:0,b:0};function i(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}u.toRgb255a1=i;function s(c){return{r:c.r,g:c.g,b:c.b}}u.clone=s;function o(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}u.fromHex=o;function a(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}u.equals=a;function l(c,d,h){return{r:c.r+(d.r-c.r)*h,g:c.g+(d.g-c.g)*h,b:c.b+(d.b-c.b)*h}}u.lerp=l})(Qn||(Qn={}));var br;(a=>{a.white={...Qn.white,a:1},a.transparent={...Qn.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=t;function n(l,u){return{...Qn.fromHex(l),a:u}}a.fromHexAndA=n;function i(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=i;function s(l,u){return Qn.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})(br||(br={}));var rm;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(rm||(rm={}));var ET;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(ET||(ET={}));var CT;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(CT||(CT={}));var vi;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(n){return t.all.includes(n)}t.is=e})(vi||(vi={}));var Ia;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(Ia||(Ia={}));var Xi;(t=>{function r(n,i=.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]*i,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}t.defaultData=r;function e(n,i){let s={...n};if(R0.forEach(o=>{Object.assign(s,{[o]:i[o]??n[o]})}),s.radial={...n.radial},i.radial){let o=n.radial,a=i.radial;N0.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},i.linear){let o=n.linear,a=i.linear;B0.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},i.grid){let o=n.grid,a=i.grid;F0.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},i.toObject){let o=n.toObject,a=i.toObject;U0.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},i.randomnessObject){let o=n.randomnessObject,a=i.randomnessObject;G0.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}t.merge=e})(Xi||(Xi={}));var im;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let e=["radial","linear","grid","toObject","randomnessObject"];function t(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of e){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=t})(im||(im={}));var R0=["count"],N0=["radius","start","end","position","scale","rotation"],B0=["position","scale","rotation"],F0=["count","size"],U0=["count","position","scale","rotation"],G0=["strength","scale","rotation","position","movement","seed","freqScale"];var Da;(t=>{let r={opacity:1,blendFunction:13,enabled:!1};t.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(Da||(Da={}));var sm;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(n){return t.all.includes(n)}t.is=e})(sm||(sm={}));var om;(t=>{function r(n){return e(n)}t.defaultData=r;function e(n){if(n==="PointLight")return{type:n,color:br.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:br.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:br.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(om||(om={}));var k0;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}t.equals=e})(k0||(k0={}));var z0;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}t.equals=e})(z0||(z0={}));var am;(e=>e.defaultData={...z0.defaultData,...k0.defaultData})(am||(am={}));var Ic;(t=>(t.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7))(Ic||(Ic={}));var lm=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],PT=["wrapping","image","video"],ur;(i=>{function r(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}i.patch=r;function e(s,o){return s==="light"&&o?t(o):n(s)}i.defaultData=e;function t(s){switch(s){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function n(s){switch(s){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:Ic.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Qn.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Qn.fromHex(6710886),a:1},colorB:{...Qn.fromHex(6710886),a:1},colorC:{...Qn.fromHex(16777215),a:1},colorD:{...Qn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:br.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,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:br.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:br.fromHexAndA(0,1),contourColor:br.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{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(ur||(ur={}));var Fn;(l=>{function r(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=r;function e(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=e;function t(){return{layers:new He}}l.defaultEmptyData=t;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function i(u,c){return{...u,name:c}}l.withName=i;function s(u,c="layer1",d="layer2"){let h=new He;return h.push({fi:0,data:ur.defaultData("light",u),id:c}),h.push({fi:1,data:ur.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=ur.defaultData("texture");Object.assign(f.texture,{image:u});let m=new He;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:ur.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=ur.defaultData("video");Object.assign(f.texture,{video:u});let m=new He;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:ur.defaultData("light",c),id:h}),{layers:m}}l.defaultTwoLayerVideoTextureData=a})(Fn||(Fn={}));var Dc;(e=>{function r(){return{points:new He,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=r})(Dc||(Dc={}));var zd;(e=>{function r(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=r})(zd||(zd={}));var Co;(e=>{function r(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Dc.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};if(t==="TextGeometry")return{type:t,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};throw new Error("not implemented")}e.defaultData=r})(Co||(Co={}));var IT;(t=>{function r(n){return n==="Component"||n==="Instance"}t.isComponentRelated=r;function e(n){return n==="Empty"||n==="Instance"}t.isEmptyOrComponent=e})(IT||(IT={}));var Oc;(i=>{i.identity={...rm.identity,hiddenMatrix:Eo.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function n(s,o){return{position:Yi.isEqual(s.position,o.position)?null:o.position,rotation:Yi.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:Yi.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Eo.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(Oc||(Oc={}));var V0;(e=>e.defaultData={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]})(V0||(V0={}));var kr;(e=>e.defaultData={states:new He,events:new He,visible:!0,raycastLock:!1,physics:null,...Oc.identity,cloner:null})(kr||(kr={}));var DT;(e=>e.defaultData={type:"Empty",...kr.defaultData})(DT||(DT={}));var OT;(e=>e.defaultData={type:"Component",...kr.defaultData})(OT||(OT={}));var Oa;(e=>e.defaultData={type:"Mesh",...kr.defaultData,...am.defaultData})(Oa||(Oa={}));var Lc;(e=>e.defaultData={...kr.defaultData,...Oc.identity,...Ia.defaultData})(Lc||(Lc={}));var cm;(e=>{function r(t){return{...kr.defaultData,...om.defaultData(t)}}e.defaultData=r})(cm||(cm={}));var Rc;(t=>{function r(n,i,s=0){for(;s<i.length;){let o=n?n[i[s]]:void 0;if(i.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}t.resolveWithDes=r;function e(n,i,s=0){let o=r(n,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}t.resolve=e})(Rc||(Rc={}));var Po;(s=>{s.rootOverrideProps=["physics"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...kr.defaultData,...a,component:o,overrides:new Ht,physics:void 0,type:"Instance"}}s.ofComponent=n;function i(o){let a=Oc.fromObject(o.data);return n(o.id,a)}s.fromComponentData=i})(Po||(Po={}));var um;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Eo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:V0.defaultData,states:new He,events:new He,cloner:null,...Ia.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",...kr.defaultData,...Oa.defaultData,geometry:Co.defaultData("RectangleGeometry"),material:Fn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...kr.defaultData,...Oa.defaultData,geometry:Co.defaultData("BooleanGeometry"),material:Fn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...kr.defaultData,...Oa.defaultData,geometry:Co.defaultData("TextGeometry"),material:Fn.defaultTwoLayerData("phong","layer1","layer2")}))(um||(um={}));var Bs;(i=>{function r(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Ht}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Ht})))):vi.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=r;function e(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Ec(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&ur.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Ec(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&&ur.patch(f,h)}}}).data),a}function t(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(...im.toOps(h,["cloner"]));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(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}i.toOps=t;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Oc.merge(a,o)),vi.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")o.geometry&&(a.geometry={...a.geometry},Object.assign(a.geometry,o.geometry)),(o.material||o.materials)&&(a=e(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Xi.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Xi.merge(a.cloner,o.cloner)});else if(sm.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=Qn.clone(l.color))}return a}i.patch=n})(Bs||(Bs={}));var Hd;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Qn.white,near:.1,far:2e3})(Hd||(Hd={}));var Nc;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(Nc||(Nc={}));var Fs;(e=>e.defaultData={orbitControls:Nc.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,hideCursor:!1,settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:typeof window<"u"?Math.floor(window.devicePixelRatio):1,stopMode:"manual",duration:5e3},web:{compress:!0,preset:1,preload:!0}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((t,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null})(Fs||(Fs={}));function Ki(r,e){return Object.setPrototypeOf(r,e),r}var jz=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),qz=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),Yz=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||La&&"ontouchend"in document,Xz=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Kz=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,Zz=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(e)},Qz=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},uee=jz(),La=qz(),Wd=Yz(),LT=Xz(),an=Kz(),Bc=Zz(),Fc=Number(Qz());function dm(r){return Array.isArray(r)?r:[r]}function RT(r,e){let t=0;for(;t<r.length&&t<e.length;){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==r.length?1:0}function jd(r){return La?r.metaKey:r.ctrlKey}var qe=[],fm={},qd={},hm={};function NT(r){qe.includes(r)||qe.push(r)}function Uc(r){delete fm[r.pointerId];for(let e=0;e<qe.length;e++)if(qe[e].pointerId===r.pointerId){qe.splice(e,1);break}}function BT(){qe.splice(0,qe.length)}function pm(r){if(r.pointerType!=="touch")return;let e=fm[r.pointerId];e===void 0&&(e={x:0,y:0},fm[r.pointerId]=e),e.x=r.pageX,e.y=r.pageY}function mm(r){let e=r.pointerId===qe[0].pointerId?qe[1]:qe[0];return fm[e.pointerId]}function FT(r){qd[r.key]=!0,hm[r.key]=hm[r.key]===void 0?1:hm[r.key]+1}function UT(r){if(La&&qd.Meta)for(let e in qd)qd[e]=!1;else qd[r.key]=!1;hm={}}function GT(r){r.addEventListener("pointerdown",NT,!0),r.addEventListener("pointerdown",pm,!0),r.addEventListener("pointermove",pm,!0),r.addEventListener("pointerup",Uc,!0),r.addEventListener("pointercancel",Uc,!0),r.addEventListener("pointerleave",Uc,!0),window.addEventListener("keydown",FT,!0),window.addEventListener("keyup",UT,!0)}function kT(r){r.removeEventListener("pointerdown",NT,!0),r.removeEventListener("pointerdown",pm,!0),r.removeEventListener("pointermove",pm,!0),r.removeEventListener("pointerup",Uc,!0),r.removeEventListener("pointercancel",Uc,!0),r.removeEventListener("pointerleave",Uc,!0),window.removeEventListener("keydown",FT,!0),window.removeEventListener("keyup",UT,!0)}var dr;(e=>e.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(dr||(dr={}));var gm;(o=>{o.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function e(a={withLight:!0,withSquare:!0}){let l=new Vt,u=um.defaultMeshObject;return a.withLight===!0&&l.push({fi:-1,data:{...cm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),a.withSquare===!0&&l.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:u,children:[]}),l}o.defaultData={backgroundColor:br.fromHexAndA(1908256,1),postprocessing:Da.defaultData,fog:Hd.defaultData,objects:e(),environment:dr.defaultData,publish:Fs.defaultData},o.emptyData=function(a){return{backgroundColor:br.fromHexAndA(1908256,1),postprocessing:Da.defaultData,fog:Hd.defaultData,objects:a?e(a):new Vt,environment:dr.defaultData,publish:Fs.defaultData}};function i(a){return{...o.defaultData,objects:Ki(a,Vt.prototype)}}o.withObjs=i;function s(a,l){return i([{id:a,data:l,children:[],fi:0}])}o.withObj=s})(gm||(gm={}));var Gc;(t=>{function r(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ki(n,Ot.prototype)}t.defaultColors=r;function e(){return{materials:new Ot,images:new Ot,videos:new Ot,colors:new Ot,audios:new Ot,fonts:new Ot,penumbraSize:[.5,.5,.5]}}t.emptyData=e})(Gc||(Gc={}));function zT(r){r.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let t=e.colorA,n=e.colorB,i=[[t.r,t.g,t.b,t.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...bc(Nn(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,o)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let t={...Nn(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,t)}})}function ym(r,e){Object.values(r.shared.materials).forEach(t=>e(t))}function vm(r,e){r.scene.objects.traverse((t,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&e(i)}):"material"in n&&typeof n.material!="string"&&e(n.material)})}function Jz(r){Object.assign(r.scene.publish,{orbitControls:{...Nc.defaultData,...Nn(r.scene.publish.orbitControls)}})}function $z(r){Object.assign(r.scene.publish.settings,{video:{...Fs.defaultData.settings.video,...Nn(r.scene.publish.settings.video)}})}function eV(r){function e(t){if(t.layers){for(let n of Object.values(t.layers))if(n){for(let[i,s]of Object.entries(n))if((lm.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(PT.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((t,n)=>{n.states.forEach(i=>{let s=i;s.material?e(s.material):s.materials&&s.materials.forEach(o=>{e(o)})})})}function tV(r){r.scene.publish.withBackground=!0}function nV(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1}}function rV(r){r.scene.objects.traverse((e,t)=>{let n=t.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function iV(r){r.scene.objects.traverse((e,t)=>{let n=t.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function sV(r){r.scene.objects.traverse((e,t)=>{let n=r.scene.objects.unproxy().parent(e);if(n){let i=Nn(r.scene.objects.data(n));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&t.type==="Mesh"&&(t.visible=Nn(t).booleanExclude!==!0)}})}function oV(r){r.scene.objects.traverse((e,t)=>{if(t.type==="Mesh"){let n=t;t.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function aV(r){function e(n){Object.setPrototypeOf(n,Ht.prototype),n.texture&&Object.setPrototypeOf(n.texture,Ht.prototype)}function t(n){Object.setPrototypeOf(n,Ht.prototype);for(let i in n)e(n[i])}r.scene.objects.traverse((n,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=Nn(o.material).layers;t(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=Nn(l).layers;t(u),l.layers=u}})})}function VT(r){r.layers===void 0&&Object.assign(r,Fn.defaultTwoLayerData("lambert"))}function H0(r){!r.layers||r.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let t=[...e.colors];t.push(e.colors[9]);let n=[...e.steps];n.push(e.steps[9]);let i={...Nn(e),colors:t,steps:n};Object.assign(e,i)}})}function lV(r){r.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&(t.geometry.type==="BooleanGeometry"||t.geometry.type==="SubdivGeometry")&&(t.geometry.phongAngle=35)})}function HT(r){r.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(n=>{typeof n!="string"&&H0(n)}):"material"in t&&typeof t.material!="string"&&H0(t.material)}),Object.values(r.shared.materials).forEach(e=>H0(e))}function cV(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((e,t)=>{(t.type==="DirectionalLight"||t.type==="SpotLight")&&(t.shadowResolution=1024,t.shadowRadius=1,t.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function uV(r){r.shared.audios=Ki({},Ot.prototype)}function dV(r){r.shared.videos=Ki({},Ot.prototype)}function hV(r){let e=r.shared.materials;Object.entries(e).forEach(([t,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(e,{[t]:i})}})}function fV(r){Object.entries(Nn(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(Nn(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function pV(r){r.scene.publish.settings.web.preload=!1}function WT(r){r.layers&&r.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function mV(r){r.shared.fonts=Ki({},Ot.prototype)}function gV(r){return r.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function yV(r){let e=[];r.scene.objects.traverse((t,n)=>{let i=n;if(i.type==="TextFrame"){let s=Fn.defaultTwoLayerData("phong"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=gV(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...kr.defaultData,...Oa.defaultData,flatShading:!1,wireframe:!1,geometry:{...Co.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Nn(i.states),events:Nn(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=Nn(r.scene.objects).parent(t);r.scene.objects.insertAfter(u??null,t,[{id:t+"new",data:l,children:[]}]),e.push(t)}}),e.forEach(t=>{r.scene.objects.delete(t)})}function vV(r){let e={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((t,n)=>{n.events.forEach(i=>{if(!!e[Number(i.type)])if(Object.assign(i,{type:e[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new He,move:new He,jump:new He}});else{let s=new He;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:ze.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.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,bc(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 He({fi:0,id:ze.generateUUID(),data:u},{fi:1,id:ze.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function xV(r){r.scene.objects.traverse((e,t)=>{function n(i,s){let o=new He,a=[];if(t.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...bc(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={...bc(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>t.events.delete(l)),o.length){let l=t.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):t.events.insertBefore(null,[{id:ze.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function jT(r){let e=r.layers.find(t=>t.type==="light")?.data;if(e?.category==="basic"){let t=ur.defaultData("light","phong"),n=e;Object.assign(n,t),n.visible=!1}}function qT(r){ym(r,jT),vm(r,jT)}function bV(r){r.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(t.geometry.scaleBaked||(t.geometry.scaleBaked=[1,1,1]))})}function wV(r){r.scene.objects.traverse((e,t)=>{(t.type==="Empty"||t.type==="Mesh")&&t.cloner&&!t.cloner.randomnessObject&&!t.cloner.toObject&&!t.cloner.randomness&&(t.cloner={...t.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 SV(r){r.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="NonParametricGeometry"&&!("material"in t)&&!("materials"in t)&&(t.material=Fn.defaultTwoLayerData("phong"))})}function AV(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.scene.objects.traverse((e,t)=>{(t.type==="OrthographicCamera"||t.type==="PerspectiveCamera")&&(t.orthographic.autoZoom===void 0&&(t.orthographic.autoZoom=!1),t.orthographic.autoZoomFrustumSize===void 0&&(t.orthographic.autoZoomFrustumSize=790))})}var YT=31;function XT(r){let e=r.schema??0;e!==YT&&(console.warn("updating from ",e,"to ",YT),e<1&&(vm(r,zT),ym(r,zT),r.schema=1),e<2&&(Jz(r),r.schema=2),e<3&&(eV(r),r.schema=3),e<4&&(tV(r),r.schema=4),e<5&&(nV(r),r.schema=5),e<6&&(rV(r),r.schema=6),e<7&&(iV(r),r.schema=7),e<8&&(r.schema=8),e<9&&(HT(r),r.schema=9),e<10&&(lV(r),r.schema=10),e<11&&(cV(r),r.schema=11),e<12&&(HT(r),r.schema=12),e<13&&(uV(r),r.schema=13),e<14&&(hV(r),r.schema=14),e<15&&(fV(r),r.schema=15),e<16&&(pV(r),r.schema=16),e<17&&(vm(r,WT),ym(r,WT),r.schema=17),e<18&&(vm(r,VT),ym(r,VT),r.schema=18),e<19&&($z(r),r.schema=19),e<20&&(mV(r),yV(r),r.schema=20),e<21&&(vV(r),xV(r),r.schema=21),e<22&&(qT(r),r.schema=22),e<23&&(bV(r),r.schema=23),e<24&&(wV(r),r.schema=24),(e<25||r.shared.videos===void 0)&&(dV(r),e<25&&(r.schema=25)),e<26&&(sV(r),r.schema=26),e<27&&(oV(r),r.schema=27),e<28&&(qT(r),r.schema=28),e<29&&(aV(r),r.schema=29),e<30&&(SV(r),r.schema=30),e<31&&(AV(r),r.schema=31))}var xm;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(xm||(xm={}));function Us(r,e=!1){let t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Ce,u=0;for(let c=0;c<r.length;++c){let d=r[c],h=0;if(t!==(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(!i.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(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(d.userData),e){let f;if(t)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(t){let c=0,d=[];for(let h=0;h<r.length;++h){let f=r[h].index;for(let m=0;m<f.count;++m)d.push(f.getX(m)+c);c+=r[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=KT(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=KT(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 KT(r){let e,t,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==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;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Be(s,t,n)}var bm;(t=>(t.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,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"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:t.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 He,move:new He,jump:new He}}))(bm||(bm={}));var ZT=Math.pow(2,-24);var Ra=class{constructor(){}};function Jr(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function W0(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function j0(r,e){e.set(r)}function q0(r,e,t){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[o],i=e[o],t[o]=n>i?n:i}}function Yd(r,e,t){for(let n=0;n<3;n++){let i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function zc(r){let e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function MV(r,e){if(!r.index){let t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;t>65535?i=new Uint32Array(new n(4*t)):i=new Uint16Array(new n(2*t)),r.setIndex(new Be(i,1));for(let s=0;s<t;s++)i[s]=s}}function EV(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let e=[],t=new Set;for(let i of r.groups)t.add(i.start),t.add(i.start+i.count);let n=Array.from(t.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];e.push({offset:s/3,count:(o-s)/3})}return e}function X0(r,e,t,n,i=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=i!==null;for(let v=e*6,b=(e+t)*6;v<b;v+=6){let w=r[v+0],S=r[v+1],_=w-S,T=w+S;_<s&&(s=_),T>l&&(l=T),y&&w<d&&(d=w),y&&w>m&&(m=w);let x=r[v+2],M=r[v+3],E=x-M,C=x+M;E<o&&(o=E),C>u&&(u=C),y&&x<h&&(h=x),y&&x>p&&(p=x);let P=r[v+4],O=r[v+5],I=P-O,N=P+O;I<a&&(a=I),N>c&&(c=N),y&&P<f&&(f=P),y&&P>g&&(g=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(i[0]=d,i[1]=h,i[2]=f,i[3]=m,i[4]=p,i[5]=g)}function CV(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=e*6,d=(e+t)*6;c<d;c+=6){let h=r[c+0];h<i&&(i=h),h>a&&(a=h);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let m=r[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function PV(r,e,t,n,i){let s=t,o=t+n-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&e[s*6+l]<a;)s++;for(;s<=o&&e[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let d=e[s*6+u*2+0];e[s*6+u*2+0]=e[o*6+u*2+0],e[o*6+u*2+0]=d;let h=e[s*6+u*2+1];e[s*6+u*2+1]=e[o*6+u*2+1],e[o*6+u*2+1]=h}s++,o--}else return s}}var Gs=32,IV=(r,e)=>r.candidate-e.candidate,Io=new Array(Gs).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),wm=new Float32Array(6);function DV(r,e,t,n,i,s){let o=-1,a=0;if(s===0)o=W0(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===1)o=W0(r),o!==-1&&(a=OV(t,n,i,o));else if(s===2){let l=zc(r),u=1.25*i,c=n*6,d=(n+i)*6;for(let h=0;h<3;h++){let f=e[h],g=(e[h+3]-f)/Gs;if(i<Gs/4){let y=[...Io];y.length=i;let v=0;for(let w=c;w<d;w+=6,v++){let S=y[v];S.candidate=t[w+2*h],S.count=0;let{bounds:_,leftCacheBounds:T,rightCacheBounds:x}=S;for(let M=0;M<3;M++)x[M]=1/0,x[M+3]=-1/0,T[M]=1/0,T[M+3]=-1/0,_[M]=1/0,_[M+3]=-1/0;Yd(w,t,_)}y.sort(IV);let b=i;for(let w=0;w<b;w++){let S=y[w];for(;w+1<b&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),b--}for(let w=c;w<d;w+=6){let S=t[w+2*h];for(let _=0;_<b;_++){let T=y[_];S>=T.candidate?Yd(w,t,T.rightCacheBounds):(Yd(w,t,T.leftCacheBounds),T.count++)}}for(let w=0;w<b;w++){let S=y[w],_=S.count,T=i-S.count,x=S.leftCacheBounds,M=S.rightCacheBounds,E=0;_!==0&&(E=zc(x)/l);let C=0;T!==0&&(C=zc(M)/l);let P=1+1.25*(E*_+C*T);P<u&&(o=h,u=P,a=S.candidate)}}else{for(let b=0;b<Gs;b++){let w=Io[b];w.count=0,w.candidate=f+g+b*g;let S=w.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let b=c;b<d;b+=6){let _=~~((t[b+2*h]-f)/g);_>=Gs&&(_=Gs-1);let T=Io[_];T.count++,Yd(b,t,T.bounds)}let y=Io[Gs-1];j0(y.bounds,y.rightCacheBounds);for(let b=Gs-2;b>=0;b--){let w=Io[b],S=Io[b+1];q0(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let b=0;b<Gs-1;b++){let w=Io[b],S=w.count,_=w.bounds,x=Io[b+1].rightCacheBounds;S!==0&&(v===0?j0(_,wm):q0(_,wm,wm)),v+=S;let M=0,E=0;v!==0&&(M=zc(wm)/l);let C=i-v;C!==0&&(E=zc(x)/l);let P=1+1.25*(M*v+E*C);P<u&&(o=h,u=P,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function OV(r,e,t,n){let i=0;for(let s=e,o=e+t;s<o;s++)i+=r[s*6+n*2];return i/t}function LV(r,e){let t=r.attributes.position,n=t.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=t.offset||0,l=3;t.isInterleavedBufferAttribute&&(l=t.data.stride);for(let u=0;u<s;u++){let c=u*3,d=u*6,h=i[c+0]*l+a,f=i[c+1]*l+a,m=i[c+2]*l+a;for(let p=0;p<3;p++){let g=n[h+p],y=n[f+p],v=n[m+p],b=g;y<b&&(b=y),v<b&&(b=v);let w=g;y>w&&(w=y),v>w&&(w=v);let S=(w-b)/2,_=p*2;o[d+_+0]=b+S,o[d+_+1]=S+(Math.abs(b)+S)*ZT,b<e[p]&&(e[p]=b),w>e[p+3]&&(e[p+3]=w)}}return o}function RV(r,e){function t(y){h&&h(y/f)}function n(y,v,b,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(r))),b<=c||S>=l)return t(v+b),y.offset=v,y.count=b,y;let _=DV(y.boundingData,w,o,v,b,d);if(_.axis===-1)return t(v+b),y.offset=v,y.count=b,y;let T=PV(a,o,v,b,_);if(T===v||T===v+b)t(v+b),y.offset=v,y.count=b;else{y.splitAxis=_.axis;let x=new Ra,M=v,E=T-v;y.left=x,x.boundingData=new Float32Array(6),X0(o,M,E,x.boundingData,s),n(x,M,E,s,S+1);let C=new Ra,P=T,O=b-E;y.right=C,C.boundingData=new Float32Array(6),X0(o,P,O,C.boundingData,s),n(C,P,O,s,S+1)}return y}MV(r,e);let i=new Float32Array(6),s=new Float32Array(6),o=LV(r,i),a=r.index.array,l=e.maxDepth,u=e.verbose,c=e.maxLeafTris,d=e.strategy,h=e.onProgress,f=r.index.count/3,m=!1,p=[],g=EV(r);if(g.length===1){let y=g[0],v=new Ra;v.boundingData=i,CV(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 Ra;v.boundingData=new Float32Array(6),X0(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function $T(r,e){let t=RV(r,e),n,i,s,o=[],a=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<t.length;c++){let d=t[c],h=l(d),f=new a(32*h);n=new Float32Array(f),i=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 i[h+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=d.left,y=d.right,v=d.splitAxis,b;if(b=u(c+32,g),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[h+6]=b/4,b=u(b,y),i[h+7]=v,b}}}var wr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}};wr.prototype.setFromBox=function(){let r=new A;return function(t,n){let i=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++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let d=t.dot(r);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var Pte=function(){let r=new wr;return function(t,n){let i=t.points,s=t.satAxes,o=t.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(r.setFromPoints(h,a),d.isSeparated(r))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(r.setFromPoints(h,i),d.isSeparated(r))return!1}}}();var NV=function(){let r=new A,e=new A,t=new A;return function(i,s,o){let a=i.start,l=r,u=s.start,c=e;t.subVectors(a,u),r.subVectors(i.end,s.start),e.subVectors(s.end,s.start);let d=t.dot(c),h=c.dot(l),f=c.dot(c),m=t.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}}(),Xd=function(){let r=new U,e=new A,t=new A;return function(i,s,o,a){NV(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let d;u<0?d=s.start:d=s.end;let h=e,f=t;if(i.closestPointToPoint(d,!0,e),s.closestPointToPoint(c,!0,t),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),eM=function(){let r=new A,e=new A,t=new xn,n=new bn;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,r).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,e);if(o.containsPoint(y))return!0}return!1}}();var BV=1e-15;function Vc(r){return Math.abs(r)<BV}var Sr=class extends Kt{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new wr),this.points=[this.a,this.b,this.c],this.sphere=new pn,this.plane=new xn,this.needsUpdate=!0}intersectsSphere(e){return eM(e,this)}update(){let e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(e,t),c.setFromPoints(u,i);let d=s[2],h=o[2];d.subVectors(t,n),h.setFromPoints(d,i);let f=s[3],m=o[3];f.subVectors(n,e),m.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};Sr.prototype.closestPointToSegment=function(){let r=new A,e=new A,t=new bn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;t.start.copy(u[h]),t.end.copy(u[f]),Xd(t,i,r,e),c=r.distanceToSquared(e),c<d&&(d=c,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(d)}}();Sr.prototype.intersectsTriangle=function(){let r=new Sr,e=new Array(3),t=new Array(3),n=new wr,i=new wr,s=new A,o=new A,a=new A,l=new A,u=new bn,c=new bn,d=new bn;return function(f,m=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,g=f.plane;if(Math.abs(p.normal.dot(g.normal))>1-1e-10){let y=this.satBounds,v=this.satAxes;t[0]=f.a,t[1]=f.b,t[2]=f.c;for(let S=0;S<4;S++){let _=y[S],T=v[S];if(n.setFromPoints(T,t),_.isSeparated(n))return!1}let b=f.satBounds,w=f.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let S=0;S<4;S++){let _=b[S],T=w[S];if(n.setFromPoints(T,e),_.isSeparated(n))return!1}for(let S=0;S<4;S++){let _=v[S];for(let T=0;T<4;T++){let x=w[T];if(s.crossVectors(_,x),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return m&&(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 y=this.points,v=!1,b=0;for(let O=0;O<3;O++){let I=y[O],N=y[(O+1)%3];u.start.copy(I),u.end.copy(N),u.delta(o);let B=v?c.start:c.end,W=Vc(g.distanceToPoint(I));if(Vc(g.normal.dot(o))&&W){c.copy(u),b=2;break}if((g.intersectLine(u,B)||W)&&!Vc(B.distanceTo(N))){if(b++,v)break;v=!0}}if(b===1&&this.containsPoint(c.start))return m&&(m.start.copy(c.start),m.end.copy(c.start)),!0;if(b!==2)return!1;let w=f.points,S=!1,_=0;for(let O=0;O<3;O++){let I=w[O],N=w[(O+1)%3];u.start.copy(I),u.end.copy(N),u.delta(a);let B=S?d.start:d.end,W=Vc(p.distanceToPoint(I));if(Vc(p.normal.dot(a))&&W){d.copy(u),_=2;break}if((p.intersectLine(u,B)||W)&&!Vc(B.distanceTo(N))){if(_++,S)break;S=!0}}if(_===1&&this.containsPoint(d.start))return m&&(m.start.copy(d.start),m.end.copy(d.start)),!0;if(_!==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 T=c.start.dot(o),x=c.end.dot(o),M=d.start.dot(o),E=d.end.dot(o),C=x<M,P=T<E;return T!==E&&M!==x&&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)}}}();Sr.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();Sr.prototype.distanceToTriangle=function(){let r=new A,e=new A,t=["a","b","c"],n=new bn,i=new bn;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=t[d],m=o[f];this.closestPointToPoint(m,r),h=m.distanceToSquared(r),h<c&&(c=h,a&&a.copy(r),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,r),h=p.distanceToSquared(r),h<c&&(c=h,a&&a.copy(p),l&&l.copy(r))}for(let d=0;d<3;d++){let h=t[d],f=t[(d+1)%3];n.set(this[h],this[f]);for(let m=0;m<3;m++){let p=t[m],g=t[(m+1)%3];i.set(o[p],o[g]),Xd(n,i,r,e);let y=r.distanceToSquared(e);y<c&&(c=y,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(c)}}();var Ar=class extends gt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new he,this.invMatrix=new he,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 wr),this.alignedSatBounds=new Array(3).fill().map(()=>new wr),this.needsUpdate=!1}set(e,t,n){super.set(e,t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Ar.prototype.update=function(){return function(){let e=this.matrix,t=this.min,n=this.max,i=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=i[h];f.x=u?n.x:t.x,f.y=c?n.y:t.y,f.z=d?n.z:t.z,f.applyMatrix4(e)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=i[h];c.subVectors(a,f),d.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Ar.prototype.intersectsBox=function(){let r=new wr;return function(t){this.needsUpdate&&this.update();let n=t.min,i=t.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,t),c.isSeparated(r))return!1}return!0}}();Ar.prototype.intersectsTriangle=function(){let r=new Sr,e=new Array(3),t=new wr,n=new wr,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let h=0;h<3;h++){let f=a[h],m=l[h];if(t.setFromPoints(m,e),f.isSeparated(t))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(t.setFromPoints(m,d),f.isSeparated(t))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(i.crossVectors(f,p),t.setFromPoints(i,e),n.setFromPoints(i,d),t.isSeparated(n))return!1}}return!0}}();Ar.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Ar.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();Ar.prototype.distanceToBox=function(){let r=["x","y","z"],e=new Array(12).fill().map(()=>new bn),t=new Array(12).fill().map(()=>new bn),n=new A,i=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),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];i.copy(y).clamp(d,h);let v=y.distanceToSquared(i);if(v<m&&(m=v,l&&l.copy(y),u&&u.copy(i),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 b=(g+1)%3,w=(g+2)%3,S=y<<b|v<<w,_=1<<g|y<<b|v<<w,T=f[S],x=f[_];e[p].set(T,x);let E=r[g],C=r[b],P=r[w],O=t[p],I=O.start,N=O.end;I[E]=d[E],I[C]=y?d[C]:h[C],I[P]=v?d[P]:h[C],N[E]=h[E],N[C]=y?d[C]:h[C],N[P]=v?d[P]:h[C],p++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?h.x:d.x,i.y=y?h.y:d.y,i.z=v?h.z:d.z,this.closestPointToPoint(i,n);let b=i.distanceToSquared(n);if(b<m&&(m=b,l&&l.copy(n),u&&u.copy(i),b<c))return Math.sqrt(b)}for(let g=0;g<12;g++){let y=e[g];for(let v=0;v<12;v++){let b=t[v];Xd(y,b,n,i);let w=n.distanceToSquared(i);if(w<m&&(m=w,l&&l.copy(n),u&&u.copy(i),w<c))return Math.sqrt(w)}}return Math.sqrt(m)}}();var Am=new A,_m=new A,Tm=new A,tM=new U,nM=new U,rM=new U,iM=new A;function FV(r,e,t,n,i,s){let o;return s===Pn?o=r.intersectTriangle(n,t,e,!0,i):o=r.intersectTriangle(e,t,n,s!==Lr,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function UV(r,e,t,n,i,s,o){Am.fromBufferAttribute(e,n),_m.fromBufferAttribute(e,i),Tm.fromBufferAttribute(e,s);let a=FV(r,Am,_m,Tm,iM,o);if(a){t&&(tM.fromBufferAttribute(t,n),nM.fromBufferAttribute(t,i),rM.fromBufferAttribute(t,s),a.uv=Kt.getUV(iM,Am,_m,Tm,tM,nM,rM,new U));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};Kt.getNormal(Am,_m,Tm,l.normal),a.face=l,a.faceIndex=n}return a}function Z0(r,e,t,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=UV(t,r.attributes.position,r.attributes.uv,o,a,l,e);return u?(u.faceIndex=n,i&&i.push(u),u):null}function sM(r,e,t,n,i,s){for(let o=n,a=n+i;o<a;o++)Z0(r,e,t,o,s)}function oM(r,e,t,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Z0(r,e,t,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Q0(r,e,t){return r===null||(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r.distance<t.near||r.distance>t.far)?null:r}function $r(r,e,t,n){let i=r.a,s=r.b,o=r.c,a=e,l=e+1,u=e+2;t&&(a=t.getX(e),l=t.getX(e+1),u=t.getX(e+2)),i.x=n.getX(a),i.y=n.getY(a),i.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 J0(r,e,t,n,i,s,o){let a=t.index,l=t.attributes.position;for(let u=r,c=e+r;u<c;u++)if($r(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var Hc=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function ks(r,e){return e[r+15]===65535}function Na(r,e){return e[r+6]}function Wc(r,e){return e[r+14]}function jc(r){return r+8}function qc(r,e){return e[r+6]}function aM(r,e){return e[r+7]}var Yc=new gt,Em=new A,kV=["x","y","z"];function Cm(r,e,t,n,i){let s=r*2,o=Xc,a=Do,l=Oo;if(ks(s,a)){let c=Na(r,l),d=Wc(s,a);sM(e,t,n,c,d,i)}else{let c=jc(r);Im(c,o,n,Em)&&Cm(c,e,t,n,i);let d=qc(r,l);Im(d,o,n,Em)&&Cm(d,e,t,n,i)}}function Pm(r,e,t,n){let i=r*2,s=Xc,o=Do,a=Oo;if(ks(i,o)){let u=Na(r,a),c=Wc(i,o);return oM(e,t,n,u,c)}else{let u=aM(r,a),c=kV[u],h=n.direction[c]>=0,f,m;h?(f=jc(r),m=qc(r,a)):(f=qc(r,a),m=jc(r));let g=Im(f,s,n,Em)?Pm(f,e,t,n):null;if(g){let b=g.point[c];if(h?b<=s[m+u]:b>=s[m+u+3])return g}let v=Im(m,s,n,Em)?Pm(m,e,t,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var lM=function(){let r,e,t=[],n=new Hc(()=>new gt);return function(...o){r=n.getPrimitive(),e=n.getPrimitive(),t.push(r,e);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(e),t.pop(),t.pop();let l=t.length;return l>0&&(e=t[l-1],r=t[l-2]),a};function i(s,o,a,l,u=null,c=0,d=0){function h(b){let w=b*2,S=Do,_=Oo;for(;!ks(w,S);)b=jc(b),w=b*2;return Na(b,_)}function f(b){let w=b*2,S=Do,_=Oo;for(;!ks(w,S);)b=qc(b,_),w=b*2;return Na(b,_)+Wc(w,S)}let m=s*2,p=Xc,g=Do,y=Oo;if(ks(m,g)){let b=Na(s,y),w=Wc(m,g);return Jr(s,p,r),l(b,w,!1,d,c+s,r)}else{let b=jc(s),w=qc(s,y),S=b,_=w,T,x,M,E;if(u&&(M=r,E=e,Jr(S,p,M),Jr(_,p,E),T=u(M),x=u(E),x<T)){S=w,_=b;let W=T;T=x,x=W,M=E}M||(M=r,Jr(S,p,M));let C=ks(S*2,g),P=a(M,C,T,d+1,c+S),O;if(P===2){let W=h(S),F=f(S)-W;O=l(W,F,!0,d+1,c+S,M)}else O=P&&i(S,o,a,l,u,c,d+1);if(O)return!0;E=e,Jr(_,p,E);let I=ks(_*2,g),N=a(E,I,x,d+1,c+_),B;if(N===2){let W=h(_),F=f(_)-W;B=l(W,F,!0,d+1,c+_,E)}else B=N&&i(_,o,a,l,u,c,d+1);return!!B}}}(),cM=function(){let r=new Sr,e=new Sr,t=new he,n=new Ar,i=new Ar;return function s(o,a,l,u,c=null){let d=o*2,h=Xc,f=Do,m=Oo;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),ks(d,f)){let g=a,y=g.index,v=g.attributes.position,b=l.index,w=l.attributes.position,S=Na(o,m),_=Wc(d,f);if(t.copy(u).invert(),l.boundsTree)return Jr(o,h,i),i.matrix.copy(t),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:x=>i.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(u),x.b.applyMatrix4(u),x.c.applyMatrix4(u),x.needsUpdate=!0;for(let M=S*3,E=(_+S)*3;M<E;M+=3)if($r(e,M,y,v),e.needsUpdate=!0,x.intersectsTriangle(e))return!0;return!1}});for(let T=S*3,x=_+S*3;T<x;T+=3){$r(r,T,y,v),r.a.applyMatrix4(t),r.b.applyMatrix4(t),r.c.applyMatrix4(t),r.needsUpdate=!0;for(let M=0,E=b.count;M<E;M+=3)if($r(e,M,b,w),e.needsUpdate=!0,r.intersectsTriangle(e))return!0}}else{let g=o+8,y=m[o+6];return Jr(g,h,Yc),!!(c.intersectsBox(Yc)&&s(g,a,l,u,c)||(Jr(y,h,Yc),c.intersectsBox(Yc)&&s(y,a,l,u,c)))}}}();function Im(r,e,t,n){return Jr(r,e,Yc),t.intersectBox(Yc,n)}var $0=[],Mm,Xc,Do,Oo;function Kc(r){Mm&&$0.push(Mm),Mm=r,Xc=new Float32Array(r),Do=new Uint16Array(r),Oo=new Uint32Array(r)}function Kd(){Mm=null,Xc=null,Do=null,Oo=null,$0.length&&Kc($0.pop())}var ex=Symbol("skip tree generation"),tx=new gt,nx=new gt,Zc=new he,Ba=new Ar,Zd=new Ar,Qd=new A,Dm=new A,zV=new A,VV=new A,HV=new A,uM=new gt,Zi=new Hc(()=>new Sr),Jt=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Jt.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let n=e.geometry,i=e._roots,s=n.getIndex(),o;return t.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(e,t,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Jt.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=e,o=new Jt(t,{...n,[ex]:!0});if(o._roots=s,n.setIndex){let a=t.getIndex();if(a===null){let l=new Be(e.index,1,!1);t.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[ex]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[ex]||(this._roots=$T(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new gt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,n=t.index.array,i=t.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,d,h=0,f=this._roots;for(let p=0,g=f.length;p<g;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),d=new Float32Array(l),m(0,h),h+=l.byteLength;function m(p,g,y=!1){let v=p*2;if(c[v+15]===65535){let w=u[p+6],S=c[v+14],_=1/0,T=1/0,x=1/0,M=-1/0,E=-1/0,C=-1/0;for(let P=3*w,O=3*(w+S);P<O;P++){let I=n[P]*a+o,N=s[I+0],B=s[I+1],W=s[I+2];N<_&&(_=N),N>M&&(M=N),B<T&&(T=B),B>E&&(E=B),W<x&&(x=W),W>C&&(C=W)}return d[p+0]!==_||d[p+1]!==T||d[p+2]!==x||d[p+3]!==M||d[p+4]!==E||d[p+5]!==C?(d[p+0]=_,d[p+1]=T,d[p+2]=x,d[p+3]=M,d[p+4]=E,d[p+5]=C,!0):!1}else{let w=p+8,S=u[p+6],_=w+g,T=S+g,x=y,M=!1,E=!1;e?x||(M=e.has(_),E=e.has(T),x=!M&&!E):(M=!0,E=!0);let C=x||M,P=x||E,O=!1;C&&(O=m(w,g,x));let I=!1;P&&(I=m(S,g,x));let N=O||I;if(N)for(let B=0;B<3;B++){let W=w+B,X=S+B,F=d[W],k=d[W+3],K=d[X],H=d[X+3];d[p+B]=F<K?F:K,d[p+B+3]=k>H?k:H}return N}}}traverse(e,t=0){let n=this._roots[t],i=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=i[a+6],h=s[u+14];e(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=i[a+6],f=i[a+7];e(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(e,t=Gi){let n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,u=o?t.side:t;for(let c=0,d=n.length;c<d;c++){let h=a?t[l[c].materialIndex].side:u,f=s.length;if(Kc(n[c]),Cm(0,i,h,e,s),Kd(),a){let m=l[c].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(e,t=Gi){let n=this._roots,i=this.geometry,s=t.isMaterial,o=Array.isArray(t),a=null,l=i.groups,u=s?t.side:t;for(let c=0,d=n.length;c<d;c++){let h=o?t[l[c].materialIndex].side:u;Kc(n[c]);let f=Pm(0,i,h,e);Kd(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(e,t){let n=this.geometry,i=!1;for(let s of this._roots)if(Kc(s),i=cM(0,n,e,t),Kd(),i)break;return i}shapecast(e,t,n){let i=this.geometry;if(e instanceof Function){if(t){let h=t;t=(f,m,p,g)=>{let y=m*3;return h(f,y,y+1,y+2,p,g)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Zi.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=e;if(l&&u){let h=l;l=(f,m,p,g,y)=>h(f,m,p,g,y)?!0:J0(f,m,i,u,p,g,s)}else l||(u?l=(h,f,m,p)=>J0(h,f,i,u,m,p,s):l=(h,f,m)=>m);let c=!1,d=0;for(let h of this._roots){if(Kc(h),c=lM(0,i,a,l,o,d),Kd(),c)break;d+=h.byteLength}return Zi.releasePrimitive(s),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=e.geometry.index,u=e.geometry.attributes.position;Zc.copy(t).invert();let c=Zi.getPrimitive(),d=Zi.getPrimitive();if(s){let f=function(m,p,g,y,v,b,w,S){for(let _=g,T=g+y;_<T;_++){$r(d,_*3,l,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let x=m,M=m+p;x<M;x++)if($r(c,x*3,o,a),c.needsUpdate=!0,s(c,d,x,_,v,b,w,S))return!0}return!1};if(i){let m=i;i=function(p,g,y,v,b,w,S,_){return m(p,g,y,v,b,w,S,_)?!0:f(p,g,y,v,b,w,S,_)}}else i=f}e.getBoundingBox(nx),nx.applyMatrix4(t);let h=this.shapecast({intersectsBounds:f=>nx.intersectsBox(f),intersectsRange:(f,m,p,g,y,v)=>(tx.copy(v),tx.applyMatrix4(Zc),e.shapecast({intersectsBounds:b=>tx.intersectsBox(b),intersectsRange:(b,w,S,_,T)=>i(f,m,b,w,g,y,_,T)}))});return Zi.releasePrimitive(c),Zi.releasePrimitive(d),h}intersectsBox(e,t){return Ba.set(e.min,e.max,t),Ba.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Ba.intersectsBox(n),intersectsTriangle:n=>Ba.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Ba.set(e.boundingBox.min,e.boundingBox.max,t),Ba.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=e.attributes.position,d=e.index,h=Zi.getPrimitive(),f=Zi.getPrimitive(),m=Dm,p=zV,g=null,y=null;i&&(g=VV,y=HV);let v=1/0,b=null,w=null;return Zc.copy(t).invert(),Zd.matrix.copy(Zc),this.shapecast({boundsTraverseOrder:S=>Ba.distanceToBox(S),intersectsBounds:(S,_,T)=>T<v&&T<o?(_&&(Zd.min.copy(S.min),Zd.max.copy(S.max),Zd.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:T=>Zd.distanceToBox(T),intersectsBounds:(T,x,M)=>M<v&&M<o,intersectsRange:(T,x)=>{for(let M=T*3,E=(T+x)*3;M<E;M+=3){$r(f,M,d,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let C=S*3,P=(S+_)*3;C<P;C+=3){$r(h,C,u,l),h.needsUpdate=!0;let O=h.distanceToTriangle(f,m,g);if(O<v&&(p.copy(m),y&&y.copy(g),v=O,b=C/3,w=M/3),O<s)return!0}}}});{let T=d?d.count:c.count;for(let x=0,M=T;x<M;x+=3){$r(f,x,d,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let E=S*3,C=(S+_)*3;E<C;E+=3){$r(h,E,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,m,g);if(P<v&&(p.copy(m),y&&y.copy(g),v=P,b=E/3,w=x/3),P<s)return!0}}}}}),Zi.releasePrimitive(h),Zi.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=b,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(Zc),p.applyMatrix4(Zc),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(e,t={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(Qd.copy(e).clamp(c.min,c.max),Qd.distanceToSquared(e)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(e,Qd);let h=e.distanceToSquared(Qd);return h<a&&(Dm.copy(Qd),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return t.point?t.point.copy(Dm):t.point=Dm.clone(),t.distance=u,t.faceIndex=l,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Jr(0,new Float32Array(n),uM),e.union(uM)}),e}},dM=Jt.prototype.raycast;Jt.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[e,t,n,i]=r;return dM.call(this,n,e.material).forEach(o=>{o=Q0(o,e,t),o&&i.push(o)}),i}else return dM.apply(this,r)};var hM=Jt.prototype.raycastFirst;Jt.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[e,t,n]=r;return Q0(hM.call(this,n,e.material),e,t)}else return hM.apply(this,r)};var fM=Jt.prototype.closestPointToPoint;Jt.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let e=r[1],t={};return r[1]=t,fM.apply(this,r),e&&e.copy(t.point),t.distance}else return fM.apply(this,r)};var pM=Jt.prototype.closestPointToGeometry;Jt.prototype.closestPointToGeometry=function(...r){let e=r[2],t=r[3];if(e&&e.isVector3||t&&t.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,pM.apply(this,r),e&&e.copy(n.point),t&&t.copy(i.point).applyMatrix4(s),n.distance}else return pM.apply(this,r)};var mM=Jt.prototype.refit;Jt.prototype.refit=function(...r){let e=r[0],t=r[1];if(t&&(t instanceof Set||Array.isArray(t))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;t.forEach(i=>n.add(i)),e&&e.forEach(i=>n.add(i)),mM.call(this,n)}else mM.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let e=Jt.prototype[r];Jt.prototype[r]=function(...t){return(t[0]===null||t[0].isMesh)&&(t.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),e.apply(this,t)}});var Tu=Qs(yM());var WV=.5*(Math.sqrt(3)-1),Jd=(3-Math.sqrt(3))/6,jV=1/3,Qi=1/6,Ane=(Math.sqrt(5)-1)/4,_ne=(5-Math.sqrt(5))/20,$d=r=>Math.floor(r)|0,vM=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]),ix=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 Om(r=Math.random){let e=bM(r),t=new Float64Array(e).map(i=>vM[i%12*2]),n=new Float64Array(e).map(i=>vM[i%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*WV,d=$d(s+c),h=$d(o+c),f=(d+h)*Jd,m=d-f,p=h-f,g=s-m,y=o-p,v,b;g>y?(v=1,b=0):(v=0,b=1);let w=g-v+Jd,S=y-b+Jd,_=g-1+2*Jd,T=y-1+2*Jd,x=d&255,M=h&255,E=.5-g*g-y*y;if(E>=0){let O=x+e[M],I=t[O],N=n[O];E*=E,a=E*E*(I*g+N*y)}let C=.5-w*w-S*S;if(C>=0){let O=x+v+e[M+b],I=t[O],N=n[O];C*=C,l=C*C*(I*w+N*S)}let P=.5-_*_-T*T;if(P>=0){let O=x+1+e[M+1],I=t[O],N=n[O];P*=P,u=P*P*(I*_+N*T)}return 70*(a+l+u)}}function xM(r=Math.random){let e=bM(r),t=new Float64Array(e).map(s=>ix[s%12*3]),n=new Float64Array(e).map(s=>ix[s%12*3+1]),i=new Float64Array(e).map(s=>ix[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*jV,m=$d(o+f),p=$d(a+f),g=$d(l+f),y=(m+p+g)*Qi,v=m-y,b=p-y,w=g-y,S=o-v,_=a-b,T=l-w,x,M,E,C,P,O;S>=_?_>=T?(x=1,M=0,E=0,C=1,P=1,O=0):S>=T?(x=1,M=0,E=0,C=1,P=0,O=1):(x=0,M=0,E=1,C=1,P=0,O=1):_<T?(x=0,M=0,E=1,C=0,P=1,O=1):S<T?(x=0,M=1,E=0,C=0,P=1,O=1):(x=0,M=1,E=0,C=1,P=1,O=0);let I=S-x+Qi,N=_-M+Qi,B=T-E+Qi,W=S-C+2*Qi,X=_-P+2*Qi,F=T-O+2*Qi,k=S-1+3*Qi,K=_-1+3*Qi,H=T-1+3*Qi,z=m&255,j=p&255,Y=g&255,G=.6-S*S-_*_-T*T;if(G<0)u=0;else{let q=z+e[j+e[Y]];G*=G,u=G*G*(t[q]*S+n[q]*_+i[q]*T)}let de=.6-I*I-N*N-B*B;if(de<0)c=0;else{let q=z+x+e[j+M+e[Y+E]];de*=de,c=de*de*(t[q]*I+n[q]*N+i[q]*B)}let te=.6-W*W-X*X-F*F;if(te<0)d=0;else{let q=z+C+e[j+P+e[Y+O]];te*=te,d=te*te*(t[q]*W+n[q]*X+i[q]*F)}let Q=.6-k*k-K*K-H*H;if(Q<0)h=0;else{let q=z+1+e[j+1+e[Y+1]];Q*=Q,h=Q*Q*(t[q]*k+n[q]*K+i[q]*H)}return 32*(u+c+d+h)}}function bM(r){let t=new Uint8Array(512);for(let n=0;n<512/2;n++)t[n]=n;for(let n=0;n<512/2-1;n++){let i=n+~~(r()*(256-n)),s=t[n];t[n]=t[i],t[i]=s}for(let n=256;n<512;n++)t[n]=t[n-256];return t}var xi=new Kt,Lm=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let i=0;i<e.count;i+=3){let s=1;xi.a.fromBufferAttribute(e,i),xi.b.fromBufferAttribute(e,i+1),xi.c.fromBufferAttribute(e,i+2),s*=xi.getArea(),t[i/3]=s}this.distribution=new Float32Array(e.count/3);let n=0;for(let i=0;i<t.length;i++)n+=t[i],this.distribution[i]=n;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let n=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*n);return this.sampleFace(i,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,n=0,i=t.length-1,s=-1;for(;n<=i;){let o=Math.ceil((n+i)/2);if(o===0||t[o-1]<=e&&t[o]>e){s=o;break}else e<t[o]?i=o-1:n=o+1}return s}sampleFace(e,t,n){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),xi.a.fromBufferAttribute(this.positionAttribute,e*3),xi.b.fromBufferAttribute(this.positionAttribute,e*3+1),xi.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(xi.a,i).addScaledVector(xi.b,s).addScaledVector(xi.c,1-(i+s)),xi.getNormal(n),this}};var SM=Qs(sx()),qV=new he,YV=new he,XV=new he,eh;(e=>{function r(t){return t&&t.__isSPEObject}e.is=r})(eh||(eh={}));var Qc=r=>class extends r{constructor(){super(...arguments);this.hiddenMatrix=new he;this.matrixWorldRigid=new he;this.shearScale=new he;this.shearScaleInv=new he}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof ht&&(n=n.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===n)return!0;i=i.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 i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){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)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseObject(n,i=0){if(n(this,i)!==!0)for(let o of this.children)eh.is(o)&&o.traverseObject(n,i+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,i=[[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,SM.SVD)(i),l=qV.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=YV.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=XV.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,i){this.updateWorldMatrix(!0,!1);let s=new he().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof he?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),i!==void 0&&(this.children.pop(),this.children.splice(i,0,n)),this}};var ox=class extends Qc(ht){},KV=r=>r.type==="Mesh",ei=class extends ox{constructor(t){super();this.object=t;this.matrixAutoUpdate=!1}expand(){let t=0,n=this.object.entityChildren(t);for(;n;){let i=this.children[t];i?.object!==n&&(i&&this.remove(i),i=new ei(n),this.add(i),i.matrixAutoUpdate=!1,i.matrix=n.matrix,i.hiddenMatrix=n.hiddenMatrix),i.expand(),t+=1,n=this.object.entityChildren(t)}for(;this.children.length>t;)this.remove(this.children[t])}get visible(){return this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(t){}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return KV(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(t){}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 Fa=new A,Ua=new A,Jc=new he,_M=[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)],ZV=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],QV=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],AM=(r,e,t)=>{r.updateEntityBoxSize(Fa,Ua),Jc.copy(e).multiply(r.matrixWorld),Ua.x===0&&Ua.y===0&&Ua.z===0?t.push(new A(Fa.x,Fa.y,Fa.z).applyMatrix4(Jc)):_M.forEach(n=>{t.push(n.clone().multiply(Ua).add(Fa).applyMatrix4(Jc))})},th=class extends gt{constructor(){super(...arguments);this.matrix=new he;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(n=>n.clone()),this.faces=t.faces.map(n=>n.clone()),this.edges=t.edges.map(n=>n.clone()),this.centerEdges=t.centerEdges.map(n=>n.clone()),this}setFromObjectSize(t,n=!1){t.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new he().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,n)}expandByObjectSize(t,n,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&AM(o,n,s)}):AM(t,n,s),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(Jc.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Ua).multiplyScalar(.5),this.getCenter(Fa),Jc.copy(this.matrix).setPosition(Fa),this.vertices=_M.map(t=>t.clone().multiply(Ua).applyMatrix4(Jc))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=ZV.map(([t,n])=>new bn(this.vertices[t],this.vertices[n])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=QV.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var bi={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Gt;(e=>{function r(t){return t&&t.__isEntity}e.is=r})(Gt||(Gt={}));var hr=r=>Gt.is(r),Nm=r=>class extends Qc(r){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._singleBBox=new th;this._recursiveBBox=new th;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0}get __isEntity(){return!0}entityChildren(n){let i=this.children[n];if(Gt.is(i))return i}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 i=n.parent;if(Gt.is(i))n=i;else return}return n}forInstancesRec(n){this.instances.forEach(i=>{i.disposed||n(i),i.forInstancesRec(n)})}super_Entity(n,i){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)Bs.toOps(this.data,o.data).forEach(l=>{let u=zp.replaceProps(l,this.data);this.updateByPatchedOp(u,this.data,i)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=Bs.patch(this.data,o),Bs.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}else this.dataPatched=this.data;s&&this.updateTransformState(this.dataPatched),this.stateSelection=n}}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,i){n.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{hr(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let i;return this.traverseEntity(s=>{s.uuid===n&&(i=s)}),i}traverseSortNextHelper(){let n=this.parent;if(n){let i=n.children,s=i.indexOf(this)+1;if(Gt.is(i[s]))return i[s];if(Gt.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&Gt.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let i=this;for(;n>0&&i!==null;)i=i.parent,n-=1;return i}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let i=this.parent;for(;i;){if(n===i)return!0;i=i.parent}return!1}countToAccestor(n){let i=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(n){for(let i of this.children)hr(i)&&n(i)}traverseEntityAncestors(n){this.traverseAncestors(i=>{Gt.is(i)&&n(i)})}traverseEntity(n,i=0){if(n(this,i)!==!0)for(let o of this.children)hr(o)&&o.traverseEntity(n,i+1)}traverseVisibleEntity(n){n(this);for(let i of this.children)hr(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,i=!0){return super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>hr(n))}isAncestorOf(n){if(this.uuid===n)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===n&&(i=!0)}),i}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return xc(i,n)}updateTransformState(n){let i=!1;return n.position&&(this.position.fromArray(n.position),i=!0),n.rotation&&(this.rotation.fromArray(n.rotation),i=!0),n.scale&&(i=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??Eo.identity)),i&&(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),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)Gt.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{Gt.is(n)&&n.disposeRecursively()})}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return xc(i,n)}updateByOp(n,i,s,o){let a=this.data;this.data=i;let l=n,u=Vi(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=lr.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=lr.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,Bs.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Vi(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(Rs.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=lr.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=Rc.resolve(i.overrides,c),h.updateByOp(n,jn.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 Po.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of Po.rootOverrideProps)if(Vi(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=Rs.filterOp(d.overrideData,c);h&&d.updateByOp(h,jn.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=Rs.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=i:f=jn.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,i,s){if(this.dataPatched=i,n.path.length===0&&n.type===0)n.props.type!==void 0&&!vi.is(n.props.type)&&bi.changeEntityProptotype(this,i,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){bi.changeEntityProptotype(this,i,s);for(let o of this.children)Gt.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,i,s)}updateByPatchedOp(n,i,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Vi(n.path,["cloner"])!==null){let o=jn.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,i){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,i),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof bi.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,i){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):(this.cloner===void 0&&(this.cloner=new bi.Cloner(this,n),i.scene.addPendingExpandCloner(this)),this.cloner.updateState(n,i.scene)))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var MM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=t.width/2,i=t.radiusTop??n,s=t.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=r.parameters,m;return d||f?m=new nh(u,c,n,i,s,o,a,l*Math.PI/180,d,d,h,f):m=new ma(u,c,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function Lo(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function TM(r){return new U(r.y,-r.x)}var nh=class extends Ce{constructor(e,t,n,i,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],y=[],v=0,b=n/2,w=new A,S=new A;f&&e==0&&(e=u),f&&t==0&&(t=c);let _=new U(e,b),T=new U(t,-b),x=null,M=null,E=null,C=null,P=_.clone().sub(T),O=0,I=0,N=0;h>0&&(O=Math.min(e,t)*(1-h),I=e-O,N=t-O);let B=_.clone();B.x-=O;let W=Math.PI-P.angle(),X=P.angle(),F=Math.tan(X/2),k=Math.tan(W/2),K=F+k,H=h?K:k,z=h?K:F;if(u=Math.min(u,(e-I)/H,P.length()/K),c=Math.min(c,(t-N)/z,P.length()/K),u>0){let Q=u/F;x=_.clone().sub(new U(Q,u)),h&&(E=x.clone(),E.x-=O-K*u),_.sub(P.clone().setLength(Q))}if(c>0){let Q=c/k;M=T.clone().sub(new U(Q,-c)),T.add(P.clone().setLength(Q)),h&&(C=M.clone(),C.x-=O-K*c,B.sub(P.clone().setLength(Q)))}P=_.clone().sub(T);let j=P.length()<.5,Y=[];for(let Q=0;Q<=i;Q++){let q=[],se=Q/i,oe=se*l+a,ae=new U(Math.sin(oe),Math.cos(oe));C&&M?(G(q,se,ae,W,c,C,-1,!0),G(q,se,ae,X,c,M,-1,!1)):M?(de(q,ae,M.x,0,-1),G(q,se,ae,X,c,M,-1,!1)):o||de(q,ae,t,N,-1);let _e=TM(P).normalize();if(Lo(_e,ae,w),!j)for(let me=0;me<=s;me++){let xe=me/s,be=P.clone().multiplyScalar(xe).add(T);Lo(be,ae,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(se,.5+S.y/n),q.push(v++)}if(E&&x?(G(q,se,ae,W,u,x,1,!1),G(q,se,ae,X,u,E,1,!0)):x?(G(q,se,ae,W,u,x,1,!1),de(q,ae,x.x,0,1)):o||de(q,ae,e,I,1),h&&!j){let me=TM(P).multiplyScalar(-1).normalize();Lo(me,ae,w);for(let xe=0;xe<=s;xe++){let be=xe/s,fe=P.clone().multiplyScalar(-be).add(B);Lo(fe,ae,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(se,.5+S.y/n),q.push(v++)}}h&&!o&&q.push(q[0]),Y.push(q)}for(let Q=0;Q<Y.length-1;Q++)for(let q=0;q<Y[0].length-1;q++){if(o&&h&&q==s)continue;let se=Y[Q][q],oe=Y[Q+1][q],ae=Y[Q+1][q+1],_e=Y[Q][q+1],me=p[ae*3+0],xe=p[ae*3+2];m.push(se,oe,_e),(me!=0||xe!=0)&&m.push(oe,ae,_e)}l<Math.PI*2&&(te(-1,Y[0],a),te(1,Y[Y.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 G(Q,q,se,oe,ae,_e,me,xe){for(let be=0;be<d+1;be++){let fe=be/d,Pe=me<0?fe:1-fe;xe&&(Pe-=1),Pe*=oe;let Ne=new U(Math.sin(Pe),Math.cos(Pe)*me),Ke=Ne.clone().multiplyScalar(ae).add(_e);Lo(Ke,se,S),p.push(S.x,S.y,S.z),Lo(Ne,se,w),g.push(w.x,w.y,w.z),y.push(q,.5+S.y/n),Q.push(v++)}}function de(Q,q,se,oe,ae){let _e=new A,me=new U,xe=[se,oe];ae<0&&xe.reverse();for(let be of xe)me.set(be,b*ae),Lo(me,q,_e),p.push(_e.x,_e.y,_e.z),g.push(0,ae,0),y.push(.5,.5),Q.push(v++)}function te(Q,q,se){let oe=new U(Math.sin(se),Math.cos(se)),ae=new U(-Math.cos(se),Math.sin(se)),_e=new A,me=Q<0?(fe,Pe,Ne)=>m.push(fe,Pe,Ne):(fe,Pe,Ne)=>m.push(fe,Ne,Pe),xe=new U((e+t+I+N)/4,0);Lo(xe,oe,_e),p.push(_e.x,_e.y,_e.z),g.push(ae.x,0,ae.y),y.push(.5,.5);let be=v++;for(let fe of q){let Pe=p.slice(fe*3,fe*3+3);p.push(...Pe),g.push(ae.x,0,ae.y);let Ne=y.slice(fe*2,fe*2+2);y.push(...Ne),v++}for(let fe=be+1;fe<v-1;fe++)me(be,fe,fe+1);me(be,v-1,be+1)}}};var EM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=r.parameters,h;return u>0||c>0||l<360?h=new nh(0,e/2,n,i,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new Dl(e/2,n,i,s,o),h.scale(1,1,t/e),Object.assign(h,{userData:{...r,type:"ConeGeometry"}})}};var CM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new In(e,t,n,i,s,o):u=new lx(e,t,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},ax=Math.PI/2,lx=class extends Ce{constructor(e=1,t=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,n/2);let c=[],d=[],h=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(y("z","y","x",-1,-1,1,n,t,e,o,0),y("z","y","x",1,-1,-1,n,t,e,o,1),y("z","y","x",-1,1,-1,n,t,e,o,1),y("z","y","x",1,1,1,n,t,e,o,0),y("x","y","z",-1,-1,-1,e,t,n,i,0),y("x","y","z",1,-1,1,e,t,n,i,1),y("x","y","z",-1,1,1,e,t,n,i,0),y("x","y","z",1,1,-1,e,t,n,i,1),y("y","x","z",-1,-1,1,t,e,n,s,0),y("y","x","z",1,-1,-1,t,e,n,s,1),y("y","x","z",1,1,1,t,e,n,s,1),y("y","x","z",-1,1,-1,t,e,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(b,w,S,_,T,x,M,E,C,P,O){let I=(x-2*a)/C,N=(M-2*a)/P,B=x/2-a,W=M/2-a,X=E/2,F=C+1,k=P+1,K=0,H=0,z=new A;for(let j=0;j<k;j++){let Y=j*N-W;for(let G=0;G<F;G++){let de=G*I-B;z[b]=de*_,z[w]=Y*T,z[S]=X,d.push(z.x,z.y,z.z),z[b]=0,z[w]=0,z[S]=E>0?1:-1,h.push(z.x,z.y,z.z),f.push(G/C),f.push(1-j/P),K+=1}}for(let j=0;j<P;j++)for(let Y=0;Y<C;Y++){let G=m+Y+F*j,de=m+Y+F*(j+1),te=m+(Y+1)+F*(j+1),Q=m+(Y+1)+F*j;c.push(G,de,Q),c.push(de,te,Q),H+=6}u.addGroup(p,H,O),p+=H,m+=K}function y(b,w,S,_,T,x,M,E,C,P,O){let I=(M-2*a)/P,N=M/2-a,B=E/2-a,W=C/2,X=P+1,F=0,k=0,K=new A,H=new A;for(let z=0;z<l+1;z++){let j=z/l*ax,Y=Math.sin(j)*a,G=(1-Math.cos(j))*a,de=Math.sin(j),te=Math.cos(j);K[w]=(B+Y)*T,K[S]=(W-G)*x,H[b]=0,H[w]=de*Math.sign(K[w]),H[S]=te*Math.sign(K[S]);for(let Q=0;Q<X;Q++){let q=Q*I-N;K[b]=q*_,d.push(K.x,K.y,K.z),h.push(H.x,H.y,H.z),f.push(Q/P),f.push(0),F+=1}}for(let z=0;z<l;z++)for(let j=0;j<P;j++){let Y=m+j+X*z,G=m+j+X*(z+1),de=m+(j+1)+X*(z+1),te=m+(j+1)+X*z;c.push(Y,G,te),c.push(G,de,te),k+=6}u.addGroup(p,k,O),p+=k,m+=F}function v(b,w,S){let _=new A,T=new A(e/2,t/2,n/2);T.subScalar(a);let x=[],M=b*w*S>0?(C,P,O)=>c.push(C,P,O):(C,P,O)=>c.push(C,O,P);for(let C=0;C<=l;C++){let P=[],O=ax*(1-C/l),I=Math.cos(O),N=Math.sin(O),B=0;for(let W=0;W<=C;W++){let X=Math.cos(B),F=Math.sin(B);_.x=I*X,_.y=N,_.z=I*F;let k=T.clone().addScaledVector(_,a);d.push(b*k.x,w*k.y,S*k.z),h.push(b*_.x,w*_.y,S*_.z),f.push(0,0),P.push(m++),B+=ax/C}x.push(P)}let E=x.length-1;for(let C=0;C<E;C++){let P=x[C],O=x[C+1],I=P.length-1;M(P[0],O[1],O[0]);for(let N=1;N<=I;N++)M(P[N-1],P[N],O[N]),M(P[N],O[N+1],O[N])}}}};var Ro=class extends Ce{constructor(e=[],t=[],n="",i=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 Kt,y=s*i,v=i-y,b=o+1,w=new A,S=(F,k)=>w.subVectors(F,k).normalize(),_=(F,k)=>Array(F).fill(void 0).map(k),T=_(e.length/3,(F,k)=>new A().fromArray(e,k*3).setLength(i)),x=[],M=1e6;for(let F=0;F<T.length;F++){let k=T[F],K=[],H,z,j,Y=1e10,G=-1;for(;(G=t.indexOf(F,G+1))!=-1;){let q=G-G%3;H=t[q+(G+1)%3],z=t[q+(G+2)%3],j=k.distanceToSquared(T[H]),Y=Math.min(Y,j),K.push([H,z,j])}Y+=1e-6;let de=[],te=0,Q=K.length;for(let q=0;q<Q;q++){[H,z,j]=K[te];let se=x[H]?.includes(F)==!0;j<=Y&&de.push(H+ +se*M),te=K.findIndex(oe=>oe[0]==z)}x.push(de)}let E=[];{let F=0,k=0,K,H,z=f==3;for(let j=0;j<=o;j++){K=j*(j+1)/2,H=(j+1)*(j+2)/2;for(let Y=0;Y<o-j;Y++)[F,k]=[K+Y+j+2,H+Y+j+3],E.push(K,H,...z?[k,K]:[F,H],k,F),[K,H]=[F,k];E.push(K,H,K+o+2)}}let C=m.clone(),P=m.clone(),O=m.clone(),I=m.clone(),N=m.clone(),B=[],W=_(T.length,()=>_(f,()=>m.clone()));for(let F=0;F<T.length;F++){m.copy(T[F]).normalize(),C.copy(m).multiplyScalar(v);let k=x[F];for(let de=0;de<k.length;de++){let te=k[de],Q=k[(de+1)%f];g.setFromPointsAndIndices(T,F,te%M,Q%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,W[F][de])}let K=[],H=[],z=[],j=new A;o==0&&[...W[F]].reduce((de,te)=>de.add(te),j).multiplyScalar(1/f);for(let de=0;de<f;de++){let te=[],Q=(de-1+f)%f,q=W[F][Q],se=W[F][de];m.copy(q).sub(C),p.copy(se).sub(C);let oe=C.angleTo(m),ae=m.angleTo(p),_e=Math.cos(oe)*y;o==0?P.copy(j):P.copy(C).setLength(v+_e),H.push(_e);let me=[P,q,se];for(let xe=0;xe<2;xe++){let be=me[xe],fe=me[xe+1];I.subVectors(be,C),N.subVectors(fe,C),O.crossVectors(I,N).normalize();for(let Pe=0;Pe<b;Pe++){let Ne=[oe,ae][xe]*Pe/b;m.copy(I).applyAxisAngle(O,Ne).add(C),K.push(m.clone()),xe&&(S(m,C),te.push([Pe==0?be:m.clone(),w.clone()]))}xe&&(S(fe,C),te.push([fe,w.clone()]))}z.push(te)}B.push(z);let Y=2*b,G=2;for(let de=0;de<f;de++){let te=Y*de,Q=Y*((de+1)%f),q=[K[te]];for(let oe=1;oe<b;oe++){I=K[te+oe],N=K[Q+oe],q.push(I);for(let ae=1,_e=oe-G+1;ae<=_e;ae++)m.lerpVectors(I,N,ae/(_e+1)),m.sub(C).setLength(H[de]).add(C),q.push(m.clone());q.push(N)}for(let oe=0;oe<b;oe++)q.push(K[oe+b+te]);q.push(K[Q+b]);let se=E.map(oe=>q[oe]);a.push(...se.map(oe=>[oe.x,oe.y,oe.z]).flat()),u.push(...se.map(oe=>(S(oe,C),[w.x,w.y,w.z])).flat())}}let X=[];for(let F=0;F<x.length;F++)for(let k=0;k<f;k++){let K=x[F][k];if(K<M){let H=x[K].findIndex(Y=>Y%M==F),z=B[F][k],j=B[K][H];for(let Y=0;Y<b;Y++){let G=z[Y],de=j[b-Y],te=z[Y+1],Q=j[b-(Y+1)];[G,de,te,te,de,Q].forEach(q=>{a.push(q[0].x,q[0].y,q[0].z),u.push(q[1].x,q[1].y,q[1].z)})}X.push(z[0][0],j[b][0],z[b][0],j[0][0])}}for(;X.length;){let F,k,K,H;[F,k]=X.splice(0,2);let z=[F];for(;F!=k;)z.push(k),K=X.indexOf(k),H=K%2,k=X.splice(K-H,2)[1-H];w.subVectors(z[0],z[1]).cross(m.subVectors(z[0],z[2])).normalize();let j=w.dot(z[0])<0;j&&w.negate();for(let Y=1;Y<=z.length-2;Y++)[z[Y+ +j],z[Y+1-+j],z[0]].forEach(G=>{a.push(G.x,G.y,G.z),u.push(w.x,w.y,w.z)})}}function d(){let h=new A;for(let T=0;T<a.length;T+=3){h.x=a[T+0],h.y=a[T+1],h.z=a[T+2];let x=S(h)/2/Math.PI+.5,M=_(h)/Math.PI+.5;l.push(x,1-M)}let f=new A,m=new A,p=new A,g=new A,y=new U,v=new U,b=new U,w=(T,x,M,E)=>{E<0&&T.x===1&&(l[x]=T.x-1),M.x===0&&M.z===0&&(l[x]=E/2/Math.PI+.5)};for(let T=0,x=0;T<a.length;T+=9,x+=6){f.set(a[T+0],a[T+1],a[T+2]),m.set(a[T+3],a[T+4],a[T+5]),p.set(a[T+6],a[T+7],a[T+8]),y.set(l[x+0],l[x+1]),v.set(l[x+2],l[x+3]),b.set(l[x+4],l[x+5]),g.copy(f).add(m).add(p).divideScalar(3);let M=S(g);w(y,x+0,f,M),w(v,x+2,m,M),w(b,x+4,p,M)}for(let T=0;T<l.length;T+=6){let x=l[T+0],M=l[T+2],E=l[T+4],C=Math.max(x,M,E),P=Math.min(x,M,E);C>.9&&P<.1&&(x<.2&&(l[T+0]+=1),M<.2&&(l[T+2]+=1),E<.2&&(l[T+4]+=1))}function S(T){return Math.atan2(T.z,-T.x)}function _(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(e){return new Ro(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var PM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new rh(e*.5,s,o):new Ll(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},rh=class extends Ro{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,n),this.type=l}static fromJSON(e){return new rh(e.radius,e.corner,e.cornerSides)}};var ih=1e-12,$c=class{constructor(e){this.position=new U;this.startPosition=new U;this.uuid=ze.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new $c(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},eu=class extends $c{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new eu(this.parent).copy(this)}},wi=class extends $c{constructor(t,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new eu(this),new eu(this))}static create(t,n){let i=new wi(t,new U(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(t){let n=this.controls.indexOf(t);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(t,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new wi(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[t,n]}computeNormals(t=new U,n=new U){let[i,s]=this.computeTangents();return i&&s&&(IM(i,t),IM(s,n)),[t,n]}computeTangent(t=new U){let[n,i]=this.computeTangents();return n&&i&&t.copy(n).add(i).normalize(),t}computeNormal(t=new U){let[n,i]=this.computeNormals();return t.copy(n).add(i).normalize(),t}};function IM(r,e=new U){let t=r.length();return e.set(-r.y/t,r.x/t)}var ux=r=>r,tu=new U,Bm=new U,JV=new U,$V=new U,e4=new U,t4=new U,OM=new A,LM=new A;function RM(r){let e=new U;e.addVectors(r.v0,tu.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new U;return t.addVectors(r.v2,Bm.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new Kn(r.v0,e,t,r.v2)}function sh(r,e,t=Number.EPSILON){return Math.abs(r-e)<t}function n4(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function r4(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function dx(r,e,t){let n=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function NM(r,e,t){return DM(r,e)&&DM(e,t)&&cx(r.position,e.position,t.position)}function cx(r,e,t){return tu.copy(e).sub(r).cross(Bm.copy(t).sub(r))===0}function BM(r,e,t,n,i){let s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),o=(r.y+e.y)/2,a=(r.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(r.y-e.y)/s,u=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function FM(r,e,t){let n=r.distanceTo(t),i=e.distanceTo(t);return n<i?e:r}function UM(r,e,t,n,i,s){let o=e.x-r.x,a=e.y-r.y,l=t.x-r.x,u=t.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return dx(e,r,t)>Math.PI&&(c*=-1),sh(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),i.set(e.x-d*a,e.y+d*o),s.set(t.x+d*u,t.y-d*l),[i,s]}function hx(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function DM(r,e){return cx(r.position,r.controls[1].position,e.position)&&cx(r.position,e.controls[0].position,e.position)}function GM(r,e,t,n,i=.5){let s=tu.subVectors(e,r).multiplyScalar(i).add(r),o=Bm.subVectors(t,e).multiplyScalar(i).add(e),a=JV.subVectors(n,t).multiplyScalar(i).add(t),l=s,u=$V.subVectors(o,s).multiplyScalar(i).add(s),c=e4.subVectors(a,o).multiplyScalar(i).add(o),d=a,h=t4.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.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 kM(r,e,t=12,n=!0){let i=LM.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let u=ux(e[l]),c=tu,d=No(u,t);a.push(d);for(let h=0;h<=d;h++)if(u instanceof Kn||u instanceof Nr||u instanceof Zn){if(u.getPoint(h/d,c),i.set(c.x,c.y,0),s!==void 0&&r4(s,i))continue;s===void 0&&(s=OM),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function zM(r,e,t,n=12,i=!0){let s=LM.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let u,c=ux(e[l]),d=tu,h=No(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof Kn||c instanceof Nr||c instanceof Zn){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=OM:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function fx(r,e=12,t=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=No(o.roundedCurveCorner,e)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=No(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=No(r[0].roundedCurveCorner,e)*.5),n}function No(r,e=12){return r&&r instanceof fa?e*2:r&&(r instanceof Zn||r instanceof md)?1:r&&r instanceof Pl?e*r.points.length:e}function VM(r,e,t=12,n=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=ux(e[o]),l=No(a,t),u=tu;for(let c=0;c<=l;c++)if(a instanceof Kn||a instanceof Nr||a instanceof Zn){if(a.getPoint(c/l,u),i!==void 0&&n4(i,u,ih))continue;i===void 0&&(i=Bm),i.copy(u),r.push(u.x,u.y),s++}}return sh(r[0],r[r.length-2],ih)&&sh(r[1],r[r.length-1],ih)&&(r.pop(),r.pop()),n&&s>1&&!(sh(r[s-1],r[1],ih)&&sh(r[s-2],r[0],ih))&&(r.push(r[0],r[1]),s++),r}var px=new U,i4=new U,s4=new U,o4=new U,a4=new U,l4=new U,vt=class extends Ps{constructor(t=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new xn(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=ze.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=n}static createFromState(t,n,i){let s=new vt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>wi.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>vt.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(t){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<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(t);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=t-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: "+t)}getBezierPointIndex(t){let n=this.points.indexOf(t);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...t]}applySize(t,n){t===0&&(t=.001),n===0&&(n=.001),this._width=t,this._height=n}applyScale(t,n){let i=px.set(t,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,n);this._update()}createPoint(t,n=0,i=ze.generateUUID()){let s;t instanceof U?s=t:s=new U(t,n);let o=new wi(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,n){this.points.splice(n,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===t)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let n=this.points.indexOf(t);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(t){let n=this.points.find(i=>i.uuid===t);n&&this.removePoint(n)}update(){for(let t=0,n=this.shapeHoles.length;t<n;t++)this.shapeHoles[t].update();this._update()}extractShapePointsToBuffer(t,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return kM(t,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=fx(this.points,t,!1),this.roundedCurveDivisions=fx(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,n,i=12){return zM(t,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),VM(t,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(t,n=!1){let i=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=No(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-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<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(t,n,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(hx(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(px.set(i.x,i.y))/d}let u=0;for(let d=0;d<t;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(t,n){hx(n,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,n.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,n.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,i=this.points.length;n<i;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 t=this.getLastPoint();if(t?.curveAfter&&(t.curveAfter=void 0),this.isClosed){let n=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(n,i)}if(this.points.length>2){let n=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],u=o.roundness,c=a&&l&&NM(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),b=Math.min(y,v),w=1-b/p,S=b/g,_=d.getPointAt(w,px),T=h.getPointAt(S,i4);this._subSplitCurve(d,f,w,_,void 0),this._subSplitCurve(h,m,S,void 0,T);let x;if(this.useCubicForRoundedCorners){let M=dx(_,o.position,T)/2,E=Math.tan(M)*_.distanceTo(o.position),[C,P]=BM(_,T,E,s4,o4),O=FM(C,P,o.position),[I,N]=UM(O,_,T,E,a4,l4);x=new Kn(_.clone(),I.clone(),N.clone(),T.clone())}else x=new Nr(_.clone(),o.position.clone(),T.clone());o.roundedCurveCorner=x,this.roundedCurves.splice(i+n,0,x),n++}}}}_subSplitCurve(t,n,i,s,o){if(t instanceof Zn)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=t,l=n,u=a.getUtoTmapping(i,0),c=GM(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 t=new vt(this._width,this._height);return t.points=this.points.map(n=>n.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(n=>n.clone()),t}toJSON(){return{points:this.points.reduce((t,n)=>t.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let n=t.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],u=t.points[s+3],c=t.points[s+4],d=t.points[s+5],h=t.points[s+6],f=new wi(ze.generateUUID(),new U(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=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new vt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let n=(s,o)=>{o instanceof Kn&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof Nr&&(s[a]=RM(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 Kn?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Zn&&(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 Kn?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof Zn&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(t.curves),t instanceof Ps&&(this.shapeHoles=t.holes.map(s=>{let o=new vt;return o.fromShape(s),o})),this.update(),this}updatePoint(t,n){let i=this.getPointByUuid(t);i&&(n.position!==void 0&&i.position.fromArray(n.position),n.roundness!==void 0&&(i.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(t,n){let s=this.getPointByUuid(t)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(t,n){let s=this.getPointByUuid(t)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var gx=Math.PI*2;function mx({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function c4(r,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+e),o=Math.sin(r+e);return[{x:n-i*t,y:i+n*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function HM(r,e,t,n){let i=r*n-e*t<0?-1:1,s=Math.min(1,Math.max(-1,r*t+e*n));return i*Math.acos(s)}function u4(r,e,t,n,i,s,o,a,l,u){let c=Math.pow(i,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*i/s*a,g=m*-s/i*o,y=p+(r+t)/2,v=g+(e+n)/2,b=(o-p)/i,w=(a-g)/s,S=(-o-p)/i,_=(-a-g)/s,T=HM(1,0,b,w),x=HM(b,w,S,_);return!u&&x>0&&(x-=gx),u&&x<0&&(x+=gx),{centerx:y,centery:v,ang1:T,ang2:x}}function WM({px:r,py:e,cx:t,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-t)/2,c=(e-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(i*=Math.sqrt(d),s*=Math.sqrt(d));let h=u4(r,e,t,n,i,s,u,c,o,a),{ang1:f,ang2:m}=h,{centerx:p,centery:g}=h,y=Math.abs(m)/(gx/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);m/=v;for(let b=0;b<v;b++)l.push(c4(f,m)),f+=m;return l.map(b=>{let{x:w,y:S}=mx(b[0],i,s,p,g),{x:_,y:T}=mx(b[1],i,s,p,g),{x,y:M}=mx(b[2],i,s,p,g);return{x1:w,y1:S,x2:_,y2:T,x,y:M}})}var It;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(It||(It={}));var Sn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Sn||(Sn={}));function We(r,e){if(!r)throw e||"Assertion Failed!"}var Ue=function(){function r(){}return r.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},r.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},r.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},r.edgeGoesLeft=function(e){return r.vertLeq(e.Dst,e.Org)},r.edgeGoesRight=function(e){return r.vertLeq(e.Org,e.Dst)},r.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},r.edgeEval=function(e,t,n){We(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-n.t)*(i/(i+s)):t.t-n.t+(n.t-e.t)*(s/(i+s)):0},r.edgeSign=function(e,t,n){We(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?(t.t-n.t)*i+(t.t-e.t)*s:0},r.transEval=function(e,t,n){We(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-n.s)*(i/(i+s)):t.s-n.s+(n.s-e.s)*(s/(i+s)):0},r.transSign=function(e,t,n){We(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?(t.s-n.s)*i+(t.s-e.s)*s:0},r.vertCCW=function(e,t,n){return e.s*(t.t-n.t)+t.s*(n.t-e.t)+n.s*(e.t-t.t)>=0},r.interpolate=function(e,t,n,i){return e=e<0?0:e,n=n<0?0:n,e<=n?n===0?(t+i)/2:t+(i-t)*(e/(e+n)):i+(t-i)*(n/(e+n))},r.intersect=function(e,t,n,i,s){var o,a,l;r.vertLeq(e,t)||(l=e,e=t,t=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.vertLeq(n,t)?r.vertLeq(t,i)?(o=r.edgeEval(e,n,t),a=r.edgeEval(n,t,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,t.s)):(o=r.edgeSign(e,n,t),a=-r.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+t.s)/2,r.transLeq(e,t)||(l=e,e=t,t=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.transLeq(n,t)?r.transLeq(t,i)?(o=r.transEval(e,n,t),a=r.transEval(n,t,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,t.t)):(o=r.transSign(e,n,t),a=-r.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+t.t)/2},r}(),oh=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Fm=function(){function r(e){this.side=e,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(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),r}(),nu=function(){function r(){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 r}(),jM=function(){function r(){var e=new nu,t=new oh,n=new Fm(0),i=new Fm(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(e){var t=new Fm(0),n=new Fm(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return n.next=i,i.Sym.next=t,t.next=e,e.Sym.next=n,t.Sym=n,t.Onext=t,t.Lnext=n,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,n.Sym=t,n.Onext=n,n.Lnext=t,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,t},r.prototype.splice_=function(e,t){var n=e.Onext,i=t.Onext;n.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=n},r.prototype.makeVertex_=function(e,t,n){var i=e;We(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},r.prototype.makeFace_=function(e,t,n){var i=e;We(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=n.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},r.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,n=e.Sym.next;t.Sym.next=n,n.Sym.next=t},r.prototype.killVertex_=function(e,t){var n=e.anEdge,i=n;do i.Org=t,i=i.Onext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.killFace_=function(e,t){var n=e.anEdge,i=n;do i.Lface=t,i=i.Lnext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var e=new nu,t=new nu,n=new oh,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(e,t){var n=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new nu;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!n){var o=new oh;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},r.prototype.delete=function(e){var t=e.Sym,n=!1;if(e.Lface!==e.Rface&&(n=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!n){var i=new oh;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},r.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),n=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new nu;return this.makeVertex_(i,n,t.Org),t.Lface=n.Lface=e.Lface,t},r.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),n=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,n),e.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=e.Rface,n.winding=e.winding,n.Sym.winding=e.Sym.winding,n.idx=e.idx,n.Sym.idx=e.Sym.idx,n},r.prototype.connect=function(e,t){var n=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!n){var o=new oh;this.makeFace_(o,i,e.Lface)}return i},r.prototype.zapFace=function(e){var t=e.anEdge,n,i,s,o,a;i=t.Lnext;do n=i,i=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!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(e){var t=e.anEdge,n=0;do n++,t=t.Lnext;while(t!==e.anEdge);return n},r.prototype.mergeConvexFaces=function(e){var t,n,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(n=t.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&Ue.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Ue.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var e=this.fHead,t=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=e,s=e;(i=s.next)!==e;s=i){We(i.prev===s),l=i.anEdge;do We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l),We(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(We(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){We(o.prev===a),l=o.anEdge;do We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l),We(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(We(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)We(l.Sym.next===u.Sym),We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Org!==null),We(l.Dst!==null),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l);We(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)},r}(),qM=function(){function r(){this.handle=null}return r}(),YM=function(){function r(){this.key=null,this.node=0}return r}(),d4=function(){function r(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var n=0;n<e+1;n++)this.nodes[n]=new qM,this.handles[n]=new YM;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(n[t[o+1].handle].key,n[t[o].handle].key)&&++o,We(o<=this.max),s=t[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.floatUp_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(n[s].key,n[i].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(e){var t,n;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new qM;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new YM}return this.freeList===0?n=t:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[t].handle=n,this.handles[n].node=t,this.handles[n].key=e,this.initialized&&this.floatUp_(t),n},r.prototype.extractMin=function(){var e=this.nodes,t=this.handles,n=e[1].handle,i=t[n].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[n].key=null,t[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(e){var t=this.nodes,n=this.handles,i;We(e>=1&&e<=this.max&&n[e].key!==null),i=n[e].node,t[i].handle=t[this.size].handle,n[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[t[i>>1].handle].key,n[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[e].key=null,n[e].node=this.freeList,this.freeList=e},r}(),yx=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),XM=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),h4=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new XM,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(e){return this.insertBefore(this.head,e)},r.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},r.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var n=new XM;return n.key=t,n.next=e.next,e.next.prev=n,n.prev=e,e.next=n,n},r.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},r}(),f4=function(){function r(){}return r.regionBelow=function(e){return e.nodeUp.prev.key},r.regionAbove=function(e){return e.nodeUp.next.key},r.debugEvent=function(e){},r.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.edgeLeq=function(e,t,n){var i=e.event,s=t.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?Ue.vertLeq(s.Org,o.Org)?Ue.edgeSign(o.Dst,s.Org,o.Org)<=0:Ue.edgeSign(s.Dst,o.Org,s.Org)>=0:Ue.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return Ue.edgeSign(s.Dst,i,s.Org)>=0;var a=Ue.edgeEval(s.Dst,i,s.Org),l=Ue.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(e,t){t.fixUpperEdge&&We(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},r.fixUpperEdge=function(e,t,n){We(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=n,n.activeRegion=t},r.topLeftRegion=function(e,t){var n=t.eUp.Org,i;do t=r.regionAbove(t);while(t.eUp.Org===n);if(t.fixUpperEdge){if(i=e.mesh.connect(r.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;r.fixUpperEdge(e,t,i),t=r.regionAbove(t)}return t},r.topRightRegion=function(e){var t=e.eUp.Dst;do e=r.regionAbove(e);while(e.eUp.Dst===t);return e},r.addRegionBelow=function(e,t,n){var i=new yx;return i.eUp=n,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(e,t){switch(e.windingRule){case It.ODD:return(t&1)!==0;case It.NONZERO:return t!==0;case It.POSITIVE:return t>0;case It.NEGATIVE:return t<0;case It.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(e,t){t.windingNumber=r.regionAbove(t).windingNumber+t.eUp.winding,t.inside=r.isWindingInside(e,t.windingNumber)},r.finishRegion=function(e,t){var n=t.eUp,i=n.Lface;i.inside=t.inside,i.anEdge=n,r.deleteRegion(e,t)},r.finishLeftRegions=function(e,t,n){for(var i,s=null,o=t,a=t.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),r.finishRegion(e,o),a=s.eUp,o=s}return a},r.addRightEdges=function(e,t,n,i,s,o){var a,l,u,c,d=!0;u=n;do We(Ue.vertLeq(u.Org,u.Dst)),r.addRegionBelow(e,t,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(t).eUp.Rprev),l=t,c=s;a=r.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(e.mesh.splice(u.Oprev,u),e.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=r.isWindingInside(e,a.windingNumber),l.dirty=!0,!d&&r.checkForRightSplice(e,l)&&(r.addWinding(u,c),r.deleteRegion(e,l),e.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,We(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(e,l)},r.spliceMergeVertices=function(e,t,n){e.mesh.splice(t,n)},r.vertexWeights=function(e,t,n){var i=Ue.vertL1dist(t,e),s=Ue.vertL1dist(n,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*n.coords[0],e.coords[1]+=o*t.coords[1]+a*n.coords[1],e.coords[2]+=o*t.coords[2]+a*n.coords[2]},r.getIntersectData=function(e,t,n,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,r.vertexWeights(t,n,i),r.vertexWeights(t,s,o)},r.checkForRightSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp;if(Ue.vertLeq(i.Org,s.Org)){if(Ue.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;Ue.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=n.dirty=!0)}else{if(Ue.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o;if(We(!Ue.vertEq(i.Dst,s.Dst)),Ue.vertLeq(i.Dst,s.Dst)){if(Ue.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(Ue.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=n.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},r.checkForIntersect=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,d,h=new nu,f,m;if(We(!Ue.vertEq(u,l)),We(Ue.edgeSign(l,e.event,o)<=0),We(Ue.edgeSign(u,e.event,a)>=0),We(o!==e.event&&a!==e.event),We(!t.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(Ue.vertLeq(o,a)){if(Ue.edgeSign(u,o,a)>0)return!1}else if(Ue.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),Ue.intersect(l,o,u,a,h),We(Math.min(o.t,l.t)<=h.t),We(h.t<=Math.max(a.t,u.t)),We(Math.min(u.s,l.s)<=h.s),We(h.s<=Math.max(a.s,o.s)),Ue.vertLeq(h,e.event)&&(h.s=e.event.s,h.t=e.event.t),f=Ue.vertLeq(o,a)?o:a,Ue.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),Ue.vertEq(h,o)||Ue.vertEq(h,a)?(r.checkForRightSplice(e,t),!1):!Ue.vertEq(l,e.event)&&Ue.edgeSign(l,e.event,h)>=0||!Ue.vertEq(u,e.event)&&Ue.edgeSign(u,e.event,h)<=0?u===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=r.topLeftRegion(e,t),i=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),n),r.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),n=t,t=r.topRightRegion(t),m=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(Ue.edgeSign(l,e.event,h)>=0&&(r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),Ue.edgeSign(u,e.event,h)<=0&&(t.dirty=n.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=h.s,i.Org.t=h.t,i.Org.pqHandle=e.pq.insert(i.Org),r.getIntersectData(e,i.Org,o,l,a,u),r.regionAbove(t).dirty=t.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(e,t){for(var n=r.regionBelow(t),i,s;;){for(;n.dirty;)t=n,n=r.regionBelow(n);if(!t.dirty&&(n=t,t=r.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(e,t)&&(n.fixUpperEdge?(r.deleteRegion(e,n),e.mesh.delete(s),n=r.regionBelow(t),s=n.eUp):t.fixUpperEdge&&(r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(r.checkForIntersect(e,t))return}else r.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n))}},r.connectRightVertex=function(e,t,n){var i,s=n.Onext,o=r.regionBelow(t),a=t.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(e,t),Ue.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=r.topLeftRegion(e,t),s=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),o),u=!0),Ue.vertEq(l.Org,e.event)&&(e.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(e,o,null),u=!0),u){r.addRightEdges(e,t,n.Onext,s,s,!0);return}Ue.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(n.Lprev,i),r.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(e,t)},r.connectLeftDegenerate=function(e,t,n){var i,s,o,a,l;if(i=t.eUp,Ue.vertEq(i.Org,n)){We(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!Ue.vertEq(i.Dst,n)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(n.anEdge,i),r.sweepEvent(e,n);return}We(!1),t=r.topRightRegion(t),l=r.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(We(s!==o),r.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(n.anEdge,o),Ue.edgeGoesLeft(s)||(s=null),r.addRightEdges(e,t,o.Onext,a,s,!0)},r.connectLeftVertex=function(e,t){var n,i,s,o,a,l,u=new yx;if(u.eUp=t.anEdge.Sym,n=e.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,Ue.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=Ue.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var c=e.mesh.connect(a.Dnext,t.anEdge);l=c.Sym}s.fixUpperEdge?r.fixUpperEdge(e,s,l):r.computeWinding(e,r.addRegionBelow(e,n,l)),r.sweepEvent(e,t)}else r.addRightEdges(e,n,t.anEdge,t.anEdge,null,!0)}},r.sweepEvent=function(e,t){e.event=t,r.debugEvent(e);for(var n=t.anEdge;n.activeRegion===null;)if(n=n.Onext,n===t.anEdge){r.connectLeftVertex(e,t);return}var i=r.topLeftRegion(e,n.activeRegion);We(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(e,s,null);a.Onext===o?r.connectRightVertex(e,i,a):r.addRightEdges(e,i,a.Onext,o,o,!0)},r.addSentinel=function(e,t,n,i){var s=new yx,o=e.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},r.initEdgeDict=function(e){e.dict=new h4(e,r.edgeLeq);var t=e.bmax[0]-e.bmin[0],n=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-n,a=e.bmax[1]+n;r.addSentinel(e,i,s,o),r.addSentinel(e,i,s,a)},r.doneEdgeDict=function(e){for(var t,n=0;(t=e.dict.min().key)!==null;)t.sentinel||(We(t.fixUpperEdge),We(++n===1)),We(t.windingNumber===0),r.deleteRegion(e,t)},r.removeDegenerateEdges=function(e){var t,n,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=n)n=t.next,i=t.Lnext,Ue.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(r.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===n||i===n.Sym)&&(n=n.next),e.mesh.delete(i)),(t===n||t===n.Sym)&&(n=n.next),e.mesh.delete(t))},r.initPriorityQ=function(e){var t,n,i,s=0;for(i=e.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,t=e.pq=new d4(s,Ue.vertLeq),i=e.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=t.insert(n);return n!==i?!1:(t.init(),!0)},r.donePriorityQ=function(e){e.pq=null},r.removeDegenerateFaces=function(e,t){var n,i,s;for(n=t.fHead.next;n!==t.fHead;n=i)i=n.next,s=n.anEdge,We(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),e.mesh.delete(s));return!0},r.computeInterior=function(e,t){t===void 0&&(t=!0);var n,i;if(r.removeDegenerateEdges(e),!r.initPriorityQ(e))return!1;for(r.initEdgeDict(e);(n=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!Ue.vertEq(i,n));)i=e.pq.extractMin(),r.spliceMergeVertices(e,n.anEdge,i.anEdge);r.sweepEvent(e,n)}return e.event=e.dict.min().key.eUp.Org,r.debugEvent(e),r.doneEdgeDict(e),r.donePriorityQ(e),r.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},r}(),p4=function(){function r(){this.mesh=new jM,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=It.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 r.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},r.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},r.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},r.prototype.computeNormal_=function(e){var t,n,i,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;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],u[g]=s,m[g]=t,l[g]=s,f[g]=t;for(t=p.next;t!==p;t=t.next)for(var y=0;y<3;++y)s=t.coords[y],s<u[y]&&(u[y]=s,m[y]=t),s>l[y]&&(l[y]=s,f[y]=t);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]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=m[v],i=f[v],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)d[0]=t.coords[0]-i.coords[0],d[1]=t.coords[1]-i.coords[1],d[2]=t.coords[2]-i.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,e[0]=h[0],e[1]=h[1],e[2]=h[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,n=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=n.next;t!==n;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],n,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,u=e.next;u!==e;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))},r.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.prototype.tessellateMonoRegion_=function(e,t){var n,i;if(n=t.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Ue.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Ue.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(Ue.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(Ue.edgeGoesLeft(i.Lnext)||Ue.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(Ue.edgeGoesRight(n.Lprev)||Ue.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=e.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)if(t=n.next,n.inside&&!this.tessellateMonoRegion_(e,n))return!1;return!0},r.prototype.discardExterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)t=n.next,n.inside||e.zapFace(n)},r.prototype.setWindingNumber_=function(e,t,n){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:n?e.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},r.prototype.outputPolymesh_=function(e,t,n,i){var s,o=0,a=0,l;n>3&&e.mergeConvexFaces(n);for(var u=e.vHead.next;u!==e.vHead;u=u.next)u.n=-1;for(var c=e.fHead.next;c!==e.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,t===Sn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=e.vHead.next;u!==e.vHead;u=u.next)if(u.n!==-1){var d=u.n*i;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],i>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=e.fHead.next;c!==e.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(t===Sn.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}}},r.prototype.outputContours_=function(e,t){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],t>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!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new jM),e<2&&(e=2),e>3&&(e=3);for(var n=null,i=0;i<t.length;i+=e)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=t[i+0],n.Org.coords[1]=t[i+1],e>2?n.Org.coords[2]=t[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(e,t,n,i,s,o){if(e===void 0&&(e=It.ODD),t===void 0&&(t=Sn.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=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),f4.computeInterior(this,o);var a=this.mesh;return t===Sn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===Sn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function Ga(r){var e=r.windingRule,t=e===void 0?It.ODD:e,n=r.elementType,i=n===void 0?Sn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,d=r.contours,h=d===void 0?[]:d,f=r.strict,m=f===void 0?!0:f,p=r.debug,g=p===void 0?!1:p;if(!h&&m)throw new Error("Contours can't be empty");if(!!h){var y=new p4;r.edgeCreateCallback&&(y.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(y.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(t,i,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 Rre=It.ODD,Nre=It.NONZERO,Bre=It.POSITIVE,Fre=It.NEGATIVE,Ure=It.ABS_GEQ_TWO,Gre=Sn.POLYGONS,kre=Sn.CONNECTED_POLYGONS,zre=Sn.BOUNDARY_CONTOURS;var ru=class extends Ce{constructor(t,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=It.ODD;this.elementType=Sn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:It.ODD,elementType:Sn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,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}!l&&!u&&(a=Ga({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));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,T=a.vertices[_+0],x=a.vertices[_+1];T<m&&(m=T),T>p&&(p=T),x<g&&(g=x),x>y&&(y=x)}let v=p-m,b=y-g;for(let w=0,S=h;w<S;w++){let _=w*2,T=a.vertices[_+0],x=a.vertices[_+1],M=(T-m)/v,E=(x-g)/b;this._positionAttribute.setXYZ(w,T,x,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,M,E)}for(let w=0,S=f;w<S;w++){let _=w*3,T=a.elements[_+0],x=a.elements[_+1],M=a.elements[_+2];this._indexAttribute.setX(_+0,T),this._indexAttribute.setX(_+1,x),this._indexAttribute.setX(_+2,M)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new ru(this._shape,this._curveSegments);return t.userData=_a(this.userData),t}};var Um=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let n=e*Um.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let n=e*Um.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let u=new Float32Array(i,o*s,2*e);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=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=t,n}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},ah=Um;ah.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var vx=(r,e)=>([t,n])=>(n<t&&(n+=e),(r>=t?r:r+e)<=n),iu=class extends Ce{constructor(t,n,i=0,s=12,o=3,a=It.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(x=>{let M=x.extractShapePointsToFlatArray([],s),E=[];for(let C=M.length-1;C>=1;C-=2){let P=M[C-1],O=M[C-0];E.push(P,O)}return E}),c=Ga({windingRule:a,elementType:Sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),d=Ga({windingRule:It.ODD,elementType:Sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]});if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let x=0;x<d.elements.length;x++){let M=d.elements[x],E=x%2===0?c.vertexCount:0;c.elements.push(M+E)}for(let x=0;x<d.vertexIndices.length;x++){let M=d.vertexIndices[x],E=c.vertexCount;c.vertexIndices.push(M+E)}for(let x=0;x<d.vertices.length;x++){let M=d.vertices[x];c.vertices.push(M)}}let f=1/0,m=-1/0,p=1/0,g=-1/0;for(let x=0,M=c.vertexCount;x<M;x++){let E=x*2,C=c.vertices[E+0],P=c.vertices[E+1];C<f&&(f=C),C>m&&(m=C),P<p&&(p=P),P>g&&(g=P)}this._minX=f,this._minY=p,this._width=m-f,this._height=g-p;let y=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new ah(y);let v=[],b=[];for(let x=c.elementCount-1;x>=0;x--){let M=x>=h,E=x*2,C=c.elements[E+0],P=c.elements[E+1],O=C+P,I={start:C,count:P,normals:[],continuous:[],concave:[]},N=C,B=O-1,W=C+1,X=this._shape.roundedCurves.length;do{let H=N-C,z=c.vertices[B*2+0],j=c.vertices[B*2+1],Y=c.vertices[N*2+0],G=c.vertices[N*2+1],de=c.vertices[W*2+0],te=c.vertices[W*2+1],Q=Y-z,q=G-j,se=Math.sqrt(Q*Q+q*q);Q/=se,q/=se;let oe=Y-de,ae=G-te,_e=Math.sqrt(oe*oe+ae*ae);oe/=_e,ae/=_e,I.normals[H*2+0]=-ae,I.normals[H*2+1]=oe,I.concave[H]=Q*ae-q*oe>0;let me=c.vertexIndices[N];if(Array.isArray(me))I.continuous[H]=!1;else{let[xe,be]=this._shape.getCurveIndexFromVertexId(me-1,!0);if(be>0&&be<1)I.continuous[H]=!0;else{let fe=be===1?xe+1:xe-1;fe=(fe+X)%X;let Pe=be===1?0:1,Ne=this._shape.roundedCurves[xe].getTangent(be),Ke=this._shape.roundedCurves[fe].getTangent(Pe);I.continuous[H]=Ne.dot(Ke)>.95}}M&&(I.normals[H*2+0]*=-1,I.normals[H*2+1]*=-1),[B,N,W]=[N,W,W+1],W>=O&&(W-=P)}while(W!==C+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(C*2,O*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((H,z)=>[z,z]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(C*2,O*2)});for(let H=1;H<=this._bevelSegments;H++){let z=H/this._bevelSegments*Math.PI/2,j=(1-Math.cos(z))*this._bevelSize,Y=[],G=[],de=[],te=[],Q=0;for(let se=0;se<P;se++){let oe=se*2,ae=(se-1+P)%P*2,_e=c.vertices[I.start*2+oe+0],me=c.vertices[I.start*2+oe+1],xe=-I.normals[ae+0]*j,be=-I.normals[ae+1]*j,fe=-I.normals[oe+0]*j,Pe=-I.normals[oe+1]*j;if(I.concave[se]||!I.concave[se]&&M){let Ne=Math.atan2(be,xe),Ke=Math.atan2(Pe,fe);Ke>Ne&&(Ke-=Math.PI*2);let R=Ke-Ne;if(I.continuous[se]||M){let D=Ne+R/2,J=Math.cos(D)*j,ce=Math.sin(D)*j;Y[2*Q+0]=_e+J*(M?-1:1),Y[2*Q+1]=me+ce*(M?-1:1),te[Q]=se,Q++}else{let D=Math.max(1,Math.floor(s/4*Math.abs(R)/Math.PI));for(let J=0;J<=D;J++){let ce=Ne+R*(J/D),pe=Math.cos(ce)*j,Me=Math.sin(ce)*j;Y[2*Q+0]=_e+pe,Y[2*Q+1]=me+Me,te[Q]=se,Q++}}}else Y[2*Q+0]=_e+xe,Y[2*Q+1]=me+be,te[Q]=se,G[se]=Q,Q++,Y[2*Q+0]=_e,Y[2*Q+1]=me,te[Q]=se,Q++,Y[2*Q+0]=_e+fe,Y[2*Q+1]=me+Pe,te[Q]=se,de[se]=Q,Q++}let q=Ga({windingRule:It.POSITIVE,elementType:Sn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Y],edgeCreateCallback:se=>{let ae=se.Org.idx,_e=te[ae],me=te[(ae+1)%te.length];se.idx=[_e,me],se.Sym.idx=[me,_e]},vertexIdCallback:se=>{let oe=se.Lprev.idx;return[oe?oe[1]:0,se.idx[0]]}});if(!q)throw console.log("Error"),new Error(`error generating bevel geometry for ${H}'th loop`);if(!q.vertexCount)break;for(let se=0;se<q.vertexIndices.length;se++){let[oe,ae]=q.vertexIndices[se];if(oe===ae)continue;let _e=ae;ae<oe&&(_e+=P);for(let me=oe;me<_e;me++){let xe=me%P,be=(me+1)%P;if(!I.continuous[xe]||!I.continuous[be]){q.vertexIndices[se]=[oe,xe],q.vertexIndices.splice(se+1,0,[be,ae]),q.vertices.splice((se+1)*2,0,q.vertices[se*2],q.vertices[se*2+1]);break}}}F.push({bevelI:H,angle:z,size:j,boundary:q,reverseMap:te,insetPoints:Y})}let k=(H,z,j)=>{let Y=0,G=H.boundary.vertexIndices.length;for(;Y<G&&j(H.boundary.vertexIndices[z]);)z=(z+1)%G,Y++;return Y},K=v.length;for(let H=1;H<F.length;H++){let z=F[H-1],j=F[H],Y=z.boundary.vertexIndices.length,G=j.boundary.vertexIndices.length;if(!Y||!G)break;let de=I.concave.length,te=0,Q=vx(te,P);for(;!z.boundary.vertexIndices.filter(Q).length||!j.boundary.vertexIndices.filter(Q).length;)te++,Q=vx(te,P);let q=z.boundary.vertexIndices.findIndex(Q),se=j.boundary.vertexIndices.findIndex(Q);do q=(q+1)%Y;while(Q(z.boundary.vertexIndices[q]));do se=(se+1)%G;while(Q(j.boundary.vertexIndices[se]));te=(te+1)%P;let oe=te,ae=this.buildBevelVert(I,z,(q-1+Y)%Y),_e=this.buildBevelVert(I,j,(se-1+G)%G),me=ae,xe=_e,be,fe,Pe=!1;do{Q=vx(te,P);let Ne=k(z,q,Q),Ke=k(j,se,Q),R=Pe;if(Pe=!1,Ne&&!Ke){for(let D=0;D<Ne;D++)be=this.buildBevelVert(I,z,(q+D)%Y,D/(Ne-1)),v.push(me.topN,be.topP,xe.topN),v.push(be.bottomP,me.bottomN,xe.bottomN),me=be;Pe=!0}else if(!Ne&&Ke)for(let D=0;D<Ke;D++)fe=this.buildBevelVert(I,j,(se+D)%G,D/(Ke-1)),v.push(xe.topN,me.topP,fe.topP),v.push(me.bottomP,xe.bottomN,fe.bottomP),xe=fe;else if(Ne&&Ke)if(be=this.buildBevelVert(I,z,q,0),fe=this.buildBevelVert(I,j,se,0),R?(v.push(me.topN,fe.topP,xe.topN),v.push(me.topN,be.topP,fe.topP),v.push(fe.bottomP,me.bottomN,xe.bottomN),v.push(fe.bottomP,be.bottomP,me.bottomN)):(v.push(xe.topN,me.topN,be.topP),v.push(xe.topN,be.topP,fe.topP),v.push(be.bottomP,me.bottomN,xe.bottomN),v.push(be.bottomP,xe.bottomN,fe.bottomP)),me=be,xe=fe,Ne===Ke)for(let D=1;D<Ne;D++)be=this.buildBevelVert(I,z,(q+D)%Y,D/(Ne-1)),fe=this.buildBevelVert(I,j,(se+D)%G,D/(Ke-1)),v.push(me.topN,be.topP,xe.topN),v.push(xe.topN,be.topP,fe.topP),v.push(be.bottomP,me.bottomN,xe.bottomN),v.push(be.bottomP,xe.bottomN,fe.bottomP),me=be,xe=fe;else if(Ne>Ke){let D=Ne/Ke,J=0;for(let ce=1;ce<Ne;ce++)be=this.buildBevelVert(I,z,(q+ce)%Y,ce/(Ne-1)),v.push(me.topN,be.topP,xe.topN),v.push(be.bottomP,me.bottomN,xe.bottomN),me=be,ce>(J+1)*D&&(J++,fe=this.buildBevelVert(I,j,(se+J)%G,J/(Ke-1)),v.push(xe.topN,be.topP,fe.topP),v.push(be.bottomP,xe.bottomN,fe.bottomP),xe=fe)}else{let D=Ke/Ne,J=0;for(let ce=1;ce<Ke;ce++)fe=this.buildBevelVert(I,j,(se+ce)%G,ce/(Ke-1)),v.push(xe.topN,be.topP,fe.topP),v.push(be.bottomP,xe.bottomN,fe.bottomP),xe=fe,ce>(J+1)*D&&(J++,be=this.buildBevelVert(I,z,(q+J)%Y,J/(Ne-1)),v.push(me.topN,be.topP,xe.topN),v.push(be.bottomP,me.bottomN,xe.bottomN),me=be)}q=(q+Ne)%Y,se=(se+Ke)%G,te=(te+1)%de}while(te!==oe)}{let H=F[0];for(let z=0,j=H.boundary.vertexCount;z<j;z++){let Y=this.buildBevelVert(I,H,z),G=this.buildBevelVert(I,H,(z+1)%j);v.push(G.topP,Y.topN,Y.bottomN),v.push(G.topP,Y.bottomN,G.bottomP)}}if(M){let H=[];for(let z=v.length-1;z>=K+2;z-=3){let j=v[z-2],Y=v[z-1],G=v[z-0];H.push(G,Y,j)}v.splice(K,v.length-K,...H)}if(M){let H=[];for(let z=F[F.length-1].boundary.vertices.length-1;z>=1;z-=2){let j=F[F.length-1].boundary.vertices[z-1],Y=F[F.length-1].boundary.vertices[z-0];H.push(j,Y)}b.push(H)}if(!M){let H=F[F.length-1],z=Ga({windingRule:F.length>1?It.POSITIVE:It.ODD,elementType:Sn.POLYGONS,vertexSize:2,strict:!0,contours:[H.insetPoints,...b]});if(!z)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:v.length});for(let j=0;j<z.elementCount*3;j+=3){let Y=this.buildSurfaceVert(z,z.elements[j+0]),G=this.buildSurfaceVert(z,z.elements[j+1]),de=this.buildSurfaceVert(z,z.elements[j+2]);v.push(Y.top,G.top,de.top),v.push(de.bottom,G.bottom,Y.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Be(Uint32Array.from(v),1),S=new Be(this._buffer.positions,3),_=new Be(this._buffer.normals,3),T=new Be(this._buffer.uvs,2);S.needsUpdate=!0,_.needsUpdate=!0,T.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",_),this.setAttribute("uv",T),this.setIndex(w)}buildSurfaceVert(t,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[n*2+0],o=t.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[i]=h,h}buildBevelVert(t,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=t.continuous[c]&&t.continuous[u]):(u=a,c=(u-1+t.count)%t.count,h=t.concave[u]&&n.bevelI>0,d=t.continuous[u]||h);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=u*2,y=c*2,v=n.boundary.vertices[p+0],b=n.boundary.vertices[p+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,_=(b-this._minY)/this._height,T=t.normals[g+0],x=t.normals[g+1],M=t.normals[y+0],E=t.normals[y+1];if(h){let N=M-T,B=E-x;T=T+N*(1-s),x=x+B*(1-s);let W=Math.sqrt(T*T+x*x);T/=W,x/=W}let C=this._buffer.get(d?2:4),P=C*3,O=C*2,I={i,fi:u,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=T*f,this._buffer.normals[P+1]=x*f,this._buffer.normals[P+2]=m,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=x*f,this._buffer.normals[P+5]=-m,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S,d||(C+=2,P+=6,O+=4,I.topP=C+0,I.bottomP=C+1,this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=M*f,this._buffer.normals[P+1]=E*f,this._buffer.normals[P+2]=m,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=M*f,this._buffer.normals[P+4]=E*f,this._buffer.normals[P+5]=-m,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S),this.vertexCache[o]=I,I}clone(){let t=new iu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=_a(this.userData),t}};var _r=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:It.ODD},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=r.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof vt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new vt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update());let l=o??new vt(n,i);return{parameters:Object.assign(t,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return e<=0?a=new ru(r.shape,i,{windingRule:o}):a=new iu(r.shape,e,t,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var ZM=Math.PI*2,QM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof vt?r.shape:new vt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=e*.5,d=t*.5,h=m4(u,c,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=_r.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function m4(r,e,t,n,i,s){if(n>=ZM)return i>30||i%4===0?(y4(r,e,t,s),Math.round(i/4)):KM(r,n,i,e,t,s);n=Math.max(n,.001);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},u=WM({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?g4(r,o.x,o.y,u,i,e,t,s):KM(r,n,i,e,t,s)}function g4(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(su(e,t));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=r.points[u],f=su(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),r.addPoint(f)}return a>0?JM(r,s,o,a):r.addPoint(su(0,0)),l}function KM(r,e,t,n,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*i;r.addPoint(su(u,c))}return e<ZM?s>0?JM(r,n,i,s):r.addPoint(su(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&$M(r,n,i,s)),1}function y4(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(Gm(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(Gm(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(Gm(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(Gm(i,s-t,i+a,s-t,i-a,s-t)),n>0&&$M(r,e,t,n)}function su(r,e){return new wi(ze.generateUUID(),new U(r,e))}function Gm(r,e,t,n,i,s){let o=su(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function JM(r,e,t,n){eE(r,e,t,n).forEach(s=>r.addPoint(s))}function $M(r,e,t,n){let i=eE(r,e,t,n),s=new vt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function eE(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new U(i/e,s/t),a=r.points.map(l=>{let u=l.clone();return u.uuid=ze.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 tE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??n),s=Math.abs(t.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(t,{width:n,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(r){let{width:e,height:t,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=r.parameters,h=new ka(!1,e,t,n,i,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...r,type:"HelixGeometry"}})}},ka=class extends Ce{constructor(e=!0,t=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1,f=!1){super();let m=e&&o===1;m&&(h=0),d>100&&(d=100);let p=()=>new A,g=new A,y=p(),v=p(),b=p(),w,S,_,T,x,M,E,C,P=p(),O=p(),I=p(),N=p(),B=p(),W=p(),X=p(),F=p(),k=n-2*l+.001,K=k/o,H=Math.ceil(a*o),z=H+1,j=k/H,Y=-k/2,G=c+1,de=2*Math.PI/c,te=Math.PI/2/h,Q=.01,q=Math.min((1-d/100)*l,l-Q),se=l-q,oe=0,ae=2,_e=h*ae+ae,me=G*_e/ae,xe=me+G*z,be=G*(z+_e),[fe,Pe,Ne]=[3,3,2].map(V=>Array(be*V).fill(0)),Ke=[],R=s-l;function D(V,ye){let ve=Math.PI/2;M=ye*j,C=2*Math.PI*(M%K)/K+ve,M+=Y,E=Math.sin(C)*R,x=Math.cos(C)*R,e?V.set(x,E,M):V.set(x,M,E)}D(g,-1e-10),D(y,0),P.copy(g),D(g,1);let J=g.distanceTo(y),ce=m?0:se+q,pe=J*H+2*ce,Me=q,ke=pe-ce;for(let V=0;V<=H;V++){D(v,V),F.subVectors(v,P).normalize(),P.copy(v),W.copy(v).setComponent(+e+1,0).normalize(),X.crossVectors(F,W).normalize();let ye=V===0,ve=V===H,Qe=ye?3*Math.PI/2:te,Re=ye?Me:ke,Je=ye?G:xe,we=ye?0:be-G,$e=F.clone().multiplyScalar(ye?-se:se).add(v),St=F.clone().multiplyScalar(ye?-1:1).normalize();for(let ot=0;ot<G;ot++){let Mn=ot*de;if(O.addVectors(g.copy(W).multiplyScalar(l*Math.cos(Mn)),y.copy(X).multiplyScalar(l*Math.sin(Mn))),I.copy(O).normalize(),ye||ve){m||(oe=we+ot,[0,1,2].forEach(Nt=>{fe[oe*3+Nt]=$e.getComponent(Nt),Pe[oe*3+Nt]=St.getComponent(Nt)}),Ne[oe*2]=+ve,Ne[oe*2+1]=ot/c),y.copy(I).multiplyScalar(q),b.addVectors(v,y);for(let Nt=0;Nt<h;Nt++){let nl=Nt*te+Qe;N.addVectors(g.copy(F).multiplyScalar(se*Math.sin(nl)),y.copy(I).multiplyScalar(se*Math.cos(nl))),B.copy(N).normalize(),y.addVectors(b,N),N.normalize(),oe=Je+Nt*G+ot,[0,1,2].forEach(ys=>{fe[oe*3+ys]=y.getComponent(ys),Pe[oe*3+ys]=B.getComponent(ys)});let yy=+ye+Math.sin(nl);Ne[oe*2]=(Re+se*yy)/pe,Ne[oe*2+1]=ot/c}}y.addVectors(v,O),oe=me+V*G+ot,[0,1,2].forEach(Nt=>{fe[oe*3+Nt]=y.getComponent(Nt),Pe[oe*3+Nt]=I.getComponent(Nt)}),Ne[oe*2]=(ce+V*J)/pe,Ne[oe*2+1]=ot/c}}let re=z+2*h+ae,Fe=1,[Le,De]=[+m,re-1];f&&(De-=1);for(let V=Le;V<=De-1;V++){let ye=m&&V===De-1;for(let ve=0;ve<G-1;ve++)w=V*G+ve,S=w+1,_=(ye?ve:w)+G,T=(ye?ve+1:S)+G,V===0?Ke.push(S,T,_):V===re-2?Ke.push(w,S,_):Ke.push(w,S,_,S,T,_)}this.setIndex(Ke),this.setAttribute("position",new Ae(fe,3)),this.setAttribute("normal",new Ae(Pe,3)),this.setAttribute("uv",new Ae(Ne,2))}};var nE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new lh(e*.5,s,o):new Nl(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},lh=class extends Ro{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,n),this.type=a}static fromJSON(e){return new lh(e.radius,e.corner,e.cornerSides)}};var rE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let t=Object.assign({},e?.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}]},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{points:e,segments:t,verticalSegments:n}=r.parameters,i=new Ps;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new Il(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var Ji=new he,xx=new ht,km=new A,Bo=class extends zt{constructor(){super(),this.uuid=ze.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new sn().getNormalMatrix(e);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(e);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return Ji.makeRotationX(e),this.applyMatrix4(Ji),this}rotateY(e){return Ji.makeRotationY(e),this.applyMatrix4(Ji),this}rotateZ(e){return Ji.makeRotationZ(e),this.applyMatrix4(Ji),this}translate(e,t,n){return Ji.makeTranslation(e,t,n),this.applyMatrix4(Ji),this}scale(e,t,n){return Ji.makeScale(e,t,n),this.applyMatrix4(Ji),this}lookAt(e){return xx.lookAt(e),xx.updateMatrix(),this.applyMatrix4(xx.matrix),this}fromBufferGeometry(e){let t=this,n=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)t.vertices.push(new A().fromBufferAttribute(s,h)),a!==void 0&&t.colors.push(new Oe().fromBufferAttribute(a,h));function c(h,f,m,p){let g=a===void 0?[]:[t.colors[h].clone(),t.colors[f].clone(),t.colors[m].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],v=new ou(h,f,m,y,g,p);t.faces.push(v),l!==void 0&&t.faceVertexUvs[0].push([new U().fromBufferAttribute(l,h),new U().fromBufferAttribute(l,f),new U().fromBufferAttribute(l,m)]),u!==void 0&&t.faceVertexUvs[1].push([new U().fromBufferAttribute(u,h),new U().fromBufferAttribute(u,f),new U().fromBufferAttribute(u,m)])}let d=e.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(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(km).negate(),this.translate(km.x,km.y,km.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,i=new he;return i.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new A,t=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)t[n]=new A;if(e){let n=new A,i=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),i.subVectors(l,u),n.cross(i),t[a.a].add(n),t[a.b].add(n),t[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)t[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let n=this.faces[e],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new Bo;e.faces=this.faces;for(let t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].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 i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],u=i.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 t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new pn),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,n=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,u=e.faces,c=this.colors,d=e.colors;t!==void 0&&(i=new sn().getNormalMatrix(t));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();t!==void 0&&p.applyMatrix4(t),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,b=new ou(m.a+s,m.b+s,m.c+s);b.normal.copy(m.normal),i!==void 0&&b.normal.applyMatrix3(i).normalize();for(let w=0,S=y.length;w<S;w++)p=y[w].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),b.vertexNormals.push(p);b.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)g=v[w],b.vertexColors.push(g.clone());b.materialIndex=m.materialIndex+n,l.push(b)}for(let h=0,f=e.faceVertexUvs.length;h<f;h++){let m=e.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 b=0,w=y.length;b<w;b++)v.push(y[b].clone());this.faceVertexUvs[h].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},n=[],i=[],s=Math.pow(10,e);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);t[d]===void 0?(t[d]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[t[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[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(e){this.vertices=[];for(let t=0,n=e.length;t<n;t++){let i=e[t];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}e.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let u=e[l]._id;o&&o.push(i[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let n=[],i=[],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,b=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,T=0;if(T=c(T,0,0),T=c(T,1,g),T=c(T,2,y),T=c(T,3,v),T=c(T,4,b),T=c(T,5,w),T=c(T,6,S),T=c(T,7,_),n.push(T),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let x=this.faceVertexUvs[0][m];n.push(f(x[0]),f(x[1]),f(x[2]))}if(b&&n.push(d(p.normal)),w){let x=p.vertexNormals;n.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&n.push(h(p.color)),_){let x=p.vertexColors;n.push(h(x[0]),h(x[1]),h(x[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]=i.length/3,i.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 e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=n,e}clone(){return new Bo().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let h=0,f=t.length;h<f;h++)this.vertices.push(t[h].clone());let n=e.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let i=e.faces;for(let h=0,f=i.length;h<f;h++)this.faces.push(i[h].clone());for(let h=0,f=e.faceVertexUvs.length;h<f;h++){let m=e.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 b=0,w=y.length;b<w;b++){let S=y[b];v.push(S.clone())}this.faceVertexUvs[h].push(v)}}let s=e.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=e.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=e.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=e.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=e.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=e.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new bx().fromGeometry(this),t=new Ce,n=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Be(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Be(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Be(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Be(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Be(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];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(c.copyVector3sArray(u.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Ae(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Ae(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new Ce,n=e.geometry;if(e.isPoints||e.isLine){let i=new Ae(n.vertices.length*3,3),s=new Ae(n.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(n.vertices)),t.setAttribute("color",s.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Ae(n.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(n.lineDistances))}n.boundingSphere!==null&&(t.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(t.boundingBox=n.boundingBox.clone())}else e.isMesh&&(t=n.toBufferGeometry());return t}};Bo.prototype.isGeometry=!0;var bx=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,t.push(n)),this.groups=t}fromGeometry(e){let t=e.faces,n=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.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=e.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=e.skinIndices,m=e.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<t.length;y++){let v=t[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let b=v.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[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=i[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 U,new U,new U))}if(o===!0){let S=i[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 U,new U,new U))}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(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},ou=class{constructor(e,t,n,i,s,o=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Oe,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var v4=["a","b","c"];function x4(r,e){switch(e){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function wx(r,e,t){let n=Math.min(r,e),i=Math.max(r,e),s=n+"_"+i;return t.get(s)}function Sx(r,e,t,n,i,s){let o=Math.min(r,e),a=Math.max(r,e),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=t[o],d=t[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[e].edges.push(u)}function b4(r,e,t,n){let i,s,o;for(i=0,s=r.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],Sx(o.a,o.b,r,n,o,t),Sx(o.b,o.c,r,n,o,t),Sx(o.c,o.a,r,n,o,t)}function zm(r,e,t,n,i){r.push(new ou(e,t,n,void 0,void 0,i))}function au(r,e){return Math.abs(e-r)/2+Math.min(r,e)}function Vm(r,e,t,n){r.push([e.clone(),t.clone(),n.clone()])}var Hm=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ce?e=new Bo().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new A,n,i,s,o,a,l=e.vertices,u=e.faces,c=e.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;b4(l,u,h,f);let m=[],p,g,y,v,b,w,S;for(let te of Array.from(f.keys())){for(g=f.get(te),y=new A,b=3/8,w=1/8,S=g.faces.length,S!=2&&(b=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(b),t.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[x4(v,v4[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(w),y.add(t),g.newEdge=m.length,m.push(y)}let _,T,x,M,E,C,P,O=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=h[i].edges,n=E.length,n==3?_=3/16:n>3&&(_=3/(8*n)),T=1-n*Number(_),x=_,n<=2&&(n==2?(T=3/4,x=1/8):n==1||n==0),P=C.clone().multiplyScalar(T),t.set(0,0,0),o=0;o<n;o++)M=E[o],p=M.a!==C?M.a:M.b,t.add(p);t.multiplyScalar(Number(x)),P.add(t),O.push(P)}let I=O.concat(m),N=O.length,B,W,X,F=[],k=[],K,H,z,j,Y=new U,G=new U,de=new U;for(i=0,s=u.length;i<s;i++)v=u[i],B=Number(wx(v.a,v.b,f).newEdge)+N,W=Number(wx(v.b,v.c,f).newEdge)+N,X=Number(wx(v.c,v.a,f).newEdge)+N,zm(F,B,W,X,v.materialIndex),zm(F,v.a,B,X,v.materialIndex),zm(F,v.b,W,B,v.materialIndex),zm(F,v.c,X,W,v.materialIndex),d&&(K=c[i],H=K[0],z=K[1],j=K[2],Y.set(au(H.x,z.x),au(H.y,z.y)),G.set(au(z.x,j.x),au(z.y,j.y)),de.set(au(H.x,j.x),au(H.y,j.y)),Vm(k,Y,G,de),Vm(k,H,Y,de),Vm(k,z,G,Y),Vm(k,j,de,G));e.vertices=I,e.faces=F,d&&(e.faceVertexUvs[0]=k)}};var An=new A,iE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=r.geometry??e?.geometry??new Ce().copy(new In(100,100,100)),n;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(An),n={width:An.x,height:An.y,depth:An.z,subdivisions:0}):n=e.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(r){let{width:e,height:t,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Ce().copy(new In(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(An)):An.set(o.width,o.height,o.depth),(e!==An.x||t!==An.y||n!==An.z)&&s.scale(An.x===0?1:e/An.x,An.y===0?1:t/An.y,An.z===0?1:n/An.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Hm(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,e,t){new kl(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(An);let o=100/An.x;Object.assign(s.parameters,{width:100,height:An.y*o,depth:An.z*o}),e(this.build(s))})}};var sE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof vt?r.shape:new vt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=e*.5,c=t*.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=i;l.roundness=i,l.update();let m=_r.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var oE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new _x(e*.5,t,i,s,o,a,l);return u.scale(1,1,n/e),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function ch(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function Ax(r,e,t,n,i,s){let o=e.clone().sub(r),a=t.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function w4(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.projectOnVector(i),n.add(e)}var _x=class extends Ce{constructor(e=.5,t=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=t/2,m=Math.PI/n,p=e*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,b=new A(0,-f,0),w=new A(0,f,0),S=new U(e,-f),_=new U(p,-f),T=new U(0,w.y).sub(_),x=new U(0,w.y).sub(S),M=new U(T.y,-T.x).normalize(),E=new U(x.y,-x.x).normalize(),P=e*Math.cos(Math.PI/n)*Math.tan((Math.PI-T.angle())/2)-1e-8;o=Math.min(o,P);let O;{let k=new A(M.x,M.y,0),K=new A(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);O=k.angleTo(K)}let I=o/Math.tan((Math.PI-T.angle())/2),N=o/Math.tan((Math.PI-O)/2),B=new A;if(!s){u.push(b.x,b.y,b.z),c.push(0,-1,0),d.push(0,0);let k=h++,K=[],H=S.clone(),z=I/Math.cos(Math.PI/n);H.x-=z;for(let j=0;j<n;j++){let Y=j/n*Math.PI*2+m,G=new U(Math.sin(Y),Math.cos(Y));ch(H,G,B),u.push(B.x,B.y,B.z),c.push(0,-1,0),d.push(0,0),K.push(h++)}for(let j=0;j<K.length;j++)l.push(K[j],k,K[(j+1)%K.length])}let W=[];{let k=new A,K=new A,H=new A,z=new A,j=new A,Y=new A;for(let G=0;G<n;G++){let de=G/n*Math.PI*2+m,te=(G+.5)/n*Math.PI*2+m,Q=(G+1)/n*Math.PI*2+m,q=new U(Math.sin(de),Math.cos(de)),se=new U(Math.sin(te),Math.cos(te)),oe=new U(Math.sin(Q),Math.cos(Q));ch(S,q,K),ch(S,oe,H),ch(M,se,k),Ax(w,K,H,N,N,z),u.push(z.x,z.y,z.z),Ax(K,w,H,N,I,j),u.push(j.x,j.y,j.z),Ax(H,K,w,I,N,Y),u.push(Y.x,Y.y,Y.z),c.push(k.x,k.y,k.z),c.push(k.x,k.y,k.z),c.push(k.x,k.y,k.z),d.push(0,0),d.push(0,0),d.push(0,0);let ae=h++,_e=h++,me=h++;if(l.push(ae,_e,me),o>0){{let fe=K.clone().add(H).multiplyScalar(.5),Pe=w.clone().sub(fe).normalize(),Ke=b.clone().sub(fe).normalize().add(Pe).normalize().multiplyScalar(-1),R=Y.clone().sub(j);X(fe,R,Ke,T.angle())}let xe,be;{let fe=new A;ch(E,oe,fe);let Pe=Y.clone().add(z).multiplyScalar(.5);Pe=w4(Pe,H,w);let Ne=Y.clone().sub(z);[xe,be]=X(Pe,Ne,fe,O,z.y)}{let fe=xe,Pe=fe.clone().setY(0).normalize(),Ne=new A(0,-1,0),Ke=Pe.clone().cross(Ne);F(fe,Pe,Ne,Ke)}W.concat(be);{let fe=T.angle(),Pe=Math.PI-fe,Ne=w.clone();Ne.y-=o/Math.sin(fe-Math.PI/2);let Ke=new A,R=[];for(let J=0;J<a;J++){let ce=[],pe=Math.PI/2-Pe*J/a,Me=Math.cos(pe),ke=Math.sin(pe),re=te;for(let Fe=0;Fe<=J;Fe++){let Le=Math.cos(re),De=Math.sin(re);k.x=Me*De,k.y=ke,k.z=Me*Le,Ke.copy(Ne).addScaledVector(k,o),u.push(Ke.x,Ke.y,Ke.z),c.push(k.x,k.y,k.z),d.push(0,0),ce.push(h++),re+=Math.PI*2/J/n}R.push(ce)}be.reverse(),R.push(be);let D=R.length-1;for(let J=0;J<D;J++){let ce=R[J],pe=R[J+1],Me=ce.length-1;l.push(pe[1],ce[0],pe[0]);for(let ke=1;ke<=Me;ke++)l.push(ce[ke],ce[ke-1],pe[ke]),l.push(pe[ke+1],ce[ke],pe[ke])}}}}}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 X(k,K,H,z,j){let Y=-z/2,G=(Math.PI-z)/2,de=K.clone().normalize().cross(H);k.addScaledVector(H,-o/Math.sin(G));let te=new A,Q=new A,q=1,se=h,oe=[];for(let ae=0;ae<=a;ae++){let _e=Y+ae/a*z;Q.set(0,0,0),Q.addScaledVector(de,Math.sin(_e)),Q.addScaledVector(H,Math.cos(_e));for(let me=0;me<=q;me++){let xe=me/q-.5;if(te.copy(k),te.addScaledVector(K,xe),te.addScaledVector(Q,o),j!=null){let be=Math.max(0,te.y-j);te.addScaledVector(K,-be/K.y)}u.push(te.x,te.y,te.z),c.push(Q.x,Q.y,Q.z),d.push(0,0),me===0&&oe.push(h),h++}}for(let ae=0;ae<a;ae++)for(let _e=0;_e<q;_e++){let me=se+_e+(q+1)*ae,xe=me+(q+1),be=xe+1,fe=me+1;l.push(me,xe,fe),l.push(xe,be,fe)}return[k.clone().addScaledVector(K,.5),oe]}function F(k,K,H,z){let j=Math.PI/2,Y=x.angle()-j,G=[],de=new A,te=new A;for(let q=0;q<=a;q++){let se=[],oe=q/a;for(let ae=0;ae<=q;ae++){let me=((q?ae/q:0)-.5)*v,xe=Math.cos(me),be=Math.sin(me),fe=Math.atan(Math.tan(Y)*xe),Pe=(j+fe)*oe,Ne=Math.cos(Pe),Ke=Math.sin(Pe);de.set(0,0,0),de.addScaledVector(K,Ke*xe),de.addScaledVector(H,Ne),de.addScaledVector(z,Ke*be),te.copy(k).addScaledVector(de,o),u.push(te.x,te.y,te.z),c.push(de.x,de.y,de.z),d.push(0,0),se.push(h++)}G.push(se)}let Q=G.length-1;for(let q=0;q<Q;q++){let se=G[q],oe=G[q+1],ae=se.length-1;l.push(se[0],oe[1],oe[0]);for(let _e=1;_e<=ae;_e++)l.push(se[_e-1],se[_e],oe[_e]),l.push(se[_e],oe[_e+1],oe[_e])}}}};var aE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(e?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof vt?r.shape:new vt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:n}}static build(r){let e=r.shape,{width:t,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:t*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(w,S,_){return S>t&&_>n?Math.min(w*t/S,w*n/_):S>t?w*t/S:_>n?w*n/_:w}let f=[];f[0]=i[0]===0?0:h(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:h(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:h(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:h(i[3],i[3]+i[0],i[3]+i[2]);let m=c.x,p=d.x,g=d.y,y=c.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,y)),e.addPoint(e.createPoint(m,y)),e.isClosed=!0;let v=!0;for(let w=0,S=e.points.length;w<S;w++)e.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(e.roundness=f[0]),e.useCubicForRoundedCorners=s!==1,e.update();let b=_r.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...r,type:"RectangleGeometry"}})}};var lE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e=100,height:t=e,depth:n=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new ga(.5*e,i,s,o,a,l,u);return c.scale(1,t/e,n/e),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var cE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(r){let{width:e=100,height:t=e,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new Cs(e,t,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var uE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new Tx(e,t,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},Tx=class extends Ce{constructor(e=1,t=1,n=1,i=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),i=Math.min(180-c,i),i*=Math.PI/180;let d=[],h=Math.PI/2,f=(te=0,Q=0,q=0)=>new A(te,Q,q),m=f(),p=f(),[g,y,v]=[t/2,e/2,n/2],b=-y,w=+y,[S,_,T]=[f(b,-g,+v),f(b,-g,-v),f(b,+g,-v)],x=(te,Q=!1)=>Math.sin(te-Math.PI/(1+ +Q)),M=(te,Q=!1)=>Math.cos(te-Math.PI/(1+ +Q));T.y=Math.sin(i)*t-g;let E=Math.cos(i)*t-v,C=S.z-c;i<=h?(T.z=Math.min(E,C),T.z==C&&(T.y-=(E-C)/Math.tan(h-i))):_.z=Math.min(_.z-E-v,S.z-c),m.subVectors(S,_),p.subVectors(T,_);let P=Math.min(m.length(),p.length())*s/100,O=P*Math.tan(i/2),I=P/Math.cos(i/2),N=m.clone().normalize().add(p.normalize()).setLength(I).add(_);m.set(0,x(i,!0),M(i,!0)),d.push([T,m.clone()]);let B=(Math.PI-i)/o;for(let te=0;te<=o;te++){let Q=h+i+te*B;m.set(0,Math.sin(Q)*O,Math.cos(Q)*O),m.add(N),p.set(0,x(Q),M(Q)),d.push([m.clone(),p.clone()])}d.push([S,f(0,1,0)]);let W=Math.sin(B/2)*O*2,X=d.length-1,F=d[0][0].distanceTo(d[1][0]),k=d[X-1][0].distanceTo(d[X][0]),K=F+W*o+k;d[0].push(1);for(let te=0;te<=o;te++)d[te+1].push(1-(F+te*W)/K);d[X].push(0);let[H,z,j]=d[0],Y,G,de;for(let te=1;te<d.length;te++)[Y,G,de]=d[te],a.push(b,H.y,H.z,b,Y.y,Y.z,w,H.y,H.z,w,H.y,H.z,b,Y.y,Y.z,w,Y.y,Y.z),l.push(0,z.y,z.z,0,G.y,G.z,0,z.y,z.z,0,z.y,z.z,0,G.y,G.z,0,G.y,G.z),u.push(0,j,0,de,1,j,1,j,0,de,1,de),[H,z,j]=[Y,G,de];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var dE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof vt?r.shape:new vt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,d=e*.5,h=t*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let w=0;w<i;w++){let S=p*w,_=f+Math.sin(S)*d,T=m+Math.cos(S)*h;c.addPoint(c.createPoint(_,T))}}else for(let w=0;w<i;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<=i,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 b=_r.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(b,{userData:{...r,type:"StarGeometry"}})}};var hE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t}=r.parameters,n=new Cs(e,t);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var fE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.round(Math.abs(t.depth??t.width*.25));return{parameters:Object.assign(t,{width:n,height:i,depth:s})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=S4(e,t,n,e*.5,o,s,0,0,i,a,l);return u.scale(1,t/e,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function S4(r,e,t,n,i,s,o,a,l,u,c){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(u=0),new ka(!0,r,e,t,n,i,s,o,a,l,u,c)}var pE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(r){let{width:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=e*.5;a!==t&&(a-=t);let l=new Bl(a,t,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var mE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof vt?r.shape:new vt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e=100,height:t,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,u=e*.5,c=t*.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=_r.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...r,type:"TriangleGeometry"}})}};function A4(){let r=new Ce;return r.setAttribute("position",new Be(new Float32Array([]),3)),r.setIndex(new Be(new Uint16Array([]),1)),r}var _4=12,T4=1,lu=class extends Ce{constructor(t,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];this.userData={parameters:t,type:"TextGeometry"};let i=n.getFont(t.font);i?.isLoaded?(this.font=i,this.update(t)):this.updateFont(t.font,n).then(()=>{this.update(t),n?.requestRender()})}async updateFont(t,n){let i=n.getFont(t);i&&(this.font=i,await i.loadingPromise)}update(t){let n=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=t,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=M4(t,n,d),{shapes:f,charWidths:m,charCoords:p}=n.generateShapes(h,t),g=i*.5,y=s*.5,v=f.map(S=>new vt().fromShape(S));this.vectorShapes=v;let b=v.map(S=>_r.create({shape:S,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?It.NONZERO:It.ODD,subdivisions:this.isLowResolution&&o>0?T4:_4}})),w=b.length?Us(b):A4();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 t=Ki(new Ce,lu.prototype);return t.copy(this),console.log("CloneGeometry",this,t),t}copy(t){return Object.entries(t.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:t})}get text(){return this.userData.parameters.text??""}};function M4(r,e,t){t=t??r.text;let n=[""],i="";for(let s of t)i+=s,s===" "||s===`
3138
3138
  `?(n[n.length-1]+=i,i="",s===`
3139
- `&&n.push("")):e.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),e.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var yE,cu=new Promise(r=>{yE=r}),gE=!1;async function vE(){if(gE)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.217/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),i=t.default,s=await i({wasmBinary:n});yE(s),gE=!0}function Va(r,e,t){let n={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let s=vt.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new kl().parse(r);else{if(r.type==="SubdivGeometry")return new ln(r,t);if(r.type==="TextGeometry")return new lu(r,e)}let i;try{i=Mx(n)}catch(s){console.error(s)}if(!i){let s=vt.createFromState(Dc.defaultData(),100,100);n.shape=s,i=Mx(n)}return i}var E4=new he;function uh(r,e,t,n){let i=r.position.array,s=r.normal.array,o=E4.makeScale(e,t,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=e,i[c+1]*=t,i[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;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var Wm=new gt,uu=new A,Ve;cu.then(r=>{Ve=r});var xE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),bE=new Uint32Array([0,1,2,3]),wE=new Uint8Array([4]),ln=class extends Ce{constructor(t,n){super();this.data=t;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=Yi.div(n,i);this.subdividedGeometry&&uh(this.subdividedGeometry.attributes,...s),this.originalGeometry&&uh(this.originalGeometry.attributes,...s),this.data=t;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(uu.fromArray(s));let a=uu.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 t,n,i;try{({originalGeometry:t,subdividedGeometry:n,subdivPointer:i}=ln.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new In(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ln.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new pn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let n=t.attributes.position,i=t.boundingSphere.center;Wm.setFromBufferAttribute(n),Wm.getCenter(i),t.boundingSphere.radius=i.distanceTo(Wm.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Wm.getSize(uu);let s={width:uu.x,height:uu.y,depth:uu.z};return this.userData.parameters=s,s}static build(t,n,i,s){let o,a,l,u=t?.phongAngle??35;i===!1&&(u=-1),n&&(Ve.free_bvh(n),Ve.free_subdivision_surface(n));try{o=ln.allocate(t,s)}catch(c){console.error(c,t),o=ln.allocate({positionWASM:xE,indexWASM:bE,verticesPerFaceWASM:wE},s)}if(Ve.set_destination_refinement_level(o,0),a=ln.buildLevel(o,!0,u),t.subdivisions>0)try{Ve.set_destination_refinement_level(o,t.subdivisions),l=ln.buildLevel(o,!1,u)}catch{try{Ve.set_destination_refinement_level(o,t.subdivisions-1),l=ln.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(t,n,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let s;if(t.type==="TorusGeometry"&&t.arc===Math.PI*2){let{width:d,height:h,depth:f,arc:m,tubularSegments:p,radialSegments:g}=t;s=new ka(!0,d,f,h,d*.5,m/(2*Math.PI),p,f/2,0,g,0,0,!0)}else s=t.shape!==void 0?n.geometry:Va(t,i,!1);let o,a,l,u;({positions:o,triIndices:u}=dh(s.getAttribute("position"),s.getIndex()));let c;if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let d=t.radialSegments*t.heightSegments*3*2,h=d+t.radialSegments*3;c=[d,h]}return{indices:a,verticesPerFace:l}=Ix(o,u,s,c),{positions:o,indices:a,verticesPerFace:l}}static allocate(t,n){let i,s,o,a=[],l=[];t.positionWASM&&t.positionWASM.length>0?(i=t.positionWASM,s=t.indexWASM,o=t.verticesPerFaceWASM):(i=xE,s=bE,o=wE);let u=i.length,c=s.length,d=o.length,h=i.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=Ve._malloc(m),v=new Float32Array(Ve.HEAPF32.buffer,y,h),b=new Uint32Array(Ve.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),b.set(s,0),b.set(o,s.length);let w;t?.scaleBaked?.some(_=>_!==1)&&(w=new he().makeScale(...t.scaleBaked)),n&&(w?w.premultiply(n):w=n);let S=w?Ve.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Ve.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Ve._free(y),S}static buildLevel(t,n,i,s,o){let a=o?Ve.get_mesh_data2(t,n?Ve.Level.CONTROL:Ve.Level.REFINED,i,o.elements):Ve.get_mesh_data(t,n?Ve.Level.CONTROL:Ve.Level.REFINED,i),l=8,u=Ve.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Ve.HEAPU32[u[d]>>2],f=Ve.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let m=Ve.HEAPU32[u[d]>>2],p=Ve.HEAPF32.subarray(m>>2,(m>>2)+c[d]);d++;let g=Ve.HEAPU32[u[d]>>2],y=Ve.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=Ve.HEAPU32[u[d]>>2],b=Ve.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let w=new Ce;if(w.setIndex(new co(b,1)),w.setAttribute("position",new Ae(f,3)),w.setAttribute("normal",new Ae(p,3)),n){w.setAttribute("faceMap",new co(y,1));let S=new Float32Array(p.length/3*4).fill(0);w.setAttribute("color",new Be(S,4))}return Ve.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,Ve.free_mesh_data(a)}static freeSubdivPointer(t){Ve.free_bvh(t),Ve.free_subdivision_surface(t)}static buildControlCageWireframe(t,n,i){let s=Ve.get_wireframe_data_for_base_level(t),o=4,a=Ve.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Ve.HEAPU32[a[u]>>2],d=Ve.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Ve.HEAPU32[a[u]>>2],f=Ve.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let m=new Ce;m.setAttribute("position",new Ae(d,3));let p=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return m.setAttribute("color",new Be(p,3)),m.setIndex(new co(f,1)),Ve.free_wireframe_data_for_base_level(s),m}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Ve.free_wireframe_data_for_base_level(s)}static updateCollabMesh(t,n,i){let s=n===0;s||Ve.set_destination_refinement_level(t,n);let o=i?Ve.get_topological_data2(t,s?Ve.Level.CONTROL:Ve.Level.REFINED,i.elements):Ve.get_topological_data(t,s?Ve.Level.CONTROL:Ve.Level.REFINED),a=6,l=Ve.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Ve.HEAPU32[l[c]>>2],h=new Float32Array(Ve.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Ve.HEAPU32[l[c]>>2],m=new Uint32Array(Ve.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Ve.HEAPU32[l[c]>>2],g=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Ve.free_topological_data(o),{positions:h,indices:m,verticesPerFace:g}}};var SE=["getX","getY","getZ"];function dh(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=e?e.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[SE[h]](c)*a)},`;if(d in t)s.push(t[d]);else{for(let h=0;h<3;h++)o.push(r[SE[h]](c));t[d]=i,s.push(i),i++}}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 jm=new A,Ex=new A,Cx=new A,Px=new A;function Ix(r,e,t,n){let i=[],s=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let o=t.userData.shape.extractShapePointsToFlatArray([]),a=t.userData.parameters.spikes;if(t.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&t.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]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=t.capStartIndex??e.length;o<a;)if(e[o+1]===e[o+3]&&e[o+2]===e[o+5]||e[o+0]===e[o+3]&&e[o+2]===e[o+4]){jm.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),Ex.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),Cx.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),Px.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),Ex.sub(jm).normalize(),Cx.sub(jm).normalize(),Px.sub(jm).normalize();let l=Ex.cross(Cx).dot(Px);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3):(i.push(e[o],e[o+1],e[o+4],e[o+5]),s.push(4),o+=6)}else i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3;if(t.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([t.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(t.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Si={};hw(Si,{calcBoolean:()=>I4,calcBooleanTopological:()=>P4,freeMeshSet:()=>L4,getMeshSet:()=>D4,transformMeshSet:()=>O4});var _E,TE=new Promise(r=>{_E=r}),AE=!1;async function ME(){if(AE)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.217/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=t.default,s=await i({wasmBinary:n});_E(s),AE=!0}var ct,du;TE.then(r=>ct=r);function C4(r,e,t){let n,{positions:i,triIndices:s}=dh(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=Ix(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let d=0;d<l[u];d++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function EE(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=ct._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(ct.HEAPU32.buffer,s,e):new Float32Array(ct.HEAPF32.buffer,s,e)).set(r,0),s}function CE(r){switch(r){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 "+r)}}function P4(r,e){du===void 0&&(du=ct.init_csg());let t=EE(r),n=ct.csg_calc_topological(du,t,r.length,CE(e));ct._free(t);let i=6,s=ct.HEAPU32.subarray(n>>2,(n>>2)+i),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 I4(r,e,t,n){du===void 0&&(du=ct.init_csg());let i=EE(r),s=ct.csg_calc(du,i,r.length,n,CE(e));ct._free(i);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];t.setAttribute("position",new Ae(d,3)),t.setAttribute("normal",new Ae(f,3));let p=ct.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new pn),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ct.free_mesh_data(s),m}function D4(r,e,t){if(ct===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,b=0;y<g.verticesPerFace.length;y++){i[b++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)i[b++]=g.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=C4(r,e,t));let o=n.length,a=i.length,l=n.length,u=i.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(i,0),ct.get_csg_mesh(f,o,f+d,a,s)}function O4(r,e){ct.transform_csg_mesh(r,e.elements)}function L4(r){ct.free_csg_mesh(r)}var R4={ConeGeometry:EM,CubeGeometry:CM,CylinderGeometry:MM,DodecahedronGeometry:PM,EllipseGeometry:QM,HelixGeometry:tE,IcosahedronGeometry:nE,LatheGeometry:rE,NonParametricGeometry:iE,PolygonGeometry:sE,PyramidGeometry:oE,RectangleGeometry:aE,SphereGeometry:lE,PlaneGeometry:cE,BackdropGeometry:uE,StarGeometry:dE,TextFrameGeometry:hE,TorusGeometry:fE,TorusKnotGeometry:pE,TriangleGeometry:mE,VectorGeometry:_r},Mx=r=>R4[r.type].create(r);function hh(r){return r!==null&&"booleanOp"in r}var hu=class extends Nm(Cn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new he}updateVisible(){super.updateVisible(),this.visible=!hh(this.parent)&&this.visible,hh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Si.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),hh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof hu&&(t.freeBooleanPointer(),hh(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t){let n=super.updateTransformState(t);return n&&hh(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var qm=new gt;function Dx(r,e=0,t=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=e;d<t;d++){let h=r.getX(d),f=r.getY(d),m=r.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)}qm.min.set(s,o,a),qm.max.set(l,u,c),qm.getCenter(n),qm.getSize(i).multiplyScalar(.5)}var N4=new Ce,B4=new Es,kt=class extends hu{constructor(e,t){super(N4,B4),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let n=this.geometry.getAttribute("position");n!==void 0?Dx(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,t):super.updateEntityBoxSize(e,t)}};var fh=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var Un=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=ze.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof Un&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}};var Ox=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},_n=new Ox;var Ge=class extends Un{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=ze.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let u=this.getTemp(t,i);if(u)return t.format(u,l,n);{u=super.generate(t,n,i,a.output,s);let c=this.generate(t,l,i);return t.addNodeCode(u+" = "+c+";"),t.format(u,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Dt=class extends Ge{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}};var Gn=class extends Dt{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof U?t:new U(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var qn=class extends Dt{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var $t=class extends Oe{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var ti=class extends Dt{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof $t?t:new $t(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var F4=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,PE=/[a-z_0-9]+/gi,Te=class extends Ge{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)t.include(this.includes[d],this);for(let d in this.extensions)t.extensions[d]=!0;let c=[];for(;a=PE.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&&_n.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=_n.getKeywordData(f);y.cache&&(g=t.keywords[f]),g=g||_n.getKeyword(f,t),y.cache&&(t.keywords[f]=g)}p=g.build(t)}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&&_n.contains(p)&&t.include(_n.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||t.include(this,void 0,u),this.name):t.format("( "+u+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=F4.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(PE);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 U4=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Lx=class extends Ge{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||Lx.PI,void 0,void 0,void 0,n)}getType(t){return t.getTypeByFormat(this.type)}parse(t,n,i,s,o){this.src=t||"";let a,l,u="",c=U4.exec(t);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(t,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 t.include(this),t.format(this.name,this.getType(t),n)}generate(t,n,i,s,o){return t.format(this.name,this.getType(t),n)}},pt=Lx;pt.PI="PI",pt.PI2="PI2",pt.RECIPROCAL_PI="RECIPROCAL_PI",pt.RECIPROCAL_PI2="RECIPROCAL_PI2",pt.LOG2="LOG2",pt.EPSILON="EPSILON";var G4=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3139
+ `&&n.push("")):e.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),e.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var yE,cu=new Promise(r=>{yE=r}),gE=!1;async function vE(){if(gE)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.218/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),i=t.default,s=await i({wasmBinary:n});yE(s),gE=!0}function Va(r,e,t){let n={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let s=vt.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new kl().parse(r);else{if(r.type==="SubdivGeometry")return new ln(r,t);if(r.type==="TextGeometry")return new lu(r,e)}let i;try{i=Mx(n)}catch(s){console.error(s)}if(!i){let s=vt.createFromState(Dc.defaultData(),100,100);n.shape=s,i=Mx(n)}return i}var E4=new he;function uh(r,e,t,n){let i=r.position.array,s=r.normal.array,o=E4.makeScale(e,t,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=e,i[c+1]*=t,i[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;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var Wm=new gt,uu=new A,Ve;cu.then(r=>{Ve=r});var xE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),bE=new Uint32Array([0,1,2,3]),wE=new Uint8Array([4]),ln=class extends Ce{constructor(t,n){super();this.data=t;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=Yi.div(n,i);this.subdividedGeometry&&uh(this.subdividedGeometry.attributes,...s),this.originalGeometry&&uh(this.originalGeometry.attributes,...s),this.data=t;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(uu.fromArray(s));let a=uu.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 t,n,i;try{({originalGeometry:t,subdividedGeometry:n,subdivPointer:i}=ln.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new In(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ln.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new pn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let n=t.attributes.position,i=t.boundingSphere.center;Wm.setFromBufferAttribute(n),Wm.getCenter(i),t.boundingSphere.radius=i.distanceTo(Wm.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Wm.getSize(uu);let s={width:uu.x,height:uu.y,depth:uu.z};return this.userData.parameters=s,s}static build(t,n,i,s){let o,a,l,u=t?.phongAngle??35;i===!1&&(u=-1),n&&(Ve.free_bvh(n),Ve.free_subdivision_surface(n));try{o=ln.allocate(t,s)}catch(c){console.error(c,t),o=ln.allocate({positionWASM:xE,indexWASM:bE,verticesPerFaceWASM:wE},s)}if(Ve.set_destination_refinement_level(o,0),a=ln.buildLevel(o,!0,u),t.subdivisions>0)try{Ve.set_destination_refinement_level(o,t.subdivisions),l=ln.buildLevel(o,!1,u)}catch{try{Ve.set_destination_refinement_level(o,t.subdivisions-1),l=ln.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(t,n,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let s;if(t.type==="TorusGeometry"&&t.arc===Math.PI*2){let{width:d,height:h,depth:f,arc:m,tubularSegments:p,radialSegments:g}=t;s=new ka(!0,d,f,h,d*.5,m/(2*Math.PI),p,f/2,0,g,0,0,!0)}else s=t.shape!==void 0?n.geometry:Va(t,i,!1);let o,a,l,u;({positions:o,triIndices:u}=dh(s.getAttribute("position"),s.getIndex()));let c;if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let d=t.radialSegments*t.heightSegments*3*2,h=d+t.radialSegments*3;c=[d,h]}return{indices:a,verticesPerFace:l}=Ix(o,u,s,c),{positions:o,indices:a,verticesPerFace:l}}static allocate(t,n){let i,s,o,a=[],l=[];t.positionWASM&&t.positionWASM.length>0?(i=t.positionWASM,s=t.indexWASM,o=t.verticesPerFaceWASM):(i=xE,s=bE,o=wE);let u=i.length,c=s.length,d=o.length,h=i.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=Ve._malloc(m),v=new Float32Array(Ve.HEAPF32.buffer,y,h),b=new Uint32Array(Ve.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),b.set(s,0),b.set(o,s.length);let w;t?.scaleBaked?.some(_=>_!==1)&&(w=new he().makeScale(...t.scaleBaked)),n&&(w?w.premultiply(n):w=n);let S=w?Ve.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Ve.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Ve._free(y),S}static buildLevel(t,n,i,s,o){let a=o?Ve.get_mesh_data2(t,n?Ve.Level.CONTROL:Ve.Level.REFINED,i,o.elements):Ve.get_mesh_data(t,n?Ve.Level.CONTROL:Ve.Level.REFINED,i),l=8,u=Ve.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Ve.HEAPU32[u[d]>>2],f=Ve.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let m=Ve.HEAPU32[u[d]>>2],p=Ve.HEAPF32.subarray(m>>2,(m>>2)+c[d]);d++;let g=Ve.HEAPU32[u[d]>>2],y=Ve.HEAPU32.subarray(g>>2,(g>>2)+c[d]);d++;let v=Ve.HEAPU32[u[d]>>2],b=Ve.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let w=new Ce;if(w.setIndex(new co(b,1)),w.setAttribute("position",new Ae(f,3)),w.setAttribute("normal",new Ae(p,3)),n){w.setAttribute("faceMap",new co(y,1));let S=new Float32Array(p.length/3*4).fill(0);w.setAttribute("color",new Be(S,4))}return Ve.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,Ve.free_mesh_data(a)}static freeSubdivPointer(t){Ve.free_bvh(t),Ve.free_subdivision_surface(t)}static buildControlCageWireframe(t,n,i){let s=Ve.get_wireframe_data_for_base_level(t),o=4,a=Ve.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Ve.HEAPU32[a[u]>>2],d=Ve.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Ve.HEAPU32[a[u]>>2],f=Ve.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let m=new Ce;m.setAttribute("position",new Ae(d,3));let p=new Float32Array(d.length);for(let g=0,y=d.length;g<y;)p[g++]=i.r,p[g++]=i.g,p[g++]=i.b;return m.setAttribute("color",new Be(p,3)),m.setIndex(new co(f,1)),Ve.free_wireframe_data_for_base_level(s),m}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Ve.free_wireframe_data_for_base_level(s)}static updateCollabMesh(t,n,i){let s=n===0;s||Ve.set_destination_refinement_level(t,n);let o=i?Ve.get_topological_data2(t,s?Ve.Level.CONTROL:Ve.Level.REFINED,i.elements):Ve.get_topological_data(t,s?Ve.Level.CONTROL:Ve.Level.REFINED),a=6,l=Ve.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Ve.HEAPU32[l[c]>>2],h=new Float32Array(Ve.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Ve.HEAPU32[l[c]>>2],m=new Uint32Array(Ve.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Ve.HEAPU32[l[c]>>2],g=new Uint8Array(Ve.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Ve.free_topological_data(o),{positions:h,indices:m,verticesPerFace:g}}};var SE=["getX","getY","getZ"];function dh(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=e?e.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[SE[h]](c)*a)},`;if(d in t)s.push(t[d]);else{for(let h=0;h<3;h++)o.push(r[SE[h]](c));t[d]=i,s.push(i),i++}}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 jm=new A,Ex=new A,Cx=new A,Px=new A;function Ix(r,e,t,n){let i=[],s=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let o=t.userData.shape.extractShapePointsToFlatArray([]),a=t.userData.parameters.spikes;if(t.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&t.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]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=t.capStartIndex??e.length;o<a;)if(e[o+1]===e[o+3]&&e[o+2]===e[o+5]||e[o+0]===e[o+3]&&e[o+2]===e[o+4]){jm.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),Ex.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),Cx.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),Px.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),Ex.sub(jm).normalize(),Cx.sub(jm).normalize(),Px.sub(jm).normalize();let l=Ex.cross(Cx).dot(Px);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3):(i.push(e[o],e[o+1],e[o+4],e[o+5]),s.push(4),o+=6)}else i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3;if(t.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([t.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(t.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Si={};hw(Si,{calcBoolean:()=>I4,calcBooleanTopological:()=>P4,freeMeshSet:()=>L4,getMeshSet:()=>D4,transformMeshSet:()=>O4});var _E,TE=new Promise(r=>{_E=r}),AE=!1;async function ME(){if(AE)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.218/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=t.default,s=await i({wasmBinary:n});_E(s),AE=!0}var ct,du;TE.then(r=>ct=r);function C4(r,e,t){let n,{positions:i,triIndices:s}=dh(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=Ix(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let d=0;d<l[u];d++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function EE(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=ct._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(ct.HEAPU32.buffer,s,e):new Float32Array(ct.HEAPF32.buffer,s,e)).set(r,0),s}function CE(r){switch(r){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 "+r)}}function P4(r,e){du===void 0&&(du=ct.init_csg());let t=EE(r),n=ct.csg_calc_topological(du,t,r.length,CE(e));ct._free(t);let i=6,s=ct.HEAPU32.subarray(n>>2,(n>>2)+i),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 I4(r,e,t,n){du===void 0&&(du=ct.init_csg());let i=EE(r),s=ct.csg_calc(du,i,r.length,n,CE(e));ct._free(i);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];t.setAttribute("position",new Ae(d,3)),t.setAttribute("normal",new Ae(f,3));let p=ct.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new pn),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ct.free_mesh_data(s),m}function D4(r,e,t){if(ct===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,b=0;y<g.verticesPerFace.length;y++){i[b++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)i[b++]=g.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=C4(r,e,t));let o=n.length,a=i.length,l=n.length,u=i.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(i,0),ct.get_csg_mesh(f,o,f+d,a,s)}function O4(r,e){ct.transform_csg_mesh(r,e.elements)}function L4(r){ct.free_csg_mesh(r)}var R4={ConeGeometry:EM,CubeGeometry:CM,CylinderGeometry:MM,DodecahedronGeometry:PM,EllipseGeometry:QM,HelixGeometry:tE,IcosahedronGeometry:nE,LatheGeometry:rE,NonParametricGeometry:iE,PolygonGeometry:sE,PyramidGeometry:oE,RectangleGeometry:aE,SphereGeometry:lE,PlaneGeometry:cE,BackdropGeometry:uE,StarGeometry:dE,TextFrameGeometry:hE,TorusGeometry:fE,TorusKnotGeometry:pE,TriangleGeometry:mE,VectorGeometry:_r},Mx=r=>R4[r.type].create(r);function hh(r){return r!==null&&"booleanOp"in r}var hu=class extends Nm(Cn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new he}updateVisible(){super.updateVisible(),this.visible=!hh(this.parent)&&this.visible,hh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Si.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),hh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof hu&&(t.freeBooleanPointer(),hh(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t){let n=super.updateTransformState(t);return n&&hh(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var qm=new gt;function Dx(r,e=0,t=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=e;d<t;d++){let h=r.getX(d),f=r.getY(d),m=r.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)}qm.min.set(s,o,a),qm.max.set(l,u,c),qm.getCenter(n),qm.getSize(i).multiplyScalar(.5)}var N4=new Ce,B4=new Es,kt=class extends hu{constructor(e,t){super(N4,B4),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let n=this.geometry.getAttribute("position");n!==void 0?Dx(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,t):super.updateEntityBoxSize(e,t)}};var fh=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var Un=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=ze.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof Un&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}};var Ox=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},_n=new Ox;var Ge=class extends Un{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=ze.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let u=this.getTemp(t,i);if(u)return t.format(u,l,n);{u=super.generate(t,n,i,a.output,s);let c=this.generate(t,l,i);return t.addNodeCode(u+" = "+c+";"),t.format(u,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Dt=class extends Ge{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}};var Gn=class extends Dt{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof U?t:new U(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var qn=class extends Dt{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var $t=class extends Oe{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var ti=class extends Dt{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof $t?t:new $t(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var F4=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,PE=/[a-z_0-9]+/gi,Te=class extends Ge{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)t.include(this.includes[d],this);for(let d in this.extensions)t.extensions[d]=!0;let c=[];for(;a=PE.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&&_n.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=_n.getKeywordData(f);y.cache&&(g=t.keywords[f]),g=g||_n.getKeyword(f,t),y.cache&&(t.keywords[f]=g)}p=g.build(t)}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&&_n.contains(p)&&t.include(_n.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||t.include(this,void 0,u),this.name):t.format("( "+u+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=F4.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(PE);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 U4=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Lx=class extends Ge{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||Lx.PI,void 0,void 0,void 0,n)}getType(t){return t.getTypeByFormat(this.type)}parse(t,n,i,s,o){this.src=t||"";let a,l,u="",c=U4.exec(t);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(t,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 t.include(this),t.format(this.name,this.getType(t),n)}generate(t,n,i,s,o){return t.format(this.name,this.getType(t),n)}},pt=Lx;pt.PI="PI",pt.PI2="PI2",pt.RECIPROCAL_PI="RECIPROCAL_PI",pt.RECIPROCAL_PI2="RECIPROCAL_PI2",pt.LOG2="LOG2",pt.EPSILON="EPSILON";var G4=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3140
3140
  )*?)}`,"gim"),k4=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),fu=class extends Ge{constructor(t=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(t)}getType(t){return t.getTypeByFormat(this.name)}getInputByName(t){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}generate(t,n,i,s,o){return n==="source"?this.src+";":t.format("( "+this.src+" )",this.getType(t),n)}parse(t=""){this.src=t,this.inputs=[];let n=G4.exec(t);if(n){let i=n[2],s;for(;s=k4.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var pu=class extends Ge{constructor(t){super("v2",{shared:!1});this.nodeType="UV";this.index=t??0}generate(t,n){t.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=t.isShader("vertex")?"uv"+i:"vUv"+i;return t.format(s,this.getType(t),n)}};_n.addKeyword("uv",function(){return new pu});_n.addKeyword("uv2",function(){return new pu(1)});var Ha=class extends Ge{constructor(t,n){super("v4");this.nodeType="ColorSpace";this.input=t,this.method=n??Ha.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(t){switch(t){case Rr:return["Linear"];case Ye:return["sRGB"];default:return[]}}generate(t,n){let i=this.input.build(t,"v4"),s=this.getType(t),o=Ha.Nodes[this.method],a=t.include(o);if(a===Ha.LINEAR_TO_LINEAR)return t.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(t,"f");return t.format(a+"( "+i+", "+l+" )",s,n)}else return t.format(a+"( "+i+" )",s,n)}fromEncoding(t){let n=Ha.getEncodingComponents(t);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(t){let n=Ha.getEncodingComponents(t);this.method=n[0]+"ToLinear",this.factor=n[1]}},fr=Ha;fr.Nodes={LinearToLinear:new Te(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3141
3141
  `)),sRGBToLinear:new Te(["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(`
3142
3142
  `)),LinearTosRGB:new Te(["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(`
@@ -4910,7 +4910,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
4910
4910
  }
4911
4911
  `,wg=new yt({vertexShader:LH,fragmentShader:RH,uniforms:{depthContrast:{value:1}}});var Sg=new Es;Sg.wireframe=!0;var AC=new A,db=class extends or{constructor(t,n){super();this.data=t;this.backupFog=new Cl(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new $t(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.needsRecomputeInstances=!1;this.ambientLight=new Qf(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=t.postprocessing,this.init(t,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=xC(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=vC(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(t){let n=t.identity.join("-"),i=this.entityIdentityToEntity[n];i&&(t.uuid=i.uuid),this.entityIdentityToEntity[n]=t,this.entityByUuid[t.uuid]=t}findInstance(t){return this.entityIdentityToEntity[t.join("-")]}getWithSortKey(t){let n=this.find(t);if(n===void 0)return;let i=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);i.splice(0,0,a)}return{entity:n,sortKey:i}}getAllSorted(t){let n=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&n.push(s)}return n.sort((i,s)=>RT(i.sortKey,s.sortKey)),n.map(i=>i.entity)}nonExistOrDescendantOf(t,n){let i=this.find(t);if(i===void 0)return!0;for(;i;){if(i.uuid===n)return!0;i=i.parent}return!1}find(t){if(t===""||t===void 0)return;let n=this.entityByUuid[t];return n===void 0?this.getObjectByProperty("uuid",t):n}debugEnsureEntity(t){let n=this.find(t);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(t){this.toExpandCloner.add(t)}addPendingUpdateCloner(t){this.toUpdateCloner.add(t)}markToExpandCloner(t){this.toExpandCloner.add(t),t.traverseEntityAncestors(n=>{this.toExpandCloner.add(n)})}doPendingExpandCloner(){this.toExpandCloner.forEach(t=>{t.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(t=>{t.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner()}updateTreeByOp(t,n){if(t.path.length===0&&t.type===7){let i=t.parent===null?this:this.find(t.parent);if(i===void 0)throw new Error("unexpected");let s=this.createObject(t.id,t.data,t.children,i,t.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),zr(s)&&Vr(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s)}else if(t.path.length===0&&t.type===8){let i=this.find(t.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(i),i.parent.remove(i),Vr(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),zr(i)&&(i.freeBooleanPointer(),s instanceof si&&s.invalidateDownstreamBooleanData().recomputeBoolean()),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i)}else if(t.path.length===0&&t.type===9){let i=this.find(t.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let o=t.parent===null?this:this.find(t.parent);if(o===void 0)throw new Error("unexpected");o.add(i),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate();let a=t.localIndex;o.children.splice(a,0,o.children.pop()),zr(i)&&(i.invalidateUpstreamBooleanData(),Vr(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof si&&s.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(t,n,i,s){if(n.type===0&&(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),n.path.includes("overrides")&&"states"in n.props)){let{states:a,rest:l}=n.props;n={...n,props:l},this.markNeedsRecomputeInstances()}let o=this.find(t);if(o)try{mC(o,n,i,{scene:this,shared:s}),o instanceof en&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,n){if(this.createChildrenObjects(t.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(pr(t.backgroundColor,n)),this.updateFog(t.fog,n),this.updateAmbientLight(t.environment.ambientLight,n),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof zn&&this.switchActiveCamera(i)}this.expandInstances(n,!0),this.traverseEntity(i=>{Vr(i)&&i.recomputeBoolean()}),this.doPendingExpandCloner()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(t){t.traverseEntity(n=>{(n.data.type==="Component"||n.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(t){Gt.is(t)&&(t.data.type==="Component"&&this.markNeedsRecomputeInstances(),t.traverseAncestors(n=>{Gt.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(t,n,i,s,o,a,l){t&&t!==s.uuid&&s.find(t)&&o.forInstancesRec(c=>{c.isInstanceRoot||(c.data=Ec(c.data,d=>{let h=d.events.data(l.id),f=c.goUp(a);if(f){let m=[...dm(f.identity),t].join("-"),p=this.entityIdentityToEntity[m];if(p){let g=p.uuid;lr.zoom(h,n)[i]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(t=>{if(t instanceof Ci&&typeof t.identity=="string"&&t.data.type==="Component")return t.traverseEntity((n,i)=>{n.data.events.forEach(s=>{s.data.type==="GameControl"?n.forInstancesRec(o=>{o.isInstanceRoot||(o.data=Ec(o.data,a=>{a.events.delete(s.id)}).data)}):s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",t,n,i,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",t,n,i,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",t,n,i,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,t,n,i,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,t,n,i,s)),s.data.inActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["inActions",o.id],"object",t,n,i,s)}),s.data.outActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["outActions",o.id],"object",t,n,i,s)})):"actions"in s.data&&s.data.actions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["actions",o.id],"object",t,n,i,s)})})}),!0})}expandInstances(t,n){let i=new Set;this.traverseEntity(s=>{if(s instanceof Ci&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:t,pendingDeletes:i}),n||s.resetBBoxNeedsUpdate(),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),xg(s)}recomputeInstances(t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof Ci&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(t,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(t){t.traverseEntity(n=>{let i=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[i]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[i]),n.dispose()})}clearScene(){for(let t of this.children)hr(t)&&t.disposeRecursively();this.children.length=0}resetAfterClear(t,n){this.init(t,n)}createPersonalCamera(){let t=new zn(db.PERSONAL_CAMERA_ID,{...Lc.defaultData,name:"Personal Camera"});return t.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(t),t}raycast(t){let n=[],i=s=>{for(let o of s.children)hr(o)&&!o.raycastLock&&o.visible&&((zr(o)||cC(o)&&this.enableHelpers&&o.objectHelper.visible)&&(t.intersectObject(o,!1,n),bC(o,t,n)),i(o))};return i(this),n}forEachEntity(t){for(let n of this.children)hr(n)&&t(n)}traverseEntity(t){for(let n of this.children)hr(n)&&n.traverseEntity(t)}traverseObject(t){for(let n of this.children)eh.is(n)&&n.traverseObject(t)}traverseVisibleEntity(t){for(let n of this.children)hr(n)&&n.visible&&n.traverseVisibleEntity(t)}updateFog(t,n){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=pr(t.color,n),this.backupFog.near=t.near,this.backupFog.far=t.far}dispose(){this.clearScene()}updateAmbientLight(t,n){t.color!==void 0&&(this.ambientLight.color=pr(t.color,n)),t.intensity!==void 0&&(this.ambientLight.intensity=t.intensity),t.groundColor!==void 0&&(this.ambientLight.groundColor=pr(t.groundColor,n)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}createChildrenObjects(t,n,i){let s=0;for(let o of t)this.createObject(o.id,o.data,o.children,n,s,i),s+=1}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let n of t.children)this.unregisterObject(n)}createObject(t,n,i,s,o,a){let l={scene:this,shared:a},u=bg(t,n,l);return u&&(this.entityByUuid[t]=u,s.add(u),s.children.splice(o,0,s.children.pop()),i.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,u,a)),u.updateState(n,l),u instanceof en&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u)),u}getCenter(t){let n=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;n.push(...c.vertices)}let i=new gt;return i.setFromPoints(n),i.getCenter(AC),AC}copyMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(t){this.traverseEntity(n=>{if(n instanceof kt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)n.material[i]instanceof Cr&&t(n.material[i]);else n.material instanceof Cr&&t(n.material)})}updateCanvasSize(t,n){this.activeCamera.setViewplaneSize(t,n);let i,s;t>=n?(i=n/t,s=1):(i=1,s=t/n),this.traverseMaterial(o=>{o.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},qs=db;qs.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var zh=(r,e)=>{let t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)},_C=(r,e)=>{let t=e.x-r.x,n=e.y-r.y;return NH(Math.atan2(n,t))},TC=(r,e,t)=>{let n={x:0,y:0};return t=Ag(t),n.x=r.x-e*Math.cos(t),n.y=r.y-e*Math.sin(t),n},Ag=r=>r*(Math.PI/180),NH=r=>r*(180/Math.PI),MC=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,hb=new Map,fb=r=>{hb.has(r)&&clearTimeout(hb.get(r)),hb.set(r,setTimeout(r,100))},Iu=(r,e,t)=>{let n=e.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.addEventListener?r.addEventListener(i,t,!1):r.attachEvent&&r.attachEvent(i,t)},pb=(r,e,t)=>{let n=e.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.removeEventListener?r.removeEventListener(i,t):r.detachEvent&&r.detachEvent(i,t)};var _g=r=>(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),mb=()=>{if(typeof window>"u")return;let r=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:r,y:e}},Tg=(r,e)=>{e.top||e.right||e.bottom||e.left?(r.style.top=e.top,r.style.right=e.right,r.style.bottom=e.bottom,r.style.left=e.left):(r.style.left=e.x+"px",r.style.top=e.y+"px")},Mg=(r,e,t)=>{let n=CC(r);for(let i in n)if(n.hasOwnProperty(i))if(typeof e=="string")n[i]=e+" "+t;else{let s="";for(let o=0,a=e.length;o<a;o+=1)s+=e[o]+" "+t+", ";n[i]=s.slice(0,-2)}return n},EC=(r,e)=>{let t=CC(r);for(let n in t)t.hasOwnProperty(n)&&(t[n]=e);return t},CC=r=>{let e={};return e[r]="",["webkit","Moz","o"].forEach(function(n){e[n+r.charAt(0).toUpperCase()+r.slice(1)]=""}),e},Eg=(r,e)=>{for(let t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r},PC=(r,e)=>{let t={};for(let n in r)r.hasOwnProperty(n)&&e.hasOwnProperty(n)?t[n]=e[n]:r.hasOwnProperty(n)&&(t[n]=r[n]);return t},Vh=(r,e)=>{if(r.length)for(let t=0,n=r.length;t<n;t+=1)e(r[t]);else e(r)},IC=(r,e,t)=>({x:Math.min(Math.max(r.x,e.x-t),e.x+t),y:Math.min(Math.max(r.y,e.y-t),e.y+t)});typeof window<"u"&&(DC="ontouchstart"in window,OC=!!window.PointerEvent,LC=!!window.MSPointerEvent);var DC,OC,LC,Hh={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"}},Du,Wh={};OC?Du=Hh.pointer:LC?Du=Hh.MSPointer:DC?(Du=Hh.touch,Wh=Hh.mouse):Du=Hh.mouse;function Qa(){}Qa.prototype.on=function(r,e){var t=this,n=r.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],t._handlers_[i]=t._handlers_[i]||[],t._handlers_[i].push(e);return t};Qa.prototype.off=function(r,e){var t=this;return t._handlers_=t._handlers_||{},r===void 0?t._handlers_={}:e===void 0?t._handlers_[r]=null:t._handlers_[r]&&t._handlers_[r].indexOf(e)>=0&&t._handlers_[r].splice(t._handlers_[r].indexOf(e),1),t};Qa.prototype.trigger=function(r,e){var t=this,n=r.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],t._handlers_[i]&&t._handlers_[i].length&&t._handlers_[i].forEach(function(o){o.call(t,{type:i,target:t},e)})};Qa.prototype.config=function(r){var e=this;e.options=e.defaults||{},r&&(e.options=PC(e.options,r))};Qa.prototype.bindEvt=function(r,e){var t=this;return t._domHandlers_=t._domHandlers_||{},t._domHandlers_[e]=function(){typeof t["on"+e]=="function"?t["on"+e].apply(t,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},Iu(r,Du[e],t._domHandlers_[e]),Wh[e]&&Iu(r,Wh[e],t._domHandlers_[e]),t};Qa.prototype.unbindEvt=function(r,e){var t=this;return t._domHandlers_=t._domHandlers_||{},pb(r,Du[e],t._domHandlers_[e]),Wh[e]&&pb(r,Wh[e],t._domHandlers_[e]),delete t._domHandlers_[e],this};var Ou=Qa;function Tn(r,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=r,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(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Tn.id,Tn.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}Tn.prototype=new Ou;Tn.constructor=Tn;Tn.id=0;Tn.prototype.buildEl=function(r){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)};Tn.prototype.stylize=function(){if(this.options.dataOnly)return this;var r=this.options.fadeTime+"ms",e=EC("borderRadius","50%"),t=Mg("transition","opacity",r),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)"},Eg(n.el,t),this.options.shape==="circle"&&Eg(n.back,e),Eg(n.front,e),this.applyStyles(n),this};Tn.prototype.applyStyles=function(r){for(var e in this.ui)if(this.ui.hasOwnProperty(e))for(var t in r[e])this.ui[e].style[t]=r[e][t];return this};Tn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Tn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Tn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Tn.prototype.show=function(r){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof r=="function"&&r.call(this)},e.options.fadeTime)),e};Tn.prototype.hide=function(r){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var t=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=t,typeof r=="function"&&r.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let t=e.options.restJoystick,n={};n.x=t===!0||t.x!==!1?0:e.instance.frontPosition.x,n.y=t===!0||t.y!==!1?0:e.instance.frontPosition.y,e.setPosition(r,n)}return e};Tn.prototype.setPosition=function(r,e){var t=this;t.frontPosition={x:e.x,y:e.y};var n=t.options.fadeTime+"ms",i={};i.front=Mg("transition",["top","left"],n);var s={front:{}};s.front={left:t.frontPosition.x+"px",top:t.frontPosition.y+"px"},t.applyStyles(i),t.applyStyles(s),t.restTimeout=setTimeout(function(){typeof r=="function"&&r.call(t),t.restCallback()},t.options.fadeTime)};Tn.prototype.restCallback=function(){var r=this,e={};e.front=Mg("transition","none",""),r.applyStyles(e),r.trigger("rested",r.instance)};Tn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Tn.prototype.computeDirection=function(r){var e=r.angle.radian,t=Math.PI/4,n=Math.PI/2,i,s,o;if(e>t&&e<t*3&&!r.lockX?i="up":e>-t&&e<=t&&!r.lockY?i="left":e>-t*3&&e<=-t&&!r.lockX?i="down":r.lockY||(i="right"),r.lockY||(e>-n&&e<n?s="left":s="right"),r.lockX||(e>0?o="up":o="down"),r.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:i},r.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return r;(!u.x||!u.y)&&this.trigger("plain",r),u.x||this.trigger("plain:"+s,r),u.y||this.trigger("plain:"+o,r),u.angle||this.trigger("dir dir:"+i,r)}else this.resetDirection();return r};var RC=Tn;function cn(r,e){var t=this;t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.pressureIntervals={},t.manager=r,t.id=cn.id,cn.id+=1,t.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},t.config(e),(t.options.mode==="static"||t.options.mode==="semi")&&(t.options.multitouch=!1),t.options.multitouch||(t.options.maxNumberOfNipples=1);let n=getComputedStyle(t.options.zone.parentElement);return n&&n.display==="flex"&&(t.parentIsFlex=!0),t.updateBox(),t.prepareNipples(),t.bindings(),t.begin(),t.nipples}cn.prototype=new Ou;cn.constructor=cn;cn.id=0;cn.prototype.prepareNipples=function(){var r=this,e=r.nipples;e.on=r.on.bind(r),e.off=r.off.bind(r),e.options=r.options,e.destroy=r.destroy.bind(r),e.ids=r.ids,e.id=r.id,e.processOnMove=r.processOnMove.bind(r),e.processOnEnd=r.processOnEnd.bind(r),e.get=function(t){if(t===void 0)return e[0];for(var n=0,i=e.length;n<i;n+=1)if(e[n].identifier===t)return e[n];return!1}};cn.prototype.bindings=function(){var r=this;r.bindEvt(r.options.zone,"start"),r.options.zone.style.touchAction="none",r.options.zone.style.msTouchAction="none"};cn.prototype.begin=function(){var r=this,e=r.options;if(e.mode==="static"){var t=r.createNipple(e.position,r.manager.getIdentifier());t.add(),r.idles.push(t)}};cn.prototype.createNipple=function(r,e){var t=this,n=t.manager.scroll,i={},s=t.options,o={x:t.parentIsFlex?n.x:n.x+t.box.left,y:t.parentIsFlex?n.y:n.y+t.box.top};if(r.x&&r.y)i={x:r.x-o.x,y:r.y-o.y};else if(r.top||r.right||r.bottom||r.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=r.top,a.style.right=r.right,a.style.bottom=r.bottom,a.style.left=r.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=r,r={x:l.left+n.x,y:l.top+n.y}}var u=new RC(t,{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:e,position:r,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Tg(u.ui.el,i),Tg(u.ui.front,u.frontPosition)),t.nipples.push(u),t.trigger("added "+u.identifier+":added",u),t.manager.trigger("added "+u.identifier+":added",u),t.bindNipple(u),u};cn.prototype.updateBox=function(){var r=this;r.box=r.options.zone.getBoundingClientRect()};cn.prototype.bindNipple=function(r){var e=this,t,n=function(i,s){t=i.type+" "+s.id+":"+i.type,e.trigger(t,s)};r.on("destroyed",e.onDestroyed.bind(e)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};cn.prototype.pressureFn=function(r,e,t){var n=this,i=0;clearInterval(n.pressureIntervals[t]),n.pressureIntervals[t]=setInterval(function(){var s=r.force||r.pressure||r.webkitForce||0;s!==i&&(e.trigger("pressure",s),n.trigger("pressure "+e.identifier+":pressure",s),i=s)}.bind(n),100)};cn.prototype.onstart=function(r){var e=this,t=e.options,n=r;r=_g(r),e.updateBox();var i=function(s){e.actives.length<t.maxNumberOfNipples?e.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(o){if(Object.values(n.touches).findIndex(function(l){return l.identifier===o})<0){var a=[r[0]];a.identifier=o,e.processOnEnd(a)}}),e.actives.length<t.maxNumberOfNipples&&e.processOnStart(s))};return Vh(r,i),e.manager.bindDocument(),!1};cn.prototype.processOnStart=function(r){var e=this,t=e.options,n,i=e.manager.getIdentifier(r),s=r.force||r.pressure||r.webkitForce||0,o={x:r.pageX,y:r.pageY},a=e.getOrCreate(i,o);a.identifier!==i&&e.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(c){c.trigger("start",c),e.trigger("start "+c.id+":start",c),c.show(),s>0&&e.pressureFn(r,c,c.identifier),e.processOnMove(r)};if((n=e.idles.indexOf(a))>=0&&e.idles.splice(n,1),e.actives.push(a),e.ids.push(a.identifier),t.mode!=="semi")l(a);else{var u=zh(o,a.position);if(u<=t.catchDistance)l(a);else{a.destroy(),e.processOnStart(r);return}}return a};cn.prototype.getOrCreate=function(r,e){var t=this,n=t.options,i;return/(semi|static)/.test(n.mode)?(i=t.idles[0],i?(t.idles.splice(0,1),i):n.mode==="semi"?t.createNipple(e,r):(console.warn("Coudln't find the needed nipple."),!1)):(i=t.createNipple(e,r),i)};cn.prototype.processOnMove=function(r){var e=this,t=e.options,n=e.manager.getIdentifier(r),i=e.nipples.get(n),s=e.manager.scroll;if(!MC(r)){this.processOnEnd(r);return}if(!i){console.error("Found zombie joystick with ID "+n),e.manager.removeIdentifier(n);return}if(t.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=n;var a=i.options.size/2,l={x:r.pageX,y:r.pageY};t.lockX&&(l.y=i.position.y),t.lockY&&(l.x=i.position.x);var u=zh(l,i.position),c=_C(l,i.position),d=Ag(c),h=u/a,f={distance:u,position:l},m,p;if(i.options.shape==="circle"?(m=Math.min(u,a),p=TC(i.position,m,c)):(p=IC(l,i.position,a),m=zh(p,i.position)),t.follow){if(u>a){let b=l.x-p.x,w=l.y-p.y;i.position.x+=b,i.position.y+=w,i.el.style.top=i.position.y-(e.box.top+s.y)+"px",i.el.style.left=i.position.x-(e.box.left+s.x)+"px",u=zh(l,i.position)}}else l=p,u=m;var g=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:g,y},t.dataOnly||Tg(i.ui.front,i.frontPosition);var v={identifier:i.identifier,position:l,force:h,pressure:r.force||r.pressure||r.webkitForce||0,distance:u,angle:{radian:d,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:i,lockX:t.lockX,lockY:t.lockY};v=i.computeDirection(v),v.angle={radian:Ag(180-c),degree:180-c},i.trigger("move",v),e.trigger("move "+i.id+":move",v)};cn.prototype.processOnEnd=function(r){var e=this,t=e.options,n=e.manager.getIdentifier(r),i=e.nipples.get(n),s=e.manager.removeIdentifier(i.identifier);!i||(t.dataOnly||i.hide(function(){t.mode==="dynamic"&&(i.trigger("removed",i),e.trigger("removed "+i.id+":removed",i),e.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(e.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),e.trigger("end "+i.id+":end",i),e.ids.indexOf(i.identifier)>=0&&e.ids.splice(e.ids.indexOf(i.identifier),1),e.actives.indexOf(i)>=0&&e.actives.splice(e.actives.indexOf(i),1),/(semi|static)/.test(t.mode)?e.idles.push(i):e.nipples.indexOf(i)>=0&&e.nipples.splice(e.nipples.indexOf(i),1),e.manager.unbindDocument(),/(semi|static)/.test(t.mode)&&(e.manager.ids[s.id]=s.identifier))};cn.prototype.onDestroyed=function(r,e){var t=this;t.nipples.indexOf(e)>=0&&t.nipples.splice(t.nipples.indexOf(e),1),t.actives.indexOf(e)>=0&&t.actives.splice(t.actives.indexOf(e),1),t.idles.indexOf(e)>=0&&t.idles.splice(t.idles.indexOf(e),1),t.ids.indexOf(e.identifier)>=0&&t.ids.splice(t.ids.indexOf(e.identifier),1),t.manager.removeIdentifier(e.identifier),t.manager.unbindDocument()};cn.prototype.destroy=function(){var r=this;r.unbindEvt(r.options.zone,"start"),r.nipples.forEach(function(t){t.destroy()});for(var e in r.pressureIntervals)r.pressureIntervals.hasOwnProperty(e)&&clearInterval(r.pressureIntervals[e]);r.trigger("destroyed",r.nipples),r.manager.unbindDocument(),r.off()};var NC=cn;function Vn(r){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=mb(),e.config(r),e.prepareCollections();var t=function(){var i;e.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:e.scroll.x+i.left,y:e.scroll.y+i.top}})})};if(typeof window>"u")return e.collections;Iu(window,"resize",function(){fb(t)});var n=function(){e.scroll=mb()};return Iu(window,"scroll",function(){fb(n)}),e.collections}Vn.prototype=new Ou;Vn.constructor=Vn;Vn.prototype.prepareCollections=function(){var r=this;r.collections.create=r.create.bind(r),r.collections.on=r.on.bind(r),r.collections.off=r.off.bind(r),r.collections.destroy=r.destroy.bind(r),r.collections.get=function(e){var t;return r.collections.every(function(n){return t=n.get(e),!t}),t}};Vn.prototype.create=function(r){return this.createCollection(r)};Vn.prototype.createCollection=function(r){var e=this,t=new NC(e,r);return e.bindCollection(t),e.collections.push(t),t};Vn.prototype.bindCollection=function(r){var e=this,t,n=function(i,s){t=i.type+" "+s.id+":"+i.type,e.trigger(t,s)};r.on("destroyed",e.onDestroyed.bind(e)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};Vn.prototype.bindDocument=function(){var r=this;r.binded||(r.bindEvt(document,"move").bindEvt(document,"end"),r.binded=!0)};Vn.prototype.unbindDocument=function(r){var e=this;(!Object.keys(e.ids).length||r===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)};Vn.prototype.getIdentifier=function(r){var e;return r?(e=r.identifier===void 0?r.pointerId:r.identifier,e===void 0&&(e=this.latest||0)):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]};Vn.prototype.removeIdentifier=function(r){var e={};for(var t in this.ids)if(this.ids[t]===r){e.id=t,e.identifier=this.ids[t],delete this.ids[t];break}return e};Vn.prototype.onmove=function(r){var e=this;return e.onAny("move",r),!1};Vn.prototype.onend=function(r){var e=this;return e.onAny("end",r),!1};Vn.prototype.oncancel=function(r){var e=this;return e.onAny("end",r),!1};Vn.prototype.onAny=function(r,e){var t=this,n,i="processOn"+r.charAt(0).toUpperCase()+r.slice(1);e=_g(e);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[i](a),a._found_=!0)},o=function(a){n=t.getIdentifier(a),Vh(t.collections,s.bind(null,a,n)),a._found_||t.removeIdentifier(n)};return Vh(e,o),!1};Vn.prototype.destroy=function(){var r=this;r.unbindDocument(!0),r.ids={},r.index=0,r.collections.forEach(function(e){e.destroy()}),r.off()};Vn.prototype.onDestroyed=function(r,e){var t=this;if(t.collections.indexOf(e)<0)return!1;t.collections.splice(t.collections.indexOf(e),1)};var BC=Vn;var FC=new BC,UC={create:function(r){return FC.create(r)},factory:FC};var GC=Qs(sx());function Ja(r,e){let t=new Ce;if(!r.getAttribute("position"))return t.setAttribute("position",new Ae([],3)),t.setIndex([]),t;let{positions:n,triIndices:i}=dh(r.getAttribute("position"),r.getIndex());return t.setAttribute("position",new Ae(n,3)),t.setIndex(i),e&&t.applyMatrix4(e),t}var BH=new he,FH=new he,cs=[[0,0,0],[0,0,0],[0,0,0]];function gb(r){let e=r.elements;cs[0][0]=e[0],cs[0][1]=e[4],cs[0][2]=e[8],cs[1][0]=e[1],cs[1][1]=e[5],cs[1][2]=e[9],cs[2][0]=e[2],cs[2][1]=e[6],cs[2][2]=e[10];let{u:t,v:n}=(0,GC.SVD)(cs),i=BH.set(t[0][0],t[0][1],t[0][2],0,t[1][0],t[1][1],t[1][2],0,t[2][0],t[2][1],t[2][2],0,0,0,0,1),s=FH.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 i.multiply(s.transpose())}var Pg=class extends zl{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,n=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,n)}),n}createRaycastLineHelper(){let e=new Xr({color:65280,linewidth:10}),t=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),i=this.camera.far-this.camera.near,s=new A().addVectors(t,n.multiplyScalar(i)),o=new Ce;return o.setFromPoints([t,s]),new ha(o,e)}};var kC=r=>r instanceof Za||r instanceof Ci;function UH(r,e){return r.distance-e.distance}function zC(r,e,t){if(!(!hr(e)||!e.visible||e.raycastLock)){zr(e)&&e.raycast(r,t);for(let n of e.children)zC(r,n,t)}}function jh(r,e,t){if(!t.some(i=>Lu(r,i)!==void 0))return[];let n=[];return e.children.forEach(i=>zC(r,i,n)),n.sort(UH),n}function qh(r){let e=[];if(r.length){let t=r[0].object;hr(t)&&e.push(t);let n=t.parent;for(;n;)kC(n)&&e.push(n),n=n.parent}return e}function Lu(r,e){if(zr(e)){if(!e.raycastLock&&e.visible){let t=[];return e.raycast(r,t),t.length?t[0]:void 0}}else if(kC(e))return VC(r,e)}function VC(r,e){if(!(!hr(e)||!e.visible||e.raycastLock)){if(zr(e)){let t=[];if(e.raycast(r,t),t.length)return t[0]}for(let t of e.children){let n=VC(r,t);if(n)return n}}}function GH(r,e,t){return{x:(r-(t.left+window.scrollX))/t.width*2-1,y:-((e-(t.top+window.scrollY))/t.height)*2+1}}var Ig=class{constructor(e,t,n,i,s,o){this.isExport=o;this.raycaster=new Pg;this.raycasterNeedsUpdate=!0;this.stopRaycast=!1;this.sharedAssets=new Vs(Gc.emptyData());this.scene=new qs({...gm.defaultData},this.sharedAssets);this.camera=new zn;this.renderer=e,this.domElement=e.domElement,this.stopRaycast=s,this.sharedAssets=i,this.scene=t,this.camera=n}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:n}=e.touches!==void 0&&e.touches.length>0?e.touches[0]:e,i=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(GH(t,n,i),this.camera)}};var yb=(o=>(o[o.keydown=0]="keydown",o[o.keyup=1]="keyup",o[o.pointerdown=2]="pointerdown",o[o.pointerup=3]="pointerup",o[o.pointermove=4]="pointermove",o[o.wheel=5]="wheel",o))(yb||{}),Hn=class{constructor(e){this.eventContext=e;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var HC=new Map,Yh=new Map,Ys=class{constructor(e,t,n,i){this.data=t;let{audio:s,volume:o,delay:a,loop:l}=t;if(!s)throw new Error("Missing property");let u=typeof s=="string"?i.getAudio(s).src:s.data;this.audioPlayer=new zs({src:u,volume:o,delay:a,loop:l}),Yh.has(n.uuid)?Yh.get(n.uuid).push(this):Yh.set(n.uuid,[this]),HC.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Ru=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=HC.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Yh.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Yh.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},us=class{constructor(e,t,n,i){this.data=t;if(t.interaction==="play")this.interaction=new Ys(e,t,n,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Ru(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Ys?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Ys?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof Ys&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function WC(r,e){let t=r.material.layers.find(n=>n.uuid===e);return t.color.texture.image.img instanceof HTMLVideoElement?t.color.texture.image.img:void 0}var jC=new Map,Xh=new Map,Ho=class{constructor(e,t,n){this.data=t;this.delay=0;this.status="stopped";let{layerId:i,loop:s,volume:o,delay:a}=t;if(this.object=n,i===void 0)throw new Error("Missing property");let l=WC(n,i);if(l)this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o);else throw new Error("Missing property");a!==void 0&&(this.delay=a),Xh.has(n.uuid)?Xh.get(n.uuid).push(this):Xh.set(n.uuid,[this]),jC.set(e,this),this.pause()}mute(){this.videoElement.muted=!0}unMute(){this.videoElement.muted=!1}play(e){let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{this.videoElement.play(),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){this.videoElement.pause(),this.status="paused"}stop(){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.stop(),this.videoElement.muted=!0}},Nu=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=jC.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Xh.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let e=[...Xh.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Wo=class{constructor(e,t,n){this.data=t;if(t.interaction==="play")this.interaction=new Ho(e,t,n);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Nu(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Ho?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Ho?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var kH="text/plain",zH="us-ascii",qC=(r,e)=>e.some(t=>t instanceof RegExp?t.test(r):t===r),VH=(r,{stripHash:e})=>{let t=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(r);if(!t)throw new Error(`Invalid URL: ${r}`);let{type:n,data:i,hash:s}=t.groups,o=n.split(";");s=e?"":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===zH)?"":`${h}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==kH)&&c.unshift(l),`data:${c.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function vb(r,e){if(e={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,...e},r=r.trim(),/^data:/i.test(r))return VH(r,e);if(/^view-source:/i.test(r))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let t=r.startsWith("//");!t&&/^\.*\//.test(r)||(r=r.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,e.defaultProtocol));let i=new URL(r);if(e.forceHttp&&e.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(e.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),e.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),e.stripAuthentication&&(i.username="",i.password=""),e.stripHash?i.hash="":e.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(i.pathname);if(!c)break;let d=c[0],h=c.index,f=i.pathname.slice(a,h);l+=f.replace(/\/{2,}/g,"/"),l+=d,a=h+d.length}let u=i.pathname.slice(a,i.pathname.length);l+=u.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(e.removeDirectoryIndex===!0&&(e.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(e.removeDirectoryIndex)&&e.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];qC(a,e.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),e.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(e.removeQueryParameters))for(let o of[...i.searchParams.keys()])qC(o,e.removeQueryParameters)&&i.searchParams.delete(o);if(e.removeQueryParameters===!0&&(i.search=""),e.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}e.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=r;return r=i.toString(),!e.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(r=r.replace(/\/$/,"")),(e.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&e.removeSingleSlash&&(r=r.replace(/\/$/,"")),t&&!e.normalizeProtocol&&(r=r.replace(/^http:\/\//,"//")),e.stripProtocol&&(r=r.replace(/^(?:https?:)?\/\//,"")),r}var Dg=class{constructor({url:e,context:t},n){this.managers=n;if(!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:vb(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){Wd?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.managers.controlsManager.orbitControls?.onPointerUp(qe[0]),BT())}};var Og=class{constructor(e,t,n,i){this.scene=t,this.sharedAssets=n,this.sceneData=e,this.managers=i}dispatch(){Lg(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager.orbitControls?.reset(),this.managers.controlsManager?.gameControls.forEach(e=>e.reset(!0))}};var JC={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},Sb={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},HH=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Ng={CSS:{},springs:{}};function ds(r,e,t){return Math.min(Math.max(r,e),t)}function Kh(r,e){return r.indexOf(e)>-1}function xb(r,e){return r.apply(null,e)}var je={arr:function(r){return Array.isArray(r)},obj:function(r){return Kh(Object.prototype.toString.call(r),"Object")},pth:function(r){return je.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||je.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return je.hex(r)||je.rgb(r)||je.hsl(r)},key:function(r){return!JC.hasOwnProperty(r)&&!Sb.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function $C(r){var e=/\(([^)]+)\)/.exec(r);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function eP(r,e){var t=$C(r),n=ds(je.und(t[0])?1:t[0],.1,100),i=ds(je.und(t[1])?100:t[1],.1,100),s=ds(je.und(t[2])?10:t[2],.1,100),o=ds(je.und(t[3])?0:t[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*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=e?e*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=Ng.springs[r];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 Ng.springs[r]=v,v}return e?h:f}function WH(r){return r===void 0&&(r=10),function(e){return Math.ceil(ds(e,1e-6,1)*r)*(1/r)}}var jH=function(){var r=11,e=1/(r-1);function t(c,d){return 1-3*d+3*c}function n(c,d){return 3*d-6*c}function i(c){return 3*c}function s(c,d,h){return((t(d,h)*c+n(d,h))*c+i(d))*c}function o(c,d,h){return 3*t(d,h)*c*c+2*n(d,h)*c+i(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(r);if(c!==d||h!==f)for(var p=0;p<r;++p)m[p]=s(p*e,c,h);function g(y){for(var v=0,b=1,w=r-1;b!==w&&m[b]<=y;++b)v+=e;--b;var S=(y-m[b])/(m[b+1]-m[b]),_=v+S*e,T=o(_,c,h);return T>=.001?l(y,_,c,h):T===0?_:a(y,v,v+e,c,h)}return function(y){return c===d&&h===f||y===0||y===1?y:s(g(y),d,f)}}return u}(),tP=function(){var r={linear:function(){return function(n){return n}}},e={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 i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=ds(n,1,10),o=ds(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(n,i){e[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(e).forEach(function(n){var i=e[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function Ab(r,e){if(je.fnc(r))return r;var t=r.split("(")[0],n=tP[t],i=$C(r);switch(t){case"spring":return eP(r,e);case"cubicBezier":return xb(jH,i);case"steps":return xb(WH,i);default:return xb(n,i)}}function nP(r){try{var e=document.querySelectorAll(r);return e}catch{return}}function Bg(r,e){for(var t=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<t;s++)if(s in r){var o=r[s];e.call(n,o,s,r)&&i.push(o)}return i}function Fg(r){return r.reduce(function(e,t){return e.concat(je.arr(t)?Fg(t):t)},[])}function YC(r){return je.arr(r)?r:(je.str(r)&&(r=nP(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function _b(r,e){return r.some(function(t){return t===e})}function Tb(r){var e={};for(var t in r)e[t]=r[t];return e}function bb(r,e){var t=Tb(r);for(var n in r)t[n]=e.hasOwnProperty(n)?e[n]:r[n];return t}function Ug(r,e){var t=Tb(r);for(var n in e)t[n]=je.und(r[n])?e[n]:r[n];return t}function qH(r){var e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return e?"rgba("+e[1]+",1)":r}function YH(r){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=r.replace(e,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(t),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function XH(r){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),t=parseInt(e[1],10)/360,n=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100,s=e[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=i;else{var c=i<.5?i*(1+n):i+n-i*n,d=2*i-c;a=o(d,c,t+1/3),l=o(d,c,t),u=o(d,c,t-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function KH(r){if(je.rgb(r))return qH(r);if(je.hex(r))return YH(r);if(je.hsl(r))return XH(r)}function Xs(r){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(r);if(e)return e[1]}function ZH(r){if(Kh(r,"translate")||r==="perspective")return"px";if(Kh(r,"rotate")||Kh(r,"skew"))return"deg"}function wb(r,e){return je.fnc(r)?r(e.target,e.id,e.total):r}function hs(r,e){return r.getAttribute(e)}function Mb(r,e,t){var n=Xs(e);if(_b([t,"deg","rad","turn"],n))return e;var i=Ng.CSS[e+t];if(!je.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(e);return Ng.CSS[e+t]=u,u}function rP(r,e,t){if(e in r.style){var n=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[e]||getComputedStyle(r).getPropertyValue(n)||"0";return t?Mb(r,i,t):i}}function Eb(r,e){if(je.dom(r)&&!je.inp(r)&&(hs(r,e)||je.svg(r)&&r[e]))return"attribute";if(je.dom(r)&&_b(HH,e))return"transform";if(je.dom(r)&&e!=="transform"&&rP(r,e))return"css";if(r[e]!=null)return"object"}function iP(r){if(!!je.dom(r)){for(var e=r.style.transform||"",t=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=t.exec(e);)n.set(i[1],i[2]);return n}}function QH(r,e,t,n){var i=Kh(e,"scale")?1:0+ZH(e),s=iP(r).get(e)||i;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),n?Mb(r,s,n):s}function Cb(r,e,t,n){switch(Eb(r,e)){case"transform":return QH(r,e,n,t);case"css":return rP(r,e,t);case"attribute":return hs(r,e);default:return r[e]||0}}function Pb(r,e){var t=/^(\*=|\+=|-=)/.exec(r);if(!t)return r;var n=Xs(r)||0,i=parseFloat(e),s=parseFloat(r.replace(t[0],""));switch(t[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function sP(r,e){if(je.col(r))return KH(r);if(/\s/g.test(r))return r;var t=Xs(r),n=t?r.substr(0,r.length-t.length):r;return e?n+e:n}function Ib(r,e){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function JH(r){return Math.PI*2*hs(r,"r")}function $H(r){return hs(r,"width")*2+hs(r,"height")*2}function e5(r){return Ib({x:hs(r,"x1"),y:hs(r,"y1")},{x:hs(r,"x2"),y:hs(r,"y2")})}function oP(r){for(var e=r.points,t=0,n,i=0;i<e.numberOfItems;i++){var s=e.getItem(i);i>0&&(t+=Ib(n,s)),n=s}return t}function t5(r){var e=r.points;return oP(r)+Ib(e.getItem(e.numberOfItems-1),e.getItem(0))}function aP(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return JH(r);case"rect":return $H(r);case"line":return e5(r);case"polyline":return oP(r);case"polygon":return t5(r)}}function n5(r){var e=aP(r);return r.setAttribute("stroke-dasharray",e),e}function r5(r){for(var e=r.parentNode;je.svg(e)&&je.svg(e.parentNode);)e=e.parentNode;return e}function lP(r,e){var t=e||{},n=t.el||r5(r),i=n.getBoundingClientRect(),s=hs(n,"viewBox"),o=i.width,a=i.height,l=t.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 i5(r,e){var t=je.str(r)?nP(r)[0]:r,n=e||100;return function(i){return{property:i,el:t,svg:lP(t),totalLength:aP(t)*(n/100)}}}function s5(r,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return r.el.getPointAtLength(l)}var n=lP(r.el,r.svg),i=t(),s=t(-1),o=t(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function XC(r,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=sP(je.pth(r)?r.totalLength:r,e)+"";return{original:n,numbers:n.match(t)?n.match(t).map(Number):[0],strings:je.str(r)||e?n.split(t):[]}}function cP(r){var e=r?Fg(je.arr(r)?r.map(YC):YC(r)):[];return Bg(e,function(t,n,i){return i.indexOf(t)===n})}function uP(r){var e=cP(r);return e.map(function(t,n){return{target:t,id:n,total:e.length,transforms:{list:iP(t)}}})}function o5(r,e){var t=Tb(e);if(/^spring/.test(t.easing)&&(t.duration=eP(t.easing)),je.arr(r)){var n=r.length,i=n===2&&!je.obj(r[0]);i?r={value:r}:je.fnc(e.duration)||(t.duration=e.duration/n)}var s=je.arr(r)?r:[r];return s.map(function(o,a){var l=je.obj(o)&&!je.pth(o)?o:{value:o};return je.und(l.delay)&&(l.delay=a?0:e.delay),je.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return Ug(o,t)})}function a5(r){for(var e=Bg(Fg(r.map(function(s){return Object.keys(s)})),function(s){return je.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},n=function(s){var o=e[s];t[o]=r.map(function(a){var l={};for(var u in a)je.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},i=0;i<e.length;i++)n(i);return t}function l5(r,e){var t=[],n=e.keyframes;n&&(e=Ug(a5(n),e));for(var i in e)je.key(i)&&t.push({name:i,tweens:o5(e[i],r)});return t}function c5(r,e){var t={};for(var n in r){var i=wb(r[n],e);je.arr(i)&&(i=i.map(function(s){return wb(s,e)}),i.length===1&&(i=i[0])),t[n]=i}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}function u5(r,e){var t;return r.tweens.map(function(n){var i=c5(n,e),s=i.value,o=je.arr(s)?s[1]:s,a=Xs(o),l=Cb(e.target,r.name,a,e),u=t?t.to.original:l,c=je.arr(s)?s[0]:u,d=Xs(c)||Xs(l),h=a||d;return je.und(o)&&(o=u),i.from=XC(c,h),i.to=XC(Pb(o,c),h),i.start=t?t.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=Ab(i.easing,i.duration),i.isPath=je.pth(s),i.isColor=je.col(i.from.original),i.isColor&&(i.round=1),t=i,i})}var dP={css:function(r,e,t){return r.style[e]=t},attribute:function(r,e,t){return r.setAttribute(e,t)},object:function(r,e,t){return r[e]=t},transform:function(r,e,t,n,i){if(n.list.set(e,t),e===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function hP(r,e){var t=uP(r);t.forEach(function(n){for(var i in e){var s=wb(e[i],n),o=n.target,a=Xs(s),l=Cb(o,i,a,n),u=a||Xs(l),c=Pb(sP(s,u),l),d=Eb(o,i);dP[d](o,i,c,n.transforms,!0)}})}function d5(r,e){var t=Eb(r.target,e.name);if(t){var n=u5(e,r),i=n[n.length-1];return{type:t,property:e.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function h5(r,e){return Bg(Fg(r.map(function(t){return e.map(function(n){return d5(t,n)})})),function(t){return!je.und(t)})}function fP(r,e){var t=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=t?Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)})):e.duration,i.delay=t?Math.min.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):e.delay,i.endDelay=t?i.duration-Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay})):e.endDelay,i}var KC=0;function f5(r){var e=bb(JC,r),t=bb(Sb,r),n=l5(t,r),i=uP(r.targets),s=h5(i,n),o=fP(s,t),a=KC;return KC++,Ug(e,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:t.startOnceDelay,pingPongDelayCorrection:t.pingPongDelayCorrection})}var oi=[],ZC=[],Rg,p5=function(){function r(){Rg=requestAnimationFrame(e)}function e(t){var n=oi.length;if(n){for(var i=0;i<n;){var s=oi[i];s.paused?(oi.splice(i,1),n-=1):(s.tick(t),i++)}r()}else Rg=cancelAnimationFrame(Rg)}return r}();function m5(){document.hidden?(oi.forEach(function(r){return r.pause()}),ZC=oi.slice(0),un.running=oi=[]):ZC.forEach(function(r){return r.play()})}typeof document<"u"&&document.addEventListener("visibilitychange",m5);function un(r){r===void 0&&(r={});var e=0,t=0,n=0,i,s=0,o=null;function a(b){var w=window.Promise&&new Promise(function(S){return o=S});return b.finished=w,w}var l=f5(r),u=a(l);function c(){var b=l.direction;b!=="alternate"&&(l.direction=b!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,i.forEach(function(w){return w.reversed=l.reversed})}function d(b){return l.reversed?l.duration-b:b}function h(){e=0,t=d(l.currentTime)*(1/un.speed)}function f(b,w){w&&(l.reversed?w.seek(w.duration*w.loop-(b-w.timelineOffset-w.pingPongDelayCorrection)):w.seek(b-w.timelineOffset-w.startOnceDelay-w.pingPongDelayCorrection))}function m(b){if(l.reversed)for(var S=s;S--;)f(b,i[S]);else for(var w=0;w<s;w++)f(b,i[w])}function p(b){var w=0,S=l.animations,_=S.length;for(l.reversePlayback===!0&&l.rewind===!1&&(b=l.duration+l.delay-l.endDelay-b);w<_;){var T=S[w],x=T.animatable,M=T.tweens,E=M.length-1,C=M[E];E&&(C=Bg(M,function(te){return b<te.end})[0]||C);for(var P=ds(b-C.start-C.delay,0,C.duration)/C.duration,O=isNaN(P)?1:C.easing(P),I=C.to.strings,N=C.round,B=[],W=C.to.numbers.length,X=void 0,F=0;F<W;F++){var k=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var K=C.to.numbers[F],H=C.from.numbers[F]||0;else var H=C.to.numbers[F],K=C.from.numbers[F]||0;C.isPath?k=s5(C.value,O*H):k=K+O*(H-K),N&&(C.isColor&&F>2||(k=Math.round(k*N)/N)),B.push(k)}var z=I.length;if(!z)X=B[0];else{X=I[0];for(var j=0;j<z;j++){var Y=I[j],G=I[j+1],de=B[j];isNaN(de)||(G?X+=de+G:X+=de+" ")}}dP[T.type](x.target,T.property,X,x.transforms),T.currentValue=X,w++}}function g(b){l[b]&&!l.passThrough&&l[b](l)}function y(){l.remaining&&l.remaining!==!0&&l.remaining--}function v(b){var w=l.duration,S=l.delay,_=w-l.endDelay,T=d(b);if(l.progress=ds(T/w*100,0,100),l.reversePlayback=T<l.currentTime,s&&m(T),!l.began&&l.currentTime>=0&&(l.began=!0,g("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,g("loopBegin")),(l.reversed||T>=0)&&T<=S&&l.currentTime!==0&&(p(0),g("change")),(T>=_&&l.currentTime!==w||!w)&&(p(w),g("change")),T>S&&T<_?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,g("changeBegin")),p(T),g("change")):l.changeBegan?(l.changeCompleted=!0,l.changeBegan=!1,g("change"),s&&g("timelineChangeComplete")):l.began&&T>_&&g("changeComplete"),l.currentTime=ds(T,0,w),l.began&&g("update"),b>=w)if(t=0,y(),!l.remaining)l.paused=!0,l.completed||(l.completed=!0,g("loopComplete"),g("complete"),!l.passThrough&&"Promise"in window&&(o(),u=a(l)));else{s?e+=l.duration/un.speed:e+=l.duration;for(let x of i)x.setStartTime(0),x.remaining=x.loop;g("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&c()}}return l.reset=function(){var b=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=b==="reverse",l.remaining=l.loop,i=l.children,s=i.length;for(var w=s;w--;)l.children[w].reset();(l.reversed&&l.loop!==!0||b==="alternate"&&l.loop===1)&&l.remaining++,p(l.reversed?l.duration:0)},l.setStartTime=function(b){e=b},l.set=function(b,w){return hP(b,w),l},l.tick=function(b){n=b,e||(e=n),v((n+(t-e))*un.speed)},l.seek=function(b){v(b-e)},l.pause=function(){l.paused=!0,h()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,oi.push(l),h(),Rg||p5())},l.reverse=function(){c(),l.completed=!l.reversed,h()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function QC(r,e){for(var t=e.length;t--;)_b(r,e[t].animatable.target)&&e.splice(t,1)}function g5(r){for(var e=cP(r),t=oi.length;t--;){var n=oi[t],i=n.animations,s=n.children;QC(e,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;QC(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function y5(r,e){e===void 0&&(e={});var t=e.direction||"normal",n=e.easing?Ab(e.easing):null,i=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",u=o==="last",c=je.arr(r),d=parseFloat(c?r[0]:r),h=c?parseFloat(r[1]):0,f=Xs(c?r[1]:r)||0,m=e.start||0+(c?d:0),p=[],g=0;return function(y,v,b){if(a&&(o=0),l&&(o=(b-1)/2),u&&(o=b-1),!p.length){for(var w=0;w<b;w++){if(!i)p.push(Math.abs(o-w));else{var S=l?(i[0]-1)/2:o%i[0],_=l?(i[1]-1)/2:Math.floor(o/i[0]),T=w%i[0],x=Math.floor(w/i[0]),M=S-T,E=_-x,C=Math.sqrt(M*M+E*E);s==="x"&&(C=-M),s==="y"&&(C=-E),p.push(C)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(O){return n(O/g)*g})),t==="reverse"&&(p=p.map(function(O){return s?O<0?O*-1:-O:Math.abs(g-O)}))}var P=c?(h-d)/g:d;return m+P*(Math.round(p[v]*100)/100)+f}}function v5(r){r===void 0&&(r={});var e=un(r);return e.duration=0,e.add=function(t,n){var i=oi.indexOf(e),s=e.children;i>-1&&oi.splice(i,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Ug(t,bb(Sb,r));l.targets=l.targets||r.targets;var u=e.duration;l.autoplay=!1,l.timelineOffset=je.und(n)?u:Pb(n,u),o(e);var c=un(l);o(c),s.push(c);var d=fP(s,r);return e.delay=d.delay,e.endDelay=d.endDelay,e.duration=d.duration,c.loop===!0&&(e.duration=1/0),e.seek(0),e.reset(),e.autoplay&&e.play(),e},e}un.version="3.2.0";un.speed=1;un.running=oi;un.remove=g5;un.get=Cb;un.set=hP;un.convertPx=Mb;un.path=i5;un.setDashoffset=n5;un.stagger=y5;un.timeline=v5;un.easing=Ab;un.penner=tP;un.random=function(r,e){return Math.floor(Math.random()*(e-r+1))+r};var pP=un;var mP=new A,gP=new A,yP=new nt;function vP(r,e,t,n){if(n===0)return t.copy(r);if(n===1)return t.copy(e);let i=r.w*e.w+r.x*e.x+r.y*e.y+r.z*e.z;if(i>=1)return t.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let c=1-n;return t.w=c*r.w+n*e.w,t.x=c*r.x+n*e.x,t.y=c*r.y+n*e.y,t.z=c*r.z+n*e.z,t.normalize(),t}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return t.w=r.w*l+e.w*u,t.x=r.x*l+e.x*u,t.y=r.y*l+e.y*u,t.z=r.z*l+e.z*u,t}function jo(r,e,t,n,i){let s=t[r]?t[r]:void 0,o=n[r];if(o==null)return;let a=s??e[r],l=o;if(a!==l)return{update:u=>{let c=ze.lerp(a,l,u);i?e[r]=Math.trunc(c):e[r]=c},start:()=>{e[r]=a},end:()=>{e[r]=l}}}function Db(r,e,t,n,i){let s=t[r]?t[r]:void 0,o=n[r];if(!o)return;let a=e[r],l=[...s??a],u=[...o];if(!(l.length!==u.length||Ta(l,u)))return{update:c=>{l.forEach((d,h)=>{let f=ze.lerp(d,u[h],c);e[r][h]=i?Math.trunc(f):f})},start:()=>{Object.assign(e[r],l)},end:()=>{Object.assign(e[r],u)}}}function Ob(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(!s)return;let o=e[r],a=i?new A().fromArray(i):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 xP(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(!s)return;let o=e[r],a=i?new he().fromArray(i):o.clone(),l=new A,u=new nt,c=new A;a.decompose(l,u,c);let d=new he().fromArray(s),h=new A,f=new nt,m=new A;if(d.decompose(h,f,m),!a.equals(d))return{update:p=>{yP.slerpQuaternions(u,f,p),mP.lerpVectors(l,h,p),gP.lerpVectors(c,m,p),o.compose(mP,yP,gP)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(h,f,m)}}}function bP(r,e,t,n,i){let s=t[r]?t[r]:void 0,o=n[r];if(!o)return;let a=e[r],l=s?typeof s=="string"?i.getColor(s).clone():new Oe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Oe().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return e[r]=c,{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function wP(r,e,t){let n=[],i=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom,s=r.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom;if(s!==void 0){let o=i??r.zoom,a=s;o!==a&&n.push({update:l=>{r.zoom=ze.lerp(o,a,l),r.updateProjectionMatrix()},start:()=>{r.zoom=o,r.updateProjectionMatrix()},end:()=>{r.zoom=a,r.updateProjectionMatrix()}})}if(t.targetOffset!==void 0){let o=jo("targetOffset",r,e,t);o&&n.push(o)}return n}function SP(r,e,t,n){let i=[];if(!("geometry"in t))return i;let s="geometry"in e?e.geometry:{},o=t.geometry;if(r instanceof Mi){let f=s.scaleBaked??r.data.geometry.scaleBaked,m=o.scaleBaked??r.data.geometry.scaleBaked;return Yi.isEqual(f,m)||i.push({update:p=>{r.updateGeometryInteractions({scaleBaked:[ze.lerp(f[0],m[0],p),ze.lerp(f[1],m[1],p),ze.lerp(f[2],m[2],p)]},n),r.invalidateDownstreamBooleanData()},start:()=>{r.updateGeometryInteractions({scaleBaked:f},n),r.invalidateDownstreamBooleanData()},end:()=>{r.updateGeometryInteractions({scaleBaked:m},n),r.invalidateDownstreamBooleanData()}}),i}let{width:a,height:l,depth:u}=s,{width:c,height:d,depth:h}=o;if(c!==void 0||d!==void 0||h!==void 0){let{width:f,height:m,depth:p}=r.geometry.userData.parameters,g=a??f,y=l??m,v=u??p,b=c??f,w=d??m,S=h??p;(g!==b||y!==w||v!==S)&&i.push({update:_=>{r.updateGeometryInteractions({width:ze.lerp(g,b,_),height:ze.lerp(y,w,_),depth:ze.lerp(v,S,_)},n),r.updateGeometryGroupsIfNeeded(),r.invalidateDownstreamBooleanData()},start:()=>{r.updateGeometryInteractions({width:g,height:y,depth:v},n),r.invalidateDownstreamBooleanData()},end:()=>{r.updateGeometryInteractions({width:b,height:w,depth:S},n),r.invalidateDownstreamBooleanData()}})}return i}function AP(r,e,t,n){let i=[];if(t.intensity!==void 0){let s=jo("intensity",r,e,t);s&&i.push(s)}if(t.color!==void 0){let s=bP("color",r,e,t,n);s&&i.push(s)}return i}function TP(r,e,t,n){let i=[];if(Array.isArray(r.material)){if(!("materials"in t&&t.materials))return i;let s="materials"in e&&e.materials?e.materials:[],o=t.materials;r.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||i.push(..._P(a,u,c,n))})}else{if(!("material"in t&&t.material))return i;let s="material"in e&&e.material?e.material:{},o=t.material;if(typeof s=="string"||typeof o=="string")return i;i.push(..._P(r.material,s,o,n))}return i}function _P(r,e,t,n){let i=[];r.transparent=ng(t,n);for(let s of r.layers){let o=e.layers?.data(s.uuid),a=t.layers.data(s.uuid);if(!a||!(s.visible??!0)||!(a.visible??!0))continue;let l=s.getNames().filter(u=>!lm.some(c=>u.includes(c)));for(let u of l)try{let c=s.getValue(u),d;if(u==="colors")d=T5(s,o,a,u);else if(Array.isArray(c))u==="steps"&&(d=_5(s,o,a,u));else if(typeof c=="number")d=x5(s,o,a,u);else{if(typeof c=="boolean")continue;c instanceof U?d=b5(s,o,a,u):c instanceof A?d=w5(s,o,a,u):c instanceof $t?d=A5(s,o,a,u,n):c instanceof Oe?d=S5(s,o,a,u,n):"isTexture"in c&&(d=M5(s,o,a,u))}d&&(Array.isArray(d)?i.push(...d):i.push(d))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${u}`,c)}}return i}function x5(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=e?e[n]:r.getValue(n),s=t[n];if(i!==s)return{update:o=>{r.setValue(n,ze.lerp(i,s,o))},start:()=>{r.setValue(n,i)},end:()=>{r.setValue(n,s)}}}function b5(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=r.getValue(n),s=e?new U().fromArray(e[n]):i.clone(),o=new U().fromArray(t[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function w5(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=r.getValue(n),s=e?new A().fromArray(e[n]):i.clone(),o=new A().fromArray(t[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function S5(r,e,t,n,i){if(!r.hasValue(n)||!(n in t))return;let s=e?e[n]:void 0,o=t[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Oe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Oe().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function A5(r,e,t,n,i){if(!r.hasValue(n)||!(n in t))return;let s=e?e[n]:void 0,o=t[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Oe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new $t(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function _5(r,e,t,n="steps"){if(!r.hasValue(n)||!(n in t))return;let i=[],s=r.getValue(n),o=e?e[n]:s,a=t[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&i.push({update:d=>{s[l]=ze.lerp(u,c,d)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return i.length?i:void 0}function T5(r,e,t,n="colors"){if(!r.hasValue(n)||!(n in t))return;let i=[],s=r.getValue(n),o=e?e[n]:s.map(l=>l.toArray()),a=t[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];kd.isEqual(u,c)||i.push({update:d=>{s[l].fromArray(kd.lerp(u,c,d))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return i.length?i:void 0}function M5(r,e,t,n="texture"){if(!r.hasValue(n)||!(n in t))return;let i=r.getNode("mat");if(!i)return;let s=e?e[n]:i,o=t[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!Pa.isEqual(a,u)||!Pa.isEqual(l,c))return{update:d=>{i.repeat=Pa.lerp(a,u,d),i.offset=Pa.lerp(l,c,d),i.updateMatrix()},start:()=>{i.repeat=[...a],i.offset=[...l],i.updateMatrix()},end:()=>{i.repeat=[...u],i.offset=[...c],i.updateMatrix()}}}var Lb=new A,MP=new qt;function EP(r,e,t,n){let i=[],s=Ob("position",r,e,t);s&&i.push(s);let o=Ob("scale",r,e,t);o&&i.push(o);let a=E5(r,e,t,n);a&&i.push(a);let l=xP("hiddenMatrix",r,e,t);if(l&&i.push(l),s||o||a||l){let u=()=>{r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r.parent?.matrixWorldFusedFalse&&(r.matrixWorld.multiplyMatrices(r.parent.matrixWorldFusedFalse,r.matrix),r.matrixWorldNeedsUpdate=!1),zr(r)&&Vr(r.parent)&&r.invalidateDownstreamBooleanData(!0)};i.push({update:u,start:u,end:u})}return i}function E5(r,e,t,n){let i=e?.rotation?e.rotation:void 0,s=t.rotation;if(!s)return;let o=i?new A().fromArray(i):new A().setFromEuler(r.rotation),a=new A().fromArray(s);if(o.equals(a))return;let l=Lb.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new nt().setFromEuler(MP.setFromVector3(o)),c=new nt().setFromEuler(MP.setFromVector3(a));return{update:d=>{vP(u,c,r.quaternion,d)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}else return{update:u=>{Lb.lerpVectors(o,a,u),r.rotation.setFromVector3(Lb)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}function Bu(r,e,t,n){if(typeof e[r]=="number")return jo(r,e,t??{},n);if(Array.isArray(e[r]))return Db(r,e,t??{},n)}function CP(r,e,t){let n=[];if(!("cloner"in t)||!r.cloner)return n;let i=r.cloner,s="cloner"in e?e.cloner:{},o=t.cloner;R0.forEach(h=>{let f;h==="count"?f=jo("count",i.parameters,s,o,!0):f=Bu(h,i.parameters,s??{},o),f&&n.push(f)});let a=C5(i,s,o);a?.length&&n.push(...a);let l=P5(i,s,o);l?.length&&n.push(...l);let u=I5(i,s,o);u?.length&&n.push(...u);let c=D5(i,s,o);c?.length&&n.push(...c);let d=O5(i,s,o);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{i.update()}}),n}function C5(r,e,t){if(r.parameters.type!=="radial")return;let n=e.radial,i=t.radial;if(!i)return;let s=r.parameters.radial,o=[];return N0.forEach(a=>{let l=Bu(a,s,n??{},i);l&&o.push(l)}),o}function P5(r,e,t){if(r.parameters.type!=="linear")return;let n=e.linear,i=t.linear;if(!i)return;let s=[],o=r.parameters.linear;return B0.forEach(a=>{let l=Bu(a,o,n??{},i);l&&s.push(l)}),s}function I5(r,e,t){if(r.parameters.type!=="grid")return;let n=e.grid,i=t.grid;if(!i)return;let s=[],o=r.parameters.grid;return F0.forEach(a=>{let l;a==="count"?l=Db(a,o,n??{},i,!0):l=Bu(a,o,n??{},i),l&&s.push(l)}),s}function D5(r,e,t){if(r.parameters.type!=="toObject")return;let n=e.toObject,i=t.toObject;if(!i)return;let s=[],o=r.parameters.toObject;return U0.forEach(a=>{let l;a==="count"?l=jo(a,o,n??{},i,!0):l=Bu(a,o,n??{},i),l&&s.push(l)}),s}function O5(r,e,t){if(!r.parameters.randomness)return;let n=e.randomnessObject,i=t.randomnessObject;if(!i)return;let s=[],o=r.parameters.randomnessObject;return G0.forEach(a=>{let l=Bu(a,o,n??{},i);l&&s.push(l)}),s}function Rb(r,e,t,n,i){let s=[];return r.data.visible&&s.push(...EP(r,e,t,i)),r.data.visible&&s.push(...CP(r,e,t)),zr(r)?(r instanceof en&&r.data.visible&&s.push(...SP(r,e,t,n)),r.data.visible&&s.push(...TP(r,e,t,n))):lC(r)?r.data.visible&&s.push(...AP(r,e,t,n)):aC(r)&&s.push(...wP(r,e,t)),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 PP=new A;function Lg(r,e,t,n=!1){let i=[];e.traverseObject(s=>{if(n&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(PP,!0),s.rigidBody?.setAngvel(PP,!0)),!Gt.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,!a.states)return;let l=!1;i.some(u=>r.objects.isDescendantOf(o,u))?l=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&i.push(o),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let u of a.states)r.environment.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||l)&&(u.data.position!==void 0||u.data.rotation!==void 0||u.data.hiddenMatrix!==void 0)||(s.states||(s.states={}),s.states[u.id]=Bs.patch(a,u.data));L5(e,s,null,t,a.events.find(u=>u.data.type==="Follow"||u.data.type==="LookAt")!==void 0)})}function L5(r,e,t,n,i=!1){e instanceof en&&e.removeInteractionGeometry(),e.changeSelectedState(t,{scene:r,shared:n},i),e instanceof en&&e.updateGeometryGroupsIfNeeded()}function R5(r){let e;switch(r.easing){case 0:e="cubicBezier( 0, 0, 1, 1 )";break;case 1:e="cubicBezier( .25, .1, .25, 1 )";break;case 2:e="cubicBezier( .42, 0, 1, 1 )";break;case 3:e="cubicBezier( 0, 0, .58, 1 )";break;case 4:e="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:t,control2:n}=r;e=`cubicBezier(
4912
4912
  ${t[0]}, ${t[1]}, ${n[0]}, ${n[1]}
4913
- )`;break;case 6:let{mass:i,stiffness:s,damping:o,velocity:a}=r;e=`spring( ${i}, ${s}, ${o}, ${a} )`;break;default:e="linear"}return{duration:r.duration,easing:e}}function IP(r){let e={delay:0,loop:r.repeat===-1?!0:r.repeat+1};if(r.repeat===0)e.direction="normal",e.rewind=r.direction==="pingpong-rewind";else switch(r.direction){case"pingpong":e.direction="alternate",e.rewind=!1;break;case"pingpong-rewind":e.direction="alternate",e.rewind=!0;break;default:e.direction="normal",e.rewind=!1;break}switch(e.delay=0,e.endDelay=0,e.startOnceDelay=0,e.pingPongDelayCorrection=0,r.delayDirection){case"start-once":e.startOnceDelay=r.delay;break;case"start":e.delay=r.delay;break;case"end":e.endDelay=r.delay;break;case"start-end":case void 0:e.delay=r.delay,e.endDelay=r.delay;break}return e.direction==="alternate"&&(e.delay/=2,e.endDelay/=2,e.delay!==0&&(e.pingPongDelayCorrection=e.delay)),e}var kg=class{constructor(e,t,n,i,s,o){this.object=e;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.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 e=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=e,this.object.dispatchEvent({type:"beginState",state:e})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let e=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=e,this.object.dispatchEvent({type:"completeState",state:e})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=Rb(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(t===void 0){let a=Gg(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=Gg(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=Gg(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...IP(i),...R5(i),change:this.onChange},this.callback=Rb(this.object,t===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}},fs=class extends zt{constructor(t,n,i){super();this.data=t;this.scene=n;this.sharedAssets=i;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.isTwoState=!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(!t.object)throw new Error("Missing property");let s=n.find(t.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,t.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.isTwoState=t.tweens.length===2;let o=this.isTwoState?1:0;this.startOnceDelay=t.tweens[o].data.delayDirection==="start-once"?t.tweens[o].data.delay:0,this.init()}get playing(){return this.tweens.some(t=>t.changeBegan)??!1}init(){this.actionCurrentState=Gg(this.object,this.object.currentState),this.toggleIsForward=!1}buildTimeline({isForward:t=!0,isRebuild:n=!1}={}){try{let i=IP(this.data.tweens[0].data),s=i.loop;n&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=pP.timeline({autoplay:!1,...i,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),i.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),t){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=new kg(this.object,l===o?void 0:u.data.state??this.actionCurrentState.id,c.data.state??this.actionCurrentState.id,c.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?i.delay:0)+(l===a&&!n?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.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=new kg(this.object,l===o+1?void 0:u.data.state??this.actionCurrentState.id,c.data.state??this.actionCurrentState.id,u.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?i.endDelay:0))}this.timeline.duration+=i.delay+(n?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause(),this.seek(0)}seek(t){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(t*this.timeline.duration)}toggle(t){clearTimeout(this.timeoutId),this.toggleIsForward=t??!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 Gg(r,e){let t,n;if(typeof e=="string"?(t=e,n=r.states?.[t]):e===null&&(t=null,n=r.data),!(t===void 0||n===void 0))return{id:t,data:n}}function Wr(r,e,t,n,i,s){let o={Audio:[],Video:[],Link:[],Reset:[],Transition:[]};return e.forEach(({id:a,data:l})=>{try{l.type==="Audio"?Pc[r.type].includes("Audio")&&o.Audio.push(new us(a,l,t,i)):l.type==="Video"?Pc[r.type].includes("Video")&&o.Video.push(new Wo(a,l,t)):l.type==="Link"?Pc[r.type].includes("Link")&&o.Link.push(new Dg(l,s)):l.type==="Reset"?Pc[r.type].includes("Reset")&&o.Reset.push(new Og(n.data,n,i,s)):l.type==="Transition"&&Pc[r.type].includes("Transition")&&o.Transition.push(new fs(l,n,i))}catch{}}),o}function jr(r){Object.values(r).forEach(e=>{e.forEach(t=>{(t instanceof us||t instanceof Wo||t instanceof fs)&&t.dispose()})})}var Nb=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],DP=r=>Nb.find(([e,t])=>t===r)?.[0],qo=r=>Nb.find(([e])=>e===r)?.[1],N5=(r,e)=>{let t=DP(r);if(t){let n=new CustomEvent(t,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:e}),n}},zg=class extends Hn{constructor(t){super(t);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=t=>{if(!t.eventName||!t.target)return;let n=this.splineEvents[DP(t.eventName)]?.[t.target.uuid];if(!n)return;t.eventName==="Scroll"&&t.deltaY!==void 0&&Object.assign(n,{deltaY:t.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(n)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{if(!!i.data?.events.length){for(let[s,o]of Nb)if(i.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(i):this.objectsPerEvents.set(s,[i]);let a={id:i.uuid,name:i.name},l=N5(o,a),u=this.splineEvents[s];u?u[i.uuid]=l:this.splineEvents[s]={[i.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var Bb=class{constructor(e,t,n,i,s,o){this.id=e;this.data=t;this.object=n;this.entered=!1;if(this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Wr(t,t.actions,n,i,s,o)}disconnect(){jr(this.actions)}dispatch(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.useToggle?this.actions.Transition.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.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{t.play()}),this.actions.Link.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(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},Vg=class extends Hn{constructor(t,n,i){super(t);this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.onMouseDown=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseDown"))};this.onMouseUp=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMousePressEvent())};this.onMousePressRelease=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMousePressEvent(!0))};this.onKeyDown=t=>{this.heldKeys[t.key]||this.handleKeyEvent(t,"KeyDown"),this.heldKeys[t.key]=!0};this.onKeyUp=t=>{this.handleKeyEvent(t,"KeyUp")};this.onKeyPressDown=t=>{this.heldKeysPress[t.key]||this.handleKeyEvent(t,"KeyPress"),this.heldKeysPress[t.key]=!0};this.onKeyPressUp=t=>{this.handleKeyEvent(t,"KeyPress",!0)};this.releaseHeldKey=t=>{delete this.heldKeys[t.key]};this.releaseHeldKeyPress=t=>{delete this.heldKeysPress[t.key]};this._onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{scene:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=a.visible?["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"]:["KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:d})=>d.type===u&&d.disabled!==!0).forEach(({id:d,data:h})=>{try{let f=new Bb(d,h,a,s,o,{controlsManager:n,eventManager:i});f.actions.Video.length&&(this.hasVideoAction=!0),c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch{}}),c[a.uuid]?.length&&this.objectsPerTypes[u].push(a)}})}connect(){let{domElement:t}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),t.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,i])=>{i.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerdown",this.onMousePressDown),t.removeEventListener("pointerup",this.onMouseUp),t.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(i=>{i.forEach(s=>{s.disconnect()})})}),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(t){let{stopRaycast:n,raycaster:i,scene:s}=this.eventContext,o=this.objectsPerTypes[t];if(!!o.length)if(n){let a=jh(i,s,o);qh(a).forEach(l=>{this.eventsPerObjects[t][l.uuid]&&this.handleObjectMouseEventDispatch(l,t)})}else o.forEach(a=>{Lu(i,a)&&this.handleObjectMouseEventDispatch(a,t)})}handleMousePressEvent(t=!1){let n="MousePress",i=this.objectsPerTypes[n],s=[];if(!!i.length){if(!t){let{stopRaycast:o,raycaster:a,scene:l}=this.eventContext;if(o){let u=jh(a,l,i);s=qh(u)}else i.forEach(u=>{Lu(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(t,n){t.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[t.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(t,n){t.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[t.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(t,n,i=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===t.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===t.key&&(i?a.dispatchRelease():a.dispatch())})})}};var B5=new A,F5=new A;var Hg=class{constructor(e,t,n,i){this.actionsIn=Wr(e,e.inActions,t,n,i),this.actionsOut=Wr(e,e.outActions,t,n,i)}disconnect(){jr(this.actionsIn),jr(this.actionsOut)}};var Fb=class extends Hg{constructor(t,n,i,s,o){super(n,i,s,o);this.id=t;this.data=n;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{let t=B5.setFromMatrixPosition(this.objects[0].matrixWorld),n=F5.setFromMatrixPosition(this.objects[1].matrixWorld),i=t.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==i){(this.stage==="in"?this.actionsIn:this.actionsOut).Transition.forEach(a=>a.pause());let o=i==="in"?this.actionsIn:this.actionsOut;o.Audio.forEach(a=>a.dispatchConditional()),o.Video.forEach(a=>a.dispatchConditional()),this.object.currentTransitionEvent=this.id,o.Transition.forEach(a=>a.play()),this.stage=i}};let{distance:a,fromObject:l,toObject:u}=n.condition;this.distance=a;for(let c of[l,u]){if(!c)throw new Error("Missing property");let d=s.find(c);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){this.objects.forEach(t=>{t.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(t=>{t.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},Ub=class extends Hg{constructor(t,n,i,s,o){super(n,i,s,o);this.id=t;this.data=n;this.object=i;this.onBegin=({target:t,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this.id,this.actionsOut.Transition.forEach(i=>i.play()))};this.onComplete=({target:t,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this.id,this.actionsIn.Transition.forEach(i=>i.play()))};let{condition:a}=n;if(!a.object)throw new Error("Missing property");let l=s.find(a.object);if(!l)throw new Error("Missing property");if(this.toObject=l,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Wg=class extends Hn{constructor(t){super(t);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length){for(let{id:o,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let l;a.condition.type==="Comparison"||(a.condition.type==="Distance"?l=new Fb(o,a,s,n,i):a.condition.type==="State"&&(l=new Ub(o,a,s,n,i))),l&&(this.eventsPerConditions[a.condition.type].push(l),(l.actionsIn.Video.length||l.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.disconnect()))}};var Fu=new A,Gb=new A,kb=new A,jg=new A,OP=new xn,LP=.01,U5={type:"requestRender"},G5=function(){let r=new A,e=new A;return(t,n,i)=>i>0?(r.subVectors(t,n),r.length()<=i?t:e.copy(n).add(r.normalize().multiplyScalar(i))):n}(),RP=function(){let r=new he;return(e,t)=>{e.position.copy(t),e.parent!==null&&(r.copy(e.parent.matrixWorld).invert(),e.position.applyMatrix4(r)),r.copy(e.hiddenMatrix).invert(),e.position.applyMatrix4(r),e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e instanceof kt&&Vr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),zb=class{constructor(e,t,n){this.data=e;this.object=t;this.tempPosition=new A;this.started=!1;this.paused=!0;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.target=e.target?n.find(e.target):void 0,this.maxDelta=e.maxDelta??0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.snapDampingFactor,this.object.getWorldPosition(this.worldPosition0)}},qg=class extends Hn{constructor(t){super(t);this.events=[];this.onTargetChangeCallbacks=[];this.onMouseMove=t=>{if(!(qe.length>1)){this.eventContext.updateRaycaster(t);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=t=>{for(let n of this.events)n.target===void 0&&(n.tempPosition.copy(n.object.position),n.snapComplete=!1,n.isReset=!1,n.currentDampingFactor=n.snapDampingFactor)};this.onMouseLeave=t=>{for(let n of this.events)n.target===void 0&&(n.tempPosition.copy(n.object.position),n.snapComplete=!1,(n.data.resetOnPointerLeave??!1)&&(n.isReset=!0,n.currentDampingFactor=n.snapDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=t=>()=>{this.updateSingleEvent(t)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="Follow"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new zb(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave);for(let n of this.events)if(n.target!==void 0){let i=this.onTargetChange(n);this.onTargetChangeCallbacks.push(i),n.target.addEventListener("requestRender",i)}}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave);let n=0;for(let i of this.events)i.started=!1,i.paused=!0,i.target!==void 0&&i.target.removeEventListener("requestRender",this.onTargetChangeCallbacks[n++])}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t)}updateSingleEvent(t){let{tempPosition:n,object:i,maxDelta:s,plane:o}=t;if(i.getWorldPosition(kb),t.isReset)jg.copy(t.worldPosition0);else if(t.target)t.target.getWorldPosition(jg);else{let{camera:l,raycaster:u}=this.eventContext;if(o==="custom"?(l.getWorldDirection(Gb),Gb.negate(),Fu.copy(Gb)):o==="xy"?Fu.set(0,0,1):o==="xz"?Fu.set(0,1,0):o==="yz"&&Fu.set(1,0,0),OP.setFromNormalAndCoplanarPoint(Fu,kb),!u.ray.intersectPlane(OP,jg))return}let a=G5(kb,jg,s);if(t.currentDampingFactor>1||t.snapComplete===!1){t.started||(t.started=!0,n.copy(a));let l=Fu.subVectors(a,n).divideScalar(t.currentDampingFactor);n.add(l),RP(i,n),t.paused=l.length()<LP,t.snapComplete=l.length()<LP*100,t.snapComplete&&(t.currentDampingFactor=t.dampingFactor)}else RP(i,a),t.paused=!0;t.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),i.dispatchEvent(U5)}};var Zh=new A,Yg=new A,$a=new he,Qh=new nt,Uu=new nt,Xg=new A,Vb=new A,Jh=new A,Kg=new xn,NP=1e-5,k5={type:"requestRender"},z5={type:"changeRotation"},V5=function(){let r=new he,e=new A,t=new A,n=new A;return(i,s)=>(s==="x"?(e.set(0,0,1),t.set(0,1,0),n.set(-1,0,0)):s==="y"?(e.set(1,0,0),t.set(0,0,1),n.set(0,-1,0)):(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1)),e.applyMatrix4(i),t.applyMatrix4(i),n.applyMatrix4(i),r.makeBasis(e,t,n))}(),BP=function(){let r=new he;return function(t,n){t.parent!==null?r.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):r.copy(t.hiddenMatrix),n.premultiply(gb(r).invert()),t.rotation.setFromRotationMatrix(n),t.updateMatrix(),t instanceof kt&&Vr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Hb=class{constructor(e,t,n){this.data=e;this.object=t;this.paused=!0;this.snapComplete=!1;this.isReset=!1;this.worldQuaternion0=new nt;this.target=e.target?n.find(e.target):void 0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.distance=e.distance??0,this.tilt=e.tilt??"up",this.axis=e.axis??"z",this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.dampingFactor,this.object.getWorldQuaternion(this.worldQuaternion0)}},Zg=class extends Hn{constructor(t){super(t);this.events=[];this.onTargetChangeCallbacks=[];this.onMouseMove=t=>{if(!(qe.length>1)){this.eventContext.updateRaycaster(t);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=t=>{for(let n of this.events)n.target===void 0&&(n.snapComplete=!1,n.isReset=!1,n.currentDampingFactor=n.snapDampingFactor)};this.onMouseLeave=t=>{for(let n of this.events)n.target===void 0&&(n.snapComplete=!1,(n.data.resetOnPointerLeave??!1)&&(n.isReset=!0,n.currentDampingFactor=n.snapDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=t=>()=>{this.updateSingleEvent(t)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Hb(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave);for(let n of this.events)if(n.target!==void 0){let i=this.onTargetChange(n);this.onTargetChangeCallbacks.push(i),n.target.addEventListener("requestRender",i)}}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave);let n=0;for(let i of this.events)i.paused=!0,i.target!==void 0&&i.target.removeEventListener("requestRender",this.onTargetChangeCallbacks[n++])}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t)}updateSingleEvent(t){let{target:n,tilt:i,axis:s,distance:o,plane:a,object:l}=t,{camera:u,raycaster:c}=this.eventContext;if(l.getWorldPosition(Xg),!t.isReset){if(t.target)t.target.getWorldPosition(Vb);else if(a==="custom"?(u.getWorldDirection(Yg),Yg.negate(),o>0?Kg.set(Yg,-o):Kg.setFromNormalAndCoplanarPoint(Yg,Xg)):(a==="xy"?Zh.set(0,0,1):a==="xz"?Zh.set(0,1,0):a==="yz"&&Zh.set(1,0,0),Kg.setFromNormalAndCoplanarPoint(Zh,Xg)),!c.ray.intersectPlane(Kg,Vb))return}t.isReset||(n?i==="up"?Jh.set(0,1,0):i==="target"&&Jh.copy(n.up).applyMatrix4($a.extractRotation(n.matrixWorld)).normalize():a==="custom"?Jh.set(0,1,0):Jh.copy(Zh)),t.isReset?Uu.copy(t.worldQuaternion0):($a.lookAt(Vb,Xg,Jh),$a.copy(V5($a,s)),Uu.setFromRotationMatrix($a)),t.currentDampingFactor>1||t.snapComplete===!1?(l.updateWorldMatrix(!0,!1),Qh.setFromRotationMatrix(gb(l.matrixWorld)),Qh.slerp(Uu,1/t.currentDampingFactor),BP(l,$a.makeRotationFromQuaternion(Qh)),t.paused=8*(1-Qh.dot(Uu))<NP,t.snapComplete=8*(1-Qh.dot(Uu))<NP*100,t.snapComplete&&(t.currentDampingFactor=t.dampingFactor)):(BP(l,$a.makeRotationFromQuaternion(Uu)),t.paused=!0),t.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),l.dispatchEvent(k5),l.dispatchEvent(z5)}};var Wb=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.entered=!1;this.actions=Wr(t,t.actions,n,i,s)}disconnect(){jr(this.actions)}dispatchEnter(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()))}dispatchLeave(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>t.playFromCurrent())}},Qg=class extends Hn{constructor(t){super(t);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onMouseUp=t=>{qe.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(i)))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:o,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let l=new Wb(o,a,s,n,i);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(l):this.eventsPerObjects[s.uuid]=[l]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp)),t.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(i=>{i.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(t=!1){let n=[];if(!t){let{stopRaycast:i,raycaster:s,scene:o}=this.eventContext;if(i){let a=jh(s,o,this.objects);n=qh(a)}else this.objects.forEach(a=>{Lu(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{n.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var jb=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.scrollCounter=0;this.actions=Wr(t,t.actions,n,i,s)}connect(){this.scrollCounter=0}disconnect(){jr(this.actions)}dispatch(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(i=>{i.init()}));let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(n))}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>{t.playFromCurrent()})}},Jg=class extends Hn{constructor(t){super(t);this.eventsPerObject=new Map;this.onWheel=t=>{[...this.eventsPerObject.entries()].forEach(([n,i])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:t.deltaY}),i.forEach(s=>s.dispatch(t.deltaY))})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Scroll")continue;let l=new jb(o,a,s,n,i);this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])}})}connect(){[...this.eventsPerObject.entries()].forEach(([t,n])=>{n.forEach(i=>i.connect()),t.addEventListener("userEvent",this.onUserEvent)}),[...this.eventsPerObject.values()].some(t=>t.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel))}disconnect(){window.removeEventListener("wheel",this.onWheel),this.domEventsNeeded.clear(),[...this.eventsPerObject.entries()].forEach(([t,n])=>{n.forEach(i=>i.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)})}};var qb=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.actions=Wr(t,t.actions,n,i,s)}disconnect(){jr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Ys?t.interaction.audioPlayer.play():t.interaction instanceof Ru&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let n=t.interaction.data.triggerAfter??"autoplay";n===e&&(t.interaction instanceof Ho?t.interaction.play(n==="autoplay"):t.interaction instanceof Nu&&t.interaction.dispatch())})}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Audio.forEach(t=>{t.interaction instanceof Ys?t.interaction.audioPlayer.play():t.interaction instanceof Ru&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Ho?t.interaction.play():t.interaction instanceof Nu&&t.interaction.dispatch()})}},$g=class extends Hn{constructor(t){super(t);this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:t,isExport:n}=this.eventContext;(n?document:t).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.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new qb(o,a,s,n,i);l.actions.Transition.length&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>i.dispatch()),t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.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(([t,n])=>{t.removeEventListener("userEvent",this.onUserEvent),n.forEach(i=>i.disconnect())})}};var ey=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.disabled=!0;this.actions=Wr(t,t.actions,n,i,s),this.target=t.target,this.useToggle=t.toggle}disconnect(){jr(this.actions)}dispatch(){this.disabled||(this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var tn;z_.then(r=>tn=r);var Iwe=new he,Dwe=new A(1,1,1),gr=new A,Yo=new nt,el=new A,Yb=new qt(0,0,0,"YXZ"),H5={type:"updateMatrix"},Xb={type:"beginEvent",eventName:"Collision"};function GP(r){if(r.scene.environment.usePhysics)return!0;let e=!1;return r.scene.objects.traverse((t,n)=>{for(let i of n.events)if(i.data.disabled!==!0&&i.data.type==="GameControl"&&i.data.collisionEnabled){e=!0;break}}),e}var FP=r=>r.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.hiddenMatrix!==void 0||e.data.cloner!==void 0),UP=r=>r.events.find(e=>e.data.disabled!==!0&&e.data.type==="Follow"),ty=class{constructor(e,t,n,i,s,o=!1){this.scene=t;this.sharedAssets=s;this.isExport=o;this.orbitControlsNeedsUpdate=!0;this.gameControls=[];this.gameControlStates=[];this.joysticks=[];this.joystickToGameControls=[];this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{},gamePads:[]};this.needsCollisionDetection=!1;this.initializationCounter=-1;this.rigidBodyToMesh=new Map;this.nActiveRigidBodies=0;this.collisionEvents=[];this.processRigidBody=e=>{if(e.bodyType()!==tn.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[t,n,i]=this.rigidBodyToMesh.get(e.handle);if(gr.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Yo.copy(e.rotation()),t.matrixWorld.compose(gr,Yo,n),t.hasNonUniformScale&&t.matrixWorld.multiply(t.shearScale),t.dispatchEvent(H5),i){let s=t.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(t.matrixWorld);for(let o of s.children)o.updateMatrixWorld(!0)}for(let o of t.children)o.updateMatrixWorld(!0)}};this.handleCollisionEvents=(e,t,n)=>{if(n!==!1)if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[e])){let i=this.sharedGameControlGlobals.colliderToEntity[t],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[t])){let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else{let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s!==void 0)for(let l of s)l.data.target==="scene"&&this.dispatchCollisionEvent(l,i);let o=this.sharedGameControlGlobals.colliderToEntity[t],a=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(a!==void 0)for(let l of a)l.data.target==="scene"&&this.dispatchCollisionEvent(l,o)}};this.onBeginState=()=>{this.orbitControls&&(this.orbitControls.enabled=!1,this.orbitControlsNeedsUpdate=!1)};this.onCompleteState=({target:e})=>{this.orbitControls&&(this.orbitControls.enabled=!0,this.orbitControls.resetTo(e.getTarget(gr),e.position,e.zoom,e.isUpVectorFlipped),e.prevState=null,e.currentState=null,e.reversibleToState=null,e.currentTransitionEvent=null,this.orbitControlsNeedsUpdate=!0)};this.domElement=n.domElement;let a;e.scene.publish.playCamera===null?a=qs.PERSONAL_CAMERA_ID:a=e.scene.publish.playCamera;let l=this.scene.find(a),u=!1,c,d=5,h=8,f=9,m="drag";if(this.usePhysics=e.scene.environment.usePhysics??dr.defaultData.usePhysics,this.pixelsPerMeter=e.scene.environment.pixelsPerMeter??dr.defaultData.pixelsPerMeter,e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach(y=>{y.data.disabled!==!0&&y.data.type==="GameControl"&&(c=y.data.keyAssignments,d=y.data.joystickPosLoc,h=y.data.joystickRotLoc,f=y.data.jumpTouchButtonLoc,m=y.data.rotByTouch)}),this.scene.traverseEntity(y=>{y.dataPatched.events.forEach(v=>{if(v.data.disabled||v.data.type!=="GameControl")return;let b=y;for(;(b=b.parent)?.parent!==null;)if(b.dataPatched.physics?.fusedBody)return;v.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([y,v.data])})}),this.usePhysics&&this.initPhysics(e.scene.environment.gravity??dr.defaultData.gravity),this.gameControlStates.forEach(([y,v])=>{u=u||v.camera===l.uuid||y.uuid===l.uuid;let b=new $h(y,n.domElement,{...v,keyAssignments:c},e.scene.environment,this.sharedGameControlGlobals,y.uuid!==l.uuid&&v.camera===l.uuid,l,this.scene,s);b.addEventListener("change",i),b.addEventListener("end",i),b.addEventListener("start",i),this.gameControls.push(b),an&&v.touchControl&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([b,"pos"]):this.joystickToGameControls[d]=[[b,"pos"]],v.moveMode==="walk"&&(this.joystickToGameControls[f]!==void 0?this.joystickToGameControls[f].push([b,"jmp"]):this.joystickToGameControls[f]=[[b,"jmp"]]),m==="joystick"&&(this.joystickToGameControls[h]!==void 0?this.joystickToGameControls[h].push([b,"rot"]):this.joystickToGameControls[h]=[[b,"rot"]]))}),u===!1){let{enableRotate:y,enablePan:v,enableZoom:b,autoRotate:w,hoverRotatePanMode:S}=e.scene.publish.orbitControls;if(y||v||b||w||S!==0){this.orbitControls=new Gu(l,n.domElement,this.isExport),this.orbitControls.addEventListener("change",i),this.orbitControls.addEventListener("end",i),this.orbitControls.addEventListener("start",i),this.orbitControls.fromJSON(e.scene.publish.orbitControls),this.orbitControls.useKeyEvents=!1,this.orbitControls.connect(),this.orbitControls.update();let _=this.orbitControls.object;_.addEventListener("beginState",this.onBeginState),_.addEventListener("completeState",this.onCompleteState)}}let p=n.domElement.width/n.getPixelRatio(),g=n.domElement.height/n.getPixelRatio();this.joystickToGameControls.forEach((y,v)=>{let b=document.body.appendChild(document.createElement("div")),[w,S,_]=(e.scene.publish.joystickSizeAndXYOffset??Fs.defaultData.joystickSizeAndXYOffset)[v],T=(p-5*w)/4+w,x={},M=y.some(O=>O[1]==="jmp"),E=M?0:w;v<10?(v<5?x.top=E/2:x.bottom=E/2,x.left=E/2+v%5*T):v===10?(x.left=E/2,x.top=g/2):(x.right=E/2,x.top=g/2),x.top?x.top-=S[1]:x.bottom+=S[1],x.left?x.left+=S[0]:x.right-=S[0];for(let O in x)x[O]+="px";if(M){let O=b.appendChild(document.createElement("div"));Object.assign(O.style,x,{position:"absolute",width:w+"px",height:w+"px",backgroundColor:`rgba(255,255,255,${_==="show"?.4:0})`,zIndex:"9999",borderRadius:w+"px",border:_==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let I=w/16*16*.4;_==="show"&&(O.innerHTML=`
4913
+ )`;break;case 6:let{mass:i,stiffness:s,damping:o,velocity:a}=r;e=`spring( ${i}, ${s}, ${o}, ${a} )`;break;default:e="linear"}return{duration:r.duration,easing:e}}function IP(r){let e={delay:0,loop:r.repeat===-1?!0:r.repeat+1};if(r.repeat===0)e.direction="normal",e.rewind=r.direction==="pingpong-rewind";else switch(r.direction){case"pingpong":e.direction="alternate",e.rewind=!1;break;case"pingpong-rewind":e.direction="alternate",e.rewind=!0;break;default:e.direction="normal",e.rewind=!1;break}switch(e.delay=0,e.endDelay=0,e.startOnceDelay=0,e.pingPongDelayCorrection=0,r.delayDirection){case"start-once":e.startOnceDelay=r.delay;break;case"start":e.delay=r.delay;break;case"end":e.endDelay=r.delay;break;case"start-end":case void 0:e.delay=r.delay,e.endDelay=r.delay;break}return e.direction==="alternate"&&(e.delay/=2,e.endDelay/=2,e.delay!==0&&(e.pingPongDelayCorrection=e.delay)),e}var kg=class{constructor(e,t,n,i,s,o){this.object=e;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.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 e=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=e,this.object.dispatchEvent({type:"beginState",state:e})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let e=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=e,this.object.dispatchEvent({type:"completeState",state:e})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=Rb(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(t===void 0){let a=Gg(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=Gg(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=Gg(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...IP(i),...R5(i),change:this.onChange},this.callback=Rb(this.object,t===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}},fs=class extends zt{constructor(t,n,i){super();this.data=t;this.scene=n;this.sharedAssets=i;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.isTwoState=!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(!t.object)throw new Error("Missing property");let s=n.find(t.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,t.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.isTwoState=t.tweens.length===2,this.startOnceDelay=t.tweens[0].data.delayDirection==="start-once"?t.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(t=>t.changeBegan)??!1}init(){this.actionCurrentState=Gg(this.object,this.object.currentState),this.toggleIsForward=!1}buildTimeline({isForward:t=!0,isRebuild:n=!1}={}){try{let i=IP(this.data.tweens[0].data),s=i.loop;n&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=pP.timeline({autoplay:!1,...i,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),i.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),t){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=new kg(this.object,l===o?void 0:u.data.state??this.actionCurrentState.id,c.data.state??this.actionCurrentState.id,c.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?i.delay:0)+(l===a&&!n?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.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=new kg(this.object,l===o+1?void 0:u.data.state??this.actionCurrentState.id,c.data.state??this.actionCurrentState.id,u.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?i.endDelay:0))}this.timeline.duration+=i.delay+(n?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause(),this.seek(0)}seek(t){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(t*this.timeline.duration)}toggle(t){clearTimeout(this.timeoutId),this.toggleIsForward=t??!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 Gg(r,e){let t,n;if(typeof e=="string"?(t=e,n=r.states?.[t]):e===null&&(t=null,n=r.data),!(t===void 0||n===void 0))return{id:t,data:n}}function Wr(r,e,t,n,i,s){let o={Audio:[],Video:[],Link:[],Reset:[],Transition:[]};return e.forEach(({id:a,data:l})=>{try{l.type==="Audio"?Pc[r.type].includes("Audio")&&o.Audio.push(new us(a,l,t,i)):l.type==="Video"?Pc[r.type].includes("Video")&&o.Video.push(new Wo(a,l,t)):l.type==="Link"?Pc[r.type].includes("Link")&&o.Link.push(new Dg(l,s)):l.type==="Reset"?Pc[r.type].includes("Reset")&&o.Reset.push(new Og(n.data,n,i,s)):l.type==="Transition"&&Pc[r.type].includes("Transition")&&o.Transition.push(new fs(l,n,i))}catch{}}),o}function jr(r){Object.values(r).forEach(e=>{e.forEach(t=>{(t instanceof us||t instanceof Wo||t instanceof fs)&&t.dispose()})})}var Nb=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],DP=r=>Nb.find(([e,t])=>t===r)?.[0],qo=r=>Nb.find(([e])=>e===r)?.[1],N5=(r,e)=>{let t=DP(r);if(t){let n=new CustomEvent(t,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:e}),n}},zg=class extends Hn{constructor(t){super(t);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=t=>{if(!t.eventName||!t.target)return;let n=this.splineEvents[DP(t.eventName)]?.[t.target.uuid];if(!n)return;t.eventName==="Scroll"&&t.deltaY!==void 0&&Object.assign(n,{deltaY:t.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(n)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{if(!!i.data?.events.length){for(let[s,o]of Nb)if(i.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(i):this.objectsPerEvents.set(s,[i]);let a={id:i.uuid,name:i.name},l=N5(o,a),u=this.splineEvents[s];u?u[i.uuid]=l:this.splineEvents[s]={[i.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var Bb=class{constructor(e,t,n,i,s,o){this.id=e;this.data=t;this.object=n;this.entered=!1;if(this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Wr(t,t.actions,n,i,s,o)}disconnect(){jr(this.actions)}dispatch(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.useToggle?this.actions.Transition.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.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{t.play()}),this.actions.Link.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(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},Vg=class extends Hn{constructor(t,n,i){super(t);this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.onMouseDown=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseDown"))};this.onMouseUp=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMousePressEvent())};this.onMousePressRelease=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMousePressEvent(!0))};this.onKeyDown=t=>{this.heldKeys[t.key]||this.handleKeyEvent(t,"KeyDown"),this.heldKeys[t.key]=!0};this.onKeyUp=t=>{this.handleKeyEvent(t,"KeyUp")};this.onKeyPressDown=t=>{this.heldKeysPress[t.key]||this.handleKeyEvent(t,"KeyPress"),this.heldKeysPress[t.key]=!0};this.onKeyPressUp=t=>{this.handleKeyEvent(t,"KeyPress",!0)};this.releaseHeldKey=t=>{delete this.heldKeys[t.key]};this.releaseHeldKeyPress=t=>{delete this.heldKeysPress[t.key]};this._onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{scene:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=a.visible?["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"]:["KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:d})=>d.type===u&&d.disabled!==!0).forEach(({id:d,data:h})=>{try{let f=new Bb(d,h,a,s,o,{controlsManager:n,eventManager:i});f.actions.Video.length&&(this.hasVideoAction=!0),c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch{}}),c[a.uuid]?.length&&this.objectsPerTypes[u].push(a)}})}connect(){let{domElement:t}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),t.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,i])=>{i.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerdown",this.onMousePressDown),t.removeEventListener("pointerup",this.onMouseUp),t.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(i=>{i.forEach(s=>{s.disconnect()})})}),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(t){let{stopRaycast:n,raycaster:i,scene:s}=this.eventContext,o=this.objectsPerTypes[t];if(!!o.length)if(n){let a=jh(i,s,o);qh(a).forEach(l=>{this.eventsPerObjects[t][l.uuid]&&this.handleObjectMouseEventDispatch(l,t)})}else o.forEach(a=>{Lu(i,a)&&this.handleObjectMouseEventDispatch(a,t)})}handleMousePressEvent(t=!1){let n="MousePress",i=this.objectsPerTypes[n],s=[];if(!!i.length){if(!t){let{stopRaycast:o,raycaster:a,scene:l}=this.eventContext;if(o){let u=jh(a,l,i);s=qh(u)}else i.forEach(u=>{Lu(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(t,n){t.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[t.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(t,n){t.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[t.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(t,n,i=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===t.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===t.key&&(i?a.dispatchRelease():a.dispatch())})})}};var B5=new A,F5=new A;var Hg=class{constructor(e,t,n,i){this.actionsIn=Wr(e,e.inActions,t,n,i),this.actionsOut=Wr(e,e.outActions,t,n,i)}disconnect(){jr(this.actionsIn),jr(this.actionsOut)}};var Fb=class extends Hg{constructor(t,n,i,s,o){super(n,i,s,o);this.id=t;this.data=n;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{let t=B5.setFromMatrixPosition(this.objects[0].matrixWorld),n=F5.setFromMatrixPosition(this.objects[1].matrixWorld),i=t.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==i){(this.stage==="in"?this.actionsIn:this.actionsOut).Transition.forEach(a=>a.pause());let o=i==="in"?this.actionsIn:this.actionsOut;o.Audio.forEach(a=>a.dispatchConditional()),o.Video.forEach(a=>a.dispatchConditional()),this.object.currentTransitionEvent=this.id,o.Transition.forEach(a=>a.play()),this.stage=i}};let{distance:a,fromObject:l,toObject:u}=n.condition;this.distance=a;for(let c of[l,u]){if(!c)throw new Error("Missing property");let d=s.find(c);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){this.objects.forEach(t=>{t.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(t=>{t.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},Ub=class extends Hg{constructor(t,n,i,s,o){super(n,i,s,o);this.id=t;this.data=n;this.object=i;this.onBegin=({target:t,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this.id,this.actionsOut.Transition.forEach(i=>i.play()))};this.onComplete=({target:t,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this.id,this.actionsIn.Transition.forEach(i=>i.play()))};let{condition:a}=n;if(!a.object)throw new Error("Missing property");let l=s.find(a.object);if(!l)throw new Error("Missing property");if(this.toObject=l,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Wg=class extends Hn{constructor(t){super(t);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length){for(let{id:o,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let l;a.condition.type==="Comparison"||(a.condition.type==="Distance"?l=new Fb(o,a,s,n,i):a.condition.type==="State"&&(l=new Ub(o,a,s,n,i))),l&&(this.eventsPerConditions[a.condition.type].push(l),(l.actionsIn.Video.length||l.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.disconnect()))}};var Fu=new A,Gb=new A,kb=new A,jg=new A,OP=new xn,LP=.01,U5={type:"requestRender"},G5=function(){let r=new A,e=new A;return(t,n,i)=>i>0?(r.subVectors(t,n),r.length()<=i?t:e.copy(n).add(r.normalize().multiplyScalar(i))):n}(),RP=function(){let r=new he;return(e,t)=>{e.position.copy(t),e.parent!==null&&(r.copy(e.parent.matrixWorld).invert(),e.position.applyMatrix4(r)),r.copy(e.hiddenMatrix).invert(),e.position.applyMatrix4(r),e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e instanceof kt&&Vr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),zb=class{constructor(e,t,n){this.data=e;this.object=t;this.tempPosition=new A;this.started=!1;this.paused=!0;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.target=e.target?n.find(e.target):void 0,this.maxDelta=e.maxDelta??0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.snapDampingFactor,this.object.getWorldPosition(this.worldPosition0)}},qg=class extends Hn{constructor(t){super(t);this.events=[];this.onTargetChangeCallbacks=[];this.onMouseMove=t=>{if(!(qe.length>1)){this.eventContext.updateRaycaster(t);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=t=>{for(let n of this.events)n.target===void 0&&(n.tempPosition.copy(n.object.position),n.snapComplete=!1,n.isReset=!1,n.currentDampingFactor=n.snapDampingFactor)};this.onMouseLeave=t=>{for(let n of this.events)n.target===void 0&&(n.tempPosition.copy(n.object.position),n.snapComplete=!1,(n.data.resetOnPointerLeave??!1)&&(n.isReset=!0,n.currentDampingFactor=n.snapDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=t=>()=>{this.updateSingleEvent(t)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="Follow"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new zb(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave);for(let n of this.events)if(n.target!==void 0){let i=this.onTargetChange(n);this.onTargetChangeCallbacks.push(i),n.target.addEventListener("requestRender",i)}}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave);let n=0;for(let i of this.events)i.started=!1,i.paused=!0,i.target!==void 0&&i.target.removeEventListener("requestRender",this.onTargetChangeCallbacks[n++])}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t)}updateSingleEvent(t){let{tempPosition:n,object:i,maxDelta:s,plane:o}=t;if(i.getWorldPosition(kb),t.isReset)jg.copy(t.worldPosition0);else if(t.target)t.target.getWorldPosition(jg);else{let{camera:l,raycaster:u}=this.eventContext;if(o==="custom"?(l.getWorldDirection(Gb),Gb.negate(),Fu.copy(Gb)):o==="xy"?Fu.set(0,0,1):o==="xz"?Fu.set(0,1,0):o==="yz"&&Fu.set(1,0,0),OP.setFromNormalAndCoplanarPoint(Fu,kb),!u.ray.intersectPlane(OP,jg))return}let a=G5(kb,jg,s);if(t.currentDampingFactor>1||t.snapComplete===!1){t.started||(t.started=!0,n.copy(a));let l=Fu.subVectors(a,n).divideScalar(t.currentDampingFactor);n.add(l),RP(i,n),t.paused=l.length()<LP,t.snapComplete=l.length()<LP*100,t.snapComplete&&(t.currentDampingFactor=t.dampingFactor)}else RP(i,a),t.paused=!0;t.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),i.dispatchEvent(U5)}};var Zh=new A,Yg=new A,$a=new he,Qh=new nt,Uu=new nt,Xg=new A,Vb=new A,Jh=new A,Kg=new xn,NP=1e-5,k5={type:"requestRender"},z5={type:"changeRotation"},V5=function(){let r=new he,e=new A,t=new A,n=new A;return(i,s)=>(s==="x"?(e.set(0,0,1),t.set(0,1,0),n.set(-1,0,0)):s==="y"?(e.set(1,0,0),t.set(0,0,1),n.set(0,-1,0)):(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1)),e.applyMatrix4(i),t.applyMatrix4(i),n.applyMatrix4(i),r.makeBasis(e,t,n))}(),BP=function(){let r=new he;return function(t,n){t.parent!==null?r.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):r.copy(t.hiddenMatrix),n.premultiply(gb(r).invert()),t.rotation.setFromRotationMatrix(n),t.updateMatrix(),t instanceof kt&&Vr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Hb=class{constructor(e,t,n){this.data=e;this.object=t;this.paused=!0;this.snapComplete=!1;this.isReset=!1;this.worldQuaternion0=new nt;this.target=e.target?n.find(e.target):void 0,this.dampingFactor=e.dampingFactor?Math.max(e.dampingFactor,1):1,this.distance=e.distance??0,this.tilt=e.tilt??"up",this.axis=e.axis??"z",this.plane=e.plane??"custom",this.snapDampingFactor=8,this.currentDampingFactor=this.dampingFactor,this.object.getWorldQuaternion(this.worldQuaternion0)}},Zg=class extends Hn{constructor(t){super(t);this.events=[];this.onTargetChangeCallbacks=[];this.onMouseMove=t=>{if(!(qe.length>1)){this.eventContext.updateRaycaster(t);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=t=>{for(let n of this.events)n.target===void 0&&(n.snapComplete=!1,n.isReset=!1,n.currentDampingFactor=n.snapDampingFactor)};this.onMouseLeave=t=>{for(let n of this.events)n.target===void 0&&(n.snapComplete=!1,(n.data.resetOnPointerLeave??!1)&&(n.isReset=!0,n.currentDampingFactor=n.snapDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=t=>()=>{this.updateSingleEvent(t)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Hb(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave);for(let n of this.events)if(n.target!==void 0){let i=this.onTargetChange(n);this.onTargetChangeCallbacks.push(i),n.target.addEventListener("requestRender",i)}}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),t.removeEventListener("pointerenter",this.onMouseEnter),t.removeEventListener("pointerleave",this.onMouseLeave);let n=0;for(let i of this.events)i.paused=!0,i.target!==void 0&&i.target.removeEventListener("requestRender",this.onTargetChangeCallbacks[n++])}onAnimationFrameDamping(){for(let t of this.events)t.paused||this.updateSingleEvent(t)}updateSingleEvent(t){let{target:n,tilt:i,axis:s,distance:o,plane:a,object:l}=t,{camera:u,raycaster:c}=this.eventContext;if(l.getWorldPosition(Xg),!t.isReset){if(t.target)t.target.getWorldPosition(Vb);else if(a==="custom"?(u.getWorldDirection(Yg),Yg.negate(),o>0?Kg.set(Yg,-o):Kg.setFromNormalAndCoplanarPoint(Yg,Xg)):(a==="xy"?Zh.set(0,0,1):a==="xz"?Zh.set(0,1,0):a==="yz"&&Zh.set(1,0,0),Kg.setFromNormalAndCoplanarPoint(Zh,Xg)),!c.ray.intersectPlane(Kg,Vb))return}t.isReset||(n?i==="up"?Jh.set(0,1,0):i==="target"&&Jh.copy(n.up).applyMatrix4($a.extractRotation(n.matrixWorld)).normalize():a==="custom"?Jh.set(0,1,0):Jh.copy(Zh)),t.isReset?Uu.copy(t.worldQuaternion0):($a.lookAt(Vb,Xg,Jh),$a.copy(V5($a,s)),Uu.setFromRotationMatrix($a)),t.currentDampingFactor>1||t.snapComplete===!1?(l.updateWorldMatrix(!0,!1),Qh.setFromRotationMatrix(gb(l.matrixWorld)),Qh.slerp(Uu,1/t.currentDampingFactor),BP(l,$a.makeRotationFromQuaternion(Qh)),t.paused=8*(1-Qh.dot(Uu))<NP,t.snapComplete=8*(1-Qh.dot(Uu))<NP*100,t.snapComplete&&(t.currentDampingFactor=t.dampingFactor)):(BP(l,$a.makeRotationFromQuaternion(Uu)),t.paused=!0),t.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),l.dispatchEvent(k5),l.dispatchEvent(z5)}};var Wb=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.entered=!1;this.actions=Wr(t,t.actions,n,i,s)}disconnect(){jr(this.actions)}dispatchEnter(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()))}dispatchLeave(){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>t.playFromCurrent())}},Qg=class extends Hn{constructor(t){super(t);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onMouseUp=t=>{qe.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=t=>{qe.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(i)))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:o,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let l=new Wb(o,a,s,n,i);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(l):this.eventsPerObjects[s.uuid]=[l]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),an&&(t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp)),t.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(i=>{i.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(t=!1){let n=[];if(!t){let{stopRaycast:i,raycaster:s,scene:o}=this.eventContext;if(i){let a=jh(s,o,this.objects);n=qh(a)}else this.objects.forEach(a=>{Lu(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{n.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var jb=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.scrollCounter=0;this.actions=Wr(t,t.actions,n,i,s)}connect(){this.scrollCounter=0}disconnect(){jr(this.actions)}dispatch(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(i=>{i.init()}));let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(n))}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>{t.playFromCurrent()})}},Jg=class extends Hn{constructor(t){super(t);this.eventsPerObject=new Map;this.onWheel=t=>{[...this.eventsPerObject.entries()].forEach(([n,i])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:t.deltaY}),i.forEach(s=>s.dispatch(t.deltaY))})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Scroll")continue;let l=new jb(o,a,s,n,i);this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])}})}connect(){[...this.eventsPerObject.entries()].forEach(([t,n])=>{n.forEach(i=>i.connect()),t.addEventListener("userEvent",this.onUserEvent)}),[...this.eventsPerObject.values()].some(t=>t.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel))}disconnect(){window.removeEventListener("wheel",this.onWheel),this.domEventsNeeded.clear(),[...this.eventsPerObject.entries()].forEach(([t,n])=>{n.forEach(i=>i.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)})}};var qb=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.actions=Wr(t,t.actions,n,i,s)}disconnect(){jr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Ys?t.interaction.audioPlayer.play():t.interaction instanceof Ru&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let n=t.interaction.data.triggerAfter??"autoplay";n===e&&(t.interaction instanceof Ho?t.interaction.play(n==="autoplay"):t.interaction instanceof Nu&&t.interaction.dispatch())})}dispatchUserEvent(e){this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(t=>{t.init()})),e?this.actions.Transition.forEach(t=>t.reverseFromCurrent()):this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Audio.forEach(t=>{t.interaction instanceof Ys?t.interaction.audioPlayer.play():t.interaction instanceof Ru&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Ho?t.interaction.play():t.interaction instanceof Nu&&t.interaction.dispatch()})}},$g=class extends Hn{constructor(t){super(t);this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:t,isExport:n}=this.eventContext;(n?document:t).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.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=qo(t);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new qb(o,a,s,n,i);l.actions.Transition.length&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>i.dispatch()),t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.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(([t,n])=>{t.removeEventListener("userEvent",this.onUserEvent),n.forEach(i=>i.disconnect())})}};var ey=class{constructor(e,t,n,i,s){this.id=e;this.data=t;this.object=n;this.disabled=!0;this.actions=Wr(t,t.actions,n,i,s),this.target=t.target,this.useToggle=t.toggle}disconnect(){jr(this.actions)}dispatch(){this.disabled||(this.object.currentTransitionEvent!==this.id&&(this.object.currentTransitionEvent=this.id,this.actions.Transition.forEach(e=>{e.init()})),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var tn;z_.then(r=>tn=r);var Iwe=new he,Dwe=new A(1,1,1),gr=new A,Yo=new nt,el=new A,Yb=new qt(0,0,0,"YXZ"),H5={type:"updateMatrix"},Xb={type:"beginEvent",eventName:"Collision"};function GP(r){if(r.scene.environment.usePhysics)return!0;let e=!1;return r.scene.objects.traverse((t,n)=>{for(let i of n.events)if(i.data.disabled!==!0&&i.data.type==="GameControl"&&i.data.collisionEnabled){e=!0;break}}),e}var FP=r=>r.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.hiddenMatrix!==void 0||e.data.cloner!==void 0),UP=r=>r.events.find(e=>e.data.disabled!==!0&&e.data.type==="Follow"),ty=class{constructor(e,t,n,i,s,o=!1){this.scene=t;this.sharedAssets=s;this.isExport=o;this.orbitControlsNeedsUpdate=!0;this.gameControls=[];this.gameControlStates=[];this.joysticks=[];this.joystickToGameControls=[];this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{},gamePads:[]};this.needsCollisionDetection=!1;this.initializationCounter=-1;this.rigidBodyToMesh=new Map;this.nActiveRigidBodies=0;this.collisionEvents=[];this.processRigidBody=e=>{if(e.bodyType()!==tn.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[t,n,i]=this.rigidBodyToMesh.get(e.handle);if(gr.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Yo.copy(e.rotation()),t.matrixWorld.compose(gr,Yo,n),t.hasNonUniformScale&&t.matrixWorld.multiply(t.shearScale),t.dispatchEvent(H5),i){let s=t.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(t.matrixWorld);for(let o of s.children)o.updateMatrixWorld(!0)}for(let o of t.children)o.updateMatrixWorld(!0)}};this.handleCollisionEvents=(e,t,n)=>{if(n!==!1)if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[e])){let i=this.sharedGameControlGlobals.colliderToEntity[t],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[t])){let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else{let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s!==void 0)for(let l of s)l.data.target==="scene"&&this.dispatchCollisionEvent(l,i);let o=this.sharedGameControlGlobals.colliderToEntity[t],a=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(a!==void 0)for(let l of a)l.data.target==="scene"&&this.dispatchCollisionEvent(l,o)}};this.onBeginState=()=>{this.orbitControls&&(this.orbitControls.enabled=!1,this.orbitControlsNeedsUpdate=!1)};this.onCompleteState=({target:e})=>{this.orbitControls&&(this.orbitControls.enabled=!0,this.orbitControls.resetTo(e.getTarget(gr),e.position,e.zoom,e.isUpVectorFlipped),e.prevState=null,e.currentState=null,e.reversibleToState=null,e.currentTransitionEvent=null,this.orbitControlsNeedsUpdate=!0)};this.domElement=n.domElement;let a;e.scene.publish.playCamera===null?a=qs.PERSONAL_CAMERA_ID:a=e.scene.publish.playCamera;let l=this.scene.find(a),u=!1,c,d=5,h=8,f=9,m="drag";if(this.usePhysics=e.scene.environment.usePhysics??dr.defaultData.usePhysics,this.pixelsPerMeter=e.scene.environment.pixelsPerMeter??dr.defaultData.pixelsPerMeter,e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach(y=>{y.data.disabled!==!0&&y.data.type==="GameControl"&&(c=y.data.keyAssignments,d=y.data.joystickPosLoc,h=y.data.joystickRotLoc,f=y.data.jumpTouchButtonLoc,m=y.data.rotByTouch)}),this.scene.traverseEntity(y=>{y.dataPatched.events.forEach(v=>{if(v.data.disabled||v.data.type!=="GameControl")return;let b=y;for(;(b=b.parent)?.parent!==null;)if(b.dataPatched.physics?.fusedBody)return;v.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([y,v.data])})}),this.usePhysics&&this.initPhysics(e.scene.environment.gravity??dr.defaultData.gravity),this.gameControlStates.forEach(([y,v])=>{u=u||v.camera===l.uuid||y.uuid===l.uuid;let b=new $h(y,n.domElement,{...v,keyAssignments:c},e.scene.environment,this.sharedGameControlGlobals,y.uuid!==l.uuid&&v.camera===l.uuid,l,this.scene,s);b.addEventListener("change",i),b.addEventListener("end",i),b.addEventListener("start",i),this.gameControls.push(b),an&&v.touchControl&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([b,"pos"]):this.joystickToGameControls[d]=[[b,"pos"]],v.moveMode==="walk"&&(this.joystickToGameControls[f]!==void 0?this.joystickToGameControls[f].push([b,"jmp"]):this.joystickToGameControls[f]=[[b,"jmp"]]),m==="joystick"&&(this.joystickToGameControls[h]!==void 0?this.joystickToGameControls[h].push([b,"rot"]):this.joystickToGameControls[h]=[[b,"rot"]]))}),u===!1){let{enableRotate:y,enablePan:v,enableZoom:b,autoRotate:w,hoverRotatePanMode:S}=e.scene.publish.orbitControls;if(y||v||b||w||S!==0){this.orbitControls=new Gu(l,n.domElement,this.isExport),this.orbitControls.addEventListener("change",i),this.orbitControls.addEventListener("end",i),this.orbitControls.addEventListener("start",i),this.orbitControls.fromJSON(e.scene.publish.orbitControls),this.orbitControls.useKeyEvents=!1,this.orbitControls.connect(),this.orbitControls.update();let _=this.orbitControls.object;_.addEventListener("beginState",this.onBeginState),_.addEventListener("completeState",this.onCompleteState)}}let p=n.domElement.width/n.getPixelRatio(),g=n.domElement.height/n.getPixelRatio();this.joystickToGameControls.forEach((y,v)=>{let b=document.body.appendChild(document.createElement("div")),[w,S,_]=(e.scene.publish.joystickSizeAndXYOffset??Fs.defaultData.joystickSizeAndXYOffset)[v],T=(p-5*w)/4+w,x={},M=y.some(O=>O[1]==="jmp"),E=M?0:w;v<10?(v<5?x.top=E/2:x.bottom=E/2,x.left=E/2+v%5*T):v===10?(x.left=E/2,x.top=g/2):(x.right=E/2,x.top=g/2),x.top?x.top-=S[1]:x.bottom+=S[1],x.left?x.left+=S[0]:x.right-=S[0];for(let O in x)x[O]+="px";if(M){let O=b.appendChild(document.createElement("div"));Object.assign(O.style,x,{position:"absolute",width:w+"px",height:w+"px",backgroundColor:`rgba(255,255,255,${_==="show"?.4:0})`,zIndex:"9999",borderRadius:w+"px",border:_==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let I=w/16*16*.4;_==="show"&&(O.innerHTML=`
4914
4914
  <svg width="${I}" height="${w*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
4915
4915
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4916
4916
  </svg>