@splinetool/runtime 0.9.137 → 0.9.138
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 +1 -1
- package/build/runtime.js +1 -1
- package/package.json +1 -1
package/build/runtime.js
CHANGED
|
@@ -3136,7 +3136,7 @@ void main() {
|
|
|
3136
3136
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3137
3137
|
}`;function vO(r,e,t){let n=new Mu,i=new B,s=new B,o=new He,a=new Eu({depthPacking:Oy}),l=new ly,u={},c=t.maxTextureSize,h={0:un,1:Gr,2:er},d=new mt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:gO,fragmentShader:yO}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let g=new De;g.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new rn(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=pf,this.render=function(b,S,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;let M=r.getRenderTarget(),x=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),E=r.state;E.setBlending(Rt),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,P=b.length;C<P;C++){let O=b[C],D=O.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;i.copy(D.mapSize);let N=D.getFrameExtents();if(i.multiply(N),s.copy(D.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/N.x),i.x=s.x*N.x,D.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/N.y),i.y=s.y*N.y,D.mapSize.y=s.y)),D.map===null){let z=this.type!==mu?{minFilter:Ut,magFilter:Ut}:{};D.map=new dt(i.x,i.y,z),D.map.texture.name=O.name+".shadowMap",D.camera.updateProjectionMatrix()}r.setRenderTarget(D.map),r.clear();let F=D.getViewportCount();for(let z=0;z<F;z++){let Y=D.getViewport(z);o.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),E.viewport(o),D.updateMatrices(O,z),n=D.getFrustum(),w(S,_,D.camera,O,this.type)}D.isPointLightShadow!==!0&&this.type===mu&&v(D,_),D.needsUpdate=!1}m.needsUpdate=!1,r.setRenderTarget(M,x,T)};function v(b,S){let _=e.update(p);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new dt(i.x,i.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(S,null,_,d,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(S,null,_,f,p,null)}function y(b,S,_,M,x,T){let E=null,C=_.isPointLight===!0?b.customDistanceMaterial:b.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,D=u[P];D===void 0&&(D={},u[P]=D);let N=D[O];N===void 0&&(N=E.clone(),D[O]=N),E=N}return E.visible=S.visible,E.wireframe=S.wireframe,T===mu?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:h[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=M,E.farDistance=x),E}function w(b,S,_,M,x){if(b.visible===!1)return;if(b.layers.test(S.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&x===mu)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,b.matrixWorld);let C=e.update(b),P=b.material;if(Array.isArray(P)){let O=C.groups;for(let D=0,N=O.length;D<N;D++){let F=O[D],z=P[F.materialIndex];if(z&&z.visible){let Y=y(b,z,M,_.near,_.far,x);r.renderBufferDirect(_,null,C,Y,b,F)}}}else if(P.visible){let O=y(b,P,M,_.near,_.far,x);r.renderBufferDirect(_,null,C,O,b,null)}}let E=b.children;for(let C=0,P=E.length;C<P;C++)w(E[C],S,_,M,x)}}function xO(r,e,t){let n=t.isWebGL2;function i(){let H=!1,xe=new He,_e=null,Qe=new He(0,0,0,0);return{setMask:function(Re){_e!==Re&&!H&&(r.colorMask(Re,Re,Re,Re),_e=Re)},setLocked:function(Re){H=Re},setClear:function(Re,Ke,we,Je,it){it===!0&&(Re*=Je,Ke*=Je,we*=Je),xe.set(Re,Ke,we,Je),Qe.equals(xe)===!1&&(r.clearColor(Re,Ke,we,Je),Qe.copy(xe))},reset:function(){H=!1,_e=null,Qe.set(-1,0,0,0)}}}function s(){let H=!1,xe=null,_e=null,Qe=null;return{setTest:function(Re){Re?q(2929):W(2929)},setMask:function(Re){xe!==Re&&!H&&(r.depthMask(Re),xe=Re)},setFunc:function(Re){if(_e!==Re){if(Re)switch(Re){case YC:r.depthFunc(512);break;case QC:r.depthFunc(519);break;case ZC:r.depthFunc(513);break;case qg:r.depthFunc(515);break;case KC:r.depthFunc(514);break;case JC:r.depthFunc(518);break;case $C:r.depthFunc(516);break;case eP:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);_e=Re}},setLocked:function(Re){H=Re},setClear:function(Re){Qe!==Re&&(r.clearDepth(Re),Qe=Re)},reset:function(){H=!1,xe=null,_e=null,Qe=null}}}function o(){let H=!1,xe=null,_e=null,Qe=null,Re=null,Ke=null,we=null,Je=null,it=null;return{setTest:function(yt){H||(yt?q(2960):W(2960))},setMask:function(yt){xe!==yt&&!H&&(r.stencilMask(yt),xe=yt)},setFunc:function(yt,At,cr){(_e!==yt||Qe!==At||Re!==cr)&&(r.stencilFunc(yt,At,cr),_e=yt,Qe=At,Re=cr)},setOp:function(yt,At,cr){(Ke!==yt||we!==At||Je!==cr)&&(r.stencilOp(yt,At,cr),Ke=yt,we=At,Je=cr)},setLocked:function(yt){H=yt},setClear:function(yt){it!==yt&&(r.clearStencil(yt),it=yt)},reset:function(){H=!1,xe=null,_e=null,Qe=null,Re=null,Ke=null,we=null,Je=null,it=null}}}let a=new i,l=new s,u=new o,c={},h={},d=new WeakMap,f=[],g=null,p=!1,m=null,v=null,y=null,w=null,b=null,S=null,_=null,M=!1,x=null,T=null,E=null,C=null,P=null,O=r.getParameter(35661),D=!1,N=0,F=r.getParameter(7938);F.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(F)[1]),D=N>=1):F.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),D=N>=2);let z=null,Y={},U=r.getParameter(3088),G=r.getParameter(2978),Q=new He().fromArray(U),V=new He().fromArray(G);function k(H,xe,_e){let Qe=new Uint8Array(4),Re=r.createTexture();r.bindTexture(H,Re),r.texParameteri(H,10241,9728),r.texParameteri(H,10240,9728);for(let Ke=0;Ke<_e;Ke++)r.texImage2D(xe+Ke,0,6408,1,1,0,6408,5121,Qe);return Re}let j={};j[3553]=k(3553,3553,1),j[34067]=k(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),q(2929),l.setFunc(qg),Te(!1),me(Hx),q(2884),ce(Rt);function q(H){c[H]!==!0&&(r.enable(H),c[H]=!0)}function W(H){c[H]!==!1&&(r.disable(H),c[H]=!1)}function he(H,xe){return h[H]!==xe?(r.bindFramebuffer(H,xe),h[H]=xe,n&&(H===36009&&(h[36160]=xe),H===36160&&(h[36009]=xe)),!0):!1}function ie(H,xe){let _e=f,Qe=!1;if(H)if(_e=d.get(xe),_e===void 0&&(_e=[],d.set(xe,_e)),H.isWebGLMultipleRenderTargets){let Re=H.texture;if(_e.length!==Re.length||_e[0]!==36064){for(let Ke=0,we=Re.length;Ke<we;Ke++)_e[Ke]=36064+Ke;_e.length=Re.length,Qe=!0}}else _e[0]!==36064&&(_e[0]=36064,Qe=!0);else _e[0]!==1029&&(_e[0]=1029,Qe=!0);Qe&&(t.isWebGL2?r.drawBuffers(_e):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(_e))}function K(H){return g!==H?(r.useProgram(H),g=H,!0):!1}let X={[Ha]:32774,[FC]:32778,[UC]:32779};if(n)X[Xx]=32775,X[Yx]=32776;else{let H=e.get("EXT_blend_minmax");H!==null&&(X[Xx]=H.MIN_EXT,X[Yx]=H.MAX_EXT)}let ne={[GC]:0,[zC]:1,[kC]:768,[Sw]:770,[XC]:776,[jC]:774,[HC]:772,[VC]:769,[Aw]:771,[qC]:775,[WC]:773};function ce(H,xe,_e,Qe,Re,Ke,we,Je){if(H===Rt){p===!0&&(W(3042),p=!1);return}if(p===!1&&(q(3042),p=!0),H!==BC){if(H!==m||Je!==M){if((v!==Ha||b!==Ha)&&(r.blendEquation(32774),v=Ha,b=Ha),Je)switch(H){case Fs:r.blendFuncSeparate(1,771,1,771);break;case Wx:r.blendFunc(1,1);break;case jx:r.blendFuncSeparate(0,769,0,1);break;case qx:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",H);break}else switch(H){case Fs:r.blendFuncSeparate(770,771,1,771);break;case Wx:r.blendFunc(770,1);break;case jx:r.blendFuncSeparate(0,769,0,1);break;case qx:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",H);break}y=null,w=null,S=null,_=null,m=H,M=Je}return}Re=Re||xe,Ke=Ke||_e,we=we||Qe,(xe!==v||Re!==b)&&(r.blendEquationSeparate(X[xe],X[Re]),v=xe,b=Re),(_e!==y||Qe!==w||Ke!==S||we!==_)&&(r.blendFuncSeparate(ne[_e],ne[Qe],ne[Ke],ne[we]),y=_e,w=Qe,S=Ke,_=we),m=H,M=null}function oe(H,xe){H.side===er?W(2884):q(2884);let _e=H.side===un;xe&&(_e=!_e),Te(_e),H.blending===Fs&&H.transparent===!1?ce(Rt):ce(H.blending,H.blendEquation,H.blendSrc,H.blendDst,H.blendEquationAlpha,H.blendSrcAlpha,H.blendDstAlpha,H.premultipliedAlpha),l.setFunc(H.depthFunc),l.setTest(H.depthTest),l.setMask(H.depthWrite),a.setMask(H.colorWrite);let Qe=H.stencilWrite;u.setTest(Qe),Qe&&(u.setMask(H.stencilWriteMask),u.setFunc(H.stencilFunc,H.stencilRef,H.stencilFuncMask),u.setOp(H.stencilFail,H.stencilZFail,H.stencilZPass)),ye(H.polygonOffset,H.polygonOffsetFactor,H.polygonOffsetUnits),H.alphaToCoverage===!0?q(32926):W(32926)}function Te(H){x!==H&&(H?r.frontFace(2304):r.frontFace(2305),x=H)}function me(H){H!==OC?(q(2884),H!==T&&(H===Hx?r.cullFace(1029):H===RC?r.cullFace(1028):r.cullFace(1032))):W(2884),T=H}function ge(H){H!==E&&(D&&r.lineWidth(H),E=H)}function ye(H,xe,_e){H?(q(32823),(C!==xe||P!==_e)&&(r.polygonOffset(xe,_e),C=xe,P=_e)):W(32823)}function de(H){H?q(3089):W(3089)}function Pe(H){H===void 0&&(H=33984+O-1),z!==H&&(r.activeTexture(H),z=H)}function Ne(H,xe){z===null&&Pe();let _e=Y[z];_e===void 0&&(_e={type:void 0,texture:void 0},Y[z]=_e),(_e.type!==H||_e.texture!==xe)&&(r.bindTexture(H,xe||j[H]),_e.type=H,_e.texture=xe)}function Ze(){let H=Y[z];H!==void 0&&H.type!==void 0&&(r.bindTexture(H.type,null),H.type=void 0,H.texture=void 0)}function R(){try{r.compressedTexImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function I(){try{r.texSubImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function le(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function fe(){try{r.texStorage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Ee(){try{r.texStorage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Ue(){try{r.texImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function re(){try{r.texImage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Fe(H){Q.equals(H)===!1&&(r.scissor(H.x,H.y,H.z,H.w),Q.copy(H))}function Oe(H){V.equals(H)===!1&&(r.viewport(H.x,H.y,H.z,H.w),V.copy(H))}function ve(){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={},z=null,Y={},h={},d=new WeakMap,f=[],g=null,p=!1,m=null,v=null,y=null,w=null,b=null,S=null,_=null,M=!1,x=null,T=null,E=null,C=null,P=null,Q.set(0,0,r.canvas.width,r.canvas.height),V.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:q,disable:W,bindFramebuffer:he,drawBuffers:ie,useProgram:K,setBlending:ce,setMaterial:oe,setFlipSided:Te,setCullFace:me,setLineWidth:ge,setPolygonOffset:ye,setScissorTest:de,activeTexture:Pe,bindTexture:Ne,unbindTexture:Ze,compressedTexImage2D:R,texImage2D:Ue,texImage3D:re,texStorage2D:fe,texStorage3D:Ee,texSubImage2D:I,texSubImage3D:J,compressedTexSubImage2D:le,scissor:Fe,viewport:Oe,reset:ve}}function bO(r,e,t,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,h=i.maxSamples,d=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap,p,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,I){return v?new OffscreenCanvas(R,I):Qd("canvas")}function w(R,I,J,le){let fe=1;if((R.width>le||R.height>le)&&(fe=le/Math.max(R.width,R.height)),fe<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ee=I?Yd:Math.floor,Ue=Ee(fe*R.width),re=Ee(fe*R.height);p===void 0&&(p=y(Ue,re));let Fe=J?y(Ue,re):p;return Fe.width=Ue,Fe.height=re,Fe.getContext("2d").drawImage(R,0,0,Ue,re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Ue+"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 b(R){return Jg(R.width)&&Jg(R.height)}function S(R){return a?!1:R.wrapS!==$n||R.wrapT!==$n||R.minFilter!==Ut&&R.minFilter!==at}function _(R,I){return R.generateMipmaps&&I&&R.minFilter!==Ut&&R.minFilter!==at}function M(R){r.generateMipmap(R)}function x(R,I,J,le,fe=!1){if(a===!1)return I;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 Ee=I;return I===6403&&(J===5126&&(Ee=33326),J===5131&&(Ee=33325),J===5121&&(Ee=33321)),I===33319&&(J===5126&&(Ee=33328),J===5131&&(Ee=33327),J===5121&&(Ee=33323)),I===6408&&(J===5126&&(Ee=34836),J===5131&&(Ee=34842),J===5121&&(Ee=le===Xe&&fe===!1?35907:32856),J===32819&&(Ee=32854),J===32820&&(Ee=32855)),(Ee===33325||Ee===33326||Ee===33327||Ee===33328||Ee===34842||Ee===34836)&&e.get("EXT_color_buffer_float"),Ee}function T(R,I,J){return _(R,J)===!0||R.isFramebufferTexture&&R.minFilter!==Ut&&R.minFilter!==at?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function E(R){return R===Ut||R===Qx||R===Zx?9728:9729}function C(R){let I=R.target;I.removeEventListener("dispose",C),O(I),I.isVideoTexture&&g.delete(I)}function P(R){let I=R.target;I.removeEventListener("dispose",P),N(I)}function O(R){let I=n.get(R);if(I.__webglInit===void 0)return;let J=R.source,le=m.get(J);if(le){let fe=le[I.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&D(R),Object.keys(le).length===0&&m.delete(J)}n.remove(R)}function D(R){let I=n.get(R);r.deleteTexture(I.__webglTexture);let J=R.source,le=m.get(J);delete le[I.__cacheKey],o.memory.textures--}function N(R){let I=R.texture,J=n.get(R),le=n.get(I);if(le.__webglTexture!==void 0&&(r.deleteTexture(le.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let fe=0;fe<6;fe++)r.deleteFramebuffer(J.__webglFramebuffer[fe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[fe]);else{if(r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let fe=0;fe<J.__webglColorRenderbuffer.length;fe++)J.__webglColorRenderbuffer[fe]&&r.deleteRenderbuffer(J.__webglColorRenderbuffer[fe]);J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let fe=0,Ee=I.length;fe<Ee;fe++){let Ue=n.get(I[fe]);Ue.__webglTexture&&(r.deleteTexture(Ue.__webglTexture),o.memory.textures--),n.remove(I[fe])}n.remove(I),n.remove(R)}let F=0;function z(){F=0}function Y(){let R=F;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),F+=1,R}function U(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function G(R,I){let J=n.get(R);if(R.isVideoTexture&&Ne(R),R.isRenderTargetTexture===!1&&R.version>0&&J.__version!==R.version){let le=R.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(J,R,I);return}}t.activeTexture(33984+I),t.bindTexture(3553,J.__webglTexture)}function Q(R,I){let J=n.get(R);if(R.version>0&&J.__version!==R.version){ie(J,R,I);return}t.activeTexture(33984+I),t.bindTexture(35866,J.__webglTexture)}function V(R,I){let J=n.get(R);if(R.version>0&&J.__version!==R.version){ie(J,R,I);return}t.activeTexture(33984+I),t.bindTexture(32879,J.__webglTexture)}function k(R,I){let J=n.get(R);if(R.version>0&&J.__version!==R.version){K(J,R,I);return}t.activeTexture(33984+I),t.bindTexture(34067,J.__webglTexture)}let j={[Xa]:10497,[$n]:33071,[Qg]:33648},q={[Ut]:9728,[Qx]:9984,[Zx]:9986,[at]:9729,[lP]:9985,[fl]:9987};function W(R,I,J){if(J?(r.texParameteri(R,10242,j[I.wrapS]),r.texParameteri(R,10243,j[I.wrapT]),(R===32879||R===35866)&&r.texParameteri(R,32882,j[I.wrapR]),r.texParameteri(R,10240,q[I.magFilter]),r.texParameteri(R,10241,q[I.minFilter])):(r.texParameteri(R,10242,33071),r.texParameteri(R,10243,33071),(R===32879||R===35866)&&r.texParameteri(R,32882,33071),(I.wrapS!==$n||I.wrapT!==$n)&&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(I.magFilter)),r.texParameteri(R,10241,E(I.minFilter)),I.minFilter!==Ut&&I.minFilter!==at&&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 le=e.get("EXT_texture_filter_anisotropic");if(I.type===Mi&&e.has("OES_texture_float_linear")===!1||a===!1&&I.type===Su&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||n.get(I).__currentAnisotropy)&&(r.texParameterf(R,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy)}}function he(R,I){let J=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",C));let le=I.source,fe=m.get(le);fe===void 0&&(fe={},m.set(le,fe));let Ee=U(I);if(Ee!==R.__cacheKey){fe[Ee]===void 0&&(fe[Ee]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,J=!0),fe[Ee].usedTimes++;let Ue=fe[R.__cacheKey];Ue!==void 0&&(fe[R.__cacheKey].usedTimes--,Ue.usedTimes===0&&D(I)),R.__cacheKey=Ee,R.__webglTexture=fe[Ee].texture}return J}function ie(R,I,J){let le=3553;I.isDataArrayTexture&&(le=35866),I.isData3DTexture&&(le=32879);let fe=he(R,I),Ee=I.source;if(t.activeTexture(33984+J),t.bindTexture(le,R.__webglTexture),Ee.version!==Ee.__currentVersion||fe===!0){r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Ue=S(I)&&b(I.image)===!1,re=w(I.image,Ue,!1,c);re=Ze(I,re);let Fe=b(re)||a,Oe=s.convert(I.format,I.encoding),ve=s.convert(I.type),H=x(I.internalFormat,Oe,ve,I.encoding,I.isVideoTexture);W(le,I,Fe);let xe,_e=I.mipmaps,Qe=a&&I.isVideoTexture!==!0,Re=Ee.__currentVersion===void 0||fe===!0,Ke=T(I,re,Fe);if(I.isDepthTexture)H=6402,a?I.type===Mi?H=36012:I.type===ds?H=33190:I.type===Us?H=35056:H=33189:I.type===Mi&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Fo&&H===6402&&I.type!==Mw&&I.type!==ds&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=ds,ve=s.convert(I.type)),I.format===ks&&H===6402&&(H=34041,I.type!==Us&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Us,ve=s.convert(I.type))),Re&&(Qe?t.texStorage2D(3553,1,H,re.width,re.height):t.texImage2D(3553,0,H,re.width,re.height,0,Oe,ve,null));else if(I.isDataTexture)if(_e.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],Qe?t.texSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,ve,xe.data):t.texImage2D(3553,we,H,xe.width,xe.height,0,Oe,ve,xe.data);I.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Ke,H,re.width,re.height),t.texSubImage2D(3553,0,0,0,re.width,re.height,Oe,ve,re.data)):t.texImage2D(3553,0,H,re.width,re.height,0,Oe,ve,re.data);else if(I.isCompressedTexture){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],I.format!==oi?Oe!==null?Qe?t.compressedTexSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,xe.data):t.compressedTexImage2D(3553,we,H,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?t.texSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,ve,xe.data):t.texImage2D(3553,we,H,xe.width,xe.height,0,Oe,ve,xe.data)}else if(I.isDataArrayTexture)Qe?(Re&&t.texStorage3D(35866,Ke,H,re.width,re.height,re.depth),t.texSubImage3D(35866,0,0,0,0,re.width,re.height,re.depth,Oe,ve,re.data)):t.texImage3D(35866,0,H,re.width,re.height,re.depth,0,Oe,ve,re.data);else if(I.isData3DTexture)Qe?(Re&&t.texStorage3D(32879,Ke,H,re.width,re.height,re.depth),t.texSubImage3D(32879,0,0,0,0,re.width,re.height,re.depth,Oe,ve,re.data)):t.texImage3D(32879,0,H,re.width,re.height,re.depth,0,Oe,ve,re.data);else if(I.isFramebufferTexture){if(Re)if(Qe)t.texStorage2D(3553,Ke,H,re.width,re.height);else{let we=re.width,Je=re.height;for(let it=0;it<Ke;it++)t.texImage2D(3553,it,H,we,Je,0,Oe,ve,null),we>>=1,Je>>=1}}else if(_e.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],Qe?t.texSubImage2D(3553,we,0,0,Oe,ve,xe):t.texImage2D(3553,we,H,Oe,ve,xe);I.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Ke,H,re.width,re.height),t.texSubImage2D(3553,0,0,0,Oe,ve,re)):t.texImage2D(3553,0,H,Oe,ve,re);_(I,Fe)&&M(le),Ee.__currentVersion=Ee.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function K(R,I,J){if(I.image.length!==6)return;let le=he(R,I),fe=I.source;if(t.activeTexture(33984+J),t.bindTexture(34067,R.__webglTexture),fe.version!==fe.__currentVersion||le===!0){r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Ee=I.isCompressedTexture||I.image[0].isCompressedTexture,Ue=I.image[0]&&I.image[0].isDataTexture,re=[];for(let we=0;we<6;we++)!Ee&&!Ue?re[we]=w(I.image[we],!1,!0,u):re[we]=Ue?I.image[we].image:I.image[we],re[we]=Ze(I,re[we]);let Fe=re[0],Oe=b(Fe)||a,ve=s.convert(I.format,I.encoding),H=s.convert(I.type),xe=x(I.internalFormat,ve,H,I.encoding),_e=a&&I.isVideoTexture!==!0,Qe=fe.__currentVersion===void 0||le===!0,Re=T(I,Fe,Oe);W(34067,I,Oe);let Ke;if(Ee){_e&&Qe&&t.texStorage2D(34067,Re,xe,Fe.width,Fe.height);for(let we=0;we<6;we++){Ke=re[we].mipmaps;for(let Je=0;Je<Ke.length;Je++){let it=Ke[Je];I.format!==oi?ve!==null?_e?t.compressedTexSubImage2D(34069+we,Je,0,0,it.width,it.height,ve,it.data):t.compressedTexImage2D(34069+we,Je,xe,it.width,it.height,0,it.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?t.texSubImage2D(34069+we,Je,0,0,it.width,it.height,ve,H,it.data):t.texImage2D(34069+we,Je,xe,it.width,it.height,0,ve,H,it.data)}}}else{Ke=I.mipmaps,_e&&Qe&&(Ke.length>0&&Re++,t.texStorage2D(34067,Re,xe,re[0].width,re[0].height));for(let we=0;we<6;we++)if(Ue){_e?t.texSubImage2D(34069+we,0,0,0,re[we].width,re[we].height,ve,H,re[we].data):t.texImage2D(34069+we,0,xe,re[we].width,re[we].height,0,ve,H,re[we].data);for(let Je=0;Je<Ke.length;Je++){let yt=Ke[Je].image[we].image;_e?t.texSubImage2D(34069+we,Je+1,0,0,yt.width,yt.height,ve,H,yt.data):t.texImage2D(34069+we,Je+1,xe,yt.width,yt.height,0,ve,H,yt.data)}}else{_e?t.texSubImage2D(34069+we,0,0,0,ve,H,re[we]):t.texImage2D(34069+we,0,xe,ve,H,re[we]);for(let Je=0;Je<Ke.length;Je++){let it=Ke[Je];_e?t.texSubImage2D(34069+we,Je+1,0,0,ve,H,it.image[we]):t.texImage2D(34069+we,Je+1,xe,ve,H,it.image[we])}}}_(I,Oe)&&M(34067),fe.__currentVersion=fe.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function X(R,I,J,le,fe){let Ee=s.convert(J.format,J.encoding),Ue=s.convert(J.type),re=x(J.internalFormat,Ee,Ue,J.encoding);n.get(I).__hasExternalTextures||(fe===32879||fe===35866?t.texImage3D(fe,0,re,I.width,I.height,I.depth,0,Ee,Ue,null):t.texImage2D(fe,0,re,I.width,I.height,0,Ee,Ue,null)),t.bindFramebuffer(36160,R),Pe(I)?d.framebufferTexture2DMultisampleEXT(36160,le,fe,n.get(J).__webglTexture,0,de(I)):r.framebufferTexture2D(36160,le,fe,n.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function ne(R,I,J){if(r.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let le=33189;if(J||Pe(I)){let fe=I.depthTexture;fe&&fe.isDepthTexture&&(fe.type===Mi?le=36012:fe.type===ds&&(le=33190));let Ee=de(I);Pe(I)?d.renderbufferStorageMultisampleEXT(36161,Ee,le,I.width,I.height):r.renderbufferStorageMultisample(36161,Ee,le,I.width,I.height)}else r.renderbufferStorage(36161,le,I.width,I.height);r.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let le=de(I);J&&Pe(I)===!1?r.renderbufferStorageMultisample(36161,le,35056,I.width,I.height):Pe(I)?d.renderbufferStorageMultisampleEXT(36161,le,35056,I.width,I.height):r.renderbufferStorage(36161,34041,I.width,I.height),r.framebufferRenderbuffer(36160,33306,36161,R)}else{let le=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let fe=0;fe<le.length;fe++){let Ee=le[fe],Ue=s.convert(Ee.format,Ee.encoding),re=s.convert(Ee.type),Fe=x(Ee.internalFormat,Ue,re,Ee.encoding),Oe=de(I);J&&Pe(I)===!1?r.renderbufferStorageMultisample(36161,Oe,Fe,I.width,I.height):Pe(I)?d.renderbufferStorageMultisampleEXT(36161,Oe,Fe,I.width,I.height):r.renderbufferStorage(36161,Fe,I.width,I.height)}}r.bindRenderbuffer(36161,null)}function ce(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),G(I.depthTexture,0);let le=n.get(I.depthTexture).__webglTexture,fe=de(I);if(I.depthTexture.format===Fo)Pe(I)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,le,0,fe):r.framebufferTexture2D(36160,36096,3553,le,0);else if(I.depthTexture.format===ks)Pe(I)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,le,0,fe):r.framebufferTexture2D(36160,33306,3553,le,0);else throw new Error("Unknown depthTexture format")}function oe(R){let I=n.get(R),J=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");ce(I.__webglFramebuffer,R)}else if(J){I.__webglDepthbuffer=[];for(let le=0;le<6;le++)t.bindFramebuffer(36160,I.__webglFramebuffer[le]),I.__webglDepthbuffer[le]=r.createRenderbuffer(),ne(I.__webglDepthbuffer[le],R,!1)}else t.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=r.createRenderbuffer(),ne(I.__webglDepthbuffer,R,!1);t.bindFramebuffer(36160,null)}function Te(R,I,J){let le=n.get(R);I!==void 0&&X(le.__webglFramebuffer,R,R.texture,36064,3553),J!==void 0&&oe(R)}function me(R){let I=R.texture,J=n.get(R),le=n.get(I);R.addEventListener("dispose",P),R.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture===void 0&&(le.__webglTexture=r.createTexture()),le.__version=I.version,o.memory.textures++);let fe=R.isWebGLCubeRenderTarget===!0,Ee=R.isWebGLMultipleRenderTargets===!0,Ue=b(R)||a;if(fe){J.__webglFramebuffer=[];for(let re=0;re<6;re++)J.__webglFramebuffer[re]=r.createFramebuffer()}else{if(J.__webglFramebuffer=r.createFramebuffer(),Ee)if(i.drawBuffers){let re=R.texture;for(let Fe=0,Oe=re.length;Fe<Oe;Fe++){let ve=n.get(re[Fe]);ve.__webglTexture===void 0&&(ve.__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=Ee?I:[I];J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer);for(let Fe=0;Fe<re.length;Fe++){let Oe=re[Fe];J.__webglColorRenderbuffer[Fe]=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer[Fe]);let ve=s.convert(Oe.format,Oe.encoding),H=s.convert(Oe.type),xe=x(Oe.internalFormat,ve,H,Oe.encoding),_e=de(R);r.renderbufferStorageMultisample(36161,_e,xe,R.width,R.height),r.framebufferRenderbuffer(36160,36064+Fe,36161,J.__webglColorRenderbuffer[Fe])}r.bindRenderbuffer(36161,null),R.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),ne(J.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(36160,null)}}if(fe){t.bindTexture(34067,le.__webglTexture),W(34067,I,Ue);for(let re=0;re<6;re++)X(J.__webglFramebuffer[re],R,I,36064,34069+re);_(I,Ue)&&M(34067),t.unbindTexture()}else if(Ee){let re=R.texture;for(let Fe=0,Oe=re.length;Fe<Oe;Fe++){let ve=re[Fe],H=n.get(ve);t.bindTexture(3553,H.__webglTexture),W(3553,ve,Ue),X(J.__webglFramebuffer,R,ve,36064+Fe,3553),_(ve,Ue)&&M(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,le.__webglTexture),W(re,I,Ue),X(J.__webglFramebuffer,R,I,36064,re),_(I,Ue)&&M(re),t.unbindTexture()}R.depthBuffer&&oe(R)}function ge(R){let I=b(R)||a,J=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let le=0,fe=J.length;le<fe;le++){let Ee=J[le];if(_(Ee,I)){let Ue=R.isWebGLCubeRenderTarget?34067:3553,re=n.get(Ee).__webglTexture;t.bindTexture(Ue,re),M(Ue),t.unbindTexture()}}}function ye(R){if(a&&R.samples>0&&Pe(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],J=R.width,le=R.height,fe=16384,Ee=[],Ue=R.stencilBuffer?33306:36096,re=n.get(R),Fe=R.isWebGLMultipleRenderTargets===!0;if(Fe)for(let Oe=0;Oe<I.length;Oe++)t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Oe,36161,null),t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Oe,3553,null,0);t.bindFramebuffer(36008,re.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,re.__webglFramebuffer);for(let Oe=0;Oe<I.length;Oe++){Ee.push(36064+Oe),R.depthBuffer&&Ee.push(Ue);let ve=re.__ignoreDepthValues!==void 0?re.__ignoreDepthValues:!1;if(ve===!1&&(R.depthBuffer&&(fe|=256),R.stencilBuffer&&(fe|=1024)),Fe&&r.framebufferRenderbuffer(36008,36064,36161,re.__webglColorRenderbuffer[Oe]),ve===!0&&(r.invalidateFramebuffer(36008,[Ue]),r.invalidateFramebuffer(36009,[Ue])),Fe){let H=n.get(I[Oe]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,H,0)}r.blitFramebuffer(0,0,J,le,0,0,J,le,fe,9728),f&&r.invalidateFramebuffer(36008,Ee)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Fe)for(let Oe=0;Oe<I.length;Oe++){t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Oe,36161,re.__webglColorRenderbuffer[Oe]);let ve=n.get(I[Oe]).__webglTexture;t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Oe,3553,ve,0)}t.bindFramebuffer(36009,re.__webglMultisampledFramebuffer)}}function de(R){return Math.min(h,R.samples)}function Pe(R){let I=n.get(R);return a&&R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ne(R){let I=o.render.frame;g.get(R)!==I&&(g.set(R,I),R.update())}function Ze(R,I){let J=R.encoding,le=R.format,fe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Kg||J!==Er&&(J===Xe?a===!1?e.has("EXT_sRGB")===!0&&le===oi?(R.format=Kg,R.minFilter=at,R.generateMipmaps=!1):I=Zd.sRGBToLinear(I):(le!==oi||fe!==Gt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),I}this.allocateTextureUnit=Y,this.resetTextureUnits=z,this.setTexture2D=G,this.setTexture2DArray=Q,this.setTexture3D=V,this.setTextureCube=k,this.rebindTextures=Te,this.setupRenderTarget=me,this.updateRenderTargetMipmap=ge,this.updateMultisampleRenderTarget=ye,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=X,this.useMultisampledRTT=Pe}function wO(r,e,t){let n=t.isWebGL2;function i(s,o=null){let a;if(s===Gt)return 5121;if(s===dP)return 32819;if(s===fP)return 32820;if(s===cP)return 5120;if(s===uP)return 5122;if(s===Mw)return 5123;if(s===hP)return 5124;if(s===ds)return 5125;if(s===Mi)return 5126;if(s===Su)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===pP)return 6406;if(s===oi)return 6408;if(s===gP)return 6409;if(s===yP)return 6410;if(s===Fo)return 6402;if(s===ks)return 34041;if(s===vP)return 6403;if(s===mP)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===Kg)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===xP)return 36244;if(s===bP)return 33319;if(s===wP)return 33320;if(s===SP)return 36249;if(s===ug||s===hg||s===dg||s===fg)if(o===Xe)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===ug)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===hg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===dg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===fg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===ug)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===hg)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===dg)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===fg)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Kx||s===Jx||s===$x||s===eb)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Kx)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Jx)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===$x)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===eb)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===AP)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===tb||s===nb)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===tb)return o===Xe?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===nb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===rb||s===ib||s===sb||s===ob||s===ab||s===lb||s===cb||s===ub||s===hb||s===db||s===fb||s===pb||s===mb||s===gb)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===rb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===ib)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===sb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ob)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===ab)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===lb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===cb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===ub)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===hb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===db)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===fb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===pb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===mb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===gb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===yb)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===yb)return o===Xe?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Us?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 cy=class extends nn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Bs=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}},SO={type:"move"},xu=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Bs,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 Bs,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 Bs,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 m=t.getJointPose(p,n);if(u.joints[p.jointName]===void 0){let y=new Bs;y.matrixAutoUpdate=!1,y.visible=!1,u.joints[p.jointName]=y,u.add(y)}let v=u.joints[p.jointName];m!==null&&(v.matrix.fromArray(m.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=m.radius),v.visible=m!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,g=.005;u.inputState.pinching&&d>f+g?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&d<=f-g&&(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(SO)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}},Hs=class extends Yt{constructor(e,t,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Fo,c!==Fo&&c!==ks)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Fo&&(n=ds),n===void 0&&c===ks&&(n=Us),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:Ut,this.minFilter=l!==void 0?l:Ut,this.flipY=!1,this.generateMipmaps=!1}},uy=class extends Lt{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=null,u=null,c=null,h=null,d=null,f=null,g=t.getContextAttributes(),p=null,m=null,v=[],y=[],w=new nn;w.layers.enable(1),w.viewport=new He;let b=new nn;b.layers.enable(2),b.viewport=new He;let S=[w,b],_=new cy;_.layers.enable(1),_.layers.enable(2);let M=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let G=v[U];return G===void 0&&(G=new xu,v[U]=G),G.getTargetRaySpace()},this.getControllerGrip=function(U){let G=v[U];return G===void 0&&(G=new xu,v[U]=G),G.getGripSpace()},this.getHand=function(U){let G=v[U];return G===void 0&&(G=new xu,v[U]=G),G.getHandSpace()};function T(U){let G=y.indexOf(U.inputSource);if(G===-1)return;let Q=v[G];Q!==void 0&&Q.dispatchEvent({type:U.type,data:U.inputSource})}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C);for(let U=0;U<v.length;U++){let G=y[U];G!==null&&(y[U]=null,v[U].disconnect(G))}M=null,x=null,e.setRenderTarget(p),d=null,h=null,c=null,i=null,m=null,Y.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(U){l=U},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(U){if(i=U,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),g.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let G={antialias:i.renderState.layers===void 0?g.antialias:!0,alpha:g.alpha,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,G),i.updateRenderState({baseLayer:d}),m=new dt(d.framebufferWidth,d.framebufferHeight,{format:oi,type:Gt,encoding:e.outputEncoding})}else{let G=null,Q=null,V=null;g.depth&&(V=g.stencil?35056:33190,G=g.stencil?ks:Fo,Q=g.stencil?Us:ds);let k={colorFormat:32856,depthFormat:V,scaleFactor:s};c=new XRWebGLBinding(i,t),h=c.createProjectionLayer(k),i.updateRenderState({layers:[h]}),m=new dt(h.textureWidth,h.textureHeight,{format:oi,type:Gt,depthTexture:new Hs(h.textureWidth,h.textureHeight,Q,void 0,void 0,void 0,void 0,void 0,void 0,G),stencilBuffer:g.stencil,encoding:e.outputEncoding,samples:g.antialias?4:0});let j=e.properties.get(m);j.__ignoreDepthValues=h.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),Y.setContext(i),Y.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function C(U){for(let G=0;G<U.removed.length;G++){let Q=U.removed[G],V=y.indexOf(Q);V>=0&&(y[V]=null,v[V].dispatchEvent({type:"disconnected",data:Q}))}for(let G=0;G<U.added.length;G++){let Q=U.added[G],V=y.indexOf(Q);if(V===-1){for(let j=0;j<v.length;j++)if(j>=y.length){y.push(Q),V=j;break}else if(y[j]===null){y[j]=Q,V=j;break}if(V===-1)break}let k=v[V];k&&k.dispatchEvent({type:"connected",data:Q})}}let P=new A,O=new A;function D(U,G,Q){P.setFromMatrixPosition(G.matrixWorld),O.setFromMatrixPosition(Q.matrixWorld);let V=P.distanceTo(O),k=G.projectionMatrix.elements,j=Q.projectionMatrix.elements,q=k[14]/(k[10]-1),W=k[14]/(k[10]+1),he=(k[9]+1)/k[5],ie=(k[9]-1)/k[5],K=(k[8]-1)/k[0],X=(j[8]+1)/j[0],ne=q*K,ce=q*X,oe=V/(-K+X),Te=oe*-K;G.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(Te),U.translateZ(oe),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();let me=q+oe,ge=W+oe,ye=ne-Te,de=ce+(V-Te),Pe=he*W/ge*me,Ne=ie*W/ge*me;U.projectionMatrix.makePerspective(ye,de,Pe,Ne,me,ge)}function N(U,G){G===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(G.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(i===null)return;_.near=b.near=w.near=U.near,_.far=b.far=w.far=U.far,(M!==_.near||x!==_.far)&&(i.updateRenderState({depthNear:_.near,depthFar:_.far}),M=_.near,x=_.far);let G=U.parent,Q=_.cameras;N(_,G);for(let k=0;k<Q.length;k++)N(Q[k],G);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),U.position.copy(_.position),U.quaternion.copy(_.quaternion),U.scale.copy(_.scale),U.matrix.copy(_.matrix),U.matrixWorld.copy(_.matrixWorld);let V=U.children;for(let k=0,j=V.length;k<j;k++)V[k].updateMatrixWorld(!0);Q.length===2?D(_,w,b):_.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(h!==null)return h.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(U){h!==null&&(h.fixedFoveation=U),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=U)};let F=null;function z(U,G){if(u=G.getViewerPose(l||o),f=G,u!==null){let Q=u.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let V=!1;Q.length!==_.cameras.length&&(_.cameras.length=0,V=!0);for(let k=0;k<Q.length;k++){let j=Q[k],q=null;if(d!==null)q=d.getViewport(j);else{let he=c.getViewSubImage(h,j);q=he.viewport,k===0&&(e.setRenderTargetTextures(m,he.colorTexture,h.ignoreDepthValues?void 0:he.depthStencilTexture),e.setRenderTarget(m))}let W=S[k];W===void 0&&(W=new nn,W.layers.enable(k),W.viewport=new He,S[k]=W),W.matrix.fromArray(j.transform.matrix),W.projectionMatrix.fromArray(j.projectionMatrix),W.viewport.set(q.x,q.y,q.width,q.height),k===0&&_.matrix.copy(W.matrix),V===!0&&_.cameras.push(W)}}for(let Q=0;Q<v.length;Q++){let V=y[Q],k=v[Q];V!==null&&k!==void 0&&k.update(V,G,l||o)}F&&F(U,G),f=null}let Y=new Pw;Y.setAnimationLoop(z),this.setAnimationLoop=function(U){F=U},this.dispose=function(){}}};function AO(r,e){function t(p,m){p.fogColor.value.copy(m.color),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function n(p,m,v,y,w){m.isMeshBasicMaterial||m.isMeshLambertMaterial?i(p,m):m.isMeshToonMaterial?(i(p,m),c(p,m)):m.isMeshPhongMaterial?(i(p,m),u(p,m)):m.isMeshStandardMaterial?(i(p,m),h(p,m),m.isMeshPhysicalMaterial&&d(p,m,w)):m.isMeshMatcapMaterial?(i(p,m),f(p,m)):m.isMeshDepthMaterial?i(p,m):m.isMeshDistanceMaterial?(i(p,m),g(p,m)):m.isMeshNormalMaterial?i(p,m):m.isLineBasicMaterial?(s(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?a(p,m,v,y):m.isSpriteMaterial?l(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function i(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===un&&(p.bumpScale.value*=-1)),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===un&&p.normalScale.value.negate()),m.specularMap&&(p.specularMap.value=m.specularMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let v=e.get(m).envMap;if(v&&(p.envMap.value=v,p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap){p.lightMap.value=m.lightMap;let b=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=m.lightMapIntensity*b}m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix));let w;m.aoMap?w=m.aoMap:m.lightMap&&(w=m.lightMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uv2Transform.value.copy(w.matrix))}function s(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function a(p,m,v,y){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*v,p.scale.value=y*.5,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let w;m.map?w=m.map:m.alphaMap&&(w=m.alphaMap),w!==void 0&&(w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix))}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function c(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function h(p,m){p.roughness.value=m.roughness,p.metalness.value=m.metalness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap),e.get(m).envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function d(p,m,v){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),p.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===un&&p.clearcoatNormalScale.value.negate())),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=v.texture,p.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap)}function f(p,m){m.matcap&&(p.matcap.value=m.matcap)}function g(p,m){p.referencePosition.value.copy(m.referencePosition),p.nearDistance.value=m.nearDistance,p.farDistance.value=m.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function _O(){let r=Qd("canvas");return r.style.display="block",r}function By(r={}){this.isWebGLRenderer=!0;let e=r.canvas!==void 0?r.canvas:_O(),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 h=null,d=null,f=[],g=[];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=Er,this.physicallyCorrectLights=!1,this.toneMapping=fs,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,m=!1,v=0,y=0,w=null,b=-1,S=null,_=new He,M=new He,x=null,T=e.width,E=e.height,C=1,P=null,O=null,D=new He(0,0,T,E),N=new He(0,0,T,E),F=!1,z=new Mu,Y=!1,U=!1,G=null,Q=new be,V=new B,k=new A,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return w===null?C:1}let W=t;function he(L,$){for(let se=0;se<L.length;se++){let te=L[se],ue=e.getContext(te,$);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${Zo}`),e.addEventListener("webglcontextlost",H,!1),e.addEventListener("webglcontextrestored",xe,!1),e.addEventListener("webglcontextcreationerror",_e,!1),W===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),W=he($,L),W===null)throw he($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let ie,K,X,ne,ce,oe,Te,me,ge,ye,de,Pe,Ne,Ze,R,I,J,le,fe,Ee,Ue,re,Fe;function Oe(){ie=new jI(W),K=new GI(W,ie,r),ie.init(K),re=new wO(W,ie,K),X=new xO(W,ie,K),ne=new YI,ce=new aO,oe=new bO(W,ie,X,ce,K,re,ne),Te=new kI(p),me=new WI(p),ge=new o2(W,K),Fe=new FI(W,ie,ge,K),ye=new qI(W,ge,ne,Fe),de=new JI(W,ye,ge,ne),fe=new KI(W,K,oe),I=new zI(ce),Pe=new oO(p,Te,me,ie,K,Fe,I),Ne=new AO(p,ce),Ze=new cO,R=new mO(ie,K),le=new BI(p,Te,X,de,c,o),J=new vO(p,de,K),Ee=new UI(W,ie,ne,K),Ue=new XI(W,ie,ne,K),ne.programs=Pe.programs,p.capabilities=K,p.extensions=ie,p.properties=ce,p.renderLists=Ze,p.shadowMap=J,p.state=X,p.info=ne}Oe();let ve=new uy(p,W);this.xr=ve,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){let L=ie.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=ie.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(L){L!==void 0&&(C=L,this.setSize(T,E,!1))},this.getSize=function(L){return L.set(T,E)},this.setSize=function(L,$,se){if(ve.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=L,E=$,e.width=Math.floor(L*C),e.height=Math.floor($*C),se!==!1&&(e.style.width=L+"px",e.style.height=$+"px"),this.setViewport(0,0,L,$)},this.getDrawingBufferSize=function(L){return L.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(L,$,se){T=L,E=$,C=se,e.width=Math.floor(L*se),e.height=Math.floor($*se),this.setViewport(0,0,L,$)},this.getCurrentViewport=function(L){return L.copy(_)},this.getViewport=function(L){return L.copy(D)},this.setViewport=function(L,$,se,te){L.isVector4?D.set(L.x,L.y,L.z,L.w):D.set(L,$,se,te),X.viewport(_.copy(D).multiplyScalar(C).floor())},this.getScissor=function(L){return L.copy(N)},this.setScissor=function(L,$,se,te){L.isVector4?N.set(L.x,L.y,L.z,L.w):N.set(L,$,se,te),X.scissor(M.copy(N).multiplyScalar(C).floor())},this.getScissorTest=function(){return F},this.setScissorTest=function(L){X.setScissorTest(F=L)},this.setOpaqueSort=function(L){P=L},this.setTransparentSort=function(L){O=L},this.getClearColor=function(L){return L.copy(le.getClearColor())},this.setClearColor=function(){le.setClearColor.apply(le,arguments)},this.getClearAlpha=function(){return le.getClearAlpha()},this.setClearAlpha=function(){le.setClearAlpha.apply(le,arguments)},this.clear=function(L=!0,$=!0,se=!0){let te=0;L&&(te|=16384),$&&(te|=256),se&&(te|=1024),W.clear(te)},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",H,!1),e.removeEventListener("webglcontextrestored",xe,!1),e.removeEventListener("webglcontextcreationerror",_e,!1),Ze.dispose(),R.dispose(),ce.dispose(),Te.dispose(),me.dispose(),de.dispose(),Fe.dispose(),Pe.dispose(),ve.dispose(),ve.removeEventListener("sessionstart",it),ve.removeEventListener("sessionend",yt),G&&(G.dispose(),G=null),At.stop()};function H(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let L=ne.autoReset,$=J.enabled,se=J.autoUpdate,te=J.needsUpdate,ue=J.type;Oe(),ne.autoReset=L,J.enabled=$,J.autoUpdate=se,J.needsUpdate=te,J.type=ue}function _e(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){Ke(L),ce.remove(L)}function Ke(L){let $=ce.get(L).programs;$!==void 0&&($.forEach(function(se){Pe.releaseProgram(se)}),L.isShaderMaterial&&Pe.releaseShaderCache(L))}this.renderBufferDirect=function(L,$,se,te,ue,et){$===null&&($=j);let rt=ue.isMesh&&ue.matrixWorld.determinant()<0,ot=AC(L,$,se,te,ue);X.setMaterial(te,rt);let st=se.index,Dt=se.attributes.position;if(st===null){if(Dt===void 0||Dt.count===0)return}else if(st.count===0)return;let pt=1;te.wireframe===!0&&(st=ye.getWireframeAttribute(se),pt=2),Fe.setup(ue,te,ot,se,st);let vt,qt=Ee;st!==null&&(vt=ge.get(st),qt=Ue,qt.setIndex(vt));let Do=st!==null?st.count:Dt.count,Ma=se.drawRange.start*pt,Ea=se.drawRange.count*pt,Si=et!==null?et.start*pt:0,_t=et!==null?et.count*pt:1/0,Ca=Math.max(Ma,Si),ln=Math.min(Do,Ma+Ea,Si+_t)-1,Ai=Math.max(0,ln-Ca+1);if(Ai!==0){if(ue.isMesh)te.wireframe===!0?(X.setLineWidth(te.wireframeLinewidth*q()),qt.setMode(1)):qt.setMode(4);else if(ue.isLine){let Cs=te.linewidth;Cs===void 0&&(Cs=1),X.setLineWidth(Cs*q()),ue.isLineSegments?qt.setMode(1):ue.isLineLoop?qt.setMode(2):qt.setMode(3)}else ue.isPoints?qt.setMode(0):ue.isSprite&&qt.setMode(4);if(ue.isInstancedMesh)qt.renderInstances(Ca,Ai,ue.count);else if(se.isInstancedBufferGeometry){let Cs=Math.min(se.instanceCount,se._maxInstanceCount);qt.renderInstances(Ca,Ai,Cs)}else qt.render(Ca,Ai)}},this.compile=function(L,$){d=R.get(L),d.init(),g.push(d),L.traverseVisible(function(se){se.isLight&&se.layers.test($.layers)&&(d.pushLight(se),se.castShadow&&d.pushShadow(se))}),d.setupLights(p.physicallyCorrectLights),L.traverse(function(se){let te=se.material;if(te)if(Array.isArray(te))for(let ue=0;ue<te.length;ue++){let et=te[ue];og(et,L,se)}else og(te,L,se)}),g.pop(),d=null};let we=null;function Je(L){we&&we(L)}function it(){At.stop()}function yt(){At.start()}let At=new Pw;At.setAnimationLoop(Je),typeof self<"u"&&At.setContext(self),this.setAnimationLoop=function(L){we=L,ve.setAnimationLoop(L),L===null?At.stop():At.start()},ve.addEventListener("sessionstart",it),ve.addEventListener("sessionend",yt),this.render=function(L,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;L.autoUpdate===!0&&L.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),ve.enabled===!0&&ve.isPresenting===!0&&(ve.cameraAutoUpdate===!0&&ve.updateCamera($),$=ve.getCamera()),L.isScene===!0&&L.onBeforeRender(p,L,$,w),d=R.get(L,g.length),d.init(),g.push(d),Q.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),z.setFromProjectionMatrix(Q),U=this.localClippingEnabled,Y=I.init(this.clippingPlanes,U,$),h=Ze.get(L,f.length),h.init(),f.push(h),cr(L,$,0,p.sortObjects),h.finish(),p.sortObjects===!0&&h.sort(P,O),Y===!0&&I.beginShadows();let se=d.state.shadowsArray;if(J.render(se,L,$),Y===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),le.render(h,L),d.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let te=$.cameras;for(let ue=0,et=te.length;ue<et;ue++){let rt=te[ue];md(h,L,rt,rt.viewport)}}else md(h,L,$);w!==null&&(oe.updateMultisampleRenderTarget(w),oe.updateRenderTargetMipmap(w)),L.isScene===!0&&L.onAfterRender(p,L,$),Fe.resetDefaultState(),b=-1,S=null,g.pop(),g.length>0?d=g[g.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function cr(L,$,se,te){if(L.visible===!1)return;if(L.layers.test($.layers)){if(L.isGroup)se=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update($);else if(L.isLight)d.pushLight(L),L.castShadow&&d.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||z.intersectsSprite(L)){te&&k.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let rt=de.update(L),ot=L.material;ot.visible&&h.push(L,rt,ot,se,k.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==ne.render.frame&&(L.skeleton.update(),L.skeleton.frame=ne.render.frame),!L.frustumCulled||z.intersectsObject(L))){te&&k.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let rt=de.update(L),ot=L.material;if(Array.isArray(ot)){let st=rt.groups;for(let Dt=0,pt=st.length;Dt<pt;Dt++){let vt=st[Dt],qt=ot[vt.materialIndex];qt&&qt.visible&&h.push(L,rt,qt,se,k.z,vt)}}else ot.visible&&h.push(L,rt,ot,se,k.z,null)}}let et=L.children;for(let rt=0,ot=et.length;rt<ot;rt++)cr(et[rt],$,se,te)}function md(L,$,se,te){let ue=L.opaque,et=L.transmissive,rt=L.transparent;d.setupLightsView(se),et.length>0&&Ta(ue,$,se),te&&X.viewport(_.copy(te)),ue.length>0&&gd(ue,$,se),et.length>0&&gd(et,$,se),rt.length>0&&gd(rt,$,se),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function Ta(L,$,se){let te=K.isWebGL2;G===null&&(G=new dt(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?Su:Gt,minFilter:fl,samples:te&&s===!0?4:0})),p.getDrawingBufferSize(V),te?G.setSize(V.x,V.y):G.setSize(Yd(V.x),Yd(V.y));let ue=p.getRenderTarget();p.setRenderTarget(G),p.clear();let et=p.toneMapping;p.toneMapping=fs,gd(L,$,se),p.toneMapping=et,oe.updateMultisampleRenderTarget(G),oe.updateRenderTargetMipmap(G),p.setRenderTarget(ue)}function gd(L,$,se){let te=$.isScene===!0?$.overrideMaterial:null;for(let ue=0,et=L.length;ue<et;ue++){let rt=L[ue],ot=rt.object,st=rt.geometry,Dt=te===null?rt.material:te,pt=rt.group;ot.layers.test(se.layers)&&SC(ot,$,se,st,Dt,pt)}}function SC(L,$,se,te,ue,et){L.onBeforeRender(p,$,se,te,ue,et),L.modelViewMatrix.multiplyMatrices(se.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),ue.onBeforeRender(p,$,se,te,L,et),ue.transparent===!0&&ue.side===er?(ue.side=un,ue.needsUpdate=!0,p.renderBufferDirect(se,$,te,ue,L,et),ue.side=Gr,ue.needsUpdate=!0,p.renderBufferDirect(se,$,te,ue,L,et),ue.side=er):p.renderBufferDirect(se,$,te,ue,L,et),L.onAfterRender(p,$,se,te,ue,et)}function og(L,$,se){$.isScene!==!0&&($=j);let te=ce.get(L),ue=d.state.lights,et=d.state.shadowsArray,rt=ue.state.version,ot=Pe.getParameters(L,ue.state,et,$,se),st=Pe.getProgramCacheKey(ot),Dt=te.programs;te.environment=L.isMeshStandardMaterial?$.environment:null,te.fog=$.fog,te.envMap=(L.isMeshStandardMaterial?me:Te).get(L.envMap||te.environment),Dt===void 0&&(L.addEventListener("dispose",Qe),Dt=new Map,te.programs=Dt);let pt=Dt.get(st);if(pt!==void 0){if(te.currentProgram===pt&&te.lightsStateVersion===rt)return zx(L,ot),pt}else ot.uniforms=Pe.getUniforms(L),L.onBuild(se,ot,p),L.onBeforeCompile(ot,p),pt=Pe.acquireProgram(ot,st),Dt.set(st,pt),te.uniforms=ot.uniforms;let vt=te.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(vt.clippingPlanes=I.uniform),zx(L,ot),te.needsLights=TC(L),te.lightsStateVersion=rt,te.needsLights&&(vt.ambientLightColor.value=ue.state.ambient,vt.lightProbe.value=ue.state.probe,vt.directionalLights.value=ue.state.directional,vt.directionalLightShadows.value=ue.state.directionalShadow,vt.spotLights.value=ue.state.spot,vt.spotLightShadows.value=ue.state.spotShadow,vt.rectAreaLights.value=ue.state.rectArea,vt.ltc_1.value=ue.state.rectAreaLTC1,vt.ltc_2.value=ue.state.rectAreaLTC2,vt.pointLights.value=ue.state.point,vt.pointLightShadows.value=ue.state.pointShadow,vt.hemisphereLights.value=ue.state.hemi,vt.directionalShadowMap.value=ue.state.directionalShadowMap,vt.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,vt.spotShadowMap.value=ue.state.spotShadowMap,vt.spotShadowMatrix.value=ue.state.spotShadowMatrix,vt.pointShadowMap.value=ue.state.pointShadowMap,vt.pointShadowMatrix.value=ue.state.pointShadowMatrix);let qt=pt.getUniforms(),Do=qa.seqWithValue(qt.seq,vt);return te.currentProgram=pt,te.uniformsList=Do,pt}function zx(L,$){let se=ce.get(L);se.outputEncoding=$.outputEncoding,se.instancing=$.instancing,se.skinning=$.skinning,se.morphTargets=$.morphTargets,se.morphNormals=$.morphNormals,se.morphColors=$.morphColors,se.morphTargetsCount=$.morphTargetsCount,se.numClippingPlanes=$.numClippingPlanes,se.numIntersection=$.numClipIntersection,se.vertexAlphas=$.vertexAlphas,se.vertexTangents=$.vertexTangents,se.toneMapping=$.toneMapping}function AC(L,$,se,te,ue){$.isScene!==!0&&($=j),oe.resetTextureUnits();let et=$.fog,rt=te.isMeshStandardMaterial?$.environment:null,ot=w===null?p.outputEncoding:w.isXRRenderTarget===!0?w.texture.encoding:Er,st=(te.isMeshStandardMaterial?me:Te).get(te.envMap||rt),Dt=te.vertexColors===!0&&!!se.attributes.color&&se.attributes.color.itemSize===4,pt=!!te.normalMap&&!!se.attributes.tangent,vt=!!se.morphAttributes.position,qt=!!se.morphAttributes.normal,Do=!!se.morphAttributes.color,Ma=te.toneMapped?p.toneMapping:fs,Ea=se.morphAttributes.position||se.morphAttributes.normal||se.morphAttributes.color,Si=Ea!==void 0?Ea.length:0,_t=ce.get(te),Ca=d.state.lights;if(Y===!0&&(U===!0||L!==S)){let _i=L===S&&te.id===b;I.setState(te,L,_i)}let ln=!1;te.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==Ca.state.version||_t.outputEncoding!==ot||ue.isInstancedMesh&&_t.instancing===!1||!ue.isInstancedMesh&&_t.instancing===!0||ue.isSkinnedMesh&&_t.skinning===!1||!ue.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==st||te.fog===!0&&_t.fog!==et||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==I.numPlanes||_t.numIntersection!==I.numIntersection)||_t.vertexAlphas!==Dt||_t.vertexTangents!==pt||_t.morphTargets!==vt||_t.morphNormals!==qt||_t.morphColors!==Do||_t.toneMapping!==Ma||K.isWebGL2===!0&&_t.morphTargetsCount!==Si)&&(ln=!0):(ln=!0,_t.__version=te.version);let Ai=_t.currentProgram;ln===!0&&(Ai=og(te,$,ue));let Cs=!1,cu=!1,ag=!1,Kn=Ai.getUniforms(),uu=_t.uniforms;if(X.useProgram(Ai.program)&&(Cs=!0,cu=!0,ag=!0),te.id!==b&&(b=te.id,cu=!0),Cs||S!==L){if(Kn.setValue(W,"projectionMatrix",L.projectionMatrix),K.logarithmicDepthBuffer&&Kn.setValue(W,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),S!==L&&(S=L,cu=!0,ag=!0),te.isShaderMaterial||te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshStandardMaterial||te.envMap){let _i=Kn.map.cameraPosition;_i!==void 0&&_i.setValue(W,k.setFromMatrixPosition(L.matrixWorld))}(te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshLambertMaterial||te.isMeshBasicMaterial||te.isMeshStandardMaterial||te.isShaderMaterial)&&Kn.setValue(W,"isOrthographic",L.isOrthographicCamera===!0),(te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshLambertMaterial||te.isMeshBasicMaterial||te.isMeshStandardMaterial||te.isShaderMaterial||te.isShadowMaterial||ue.isSkinnedMesh)&&Kn.setValue(W,"viewMatrix",L.matrixWorldInverse)}if(ue.isSkinnedMesh){Kn.setOptional(W,ue,"bindMatrix"),Kn.setOptional(W,ue,"bindMatrixInverse");let _i=ue.skeleton;_i&&(K.floatVertexTextures?(_i.boneTexture===null&&_i.computeBoneTexture(),Kn.setValue(W,"boneTexture",_i.boneTexture,oe),Kn.setValue(W,"boneTextureSize",_i.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 lg=se.morphAttributes;return(lg.position!==void 0||lg.normal!==void 0||lg.color!==void 0&&K.isWebGL2===!0)&&fe.update(ue,se,te,Ai),(cu||_t.receiveShadow!==ue.receiveShadow)&&(_t.receiveShadow=ue.receiveShadow,Kn.setValue(W,"receiveShadow",ue.receiveShadow)),cu&&(Kn.setValue(W,"toneMappingExposure",p.toneMappingExposure),_t.needsLights&&_C(uu,ag),et&&te.fog===!0&&Ne.refreshFogUniforms(uu,et),Ne.refreshMaterialUniforms(uu,te,C,E,G),qa.upload(W,_t.uniformsList,uu,oe)),te.isShaderMaterial&&te.uniformsNeedUpdate===!0&&(qa.upload(W,_t.uniformsList,uu,oe),te.uniformsNeedUpdate=!1),te.isSpriteMaterial&&Kn.setValue(W,"center",ue.center),Kn.setValue(W,"modelViewMatrix",ue.modelViewMatrix),Kn.setValue(W,"normalMatrix",ue.normalMatrix),Kn.setValue(W,"modelMatrix",ue.matrixWorld),Ai}function _C(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 TC(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(L,$,se){ce.get(L.texture).__webglTexture=$,ce.get(L.depthTexture).__webglTexture=se;let te=ce.get(L);te.__hasExternalTextures=!0,te.__hasExternalTextures&&(te.__autoAllocateDepthBuffer=se===void 0,te.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),te.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,$){let se=ce.get(L);se.__webglFramebuffer=$,se.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(L,$=0,se=0){w=L,v=$,y=se;let te=!0;if(L){let st=ce.get(L);st.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(36160,null),te=!1):st.__webglFramebuffer===void 0?oe.setupRenderTarget(L):st.__hasExternalTextures&&oe.rebindTextures(L,ce.get(L.texture).__webglTexture,ce.get(L.depthTexture).__webglTexture)}let ue=null,et=!1,rt=!1;if(L){let st=L.texture;(st.isData3DTexture||st.isDataArrayTexture)&&(rt=!0);let Dt=ce.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(ue=Dt[$],et=!0):K.isWebGL2&&L.samples>0&&oe.useMultisampledRTT(L)===!1?ue=ce.get(L).__webglMultisampledFramebuffer:ue=Dt,_.copy(L.viewport),M.copy(L.scissor),x=L.scissorTest}else _.copy(D).multiplyScalar(C).floor(),M.copy(N).multiplyScalar(C).floor(),x=F;if(X.bindFramebuffer(36160,ue)&&K.drawBuffers&&te&&X.drawBuffers(L,ue),X.viewport(_),X.scissor(M),X.setScissorTest(x),et){let st=ce.get(L.texture);W.framebufferTexture2D(36160,36064,34069+$,st.__webglTexture,se)}else if(rt){let st=ce.get(L.texture),Dt=$||0;W.framebufferTextureLayer(36160,36064,st.__webglTexture,se||0,Dt)}b=-1},this.readRenderTargetPixels=function(L,$,se,te,ue,et,rt){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=ce.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&rt!==void 0&&(ot=ot[rt]),ot){X.bindFramebuffer(36160,ot);try{let st=L.texture,Dt=st.format,pt=st.type;if(Dt!==oi&&re.convert(Dt)!==W.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let vt=pt===Su&&(ie.has("EXT_color_buffer_half_float")||K.isWebGL2&&ie.has("EXT_color_buffer_float"));if(pt!==Gt&&re.convert(pt)!==W.getParameter(35738)&&!(pt===Mi&&(K.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!vt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=L.width-te&&se>=0&&se<=L.height-ue&&W.readPixels($,se,te,ue,re.convert(Dt),re.convert(pt),et)}finally{let st=w!==null?ce.get(w).__webglFramebuffer:null;X.bindFramebuffer(36160,st)}}},this.copyFramebufferToTexture=function(L,$,se=0){let te=Math.pow(2,-se),ue=Math.floor($.image.width*te),et=Math.floor($.image.height*te);oe.setTexture2D($,0),W.copyTexSubImage2D(3553,se,0,0,L.x,L.y,ue,et),X.unbindTexture()},this.copyTextureToTexture=function(L,$,se,te=0){let ue=$.image.width,et=$.image.height,rt=re.convert(se.format),ot=re.convert(se.type);oe.setTexture2D(se,0),W.pixelStorei(37440,se.flipY),W.pixelStorei(37441,se.premultiplyAlpha),W.pixelStorei(3317,se.unpackAlignment),$.isDataTexture?W.texSubImage2D(3553,te,L.x,L.y,ue,et,rt,ot,$.image.data):$.isCompressedTexture?W.compressedTexSubImage2D(3553,te,L.x,L.y,$.mipmaps[0].width,$.mipmaps[0].height,rt,$.mipmaps[0].data):W.texSubImage2D(3553,te,L.x,L.y,rt,ot,$.image),te===0&&se.generateMipmaps&&W.generateMipmap(3553),X.unbindTexture()},this.copyTextureToTexture3D=function(L,$,se,te,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let et=L.max.x-L.min.x+1,rt=L.max.y-L.min.y+1,ot=L.max.z-L.min.z+1,st=re.convert(te.format),Dt=re.convert(te.type),pt;if(te.isData3DTexture)oe.setTexture3D(te,0),pt=32879;else if(te.isDataArrayTexture)oe.setTexture2DArray(te,0),pt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(37440,te.flipY),W.pixelStorei(37441,te.premultiplyAlpha),W.pixelStorei(3317,te.unpackAlignment);let vt=W.getParameter(3314),qt=W.getParameter(32878),Do=W.getParameter(3316),Ma=W.getParameter(3315),Ea=W.getParameter(32877),Si=se.isCompressedTexture?se.mipmaps[0]:se.image;W.pixelStorei(3314,Si.width),W.pixelStorei(32878,Si.height),W.pixelStorei(3316,L.min.x),W.pixelStorei(3315,L.min.y),W.pixelStorei(32877,L.min.z),se.isDataTexture||se.isData3DTexture?W.texSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,Dt,Si.data):se.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),W.compressedTexSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,Si.data)):W.texSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,Dt,Si),W.pixelStorei(3314,vt),W.pixelStorei(32878,qt),W.pixelStorei(3316,Do),W.pixelStorei(3315,Ma),W.pixelStorei(32877,Ea),ue===0&&te.generateMipmaps&&W.generateMipmap(pt),X.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?oe.setTextureCube(L,0):L.isData3DTexture?oe.setTexture3D(L,0):L.isDataArrayTexture?oe.setTexture2DArray(L,0):oe.setTexture2D(L,0),X.unbindTexture()},this.resetState=function(){v=0,y=0,w=null,X.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var hy=class extends By{};hy.prototype.isWebGL1Renderer=!0;var Ka=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Le(e),this.near=t,this.far=n}clone(){return new Ka(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},rr=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}},tf=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Zg,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ei()}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=Ei()),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=Ei()),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}}},Jn=new A,zo=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++)Jn.fromBufferAttribute(this,t),Jn.applyMatrix4(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.applyNormalMatrix(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.transformDirection(e),this.setXYZ(t,Jn.x,Jn.y,Jn.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 Ge(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 zo(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 nf=class extends Ge{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 zr=class extends Go{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Le(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}},tw=new A,nw=new A,rw=new be,kg=new ai,Ud=new Mn,ko=class extends ht{constructor(e=new De,t=new zr){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++)tw.fromBufferAttribute(t,i-1),nw.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=tw.distanceTo(nw);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(),Ud.copy(n.boundingSphere),Ud.applyMatrix4(i),Ud.radius+=s,e.ray.intersectsSphere(Ud)===!1)return;rw.copy(i).invert(),kg.copy(e.ray).applyMatrix4(rw);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,h=new A,d=new A,f=this.isLineSegments?2:1,g=n.index,m=n.attributes.position;if(g!==null){let v=Math.max(0,o.start),y=Math.min(g.count,o.start+o.count);for(let w=v,b=y-1;w<b;w+=f){let S=g.getX(w),_=g.getX(w+1);if(u.fromBufferAttribute(m,S),c.fromBufferAttribute(m,_),kg.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(d);x<e.near||x>e.far||t.push({distance:x,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{let v=Math.max(0,o.start),y=Math.min(m.count,o.start+o.count);for(let w=v,b=y-1;w<b;w+=f){if(u.fromBufferAttribute(m,w),c.fromBufferAttribute(m,w+1),kg.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(d);_<e.near||_>e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:w,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}}}}},iw=new A,sw=new A,Ws=class extends ko{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)iw.fromBufferAttribute(t,i),sw.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+iw.distanceTo(sw);e.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};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],d=n[i+1]-c,f=(o-c)/d;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 B: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 be;for(let f=0;f<=e;f++){let g=f/e;i[f]=this.getTangentAt(g,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),h<=u&&(u=h,n.set(0,1,0)),d<=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 g=Math.acos(pn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,g))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(pn(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let g=1;g<=e;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),o[g].crossVectors(i[g],s[g])}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}},Vo=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 B,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),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+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}},dy=class extends Vo{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Fy(){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,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var Gd=new A,Vg=new Fy,Hg=new Fy,Wg=new Fy,fy=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]:(Gd.subVectors(i[0],i[1]).add(i[0]),u=Gd);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Gd.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Gd),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,g=Math.pow(u.distanceToSquared(h),f),p=Math.pow(h.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(c),f);p<1e-4&&(p=1),g<1e-4&&(g=p),m<1e-4&&(m=p),Vg.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,g,p,m),Hg.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,g,p,m),Wg.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,g,p,m)}else this.curveType==="catmullrom"&&(Vg.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),Hg.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),Wg.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return n.set(Vg.calc(l),Hg.calc(l),Wg.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 ow(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 TO(r,e){let t=1-r;return t*t*e}function MO(r,e){return 2*(1-r)*r*e}function EO(r,e){return r*r*e}function bu(r,e,t,n){return TO(r,e)+MO(r,t)+EO(r,n)}function CO(r,e){let t=1-r;return t*t*t*e}function PO(r,e){let t=1-r;return 3*t*t*r*e}function DO(r,e){return 3*(1-r)*r*r*e}function IO(r,e){return r*r*r*e}function wu(r,e,t,n,i){return CO(r,e)+PO(r,t)+DO(r,n)+IO(r,i)}var Wn=class extends kr{constructor(e=new B,t=new B,n=new B,i=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(wu(e,i.x,s.x,o.x,a.x),wu(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}},py=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(wu(e,i.x,s.x,o.x,a.x),wu(e,i.y,s.y,o.y,a.y),wu(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}},jn=class extends kr{constructor(e=new B,t=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new B){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 B;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}},Cu=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}},Cr=class extends kr{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(bu(e,i.x,s.x,o.x),bu(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}},my=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(bu(e,i.x,s.x,o.x),bu(e,i.y,s.y,o.y),bu(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}},Ja=class extends kr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new B){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],h=i[o>i.length-3?i.length-1:o+2];return n.set(ow(a,l.x,u.x,c.x,h.x),ow(a,l.y,u.y,c.y,h.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 B().fromArray(i))}return this}},LO=Object.freeze({__proto__:null,ArcCurve:dy,CatmullRomCurve3:fy,CubicBezierCurve:Wn,CubicBezierCurve3:py,EllipseCurve:Vo,LineCurve:jn,LineCurve3:Cu,QuadraticBezierCurve:Cr,QuadraticBezierCurve3:my,SplineCurve:Ja}),gy=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 jn(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 LO[i.type]().fromJSON(i))}return this}},Ho=class extends gy{constructor(e){super(),this.type="Path",this.currentPoint=new B,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 jn(this.currentPoint.clone(),new B(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new Cr(this.currentPoint.clone(),new B(e,t),new B(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new Wn(this.currentPoint.clone(),new B(e,t),new B(n,i),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new Ja(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 Vo(e,t,n,i,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.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}},$a=class extends De{constructor(e=[new B(0,.5),new B(.5,0),new B(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=pn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/t,h=new A,d=new B,f=new A,g=new A,p=new A,m=0,v=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:m=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,f.x=v*1,f.y=-m,f.z=v*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:m=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,f.x=v*1,f.y=-m,f.z=v*0,g.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(g)}for(let y=0;y<=t;y++){let w=n+y*c*i,b=Math.sin(w),S=Math.cos(w);for(let _=0;_<=e.length-1;_++){h.x=e[_].x*b,h.y=e[_].y,h.z=e[_].x*S,o.push(h.x,h.y,h.z),d.x=y/t,d.y=_/(e.length-1),a.push(d.x,d.y);let M=l[3*_+0]*b,x=l[3*_+1],T=l[3*_+0]*S;u.push(M,x,T)}}for(let y=0;y<t;y++)for(let w=0;w<e.length-1;w++){let b=w+y*e.length,S=b,_=b+e.length,M=b+e.length+1,x=b+1;s.push(S,_,x),s.push(M,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 $a(e.points,e.segments,e.phiStart,e.phiLength)}};var Wo=class extends De{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=[],h=[],d=[],f=[],g=0,p=[],m=n/2,v=0;y(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(c),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(d,3)),this.setAttribute("uv",new Ae(f,2));function y(){let b=new A,S=new A,_=0,M=(t-e)/n;for(let x=0;x<=s;x++){let T=[],E=x/s,C=E*(t-e)+e;for(let P=0;P<=i;P++){let O=P/i,D=O*l+a,N=Math.sin(D),F=Math.cos(D);S.x=C*N,S.y=-E*n+m,S.z=C*F,h.push(S.x,S.y,S.z),b.set(N,M,F).normalize(),d.push(b.x,b.y,b.z),f.push(O,1-E),T.push(g++)}p.push(T)}for(let x=0;x<i;x++)for(let T=0;T<s;T++){let E=p[T][x],C=p[T+1][x],P=p[T+1][x+1],O=p[T][x+1];c.push(E,C,O),c.push(C,P,O),_+=6}u.addGroup(v,_,0),v+=_}function w(b){let S=g,_=new B,M=new A,x=0,T=b===!0?e:t,E=b===!0?1:-1;for(let P=1;P<=i;P++)h.push(0,m*E,0),d.push(0,E,0),f.push(.5,.5),g++;let C=g;for(let P=0;P<=i;P++){let D=P/i*l+a,N=Math.cos(D),F=Math.sin(D);M.x=T*F,M.y=m*E,M.z=T*N,h.push(M.x,M.y,M.z),d.push(0,E,0),_.x=N*.5+.5,_.y=F*.5*E+.5,f.push(_.x,_.y),g++}for(let P=0;P<i;P++){let O=S+P,D=C+P;b===!0?c.push(D,D+1,O):c.push(D+1,D,O),x+=3}u.addGroup(v,x,b===!0?1:2),v+=x}}static fromJSON(e){return new Wo(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},el=class extends Wo{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 el(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},tl=class extends De{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(y){let w=new A,b=new A,S=new A;for(let _=0;_<t.length;_+=3)f(t[_+0],w),f(t[_+1],b),f(t[_+2],S),l(w,b,S,y)}function l(y,w,b,S){let _=S+1,M=[];for(let x=0;x<=_;x++){M[x]=[];let T=y.clone().lerp(b,x/_),E=w.clone().lerp(b,x/_),C=_-x;for(let P=0;P<=C;P++)P===0&&x===_?M[x][P]=T:M[x][P]=T.clone().lerp(E,P/C)}for(let x=0;x<_;x++)for(let T=0;T<2*(_-x)-1;T++){let E=Math.floor(T/2);T%2===0?(d(M[x][E+1]),d(M[x+1][E]),d(M[x][E])):(d(M[x][E+1]),d(M[x+1][E+1]),d(M[x+1][E]))}}function u(y){let w=new A;for(let b=0;b<s.length;b+=3)w.x=s[b+0],w.y=s[b+1],w.z=s[b+2],w.normalize().multiplyScalar(y),s[b+0]=w.x,s[b+1]=w.y,s[b+2]=w.z}function c(){let y=new A;for(let w=0;w<s.length;w+=3){y.x=s[w+0],y.y=s[w+1],y.z=s[w+2];let b=m(y)/2/Math.PI+.5,S=v(y)/Math.PI+.5;o.push(b,1-S)}g(),h()}function h(){for(let y=0;y<o.length;y+=6){let w=o[y+0],b=o[y+2],S=o[y+4],_=Math.max(w,b,S),M=Math.min(w,b,S);_>.9&&M<.1&&(w<.2&&(o[y+0]+=1),b<.2&&(o[y+2]+=1),S<.2&&(o[y+4]+=1))}}function d(y){s.push(y.x,y.y,y.z)}function f(y,w){let b=y*3;w.x=e[b+0],w.y=e[b+1],w.z=e[b+2]}function g(){let y=new A,w=new A,b=new A,S=new A,_=new B,M=new B,x=new B;for(let T=0,E=0;T<s.length;T+=9,E+=6){y.set(s[T+0],s[T+1],s[T+2]),w.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),_.set(o[E+0],o[E+1]),M.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),S.copy(y).add(w).add(b).divideScalar(3);let C=m(S);p(_,E+0,y,C),p(M,E+2,w,C),p(x,E+4,b,C)}}function p(y,w,b,S){S<0&&y.x===1&&(o[w]=y.x-1),b.x===0&&b.z===0&&(o[w]=S/2/Math.PI+.5)}function m(y){return Math.atan2(y.z,-y.x)}function v(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new tl(e.vertices,e.indices,e.radius,e.details)}},nl=class extends tl{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 nl(e.radius,e.detail)}};var ms=class extends Ho{constructor(e){super(e),this.uuid=Ei(),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 Ho().fromJSON(i))}return this}},OO={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=Nw(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(n&&(s=UO(r,e,s,t)),r.length>80*t){a=u=r[0],l=c=r[1];for(let g=t;g<i;g+=t)h=r[g],d=r[g+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?1/f:0}return Pu(s,o,t,a,l,f),o}};function Nw(r,e,t,n,i){let s,o;if(i===QO(r,e,t,n)>0)for(s=e;s<t;s+=n)o=aw(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=aw(s,r[s],r[s+1],o);return o&&gf(o,o.next)&&(Iu(o),o=o.next),o}function js(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(gf(t,t.next)||Wt(t.prev,t,t.next)===0)){if(Iu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Pu(r,e,t,n,i,s,o){if(!r)return;!o&&s&&HO(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?NO(r,n,i,s):RO(r)){e.push(l.i/t),e.push(r.i/t),e.push(u.i/t),Iu(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=BO(js(r),e,t),Pu(r,e,t,n,i,s,2)):o===2&&FO(r,e,t,n,i,s):Pu(js(r),e,t,n,i,s,1);break}}}function RO(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(ja(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 NO(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,h=yy(a,l,e,t,n),d=yy(u,c,e,t,n),f=r.prevZ,g=r.nextZ;for(;f&&f.z>=h&&g&&g.z<=d;){if(f!==r.prev&&f!==r.next&&ja(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,g!==r.prev&&g!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,g.x,g.y)&&Wt(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;f&&f.z>=h;){if(f!==r.prev&&f!==r.next&&ja(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(;g&&g.z<=d;){if(g!==r.prev&&g!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,g.x,g.y)&&Wt(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function BO(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!gf(i,s)&&Bw(i,n,n.next,s)&&Du(i,s)&&Du(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Iu(n),Iu(n.next),n=r=s),n=n.next}while(n!==r);return js(n)}function FO(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&qO(o,a)){let l=Fw(o,a);o=js(o,o.next),l=js(l,l.next),Pu(o,e,t,n,i,s),Pu(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function UO(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=Nw(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(jO(u));for(i.sort(GO),s=0;s<i.length;s++)zO(i[s],t),t=js(t,t.next);return t}function GO(r,e){return r.x-e.x}function zO(r,e){if(e=kO(r,e),e){let t=Fw(e,r);js(e,e.next),js(t,t.next)}}function kO(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 d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s){if(s=d,d===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,h;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&ja(i<u?n:s,i,l,u,i<u?s:n,i,t.x,t.y)&&(h=Math.abs(i-t.y)/(n-t.x),Du(t,r)&&(h<c||h===c&&(t.x>o.x||t.x===o.x&&VO(o,t)))&&(o=t,c=h)),t=t.next;while(t!==a);return o}function VO(r,e){return Wt(r.prev,r,e.prev)<0&&Wt(e.next,r,r.next)<0}function HO(r,e,t,n){let i=r;do i.z===null&&(i.z=yy(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,WO(i)}function WO(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 yy(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 jO(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 ja(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 qO(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!XO(r,e)&&(Du(r,e)&&Du(e,r)&&YO(r,e)&&(Wt(r.prev,r,e.prev)||Wt(r,e.prev,e))||gf(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 gf(r,e){return r.x===e.x&&r.y===e.y}function Bw(r,e,t,n){let i=kd(Wt(r,e,t)),s=kd(Wt(r,e,n)),o=kd(Wt(t,n,r)),a=kd(Wt(t,n,e));return!!(i!==s&&o!==a||i===0&&zd(r,t,e)||s===0&&zd(r,n,e)||o===0&&zd(t,r,n)||a===0&&zd(t,e,n))}function zd(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 kd(r){return r>0?1:r<0?-1:0}function XO(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&&Bw(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Du(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 YO(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 Fw(r,e){let t=new vy(r.i,r.x,r.y),n=new vy(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 aw(r,e,t,n){let i=new vy(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 Iu(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 vy(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 QO(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=[];lw(e),cw(n,e);let o=e.length;t.forEach(lw);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,cw(n,t[l]);let a=OO.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function lw(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function cw(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var il=class extends tl{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 il(e.radius,e.detail)}};var jo=class extends De{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=[],h=new A,d=new A,f=[],g=[],p=[],m=[];for(let v=0;v<=n;v++){let y=[],w=v/n,b=0;v==0&&o==0?b=.5/t:v==n&&l==Math.PI&&(b=-.5/t);for(let S=0;S<=t;S++){let _=S/t;h.x=-e*Math.cos(i+_*s)*Math.sin(o+w*a),h.y=e*Math.cos(o+w*a),h.z=e*Math.sin(i+_*s)*Math.sin(o+w*a),g.push(h.x,h.y,h.z),d.copy(h).normalize(),p.push(d.x,d.y,d.z),m.push(_+b,1-w),y.push(u++)}c.push(y)}for(let v=0;v<n;v++)for(let y=0;y<t;y++){let w=c[v][y+1],b=c[v][y],S=c[v+1][y],_=c[v+1][y+1];(v!==0||o>0)&&f.push(w,b,_),(v!==n-1||l<Math.PI)&&f.push(b,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(g,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(m,2))}static fromJSON(e){return new jo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var sl=class extends De{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=[],h=new A,d=new A,f=new A,g=new A,p=new A,m=new A,v=new A;for(let w=0;w<=n;++w){let b=w/n*s*Math.PI*2;y(b,s,o,e,f),y(b+.01,s,o,e,g),m.subVectors(g,f),v.addVectors(g,f),p.crossVectors(m,v),v.crossVectors(p,m),p.normalize(),v.normalize();for(let S=0;S<=i;++S){let _=S/i*Math.PI*2,M=-t*Math.cos(_),x=t*Math.sin(_);h.x=f.x+(M*v.x+x*p.x),h.y=f.y+(M*v.y+x*p.y),h.z=f.z+(M*v.z+x*p.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(w/n),c.push(S/i)}}for(let w=1;w<=n;w++)for(let b=1;b<=i;b++){let S=(i+1)*(w-1)+(b-1),_=(i+1)*w+(b-1),M=(i+1)*w+b,x=(i+1)*(w-1)+b;a.push(S,_,x),a.push(_,M,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 y(w,b,S,_,M){let x=Math.cos(w),T=Math.sin(w),E=S/b*w,C=Math.cos(E);M.x=_*(2+C)*.5*x,M.y=_*(2+C)*T*.5,M.z=_*Math.sin(E)*.5}}static fromJSON(e){return new sl(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var fn={arraySlice:function(r,e,t){return fn.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(),h=[],d=[];for(let f=0;f<u.times.length;++f){let g=u.times[f]*i;if(!(g<t||g>=n)){h.push(u.times[f]);for(let p=0;p<c;++p)d.push(u.values[f*c+p])}}h.length!==0&&(u.times=fn.convertArray(h,u.times.constructor),u.values=fn.convertArray(d,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(v){return v.name===a.name&&v.ValueTypeName===l});if(u===void 0)continue;let c=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);let d=0,f=u.getValueSize();u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let g=a.times.length-1,p;if(s<=a.times[0]){let v=c,y=h-c;p=fn.arraySlice(a.values,v,y)}else if(s>=a.times[g]){let v=g*h+c,y=v+h-c;p=fn.arraySlice(a.values,v,y)}else{let v=a.createInterpolant(),y=c,w=h-c;v.evaluate(s),p=fn.arraySlice(v.resultBuffer,y,w)}l==="quaternion"&&new nt().fromArray(p).normalize().conjugate().toArray(p);let m=u.times.length;for(let v=0;v<m;++v){let y=v*f+d;if(l==="quaternion")nt.multiplyQuaternionsFlat(u.values,y,p,0,u.values,y);else{let w=f-d*2;for(let b=0;b<w;++b)u.values[y+b]-=p[b]}}}return r.blendMode=_P,r}},ol=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_(){}},xy=class extends ol{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:vb,endingEnd:vb}}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 xb:s=e,a=2*t-n;break;case bb: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 xb:o=e,l=2*n-t;break;case bb: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,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),p=g*g,m=p*g,v=-d*m+2*d*p-d*g,y=(1+d)*m+(-1.5-2*d)*p+(-.5+d)*g+1,w=(-1-f)*m+(1.5+f)*p+.5*g,b=f*m-f*p;for(let S=0;S!==a;++S)s[S]=v*o[c+S]+y*o[u+S]+w*o[l+S]+b*o[h+S];return s}},by=class extends ol{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),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},wy=class extends ol{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},ci=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=fn.convertArray(t,this.TimeBufferType),this.values=fn.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:fn.convertArray(e.times,Array),values:fn.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new wy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new by(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new xy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case qd:t=this.InterpolantFactoryMethodDiscrete;break;case Xd:t=this.InterpolantFactoryMethodLinear;break;case pg: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 qd;case this.InterpolantFactoryMethodLinear:return Xd;case this.InterpolantFactoryMethodSmooth:return pg}}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=fn.arraySlice(n,s,o),this.values=fn.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&&fn.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=fn.arraySlice(this.times),t=fn.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===pg,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 h=a*n,d=h-n,f=h+n;for(let g=0;g!==n;++g){let p=t[h+g];if(p!==t[d+g]||p!==t[f+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let h=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[h+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=fn.arraySlice(e,0,o),this.values=fn.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=fn.arraySlice(this.times,0),t=fn.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};ci.prototype.TimeBufferType=Float32Array;ci.prototype.ValueBufferType=Float32Array;ci.prototype.DefaultInterpolation=Xd;var qo=class extends ci{};qo.prototype.ValueTypeName="bool";qo.prototype.ValueBufferType=Array;qo.prototype.DefaultInterpolation=qd;qo.prototype.InterpolantFactoryMethodLinear=void 0;qo.prototype.InterpolantFactoryMethodSmooth=void 0;var Sy=class extends ci{};Sy.prototype.ValueTypeName="color";var Ay=class extends ci{};Ay.prototype.ValueTypeName="number";var _y=class extends ol{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}},Lu=class extends ci{InterpolantFactoryMethodLinear(e){return new _y(this.times,this.values,this.getValueSize(),e)}};Lu.prototype.ValueTypeName="quaternion";Lu.prototype.DefaultInterpolation=Xd;Lu.prototype.InterpolantFactoryMethodSmooth=void 0;var Xo=class extends ci{};Xo.prototype.ValueTypeName="string";Xo.prototype.ValueBufferType=Array;Xo.prototype.DefaultInterpolation=qd;Xo.prototype.InterpolantFactoryMethodLinear=void 0;Xo.prototype.InterpolantFactoryMethodSmooth=void 0;var Ty=class extends ci{};Ty.prototype.ValueTypeName="vector";var uw={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={}}},Ou=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,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],g=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return g}return null}}},ZO=new Ou,al=class{constructor(e){this.manager=e!==void 0?e:ZO,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}},us={},ll=class extends al{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=uw.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(us[e]!==void 0){us[e].push({onLoad:t,onProgress:n,onError:i});return}us[e]=[],us[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=us[e],h=u.body.getReader(),d=u.headers.get("Content-Length"),f=d?parseInt(d):0,g=f!==0,p=0,m=new ReadableStream({start(v){y();function y(){h.read().then(({done:w,value:b})=>{if(w)v.close();else{p+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:g,loaded:p,total:f});for(let _=0,M=c.length;_<M;_++){let x=c[_];x.onProgress&&x.onProgress(S)}v.enqueue(b),y()}})}}});return new Response(m)}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 h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(g=>f.decode(g))}}}).then(u=>{uw.add(e,u);let c=us[e];delete us[e];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=us[e];if(c===void 0)throw this.manager.itemError(e),u;delete us[e];for(let h=0,d=c.length;h<d;h++){let f=c[h];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 cl=class extends ht{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Le(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}},Yo=class extends cl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.groundColor=new Le(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},hw=new be,dw=new A,fw=new A,Ru=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Mu,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new He(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;dw.setFromMatrixPosition(e.matrixWorld),t.position.copy(dw),fw.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(fw),t.updateMatrixWorld(),hw.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hw),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}},My=class extends Ru{constructor(){super(new nn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=Au*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}},rf=class extends cl{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 My}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}},pw=new be,pu=new A,jg=new A,Ey=class extends Ru{constructor(){super(new nn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new He(2,1,1,1),new He(0,1,1,1),new He(3,1,1,1),new He(1,1,1,1),new He(3,0,1,1),new He(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()),pu.setFromMatrixPosition(e.matrixWorld),n.position.copy(pu),jg.copy(n.position),jg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(jg),n.updateMatrixWorld(),i.makeTranslation(-pu.x,-pu.y,-pu.z),pw.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(pw)}},sf=class extends cl{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 Ey}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}},Cy=class extends Ru{constructor(){super(new Za(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},of=class extends cl{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 Cy}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var Py=class extends De{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}},ul=class extends al{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new ll(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,g){if(t[g]!==void 0)return t[g];let m=f.interleavedBuffers[g],v=s(f,m.buffer),y=yd(m.type,v),w=new tf(y,m.stride);return w.uuid=m.uuid,t[g]=w,w}function s(f,g){if(n[g]!==void 0)return n[g];let m=f.arrayBuffers[g],v=new Uint32Array(m).buffer;return n[g]=v,v}let o=e.isInstancedBufferGeometry?new Py:new De,a=e.data.index;if(a!==void 0){let f=yd(a.type,a.array);o.setIndex(new Ge(f,1))}let l=e.data.attributes;for(let f in l){let g=l[f],p;if(g.isInterleavedBufferAttribute){let m=i(e.data,g.data);p=new zo(m,g.itemSize,g.offset,g.normalized)}else{let m=yd(g.type,g.array),v=g.isInstancedBufferAttribute?nf:Ge;p=new v(m,g.itemSize,g.normalized)}g.name!==void 0&&(p.name=g.name),g.usage!==void 0&&p.setUsage(g.usage),g.updateRange!==void 0&&(p.updateRange.offset=g.updateRange.offset,p.updateRange.count=g.updateRange.count),o.setAttribute(f,p)}let u=e.data.morphAttributes;if(u)for(let f in u){let g=u[f],p=[];for(let m=0,v=g.length;m<v;m++){let y=g[m],w;if(y.isInterleavedBufferAttribute){let b=i(e.data,y.data);w=new zo(b,y.itemSize,y.offset,y.normalized)}else{let b=yd(y.type,y.array);w=new Ge(b,y.itemSize,y.normalized)}y.name!==void 0&&(w.name=y.name),p.push(w)}o.morphAttributes[f]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let f=0,g=h.length;f!==g;++f){let p=h[f];o.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let f=new A;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new Mn(f,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var af=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=mw(),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=mw();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function mw(){return(typeof performance>"u"?Date:performance).now()}var Uy="\\[\\]\\.:\\/",KO=new RegExp("["+Uy+"]","g"),Gy="[^"+Uy+"]",JO="[^"+Uy.replace("\\.","")+"]",$O=/((?:WC+[\/:])*)/.source.replace("WC",Gy),eR=/(WCOD+)?/.source.replace("WCOD",JO),tR=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gy),nR=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gy),rR=new RegExp("^"+$O+eR+tR+nR+"$"),iR=["material","materials","bones"],Dy=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(KO,"")}static parseTrackName(e){let t=rR.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);iR.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=Dy;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 hl=class{constructor(e,t,n=0,i=1/0){this.ray=new ai(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new _u,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 Iy(e,this,n,t),n.sort(gw),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Iy(e[i],this,n,t);return n.sort(gw),n}};function gw(r,e){return r.distance-e.distance}function Iy(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++)Iy(i[s],e,t,!0)}}var Nu=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(pn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var yw=new B,lf=class{constructor(e=new B(1/0,1/0),t=new B(-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=yw.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 yw.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)}},vw=new A,Vd=new A,gn=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){vw.subVectors(e,this.start),Vd.subVectors(this.end,this.start);let n=Vd.dot(Vd),s=Vd.dot(vw)/n;return t&&(s=pn(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)}},xw=new A,cf=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 De,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 zr({fog:!1,toneMapped:!1});this.cone=new Ws(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),xw.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(xw),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var uf=class extends rn{constructor(e,t,n){let i=new jo(t,4,2),s=new Tu({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 bw=new A,Hd=new A,ww=new A,hf=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 De;i.setAttribute("position",new Ae([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new zr({fog:!1,toneMapped:!1});this.lightPlane=new ko(i,s),this.add(this.lightPlane),i=new De,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new ko(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(){bw.setFromMatrixPosition(this.light.matrixWorld),Hd.setFromMatrixPosition(this.light.target.matrixWorld),ww.subVectors(Hd,bw),this.lightPlane.lookAt(Hd),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(Hd),this.targetLine.scale.z=ww.length()}},Wd=new A,Xt=new li,Vr=class extends Ws{constructor(e){let t=new De,n=new zr({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(g,p){l(g),l(p)}function l(g){i.push(0,0,0),s.push(0,0,0),o[g]===void 0&&(o[g]=[]),o[g].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 Le(16755200),c=new Le(16711680),h=new Le(43775),d=new Le(16777215),f=new Le(3355443);this.setColors(u,c,h,d,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),tn("c",t,e,Xt,0,0,-1),tn("t",t,e,Xt,0,0,1),tn("n1",t,e,Xt,-n,-i,-1),tn("n2",t,e,Xt,n,-i,-1),tn("n3",t,e,Xt,-n,i,-1),tn("n4",t,e,Xt,n,i,-1),tn("f1",t,e,Xt,-n,-i,1),tn("f2",t,e,Xt,n,-i,1),tn("f3",t,e,Xt,-n,i,1),tn("f4",t,e,Xt,n,i,1),tn("u1",t,e,Xt,n*.7,i*1.1,-1),tn("u2",t,e,Xt,-n*.7,i*1.1,-1),tn("u3",t,e,Xt,0,i*2,-1),tn("cf1",t,e,Xt,-n,0,1),tn("cf2",t,e,Xt,n,0,1),tn("cf3",t,e,Xt,0,-i,1),tn("cf4",t,e,Xt,0,i,1),tn("cn1",t,e,Xt,-n,0,-1),tn("cn2",t,e,Xt,n,0,-1),tn("cn3",t,e,Xt,0,-i,-1),tn("cn4",t,e,Xt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function tn(r,e,t,n,i,s,o){Wd.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],Wd.x,Wd.y,Wd.z)}}var Qo=class extends Ws{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 De;s.setIndex(new Ge(n,1)),s.setAttribute("position",new Ae(i,3)),super(s,new zr({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 df=class extends Ws{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 De;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(n,3));let s=new zr({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new Le,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:CH,uint32View:PH,baseTable:DH,shiftTable:IH,mantissaTable:LH,exponentTable:OH,offsetTable:RH}=sR();function sR(){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 ff=class extends dt{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:Zo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Zo);var ml=".",Bu=Symbol("target"),zy=Symbol("unsubscribe");function Fu(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function Uw(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var Dr=Array.isArray;function Ko(r){return typeof r=="symbol"}var oR={after:(r,e)=>Dr(r)?r.slice(e.length):e===""?r:r.slice(e.length+1),concat:(r,e)=>Dr(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+=ml),Ko(e)?r+e.toString():r+e):r,initial:r=>{if(Dr(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(ml);return e===-1?"":r.slice(0,e)},last:r=>{if(Dr(r))return r[r.length-1]||"";if(r==="")return r;let e=r.lastIndexOf(ml);return e===-1?r:r.slice(e+1)},walk:(r,e)=>{if(Dr(r))for(let t of r)e(t);else if(r!==""){let t=0,n=r.indexOf(ml);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(ml,t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r}},ir=oR;function ky(r){return typeof r=="object"&&typeof r.next=="function"}function Vy(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[Bu].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 yf(r,e,t){return r.isUnsubscribed||e.ignoreSymbols&&Ko(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Uu=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,ir.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 gl(r){return toString.call(r)==="[object Object]"}function yl(){return!0}function qs(r,e){return r.length!==e.length||r.some((t,n)=>e[n]!==t)}var vf=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var aR=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Hy={push:yl,pop:yl,shift:yl,unshift:yl,copyWithin:qs,reverse:qs,sort:qs,splice:qs,flat:qs,fill:qs},Gw=new Set([...vf,...aR,...Object.keys(Hy)]);function vl(r,e){if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var Wy=["keys","values","entries"],jy=new Set(["has","toString"]),qy={add:vl,clear:vl,delete:vl,forEach:vl},zw=new Set([...jy,...Object.keys(qy),...Wy]);function xl(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 lR=new Set([...jy,"get"]),Xy={set:xl,clear:xl,delete:xl,forEach:xl},kw=new Set([...lR,...Object.keys(Xy),...Wy]);var Cn=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 vf.has(e)}_shallowClone(e){let t=e;if(gl(e))t={...e};else if(Dr(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?(Dr(i)?this._onIsChanged=Hy[t]:i instanceof Set?this._onIsChanged=qy[t]:i instanceof Map&&(this._onIsChanged=Xy[t]),i):n}update(e,t,n){let i=ir.after(e,this._path);if(t!=="length"){let s=this.clone;ir.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],ir.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var bl=class extends Cn{static isHandledMethod(e){return Gw.has(e)}};var Gu=class extends Cn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var wl=class extends Cn{static isHandledMethod(e){return zw.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 Sl=class extends Cn{static isHandledMethod(e){return kw.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 zu=class extends Cn{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 ku=class extends Cn{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 hi=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return gl(e)||Dr(e)||Fu(e)}static isHandledMethod(e,t){return gl(e)?Cn.isHandledMethod(t):Dr(e)?bl.isHandledMethod(t):e instanceof Set?wl.isHandledMethod(t):e instanceof Map?Sl.isHandledMethod(t):Fu(e)}get isCloning(){return this._stack.length>0}start(e,t,n){let i=Cn;Dr(e)?i=bl:e instanceof Date?i=Gu:e instanceof Set?i=wl:e instanceof Map?i=Sl:e instanceof WeakSet?i=zu:e instanceof WeakMap&&(i=ku),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=hi.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 cR={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Yy=(r,e,t={})=>{t={...cR,...t};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new Uu(i),u=typeof t.onValidate=="function",c=new hi(u),h=(y,w,b,S,_)=>!u||c.isCloning||t.onValidate(ir.concat(l.getPath(y),w),b,S,_)===!0,d=(y,w,b,S)=>{!yf(l,t,w)&&!(o&&l.isDetached(y,r))&&f(l.getPath(y),w,b,S)},f=(y,w,b,S,_)=>{c.isCloning?c.update(y,w,S):e(ir.concat(y,w),b,S,_)},g=y=>y&&(y[n]||y),p=(y,w,b,S)=>Uw(y)||b==="constructor"||s&&!hi.isHandledMethod(w,b)||yf(l,t,b)||l.isGetInvariant(w,b)||o&&l.isDetached(w,r)?y:(S===void 0&&(S=l.getPath(w)),l.getProxy(y,ir.concat(S,b),m,n)),m={get(y,w,b){if(Ko(w)){if(w===n||w===Bu)return y;if(w===zy&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let S=Fu(y)?Reflect.get(y,w):Reflect.get(y,w,b);return p(S,y,w)},set(y,w,b,S){b=g(b);let _=y[n]||y,M=_[w];if(i(M,b)&&w in y)return!0;let x=h(y,w,b,M);return x&&l.setProperty(_,w,b,S,M)?(d(y,w,y[w],M),!0):!x},defineProperty(y,w,b){if(!l.isSameDescriptor(b,y,w)){let S=y[w];h(y,w,b.value,S)&&l.defineProperty(y,w,b,S)&&d(y,w,b.value,S)}return!0},deleteProperty(y,w){if(!Reflect.has(y,w))return!0;let b=Reflect.get(y,w),S=h(y,w,void 0,b);return S&&l.deleteProperty(y,w,b)?(d(y,w,void 0,b),!0):!S},apply(y,w,b){let S=w[n]||w;if(l.isUnsubscribed)return Reflect.apply(y,S,b);if((a===!1||a!==!0&&!a.includes(y.name))&&hi.isHandledType(S)){let _=ir.initial(l.getPath(y)),M=hi.isHandledMethod(S,y.name);c.start(S,_,b);let x=Reflect.apply(y,c.preferredThisArg(y,w,S),M?b.map(C=>g(C)):b),T=c.isChanged(S,i),E=c.stop();if(hi.isHandledType(x)&&M&&(w instanceof Map&&y.name==="get"&&(_=ir.concat(_,b[0])),x=l.getProxy(x,_,m)),T){let C={name:y.name,args:b,result:x},P=c.isCloning?ir.initial(_):_,O=c.isCloning?ir.last(_):"";h(ir.get(r,P),O,S,E,C)?f(P,O,S,E,C):c.undo(S)}return(w instanceof Map||w instanceof Set)&&ky(x)?Vy(x,y,w,_,p):x}return Reflect.apply(y,w,b)}},v=l.getProxy(r,t.pathAsArray?[]:"",m);return e=e.bind(v),u&&(t.onValidate=t.onValidate.bind(v)),v};Yy.target=r=>r&&r[Bu]||r;Yy.unsubscribe=r=>r[zy]||r;var Qy=Yy;var uR=typeof global=="object"&&global&&global.Object===Object&&global,xf=uR;var hR=typeof self=="object"&&self&&self.Object===Object&&self,dR=xf||hR||Function("return this")(),Zt=dR;var fR=Zt.Symbol,sr=fR;var Vw=Object.prototype,pR=Vw.hasOwnProperty,mR=Vw.toString,Vu=sr?sr.toStringTag:void 0;function gR(r){var e=pR.call(r,Vu),t=r[Vu];try{r[Vu]=void 0;var n=!0}catch{}var i=mR.call(r);return n&&(e?r[Vu]=t:delete r[Vu]),i}var Hw=gR;var yR=Object.prototype,vR=yR.toString;function xR(r){return vR.call(r)}var Ww=xR;var bR="[object Null]",wR="[object Undefined]",jw=sr?sr.toStringTag:void 0;function SR(r){return r==null?r===void 0?wR:bR:jw&&jw in Object(r)?Hw(r):Ww(r)}var Ir=SR;function AR(r){return r!=null&&typeof r=="object"}var qn=AR;var _R="[object Symbol]";function TR(r){return typeof r=="symbol"||qn(r)&&Ir(r)==_R}var Xs=TR;function MR(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 bf=MR;var ER=Array.isArray,yn=ER;var CR=1/0,qw=sr?sr.prototype:void 0,Xw=qw?qw.toString:void 0;function Yw(r){if(typeof r=="string")return r;if(yn(r))return bf(r,Yw)+"";if(Xs(r))return Xw?Xw.call(r):"";var e=r+"";return e=="0"&&1/r==-CR?"-0":e}var Qw=Yw;var PR=/\s/;function DR(r){for(var e=r.length;e--&&PR.test(r.charAt(e)););return e}var Zw=DR;var IR=/^\s+/;function LR(r){return r&&r.slice(0,Zw(r)+1).replace(IR,"")}var Kw=LR;function OR(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Ht=OR;var Jw=0/0,RR=/^[-+]0x[0-9a-f]+$/i,NR=/^0b[01]+$/i,BR=/^0o[0-7]+$/i,FR=parseInt;function UR(r){if(typeof r=="number")return r;if(Xs(r))return Jw;if(Ht(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Ht(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=Kw(r);var t=NR.test(r);return t||BR.test(r)?FR(r.slice(2),t?2:8):RR.test(r)?Jw:+r}var Zy=UR;function GR(r){return r}var wf=GR;var zR="[object AsyncFunction]",kR="[object Function]",VR="[object GeneratorFunction]",HR="[object Proxy]";function WR(r){if(!Ht(r))return!1;var e=Ir(r);return e==kR||e==VR||e==zR||e==HR}var Al=WR;var jR=Zt["__core-js_shared__"],Sf=jR;var $w=function(){var r=/[^.]+$/.exec(Sf&&Sf.keys&&Sf.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function qR(r){return!!$w&&$w in r}var eS=qR;var XR=Function.prototype,YR=XR.toString;function QR(r){if(r!=null){try{return YR.call(r)}catch{}try{return r+""}catch{}}return""}var gs=QR;var ZR=/[\\^$.*+?()[\]{}|]/g,KR=/^\[object .+?Constructor\]$/,JR=Function.prototype,$R=Object.prototype,e3=JR.toString,t3=$R.hasOwnProperty,n3=RegExp("^"+e3.call(t3).replace(ZR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function r3(r){if(!Ht(r)||eS(r))return!1;var e=Al(r)?n3:KR;return e.test(gs(r))}var tS=r3;function i3(r,e){return r?.[e]}var nS=i3;function s3(r,e){var t=nS(r,e);return tS(t)?t:void 0}var hr=s3;var o3=hr(Zt,"WeakMap"),Af=o3;var rS=Object.create,a3=function(){function r(){}return function(e){if(!Ht(e))return{};if(rS)return rS(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),iS=a3;function l3(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 sS=l3;function c3(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var _f=c3;var u3=800,h3=16,d3=Date.now;function f3(r){var e=0,t=0;return function(){var n=d3(),i=h3-(n-t);if(t=n,i>0){if(++e>=u3)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var oS=f3;function p3(r){return function(){return r}}var aS=p3;var m3=function(){try{var r=hr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),_l=m3;var g3=_l?function(r,e){return _l(r,"toString",{configurable:!0,enumerable:!1,value:aS(e),writable:!0})}:wf,lS=g3;var y3=oS(lS),Tf=y3;function v3(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var cS=v3;var x3=9007199254740991,b3=/^(?:0|[1-9]\d*)$/;function w3(r,e){var t=typeof r;return e=e??x3,!!e&&(t=="number"||t!="symbol"&&b3.test(r))&&r>-1&&r%1==0&&r<e}var Ys=w3;function S3(r,e,t){e=="__proto__"&&_l?_l(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var Tl=S3;function A3(r,e){return r===e||r!==r&&e!==e}var Qs=A3;var _3=Object.prototype,T3=_3.hasOwnProperty;function M3(r,e,t){var n=r[e];(!(T3.call(r,e)&&Qs(n,t))||t===void 0&&!(e in r))&&Tl(r,e,t)}var Ml=M3;function E3(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?Tl(t,a,l):Ml(t,a,l)}return t}var Hr=E3;var uS=Math.max;function C3(r,e,t){return e=uS(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,s=uS(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),sS(r,this,a)}}var Mf=C3;function P3(r,e){return Tf(Mf(r,e,wf),r+"")}var hS=P3;var D3=9007199254740991;function I3(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=D3}var El=I3;function L3(r){return r!=null&&El(r.length)&&!Al(r)}var Zs=L3;function O3(r,e,t){if(!Ht(t))return!1;var n=typeof e;return(n=="number"?Zs(t)&&Ys(e,t.length):n=="string"&&e in t)?Qs(t[e],r):!1}var dS=O3;function R3(r){return hS(function(e,t){var n=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=r.length>3&&typeof s=="function"?(i--,s):void 0,o&&dS(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++n<i;){var a=t[n];a&&r(e,a,n,s)}return e})}var fS=R3;var N3=Object.prototype;function B3(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||N3;return r===t}var Cl=B3;function F3(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var pS=F3;var U3="[object Arguments]";function G3(r){return qn(r)&&Ir(r)==U3}var Ky=G3;var mS=Object.prototype,z3=mS.hasOwnProperty,k3=mS.propertyIsEnumerable,V3=Ky(function(){return arguments}())?Ky:function(r){return qn(r)&&z3.call(r,"callee")&&!k3.call(r,"callee")},ys=V3;function H3(){return!1}var gS=H3;var xS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yS=xS&&typeof module=="object"&&module&&!module.nodeType&&module,W3=yS&&yS.exports===xS,vS=W3?Zt.Buffer:void 0,j3=vS?vS.isBuffer:void 0,q3=j3||gS,Pl=q3;var X3="[object Arguments]",Y3="[object Array]",Q3="[object Boolean]",Z3="[object Date]",K3="[object Error]",J3="[object Function]",$3="[object Map]",eN="[object Number]",tN="[object Object]",nN="[object RegExp]",rN="[object Set]",iN="[object String]",sN="[object WeakMap]",oN="[object ArrayBuffer]",aN="[object DataView]",lN="[object Float32Array]",cN="[object Float64Array]",uN="[object Int8Array]",hN="[object Int16Array]",dN="[object Int32Array]",fN="[object Uint8Array]",pN="[object Uint8ClampedArray]",mN="[object Uint16Array]",gN="[object Uint32Array]",zt={};zt[lN]=zt[cN]=zt[uN]=zt[hN]=zt[dN]=zt[fN]=zt[pN]=zt[mN]=zt[gN]=!0;zt[X3]=zt[Y3]=zt[oN]=zt[Q3]=zt[aN]=zt[Z3]=zt[K3]=zt[J3]=zt[$3]=zt[eN]=zt[tN]=zt[nN]=zt[rN]=zt[iN]=zt[sN]=!1;function yN(r){return qn(r)&&El(r.length)&&!!zt[Ir(r)]}var bS=yN;function vN(r){return function(e){return r(e)}}var Dl=vN;var wS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Hu=wS&&typeof module=="object"&&module&&!module.nodeType&&module,xN=Hu&&Hu.exports===wS,Jy=xN&&xf.process,bN=function(){try{var r=Hu&&Hu.require&&Hu.require("util").types;return r||Jy&&Jy.binding&&Jy.binding("util")}catch{}}(),vs=bN;var SS=vs&&vs.isTypedArray,wN=SS?Dl(SS):bS,Ef=wN;var SN=Object.prototype,AN=SN.hasOwnProperty;function _N(r,e){var t=yn(r),n=!t&&ys(r),i=!t&&!n&&Pl(r),s=!t&&!n&&!i&&Ef(r),o=t||n||i||s,a=o?pS(r.length,String):[],l=a.length;for(var u in r)(e||AN.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Ys(u,l)))&&a.push(u);return a}var Cf=_N;function TN(r,e){return function(t){return r(e(t))}}var Pf=TN;var MN=Pf(Object.keys,Object),AS=MN;var EN=Object.prototype,CN=EN.hasOwnProperty;function PN(r){if(!Cl(r))return AS(r);var e=[];for(var t in Object(r))CN.call(r,t)&&t!="constructor"&&e.push(t);return e}var _S=PN;function DN(r){return Zs(r)?Cf(r):_S(r)}var Il=DN;function IN(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var TS=IN;var LN=Object.prototype,ON=LN.hasOwnProperty;function RN(r){if(!Ht(r))return TS(r);var e=Cl(r),t=[];for(var n in r)n=="constructor"&&(e||!ON.call(r,n))||t.push(n);return t}var MS=RN;function NN(r){return Zs(r)?Cf(r,!0):MS(r)}var Ci=NN;var BN=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,FN=/^\w*$/;function UN(r,e){if(yn(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||Xs(r)?!0:FN.test(r)||!BN.test(r)||e!=null&&r in Object(e)}var ES=UN;var GN=hr(Object,"create"),xs=GN;function zN(){this.__data__=xs?xs(null):{},this.size=0}var CS=zN;function kN(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var PS=kN;var VN="__lodash_hash_undefined__",HN=Object.prototype,WN=HN.hasOwnProperty;function jN(r){var e=this.__data__;if(xs){var t=e[r];return t===VN?void 0:t}return WN.call(e,r)?e[r]:void 0}var DS=jN;var qN=Object.prototype,XN=qN.hasOwnProperty;function YN(r){var e=this.__data__;return xs?e[r]!==void 0:XN.call(e,r)}var IS=YN;var QN="__lodash_hash_undefined__";function ZN(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=xs&&e===void 0?QN:e,this}var LS=ZN;function Ll(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])}}Ll.prototype.clear=CS;Ll.prototype.delete=PS;Ll.prototype.get=DS;Ll.prototype.has=IS;Ll.prototype.set=LS;var $y=Ll;function KN(){this.__data__=[],this.size=0}var OS=KN;function JN(r,e){for(var t=r.length;t--;)if(Qs(r[t][0],e))return t;return-1}var Ks=JN;var $N=Array.prototype,eB=$N.splice;function tB(r){var e=this.__data__,t=Ks(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():eB.call(e,t,1),--this.size,!0}var RS=tB;function nB(r){var e=this.__data__,t=Ks(e,r);return t<0?void 0:e[t][1]}var NS=nB;function rB(r){return Ks(this.__data__,r)>-1}var BS=rB;function iB(r,e){var t=this.__data__,n=Ks(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var FS=iB;function Ol(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])}}Ol.prototype.clear=OS;Ol.prototype.delete=RS;Ol.prototype.get=NS;Ol.prototype.has=BS;Ol.prototype.set=FS;var Js=Ol;var sB=hr(Zt,"Map"),$s=sB;function oB(){this.size=0,this.__data__={hash:new $y,map:new($s||Js),string:new $y}}var US=oB;function aB(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var GS=aB;function lB(r,e){var t=r.__data__;return GS(e)?t[typeof e=="string"?"string":"hash"]:t.map}var eo=lB;function cB(r){var e=eo(this,r).delete(r);return this.size-=e?1:0,e}var zS=cB;function uB(r){return eo(this,r).get(r)}var kS=uB;function hB(r){return eo(this,r).has(r)}var VS=hB;function dB(r,e){var t=eo(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var HS=dB;function Rl(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])}}Rl.prototype.clear=US;Rl.prototype.delete=zS;Rl.prototype.get=kS;Rl.prototype.has=VS;Rl.prototype.set=HS;var Wu=Rl;var fB="Expected a function";function ev(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(fB);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(ev.Cache||Wu),t}ev.Cache=Wu;var WS=ev;var pB=500;function mB(r){var e=WS(r,function(n){return t.size===pB&&t.clear(),n}),t=e.cache;return e}var jS=mB;var gB=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,yB=/\\(\\)?/g,vB=jS(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(gB,function(t,n,i,s){e.push(i?s.replace(yB,"$1"):n||t)}),e}),qS=vB;function xB(r){return r==null?"":Qw(r)}var XS=xB;function bB(r,e){return yn(r)?r:ES(r,e)?[r]:qS(XS(r))}var Wr=bB;var wB=1/0;function SB(r){if(typeof r=="string"||Xs(r))return r;var e=r+"";return e=="0"&&1/r==-wB?"-0":e}var to=SB;function AB(r,e){e=Wr(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[to(e[t++])];return t&&t==n?r:void 0}var Df=AB;function _B(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Nl=_B;var YS=sr?sr.isConcatSpreadable:void 0;function TB(r){return yn(r)||ys(r)||!!(YS&&r&&r[YS])}var QS=TB;function ZS(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=QS),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?ZS(a,e-1,t,n,i):Nl(i,a):n||(i[i.length]=a)}return i}var KS=ZS;function MB(r){var e=r==null?0:r.length;return e?KS(r,1):[]}var JS=MB;function EB(r){return Tf(Mf(r,void 0,JS),r+"")}var If=EB;var CB=Pf(Object.getPrototypeOf,Object),Bl=CB;var PB="[object Object]",DB=Function.prototype,IB=Object.prototype,$S=DB.toString,LB=IB.hasOwnProperty,OB=$S.call(Object);function RB(r){if(!qn(r)||Ir(r)!=PB)return!1;var e=Bl(r);if(e===null)return!0;var t=LB.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&$S.call(t)==OB}var Lf=RB;function NB(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=NB;function BB(){this.__data__=new Js,this.size=0}var tA=BB;function FB(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var nA=FB;function UB(r){return this.__data__.get(r)}var rA=UB;function GB(r){return this.__data__.has(r)}var iA=GB;var zB=200;function kB(r,e){var t=this.__data__;if(t instanceof Js){var n=t.__data__;if(!$s||n.length<zB-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new Wu(n)}return t.set(r,e),this.size=t.size,this}var sA=kB;function Fl(r){var e=this.__data__=new Js(r);this.size=e.size}Fl.prototype.clear=tA;Fl.prototype.delete=nA;Fl.prototype.get=rA;Fl.prototype.has=iA;Fl.prototype.set=sA;var Of=Fl;function VB(r,e){return r&&Hr(e,Il(e),r)}var oA=VB;function HB(r,e){return r&&Hr(e,Ci(e),r)}var aA=HB;var hA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lA=hA&&typeof module=="object"&&module&&!module.nodeType&&module,WB=lA&&lA.exports===hA,cA=WB?Zt.Buffer:void 0,uA=cA?cA.allocUnsafe:void 0;function jB(r,e){if(e)return r.slice();var t=r.length,n=uA?uA(t):new r.constructor(t);return r.copy(n),n}var Rf=jB;function qB(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 dA=qB;function XB(){return[]}var Nf=XB;var YB=Object.prototype,QB=YB.propertyIsEnumerable,fA=Object.getOwnPropertySymbols,ZB=fA?function(r){return r==null?[]:(r=Object(r),dA(fA(r),function(e){return QB.call(r,e)}))}:Nf,Ul=ZB;function KB(r,e){return Hr(r,Ul(r),e)}var pA=KB;var JB=Object.getOwnPropertySymbols,$B=JB?function(r){for(var e=[];r;)Nl(e,Ul(r)),r=Bl(r);return e}:Nf,Bf=$B;function eF(r,e){return Hr(r,Bf(r),e)}var mA=eF;function tF(r,e,t){var n=e(r);return yn(r)?n:Nl(n,t(r))}var Ff=tF;function nF(r){return Ff(r,Il,Ul)}var gA=nF;function rF(r){return Ff(r,Ci,Bf)}var Uf=rF;var iF=hr(Zt,"DataView"),Gf=iF;var sF=hr(Zt,"Promise"),zf=sF;var oF=hr(Zt,"Set"),kf=oF;var yA="[object Map]",aF="[object Object]",vA="[object Promise]",xA="[object Set]",bA="[object WeakMap]",wA="[object DataView]",lF=gs(Gf),cF=gs($s),uF=gs(zf),hF=gs(kf),dF=gs(Af),Jo=Ir;(Gf&&Jo(new Gf(new ArrayBuffer(1)))!=wA||$s&&Jo(new $s)!=yA||zf&&Jo(zf.resolve())!=vA||kf&&Jo(new kf)!=xA||Af&&Jo(new Af)!=bA)&&(Jo=function(r){var e=Ir(r),t=e==aF?r.constructor:void 0,n=t?gs(t):"";if(n)switch(n){case lF:return wA;case cF:return yA;case uF:return vA;case hF:return xA;case dF:return bA}return e});var Gl=Jo;var fF=Object.prototype,pF=fF.hasOwnProperty;function mF(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&pF.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var SA=mF;var gF=Zt.Uint8Array,tv=gF;function yF(r){var e=new r.constructor(r.byteLength);return new tv(e).set(new tv(r)),e}var zl=yF;function vF(r,e){var t=e?zl(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var AA=vF;var xF=/\w*$/;function bF(r){var e=new r.constructor(r.source,xF.exec(r));return e.lastIndex=r.lastIndex,e}var _A=bF;var TA=sr?sr.prototype:void 0,MA=TA?TA.valueOf:void 0;function wF(r){return MA?Object(MA.call(r)):{}}var EA=wF;function SF(r,e){var t=e?zl(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var Vf=SF;var AF="[object Boolean]",_F="[object Date]",TF="[object Map]",MF="[object Number]",EF="[object RegExp]",CF="[object Set]",PF="[object String]",DF="[object Symbol]",IF="[object ArrayBuffer]",LF="[object DataView]",OF="[object Float32Array]",RF="[object Float64Array]",NF="[object Int8Array]",BF="[object Int16Array]",FF="[object Int32Array]",UF="[object Uint8Array]",GF="[object Uint8ClampedArray]",zF="[object Uint16Array]",kF="[object Uint32Array]";function VF(r,e,t){var n=r.constructor;switch(e){case IF:return zl(r);case AF:case _F:return new n(+r);case LF:return AA(r,t);case OF:case RF:case NF:case BF:case FF:case UF:case GF:case zF:case kF:return Vf(r,t);case TF:return new n;case MF:case PF:return new n(r);case EF:return _A(r);case CF:return new n;case DF:return EA(r)}}var CA=VF;function HF(r){return typeof r.constructor=="function"&&!Cl(r)?iS(Bl(r)):{}}var Hf=HF;var WF="[object Map]";function jF(r){return qn(r)&&Gl(r)==WF}var PA=jF;var DA=vs&&vs.isMap,qF=DA?Dl(DA):PA,IA=qF;var XF="[object Set]";function YF(r){return qn(r)&&Gl(r)==XF}var LA=YF;var OA=vs&&vs.isSet,QF=OA?Dl(OA):LA,RA=QF;var ZF=1,KF=2,JF=4,NA="[object Arguments]",$F="[object Array]",eU="[object Boolean]",tU="[object Date]",nU="[object Error]",BA="[object Function]",rU="[object GeneratorFunction]",iU="[object Map]",sU="[object Number]",FA="[object Object]",oU="[object RegExp]",aU="[object Set]",lU="[object String]",cU="[object Symbol]",uU="[object WeakMap]",hU="[object ArrayBuffer]",dU="[object DataView]",fU="[object Float32Array]",pU="[object Float64Array]",mU="[object Int8Array]",gU="[object Int16Array]",yU="[object Int32Array]",vU="[object Uint8Array]",xU="[object Uint8ClampedArray]",bU="[object Uint16Array]",wU="[object Uint32Array]",Nt={};Nt[NA]=Nt[$F]=Nt[hU]=Nt[dU]=Nt[eU]=Nt[tU]=Nt[fU]=Nt[pU]=Nt[mU]=Nt[gU]=Nt[yU]=Nt[iU]=Nt[sU]=Nt[FA]=Nt[oU]=Nt[aU]=Nt[lU]=Nt[cU]=Nt[vU]=Nt[xU]=Nt[bU]=Nt[wU]=!0;Nt[nU]=Nt[BA]=Nt[uU]=!1;function Wf(r,e,t,n,i,s){var o,a=e&ZF,l=e&KF,u=e&JF;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!Ht(r))return r;var c=yn(r);if(c){if(o=SA(r),!a)return _f(r,o)}else{var h=Gl(r),d=h==BA||h==rU;if(Pl(r))return Rf(r,a);if(h==FA||h==NA||d&&!i){if(o=l||d?{}:Hf(r),!a)return l?mA(r,aA(o,r)):pA(r,oA(o,r))}else{if(!Nt[h])return i?r:{};o=CA(r,h,a)}}s||(s=new Of);var f=s.get(r);if(f)return f;s.set(r,o),RA(r)?r.forEach(function(m){o.add(Wf(m,e,t,m,r,s))}):IA(r)&&r.forEach(function(m,v){o.set(v,Wf(m,e,t,v,r,s))});var g=u?l?Uf:gA:l?Ci:Il,p=c?void 0:g(r);return cS(p||r,function(m,v){p&&(v=m,m=r[v]),Ml(o,v,Wf(m,e,t,v,r,s))}),o}var jf=Wf;var SU=1,AU=4;function _U(r){return jf(r,SU|AU)}var ju=_U;function TU(r,e){return r!=null&&e in Object(r)}var UA=TU;function MU(r,e,t){e=Wr(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=to(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&&El(i)&&Ys(o,i)&&(yn(r)||ys(r)))}var GA=MU;function EU(r,e){return r!=null&&GA(r,e,UA)}var zA=EU;function CU(r){return function(e,t,n){for(var i=-1,s=Object(e),o=n(e),a=o.length;a--;){var l=o[r?a:++i];if(t(s[l],l,s)===!1)break}return e}}var kA=CU;var PU=kA(),VA=PU;var DU=function(){return Zt.Date.now()},qf=DU;var IU="Expected a function",LU=Math.max,OU=Math.min;function RU(r,e,t){var n,i,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof r!="function")throw new TypeError(IU);e=Zy(e)||0,Ht(t)&&(c=!!t.leading,h="maxWait"in t,s=h?LU(Zy(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function f(_){var M=n,x=i;return n=i=void 0,u=_,o=r.apply(x,M),o}function g(_){return u=_,a=setTimeout(v,e),c?f(_):o}function p(_){var M=_-l,x=_-u,T=e-M;return h?OU(T,s-x):T}function m(_){var M=_-l,x=_-u;return l===void 0||M>=e||M<0||h&&x>=s}function v(){var _=qf();if(m(_))return y(_);a=setTimeout(v,p(_))}function y(_){return a=void 0,d&&n?f(_):(n=i=void 0,o)}function w(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function b(){return a===void 0?o:y(qf())}function S(){var _=qf(),M=m(_);if(n=arguments,i=this,l=_,M){if(a===void 0)return g(l);if(h)return clearTimeout(a),a=setTimeout(v,e),f(l)}return a===void 0&&(a=setTimeout(v,e)),o}return S.cancel=w,S.flush=b,S}var qu=RU;function NU(r,e,t){(t!==void 0&&!Qs(r[e],t)||t===void 0&&!(e in r))&&Tl(r,e,t)}var Xu=NU;function BU(r){return qn(r)&&Zs(r)}var HA=BU;function FU(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}var Yu=FU;function UU(r){return Hr(r,Ci(r))}var WA=UU;function GU(r,e,t,n,i,s,o){var a=Yu(r,t),l=Yu(e,t),u=o.get(l);if(u){Xu(r,t,u);return}var c=s?s(a,l,t+"",r,e,o):void 0,h=c===void 0;if(h){var d=yn(l),f=!d&&Pl(l),g=!d&&!f&&Ef(l);c=l,d||f||g?yn(a)?c=a:HA(a)?c=_f(a):f?(h=!1,c=Rf(l,!0)):g?(h=!1,c=Vf(l,!0)):c=[]:Lf(l)||ys(l)?(c=a,ys(a)?c=WA(a):(!Ht(a)||Al(a))&&(c=Hf(l))):h=!1}h&&(o.set(l,c),i(c,l,n,s,o),o.delete(l)),Xu(r,t,c)}var jA=GU;function qA(r,e,t,n,i){r!==e&&VA(e,function(s,o){if(i||(i=new Of),Ht(s))jA(r,e,o,t,qA,n,i);else{var a=n?n(Yu(r,o),s,o+"",r,e,i):void 0;a===void 0&&(a=s),Xu(r,o,a)}},Ci)}var XA=qA;function zU(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var YA=zU;function kU(r,e){return e.length<2?r:Df(r,eA(e,0,-1))}var QA=kU;var VU=fS(function(r,e,t){XA(r,e,t)}),$o=VU;function HU(r,e){return e=Wr(e,r),r=QA(r,e),r==null||delete r[to(YA(e))]}var ZA=HU;function WU(r){return Lf(r)?void 0:r}var KA=WU;var jU=1,qU=2,XU=4,YU=If(function(r,e){var t={};if(r==null)return t;var n=!1;e=bf(e,function(s){return s=Wr(s,r),n||(n=s.length>1),s}),Hr(r,Uf(r),t),n&&(t=jf(t,jU|qU|XU,KA));for(var i=e.length;i--;)ZA(t,e[i]);return t}),kl=YU;function QU(r,e,t,n){if(!Ht(r))return r;e=Wr(e,r);for(var i=-1,s=e.length,o=s-1,a=r;a!=null&&++i<s;){var l=to(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=Ht(c)?c:Ys(e[i+1])?[]:{})}Ml(a,l,u),a=a[l]}return r}var JA=QU;function ZU(r,e,t){for(var n=-1,i=e.length,s={};++n<i;){var o=e[n],a=Df(r,o);t(a,o)&&JA(s,Wr(o,r),a)}return s}var $A=ZU;function KU(r,e){return $A(r,e,function(t,n){return zA(r,n)})}var e1=KU;var JU=If(function(r,e){return r==null?{}:e1(r,e)}),Vl=JU;var n1,r1=new Promise(r=>{n1=r}),t1=!1;async function i1(){if(t1)return;let r=await import("./physics.js");await r.init(),n1(r),t1=!0}var kt=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,kt.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,kt.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,kt.prototype),delete s[n],{data:s,actual:e,reverse:{type:1,id:n,data:i}}}}throw new Error("illegal arg")}};function Qu(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"&&Qu(n)}return Object.freeze(r)}function s1(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 Hl=class extends Error{};function Pi(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 ea(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 o1(){return typeof process<"u"}function a1(r,e){for(let t of r)e(t.id,t.data),a1(t.children,e)}function l1(r,e){e(r.id,r.data);for(let t of r.children)l1(t,e)}var Bt=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Bt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Qu(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)]}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&&l1(i,n)}}traverse(t){a1(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,Bt.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)}}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((d,f)=>d.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 Hl("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],h=this.modifyArrayBy(o,l);o=n,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,g)=>f.fi-g.fi),t.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:t,reverse:{type:9,parent:a,fi:d,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)=>s1(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 Pi(0,i,i);{let o=s[0].fi;return Pi(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 Pi(l,l+i,i)}else return Pi(o.fi,a.fi,i)}}};var Wl;(e=>{function r(t,n){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})(Wl||(Wl={}));var Ve=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Ve.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Qu(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,Ve.prototype);let n=t;return o1()||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)}}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,h)=>c.fi-h.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 Pi(0,n,n);{let s=i[0].fi;return Pi(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 Pi(a,a+n,n)}else return Pi(s.fi,o.fi,n)}}};var Lr=class{unusedFun(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 instanceof Bt||n instanceof Ve)return null;i+=1}n={...n};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;)Object.keys(n).length===0?(n={...t[i-1]},delete n[e.path[i-1]]):n={...t[i-1],[e.path[i-1]]:n},i-=1;let o=Object.setPrototypeOf(n,Lr.prototype),a={...e,props:s};return{data:o,actual:e,reverse:a}}},c1;(t=>{function r(n,i){return Zu(n,i)??n}t.apply=r;function e(n,i){if(i.type===0){let s=0,o=i.path,a=n;for(;s<o.length&&a!==void 0;){if(a=Di.zoomOnce(a,o[s]),a instanceof Bt||a instanceof Ve)return;s+=1}if(a===void 0)return i;if(typeof a=="string"||typeof a=="number"||ea(a))return;if(a&&typeof a=="object"){let l={...i.props};for(let u of Object.keys(a))delete l[u];return{...i,props:l}}else return}else if(i.type===1||i.type===4||i.type===7){let s=Di.zoom(n,[...i.path,i.id]);if(s===void 0)return i;if(typeof s=="string"||typeof s=="number"||ea(s))return;if(s&&typeof s=="object"){let o={...i.data,...s};return{...i,data:o}}else return}else return i}t.filterOp=e})(c1||(c1={}));function u1(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Zu(i.data,e[s]);t=t||o!==void 0,o===void 0&&(o=i.data);let a=u1(i.children,e);return a!==void 0?t=!0:a=i.children,{...i,id:s,data:o,children:a}});if(t)return n}function $U(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Zu(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 Zu(r,e){if(e!==void 0){if(e instanceof Ve||e instanceof Bt||typeof e=="string"||typeof e=="number"||e===null)return e;if(r instanceof Bt){let t=u1(r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else{if(r instanceof Ve)return $U(r,e);if(Array.isArray(r)){let t=!1,n=r.map((i,s)=>{let o=Zu(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&&typeof r=="object"){let t={},n=!1;for(let[i,s]of Object.entries(r)){let o=Zu(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}else return e??r}}}function h1(r,e){let t={cur:[],result:[],len:0};return r=Ku(r,e,t)??r,[r,t.result]}function Xf(r,e){return r===null?null:(r.cur[r.len]=e,r.len+=1,r)}function Yf(r){r&&(r.len-=1)}function eG(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function d1(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=Ku(s.data,e,Xf(t,o));Yf(t),n=n||l!==void 0,l===void 0&&(l=s.data);let u=d1(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 tG(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=Ku(s.data,e,Xf(t,o));return Yf(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 Ku(r,e,t){if(r instanceof Bt){let n=d1(r,e,t);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof Ve)return tG(r,e,t);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=Ku(s,e,Xf(t,o));return Yf(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"){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=Ku(o,e,Xf(t,s));Yf(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");eG(t)}return n}else return}}var f1;(e=>{function r(t,n){let i=Di.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})(f1||(f1={}));var no;(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 h=[];;){let d;if(l instanceof Lr&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),h.length===c.length&&(l instanceof Bt||l instanceof Ve||l instanceof kt?d=l.runOp(u):d=Wl.runOp(l,u)),d!==void 0)if(d!==null){let p=d.data;for(let m=h.length-1;m>=0;m--){let v=c[m],y=h[m];if(y instanceof Bt){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof Ve){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof kt){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof Lr){let w={...y,[v]:p};p=Object.setPrototypeOf(w,Lr.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let w=p;p=[...y],p[v]=w}else p={...y,[v]:p};else return null}return{data:p,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],g;if(l instanceof Bt){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else if(l instanceof Ve){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else l!==null&&(g=l[f]);if(g!==void 0)h.push(l),l=g;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})(no||(no={}));var p1;(l=>{function r(){return[]}l.empty=r;function e(u,c){let h=[];for(let d of u){let[f,...g]=d.path;f===c&&h.push({...d,path:g})}return h}l.removePrefix=e;function t(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=t;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(d=>!c.some(f=>no.subsumed(d,f))),...c]}l.compress=i;function s(u,c){return u.every(h=>c.every(d=>no.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let g of c)try{if(g.type===3){let p=Di.zoom(h,[...g.path,g.id]),m=no.apply(h,{...g,type:2});if(m!==null){h=m.data;let[v,y]=h1(h,{[g.id]:p});h=v;for(let w of y){let b=w[w.length-1];w.splice(w.length-1,1),d.push({type:0,path:w,props:{[b]:p}}),f.push({type:0,path:w,props:{[b]:g.id}})}f.push(m.reverse),d.push(m.actual)}}else{let p=no.apply(h,g);p!==null&&(d.push(p.actual),h=p.data,f.push(p.reverse))}}catch(p){if(p instanceof Hl)return null;throw p}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(p1||(p1={}));var m1=Symbol(),Ju=Symbol(),ta=class{reportOp(e,t,n=[]){let i=this;if(t===null)return;i._current=t.data;let s=n;for(;!(i instanceof Zf);){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[Ju];n&&n(),delete this._children[e]}}}},rv=class extends ta{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,Wl.runOp(this._current,e),e.path)}},iv=class extends ta{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,kt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},g1={get(r,e){if(e===Ju)return()=>{r._parent=null};if(e===m1)return r._current;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=Kf(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]}}},nG={...g1,set(r,e,t){let n={type:0,props:{[e]:dr(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}},rG={...g1,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}},jl=class extends ta{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Ju]=()=>{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=Kf(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)}},Qf=class extends ta{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n,this[Ju]=()=>{this._parent=null}}feedOp(e){let{path:t,...n}=e;this.reportOp(n,no.apply(this._current,e),t)}},ql=class extends ta{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Ju]=()=>{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=Kf(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 nv(r,e,t){if(r.length>0){let n=r[r.length-1];if(n.type===0&&e.type===0&&Di.equal(n.path,t)){Object.assign(n.props,e.props);return}}r.push({...e,path:t})}var Zf=class{constructor(e){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){nv(this.ts,t,e),nv(this.actual,n,e),nv(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Kf(r,e,t){return t instanceof Bt?new jl(r,e,t):t instanceof Ve?new ql(r,e,t):t instanceof Lr?new Qf(r,e,t):t instanceof kt?new Proxy(new iv(r,e,t),rG):t!==null&&typeof t=="object"?ea(t)?t:new Proxy(new rv(r,e,t),nG):t}function sv(r){let e=new Zf(r);return[Kf(e,"",r),e]}function ov(r,e){let[t,n]=sv(r);return e(t),n.result()}function dr(r){return r instanceof jl||r instanceof ql||r instanceof Qf?r._current:r!==null&&typeof r=="object"?r[m1]:r}var Di;(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 Bt||s instanceof jl)&&typeof o=="string")return s.data(o);if((s instanceof Ve||s instanceof ql)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object")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})(Di||(Di={}));var Jf=class{},$u=class extends Jf{constructor(t){super();this.id=t}},eh=class extends Jf{constructor(t){super();this.data=t}};var lv;try{lv=new TextDecoder}catch{}var Ie,io,Z=0;var _1=[],cv=_1,uv=0,fr={},xt,ro,jr=0,Ii=0,Or,bs,or=[],Et,y1={useRecords:!1,mapsAsObjects:!0},th=class{},dv=new th;dv.name="MessagePack 0xC1";var Xl=!1,Li=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 P1(()=>(ep(),this?this.unpack(e,t):Li.prototype.unpack.call(y1,e,t)));io=t>-1?t:e.length,Z=0,uv=0,Ii=0,ro=null,cv=_1,Or=null,Ie=e;try{Et=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 Li){if(fr=this,this.structures)return xt=this.structures,$f();(!xt||xt.length>0)&&(xt=[])}else fr=y1,(!xt||xt.length>0)&&(xt=[]);return $f()}unpackMultiple(e,t){let n,i=0;try{Xl=!0;let s=e.length,o=this?this.unpack(e,s):rp.unpack(e,s);if(t){for(t(o);Z<s;)if(i=Z,t($f())===!1)return}else{for(n=[o];Z<s;)i=Z,n.push($f());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Xl=!1,ep()}}_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 $f(){try{if(!fr.trusted&&!Xl){let e=xt.sharedLength||0;e<xt.length&&(xt.length=e)}let r=Kt();if(Z==io)xt.restoreStructures&&v1(),xt=null,Ie=null,bs&&(bs=null);else if(Z>io){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Xl)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw xt.restoreStructures&&v1(),ep(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function v1(){for(let r in xt.restoreStructures)xt[r]=xt.restoreStructures[r];xt.restoreStructures=null}function Kt(){let r=Ie[Z++];if(r<160)if(r<128){if(r<64)return r;{let e=xt[r&63]||fr.getStructures&&T1()[r&63];return e?(e.read||(e.read=fv(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,fr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[E1()]=Kt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Kt(),Kt());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Kt();return e}else if(r<192){let e=r-160;if(Ii>=Z)return ro.slice(Z-jr,(Z+=e)-jr);if(Ii==0&&io<140){let t=e<16?pv(e):M1(e);if(t!=null)return t}return hv(e)}else{let e;switch(r){case 192:return null;case 193:return Or?(e=Kt(),e>0?Or[1].slice(Or.position1,Or.position1+=e):Or[0].slice(Or.position0,Or.position0-=e)):dv;case 194:return!1;case 195:return!0;case 196:return av(Ie[Z++]);case 197:return e=Et.getUint16(Z),Z+=2,av(e);case 198:return e=Et.getUint32(Z),Z+=4,av(e);case 199:return na(Ie[Z++]);case 200:return e=Et.getUint16(Z),Z+=2,na(e);case 201:return e=Et.getUint32(Z),Z+=4,na(e);case 202:if(e=Et.getFloat32(Z),fr.useFloat32>2){let t=np[(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=Et.getFloat64(Z),Z+=8,e;case 204:return Ie[Z++];case 205:return e=Et.getUint16(Z),Z+=2,e;case 206:return e=Et.getUint32(Z),Z+=4,e;case 207:return fr.int64AsNumber?(e=Et.getUint32(Z)*4294967296,e+=Et.getUint32(Z+4)):e=Et.getBigUint64(Z),Z+=8,e;case 208:return Et.getInt8(Z++);case 209:return e=Et.getInt16(Z),Z+=2,e;case 210:return e=Et.getInt32(Z),Z+=4,e;case 211:return fr.int64AsNumber?(e=Et.getInt32(Z)*4294967296,e+=Et.getUint32(Z+4)):e=Et.getBigInt64(Z),Z+=8,e;case 212:if(e=Ie[Z++],e==114)return A1(Ie[Z++]&63);{let t=or[e];if(t)return t.read?(Z++,t.read(Kt())):t.noBuffer?(Z++,t()):t(Ie.subarray(Z,++Z));throw new Error("Unknown extension "+e)}case 213:return e=Ie[Z],e==114?(Z++,A1(Ie[Z++]&63,Ie[Z++])):na(2);case 214:return na(4);case 215:return na(8);case 216:return na(16);case 217:return e=Ie[Z++],Ii>=Z?ro.slice(Z-jr,(Z+=e)-jr):sG(e);case 218:return e=Et.getUint16(Z),Z+=2,Ii>=Z?ro.slice(Z-jr,(Z+=e)-jr):oG(e);case 219:return e=Et.getUint32(Z),Z+=4,Ii>=Z?ro.slice(Z-jr,(Z+=e)-jr):aG(e);case 220:return e=Et.getUint16(Z),Z+=2,b1(e);case 221:return e=Et.getUint32(Z),Z+=4,b1(e);case 222:return e=Et.getUint16(Z),Z+=2,w1(e);case 223:return e=Et.getUint32(Z),Z+=4,w1(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 iG=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function fv(r,e){function t(){if(t.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>iG.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Kt);return r.highByte===0&&(r.read=x1(e,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=Kt()}return n}return t.count=0,r.highByte===0?x1(e,t):t}var x1=(r,e)=>function(){let t=Ie[Z++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),i=xt[n]||T1()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=fv(i,r)),i.read()};function T1(){let r=P1(()=>(Ie=null,fr.getStructures()));return xt=fr._mergeStructures(r,xt)}var hv=tp,sG=tp,oG=tp,aG=tp;function tp(r){let e;if(r<16&&(e=pv(r)))return e;if(r>64&&lv)return lv.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+=Pn.apply(String,n),n.length=0)}return n.length>0&&(e+=Pn.apply(String,n)),e}function b1(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Kt();return e}function w1(r){if(fr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[E1()]=Kt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Kt(),Kt());return e}}var Pn=String.fromCharCode;function M1(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 Pn.apply(String,t)}function pv(r){if(r<4)if(r<2){if(r===0)return"";{let e=Ie[Z++];if((e&128)>1){Z-=1;return}return Pn(e)}}else{let e=Ie[Z++],t=Ie[Z++];if((e&128)>0||(t&128)>0){Z-=2;return}if(r<3)return Pn(e,t);let n=Ie[Z++];if((n&128)>0){Z-=3;return}return Pn(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 Pn(e,t,n,i);{let s=Ie[Z++];if((s&128)>0){Z-=5;return}return Pn(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 Pn(e,t,n,i,s,o);let a=Ie[Z++];if((a&128)>0){Z-=7;return}return Pn(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 Pn(e,t,n,i,s,o,a,l);{let u=Ie[Z++];if((u&128)>0){Z-=9;return}return Pn(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 Pn(e,t,n,i,s,o,a,l,u,c);let h=Ie[Z++];if((h&128)>0){Z-=11;return}return Pn(e,t,n,i,s,o,a,l,u,c,h)}else{let u=Ie[Z++],c=Ie[Z++],h=Ie[Z++],d=Ie[Z++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){Z-=12;return}if(r<14){if(r===12)return Pn(e,t,n,i,s,o,a,l,u,c,h,d);{let f=Ie[Z++];if((f&128)>0){Z-=13;return}return Pn(e,t,n,i,s,o,a,l,u,c,h,d,f)}}else{let f=Ie[Z++],g=Ie[Z++];if((f&128)>0||(g&128)>0){Z-=14;return}if(r<15)return Pn(e,t,n,i,s,o,a,l,u,c,h,d,f,g);let p=Ie[Z++];if((p&128)>0){Z-=15;return}return Pn(e,t,n,i,s,o,a,l,u,c,h,d,f,g,p)}}}}}function av(r){return fr.copyBuffers?Uint8Array.prototype.slice.call(Ie,Z,Z+=r):Ie.subarray(Z,Z+=r)}function na(r){let e=Ie[Z++];if(or[e])return or[e](Ie.subarray(Z,Z+=r));throw new Error("Unknown extension type "+e)}var S1=new Array(4096);function E1(){let r=Ie[Z++];if(r>=160&&r<192){if(r=r-160,Ii>=Z)return ro.slice(Z-jr,(Z+=r)-jr);if(!(Ii==0&&io<180))return hv(r)}else return Z--,Kt();let e=(r<<5^(r>1?Et.getUint16(Z):r>0?Ie[Z]:0))&4095,t=S1[e],n=Z,i=Z+r-3,s,o=0;if(t&&t.bytes==r){for(;n<i;){if(s=Et.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=[],S1[e]=t,t.bytes=r;n<i;)s=Et.getUint32(n),t.push(s),n+=4;for(i+=3;n<i;)s=Ie[n++],t.push(s);let a=r<16?pv(r):M1(r);return a!=null?t.string=a:t.string=hv(r)}var A1=(r,e)=>{var t=Kt();let n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let i=xt[r];return i&&i.isShared&&((xt.restoreStructures||(xt.restoreStructures=[]))[r]=i),xt[r]=t,t.read=fv(t,n),t.read()},C1=typeof self=="object"?self:global;or[0]=()=>{};or[0].noBuffer=!0;or[101]=()=>{let r=Kt();return(C1[r[0]]||Error)(r[1])};or[105]=r=>{let e=Et.getUint32(Z-4);bs||(bs=new Map);let t=Ie[Z],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let i={target:n};bs.set(e,i);let s=Kt();return i.used?Object.assign(n,s):(i.target=s,s)};or[112]=r=>{let e=Et.getUint32(Z-4),t=bs.get(e);return t.used=!0,t.target};or[115]=()=>new Set(Kt());var mv=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");or[116]=r=>{let e=r[0],t=mv[e];if(!t)throw new Error("Could not find typed array for code "+e);return new C1[t](Uint8Array.prototype.slice.call(r,1).buffer)};or[120]=()=>{let r=Kt();return new RegExp(r[0],r[1])};or[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=Z;Z+=e-4,Or=[Kt(),Kt()],Or.position0=0,Or.position1=0;let n=Z;Z=t;try{return Kt()}finally{Z=n}};or[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 P1(r){let e=io,t=Z,n=uv,i=jr,s=Ii,o=ro,a=cv,l=bs,u=Or,c=new Uint8Array(Ie.slice(0,io)),h=xt,d=xt.slice(0,xt.length),f=fr,g=Xl,p=r();return io=e,Z=t,uv=n,jr=i,Ii=s,ro=o,cv=a,bs=l,Or=u,Ie=c,Xl=g,xt=h,xt.splice(0,xt.length,...d),fr=f,Et=new DataView(Ie.buffer,Ie.byteOffset,Ie.byteLength),p}function ep(){Ie=null,bs=null,xt=null}function D1(r){r.unpack?or[r.type]=r.unpack:or[r.type]=r}var np=new Array(147);for(let r=0;r<256;r++)np[r]=+("1e"+Math.floor(45.15-r*.30103));var rp=new Li({useRecords:!1}),lG=rp.unpack,cG=rp.unpackMultiple,uG=rp.unpack,ip={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},hG=new Float32Array(1),jQ=new Uint8Array(hG.buffer,0,4);var sp;try{sp=new TextEncoder}catch{}var op,yv,ap=typeof Buffer<"u",gv=ap?Buffer.allocUnsafeSlow:Uint8Array,R1=ap?Buffer:Uint8Array,I1=ap?4294967296:2144337920,ae,sn,ee=0,Oi,Ri=null,dG=/[\u0080-\uFFFF]/,nh=Symbol("record-id"),ra=class extends Li{constructor(e){super(e),this.offset=0;let t,n,i,s,o,a,l=0,u=R1.prototype.utf8Write?function(x,T,E){return ae.utf8Write(x,T,E)}:sp&&sp.encodeInto?function(x,T){return sp.encodeInto(x,ae.subarray(T)).written}:!1,c=this;e||(e={});let h=e&&e.sequential,d=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let g=e.maxOwnStructures;g==null&&(g=d?32:64),h&&!e.saveStructures&&(this.structures=[]);let p=f>32||g+f>64,m=f+64,v=f+g+64;if(v>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],w=0,b=0;this.pack=this.encode=function(x,T){if(ae||(ae=new gv(8192),sn=new DataView(ae.buffer,0,8192),ee=0),Oi=ae.length-10,Oi-ee<2048?(ae=new gv(ae.length),sn=new DataView(ae.buffer,0,ae.length),Oi=ae.length-10,ee=0):ee=ee+7&2147483640,n=ee,a=c.structuredClone?new Map:null,c.bundleStrings?(Ri=["",""],ae[ee++]=214,ae[ee++]=98,Ri.position=ee-n,ee+=4):Ri=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,D=i.transitions;for(let N=0,F=P.length;N<F;N++){let z=P[N];O=D[z],O||(O=D[z]=Object.create(null)),D=O}D[nh]=C+64}l=E}h||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(x),Ri){sn.setUint32(Ri.position+n,ee-Ri.position-n);let E=Ri;Ri=null,S(E[0]),S(E[1])}if(c.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>Oi&&M(ee),c.offset=ee;let E=pG(ae.subarray(n,ee),a.idsToInsert);return a=null,E}return T&B1?(ae.start=n,ae.end=ee,ae):ae.subarray(n,ee)}finally{if(i){if(b<10&&b++,w>1e4)i.transitions=null,b=0,w=0,y.length>0&&(y=[]);else if(y.length>0&&!h){for(let E=0,C=y.length;E<C;E++)y[E][nh]=0;y=[]}if(s&&c.saveStructures){let E=i.sharedLength||f;i.length>E&&(i=i.slice(0,E));let C=ae.subarray(n,ee);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=E,C)}}T&wG&&(ee=n)}};let S=x=>{ee>Oi&&(ae=M(ee));var T=typeof x,E;if(T==="string"){let C=x.length;if(Ri&&C>=8&&C<4096){let D=dG.test(x);Ri[D?0:1]+=x,ae[ee++]=193,S(D?-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>Oi&&(ae=M(ee+O)),C<64||!u){let D,N,F,z=ee+P;for(D=0;D<C;D++)N=x.charCodeAt(D),N<128?ae[z++]=N:N<2048?(ae[z++]=N>>6|192,ae[z++]=N&63|128):(N&64512)===55296&&((F=x.charCodeAt(D+1))&64512)===56320?(N=65536+((N&1023)<<10)+(F&1023),D++,ae[z++]=N>>18|240,ae[z++]=N>>12&63|128,ae[z++]=N>>6&63|128,ae[z++]=N&63|128):(ae[z++]=N>>12|224,ae[z++]=N>>6&63|128,ae[z++]=N&63|128);E=z-ee-P}else E=u(x,ee+P,O);E<32?ae[ee++]=160|E:E<256?(P<2&&ae.copyWithin(ee+2,ee+1,ee+1+E),ae[ee++]=217,ae[ee++]=E):E<65536?(P<3&&ae.copyWithin(ee+3,ee+2,ee+2+E),ae[ee++]=218,ae[ee++]=E>>8,ae[ee++]=E&255):(P<5&&ae.copyWithin(ee+5,ee+3,ee+3+E),ae[ee++]=219,sn.setUint32(ee,E),ee+=4),ee+=E}else if(T==="number")if(x>>>0===x)x<64?ae[ee++]=x:x<256?(ae[ee++]=204,ae[ee++]=x):x<65536?(ae[ee++]=205,ae[ee++]=x>>8,ae[ee++]=x&255):(ae[ee++]=206,sn.setUint32(ee,x),ee+=4);else if(x>>0===x)x>=-32?ae[ee++]=256+x:x>=-128?(ae[ee++]=208,ae[ee++]=x+256):x>=-32768?(ae[ee++]=209,sn.setInt16(ee,x),ee+=2):(ae[ee++]=210,sn.setInt32(ee,x),ee+=4);else{let C;if((C=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){ae[ee++]=202,sn.setFloat32(ee,x);let P;if(C<4||(P=x*np[(ae[ee]&127)<<1|ae[ee+1]>>7])>>0===P){ee+=4;return}else ee--}ae[ee++]=203,sn.setFloat64(ee,x),ee+=8}else if(T==="object")if(!x)ae[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)}ae[ee++]=214,ae[ee++]=112,sn.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?ae[ee++]=144|E:E<65536?(ae[ee++]=220,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=221,sn.setUint32(ee,E),ee+=4);for(let P=0;P<E;P++)S(x[P])}else if(C===Map){E=x.size,E<16?ae[ee++]=128|E:E<65536?(ae[ee++]=222,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=223,sn.setUint32(ee,E),ee+=4);for(let[P,O]of x)S(P),S(O)}else{for(let P=0,O=op.length;P<O;P++){let D=yv[P];if(x instanceof D){let N=op[P];if(N.write){N.type&&(ae[ee++]=212,ae[ee++]=N.type,ae[ee++]=0),S(N.write.call(this,x));return}let F=ae,z=sn,Y=ee;ae=null;let U;try{U=N.pack.call(this,x,G=>(ae=F,F=null,ee+=G,ee>Oi&&M(ee),{target:ae,targetView:sn,position:ee-G}),S)}finally{F&&(ae=F,sn=z,ee=Y,Oi=ae.length-10)}U&&(U.length+ee>Oi&&M(U.length+ee),ee=fG(U,ae,ee,N.type));return}}_(x,!x.hasOwnProperty)}}else if(T==="boolean")ae[ee++]=x?195:194;else if(T==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))ae[ee++]=211,sn.setBigInt64(ee,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)ae[ee++]=207,sn.setBigUint64(ee,x);else if(this.largeBigIntToFloat)ae[ee++]=203,sn.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(T==="undefined")this.encodeUndefinedAsNil?ae[ee++]=192:(ae[ee++]=212,ae[ee++]=0,ae[ee++]=0);else if(T==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},_=this.useRecords===!1?this.variableMapSize?x=>{let T=Object.keys(x),E=T.length;E<16?ae[ee++]=128|E:E<65536?(ae[ee++]=222,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=223,sn.setUint32(ee,E),ee+=4);let C;for(let P=0;P<E;P++)S(C=T[P]),S(x[C])}:(x,T)=>{ae[ee++]=222;let E=ee-n;ee+=2;let C=0;for(let P in x)(T||x.hasOwnProperty(P))&&(S(P),S(x[P]),C++);ae[E+++n]=C>>8,ae[E+n]=C&255}:x=>{let T=Object.keys(x),E,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let D=0,N=T.length;D<N;D++){let F=T[D];E=C[F],E||(E=C[F]=Object.create(null),P++),C=E}let O=C[nh];if(O)O>=96&&p?(ae[ee++]=((O-=96)&31)+96,ae[ee++]=O>>5):ae[ee++]=O;else{O=o.nextId,O||(O=64),O<m&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(O=o.nextOwnId,O<v||(O=m),o.nextOwnId=O+1):(O>=v&&(O=m),o.nextId=O+1);let D=T.highByte=O>=96&&p?O-96>>5:-1;C[nh]=O,o[O-64]=T,O<m?(T.isShared=!0,o.sharedLength=O-63,s=!0,D>=0?(ae[ee++]=(O&31)+96,ae[ee++]=D):ae[ee++]=O):(D>=0?(ae[ee++]=213,ae[ee++]=114,ae[ee++]=(O&31)+96,ae[ee++]=D):(ae[ee++]=212,ae[ee++]=114,ae[ee++]=O),P&&(w+=b*P),y.length>=g&&(y.shift()[nh]=0),y.push(C),S(T))}for(let D=0,N=T.length;D<N;D++)S(x[T[D]])},M=x=>{let T;if(x>16777216){if(x-n>I1)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(I1,Math.round(Math.max((x-n)*(x>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(x-n<<2,ae.length-1)>>12)+1<<12;let E=new gv(T);return sn=new DataView(E.buffer,0,T),ae.copy?ae.copy(E,0,n,x):E.set(ae.slice(n,x)),ee-=n,n=0,Oi=E.length-10,ae=E}}useBuffer(e){ae=e,sn=new DataView(ae.buffer,ae.byteOffset,ae.byteLength),ee=0}};yv=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,th];op=[{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?L1(r,16,e):O1(ap?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==R1&&this.structuredClone?L1(r,mv.indexOf(t.name),e):O1(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function L1(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 O1(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 fG(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 pG(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 so(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)");yv.unshift(r.Class),op.unshift(r)}D1(r)}var N1=new ra({useRecords:!1}),mG=N1.pack,gG=N1.pack;var{NEVER:yG,ALWAYS:vG,DECIMAL_ROUND:xG,DECIMAL_FIT:bG}=ip,B1=512,wG=1024;var F1=new ra({structuredClone:!0});so({Class:kt.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,kt.prototype),r}});so({Class:Ve.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Ve.prototype),r}});so({Class:Bt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Bt.prototype),r}});so({Class:$u.prototype.constructor,type:4,write(r){return r.id},read(r){return new $u(r)}});so({Class:eh.prototype.constructor,type:5,write(r){return r.data},read(r){return new eh(r)}});so({Class:Lr.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Lr.prototype),r}});function SG(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 vv(r){if(ea(r))return r;if(Array.isArray(r))return r.map(vv);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=vv(r[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else return r}var lp;(n=>{function r(i){return F1.pack(i)}n.serialize=r;function e(i){return F1.unpack(i)}n.deserialize=e;function t(i){return SG(r(vv(i))).toString()}n.checksum=t})(lp||(lp={}));var up={["LookAt"]:[],["Follow"]:[],["MouseHover"]:["Transition"],["Scroll"]:["Transition"],["Start"]:["Transition","Audio"],["Conditional"]:["Transition","Audio"],["MouseDown"]:["Transition","Audio","Link"],["MouseUp"]:["Transition","Audio","Link"],["KeyDown"]:["Transition","Audio","Link"],["KeyUp"]:["Transition","Audio","Link"],["GameControl"]:["Transition","Audio"],["Collision"]:["Transition","Audio"]},U1;(t=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"}t.is=r;function e(n){return n==="MouseDown"||n==="MouseUp"?{type:n,toggle:!1,actions:new Ve}:{type:n,key:void 0,toggle:!1,actions:new Ve}}t.defaultData=e})(U1||(U1={}));var cp;(t=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}t.propertyDefaultData=r,t.valueDefaultData={type:"Literal",value:0}})(cp||(cp={}));var xv;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:cp.propertyDefaultData(i),rOperand:{...cp.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})(xv||(xv={}));var G1;(t=>{function r(n){return n.type==="Conditional"}t.is=r;function e(n){return{type:"Conditional",inActions:new Ve,outActions:new Ve,condition:xv.distanceDefaultData(n)}}t.defaultData=e})(G1||(G1={}));var z1;(e=>e.defaultData={type:"Follow"})(z1||(z1={}));var k1;(e=>{function r(){return{type:"LookAt",distance:1e3}}e.defaultData=r})(k1||(k1={}));var V1;(t=>{function r(n){return n.type==="MouseHover"}t.is=r;function e(){return{type:"MouseHover",actions:new Ve}}t.defaultData=e})(V1||(V1={}));var H1;(t=>{function r(n){return n.type==="Scroll"}t.is=r;function e(){return{type:"Scroll",steps:100,actions:new Ve}}t.defaultData=e})(H1||(H1={}));var W1;(t=>{function r(n){return n.type==="Start"}t.is=r;function e(){return{type:"Start",actions:new Ve}}t.defaultData=e})(W1||(W1={}));var j1;(t=>{function r(n){return n.type==="Collision"}t.is=r;function e(){return{type:"Collision",toggle:!1,target:"character",actions:new Ve}}t.defaultData=e})(j1||(j1={}));var ia;(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})(ia||(ia={}));var Yl;(i=>{function r(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=r;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function n(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=n})(Yl||(Yl={}));var rh;(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})(rh||(rh={}));var oo;(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})(oo||(oo={}));var Xn;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function n(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:1}}l.toRgb255a1=n;function i(u){return{r:u.r,g:u.g,b:u.b}}l.clone=i;function s(u){return u=Math.floor(u),{r:(u>>16&255)/255,g:(u>>8&255)/255,b:(u&255)/255}}l.fromHex=s;function o(u,c){return u.r===c.r&&u.g===c.g&&u.b===c.b}l.equals=o;function a(u,c,h){return{r:u.r+(c.r-u.r)*h,g:u.g+(c.g-u.g)*h,b:u.b+(c.b-u.b)*h}}l.lerp=a})(Xn||(Xn={}));var pr;(a=>{a.white={...Xn.white,a:1},a.transparent={...Xn.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{...Xn.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 Xn.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})(pr||(pr={}));var hp;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(hp||(hp={}));var q1;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(q1||(q1={}));var X1;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(X1||(X1={}));var Ni;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(n){return t.all.includes(n)}t.is=e})(Ni||(Ni={}));var sa;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(sa||(sa={}));var dp;(e=>{function r(t,n=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*n,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+n)),useCenter:!0}}}e.defaultData=r})(dp||(dp={}));var oa;(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}}})(oa||(oa={}));var fp;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(n){return t.all.includes(n)}t.is=e})(fp||(fp={}));var pp;(t=>{function r(n){return e(n)}t.defaultData=r;function e(n){if(n==="PointLight")return{type:n,color:pr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:pr.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:pr.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(pp||(pp={}));var bv;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}t.equals=e})(bv||(bv={}));var wv;(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})(wv||(wv={}));var mp;(e=>e.defaultData={...wv.defaultData,...bv.defaultData,cloner:null,booleanExclude:null})(mp||(mp={}));var gp=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Y1=["wrapping","image"],Bi;(n=>{function r(i,s){return i==="light"&&s?e(s):t(i)}n.defaultData=r;function e(i){switch(i){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 t(i){switch(i){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:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Xn.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:{...Xn.fromHex(6710886),a:1},colorB:{...Xn.fromHex(6710886),a:1},colorC:{...Xn.fromHex(16777215),a:1},colorD:{...Xn.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:pr.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:pr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:pr.fromHexAndA(0,1),contourColor:pr.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}}}})(Bi||(Bi={}));var Bn;(a=>{function r(l){return!l.layers.some(c=>c.data.type==="texture"&&c.data.projection!==0||c.data.type==="depth"&&!c.data.isWorldSpace||c.data.type==="noise"||c.data.type==="displace")&&!t(l)}a.isMergable=r;function e(l){let u="";return l.layers.forEach(c=>{Object.entries(c.data).forEach(([h,d])=>{u+=`${h}${d}`,Array.isArray(d)?d.forEach(f=>u+=`${f}`):typeof d=="object"?Object.values(d).forEach(f=>{typeof f=="number"?u+=`${f.toFixed(4)}`:u+=`${f}`}):u+=`${d}`})}),u}a.getHash=e;function t(l){let u=0;for(let c of l.layers)"alpha"in c.data&&c.data.type!=="light"&&c.data.type!=="fresnel"&&(u+=(1-u)*c.data.alpha);return u<1}a.isTransparent=t;function n(){return{layers:new Ve}}a.defaultEmptyData=n;function i(l="layer1",u="layer2"){return s("phong",l,u)}a.defaultData=i;function s(l,u="layer1",c="layer2"){let h=new Ve;return h.push({fi:0,data:Bi.defaultData("light",l),id:u}),h.push({fi:1,data:Bi.defaultData("color"),id:c}),{layers:h}}a.defaultTwoLayerData=s;function o(l,u="phong",c="layer1",h="layer2"){let d=Bi.defaultData("texture");Object.assign(d.texture,{image:l});let f=new Ve;return f.push({fi:0,data:d,id:c}),f.push({fi:1,data:Bi.defaultData("light",u),id:h}),{layers:f}}a.defaultTwoLayerTextureData=o})(Bn||(Bn={}));var Ql;(e=>{function r(){return{points:new Ve,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=r})(Ql||(Ql={}));var Zl;(e=>{function r(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=r})(Zl||(Zl={}));var ao;(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:Ql.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})(ao||(ao={}));var ih;(i=>{i.identity={...hp.identity,hiddenMatrix:oo.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:Yl.isEqual(s.position,o.position)?null:o.position,rotation:Yl.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:Yl.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:oo.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(ih||(ih={}));var Sv;(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]})(Sv||(Sv={}));var di;(e=>e.defaultData={states:new Ve,events:new Ve,visible:!0,raycastLock:!1,physics:null,...ih.identity})(di||(di={}));var Q1;(e=>e.defaultData={type:"Empty",...di.defaultData})(Q1||(Q1={}));var aa;(e=>e.defaultData={type:"Mesh",...di.defaultData,...mp.defaultData})(aa||(aa={}));var yp;(e=>e.defaultData={...di.defaultData,...ih.identity,...sa.defaultData})(yp||(yp={}));var vp;(e=>{function r(t){return{...di.defaultData,...pp.defaultData(t)}}e.defaultData=r})(vp||(vp={}));var xp;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:oo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Sv.defaultData,states:new Ve,events:new Ve,...sa.defaultData},i.defaultMeshObject={name:"Rectangle",...di.defaultData,...aa.defaultData,geometry:ao.defaultData("RectangleGeometry"),material:Bn.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...di.defaultData,...aa.defaultData,geometry:ao.defaultData("BooleanGeometry"),material:Bn.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...di.defaultData,...aa.defaultData,geometry:ao.defaultData("TextGeometry"),material:Bn.defaultTwoLayerData("phong","layer1","layer2")}))(xp||(xp={}));var sh;(t=>{function r(n,i){if(i===void 0)return n;let s={...n};return"material"in s&&"material"in i&&i.material&&(s.material=ov(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let u=o.layers.data(a);u&&$o(u,l)}}).data),s.materials&&i.materials&&(s.materials=ov(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[u,c]of Object.entries(l.layers)){let h=o[a]?.layers?.data(u);h&&$o(h,c)}}}).data),s}t.patchMaterialState=r;function e(n,i){if(i===void 0)return n;let s={...n};if(Object.assign(s,ih.merge(s,i)),Ni.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(n.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=r(s,i);else if(fp.is(n.type)){let o=i;o.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=Xn.clone(o.color))}return s}t.patch=e})(sh||(sh={}));var oh;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Xn.white,near:.1,far:2e3})(oh||(oh={}));var Kl;(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})(Kl||(Kl={}));var ws;(e=>e.defaultData={orbitControls:Kl.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio: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})(ws||(ws={}));var ar;(e=>e.defaultData={ambientLight:{enabled:!0,type:"HemisphereLight",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:45})(ar||(ar={}));var bp;(n=>{function r(){let i=new Bt,s=xp.defaultMeshObject;return i.push({fi:-1,data:{...vp.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),i.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:s,children:[]}),i}n.defaultData={backgroundColor:pr.fromHexAndA(1908256,1),postprocessing:oa.defaultData,fog:oh.defaultData,objects:r(),environment:ar.defaultData,publish:ws.defaultData},n.emptyData=function(){return{backgroundColor:pr.fromHexAndA(1908256,1),postprocessing:oa.defaultData,fog:oh.defaultData,objects:new Bt,environment:ar.defaultData,publish:ws.defaultData}}})(bp||(bp={}));function la(r,e){return Object.setPrototypeOf(r,e),r}var AG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),_G=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),TG=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||ca&&"ontouchend"in document,MG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,EG=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,CG=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(e)},PG=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},wK=AG(),ca=_G(),Av=TG(),Z1=MG(),vn=EG(),Jl=CG(),$l=Number(PG());function K1(r){return Array.isArray(r)?r:[r]}function ah(r){return ca?r.metaKey:r.ctrlKey}var $e=[],Sp={},lh={},wp={};function J1(r){$e.includes(r)||$e.push(r)}function ec(r){delete Sp[r.pointerId];for(let e=0;e<$e.length;e++)if($e[e].pointerId===r.pointerId){$e.splice(e,1);break}}function Ap(r){if(r.pointerType!=="touch")return;let e=Sp[r.pointerId];e===void 0&&(e={x:0,y:0},Sp[r.pointerId]=e),e.x=r.pageX,e.y=r.pageY}function _p(r){let e=r.pointerId===$e[0].pointerId?$e[1]:$e[0];return Sp[e.pointerId]}function $1(r){lh[r.key]=!0,wp[r.key]=wp[r.key]===void 0?1:wp[r.key]+1}function e_(r){if(ca&&lh.Meta)for(let e in lh)lh[e]=!1;else lh[r.key]=!1;wp={}}function t_(r){r.addEventListener("pointerdown",J1,!0),r.addEventListener("pointerdown",Ap,!0),r.addEventListener("pointermove",Ap,!0),r.addEventListener("pointerup",ec,!0),r.addEventListener("pointercancel",ec,!0),r.addEventListener("pointerleave",ec,!0),window.addEventListener("keydown",$1,!0),window.addEventListener("keyup",e_,!0)}function n_(r){r.removeEventListener("pointerdown",J1,!0),r.removeEventListener("pointerdown",Ap,!0),r.removeEventListener("pointermove",Ap,!0),r.removeEventListener("pointerup",ec,!0),r.removeEventListener("pointercancel",ec,!0),r.removeEventListener("pointerleave",ec,!0),window.removeEventListener("keydown",$1,!0),window.removeEventListener("keyup",e_,!0)}var tc;(t=>{function r(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},la(n,kt.prototype)}t.defaultColors=r;function e(){return{materials:new kt,images:new kt,colors:new kt,audios:new kt,fonts:new kt,penumbraSize:[.5,.5,.5]}}t.emptyData=e})(tc||(tc={}));function r_(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={...Vl(dr(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={...dr(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,t)}})}function Tp(r,e){Object.values(r.shared.materials).forEach(t=>e(t))}function Mp(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 DG(r){Object.assign(r.scene.publish,{orbitControls:{...Kl.defaultData,...dr(r.scene.publish.orbitControls)}})}function IG(r){Object.assign(r.scene.publish.settings,{video:{...ws.defaultData.settings.video,...dr(r.scene.publish.settings.video)}})}function LG(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((gp.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(Y1.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 OG(r){r.scene.publish.withBackground=!0}function RG(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1}}function NG(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 BG(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 FG(r){r.scene.objects.traverse((e,t)=>{let n=r.scene.objects.parent(e);t.type==="Mesh"&&(!n||r.scene.objects.data(n).geometry?.type!=="BooleanGeometry")&&(t.booleanExclude=null)})}function i_(r){r.layers===void 0&&Object.assign(r,Bn.defaultTwoLayerData("lambert"))}function _v(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={...dr(e),colors:t,steps:n};Object.assign(e,i)}})}function UG(r){r.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&(t.geometry.type==="BooleanGeometry"||t.geometry.type==="SubdivGeometry")&&(t.geometry.phongAngle=35)})}function s_(r){r.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(n=>{typeof n!="string"&&_v(n)}):"material"in t&&typeof t.material!="string"&&_v(t.material)}),Object.values(r.shared.materials).forEach(e=>_v(e))}function GG(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 zG(r){r.shared.audios=la({},kt.prototype)}function kG(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 VG(r){Object.entries(dr(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(dr(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function HG(r){r.scene.publish.settings.web.preload=!1}function o_(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 WG(r){r.shared.fonts=la({},kt.prototype)}function jG(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 qG(r){let e=[];r.scene.objects.traverse((t,n)=>{let i=n;if(i.type==="TextFrame"){let s=Bn.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=jG(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...di.defaultData,...aa.defaultData,flatShading:!1,wireframe:!1,geometry:{...ao.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:dr(i.states),events:dr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=dr(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 XG(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 Ve,move:new Ve,jump:new Ve}});else{let s=new Ve;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:Be.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,Vl(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Ve({fi:0,id:Be.generateUUID(),data:u},{fi:1,id:Be.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function YG(r){r.scene.objects.traverse((e,t)=>{function n(i,s){let o=new Ve,a=[];if(t.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Vl(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...Vl(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),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:Be.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function a_(r){let e=r.layers.find(t=>t.type==="light")?.data;if(e?.category==="basic"){let t=Bi.defaultData("light","phong"),n=e;Object.assign(n,t),n.visible=!1}}function QG(r){Tp(r,a_),Mp(r,a_)}var l_=22;function c_(r){let e=r.schema??0;e!==l_&&(console.warn("updating from ",e,"to ",l_),e<1&&(Mp(r,r_),Tp(r,r_),r.schema=1),e<2&&(DG(r),r.schema=2),e<3&&(LG(r),r.schema=3),e<4&&(OG(r),r.schema=4),e<5&&(RG(r),r.schema=5),e<6&&(NG(r),r.schema=6),e<7&&(BG(r),r.schema=7),e<8&&(FG(r),r.schema=8),e<9&&(s_(r),r.schema=9),e<10&&(UG(r),r.schema=10),e<11&&(GG(r),r.schema=11),e<12&&(s_(r),r.schema=12),e<13&&(zG(r),r.schema=13),e<14&&(kG(r),r.schema=14),e<15&&(VG(r),r.schema=15),e<16&&(HG(r),r.schema=16),e<17&&(Mp(r,o_),Tp(r,o_),r.schema=17),e<18&&(Mp(r,i_),Tp(r,i_),r.schema=18),e<19&&(IG(r),r.schema=19),e<20&&(WG(r),qG(r),r.schema=20),e<21&&(XG(r),YG(r),r.schema=21),e<22&&(QG(r),r.schema=22))}var Ep;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Ep||(Ep={}));function Ss(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 De,u=0;for(let c=0;c<r.length;++c){let h=r[c],d=0;if(t!==(h.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 h.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(h.attributes[f]),d++}if(d!==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!==h.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 h.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(h.morphAttributes[f])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(h.userData),e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+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,h=[];for(let d=0;d<r.length;++d){let f=r[d].index;for(let g=0;g<f.count;++g)h.push(f.getX(g)+c);c+=r[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=u_(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][d]);let g=u_(f);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(g)}}return l}function u_(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 Ge(s,t,n)}var Cp;(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,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 Ve,move:new Ve,jump:new Ve}}))(Cp||(Cp={}));var h_=Math.pow(2,-24);var ua=class{constructor(){}};function qr(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 Tv(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 Mv(r,e){e.set(r)}function Ev(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 ch(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 rc(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 JG(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 Ge(i,1));for(let s=0;s<t;s++)i[s]=s}}function $G(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 Pv(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,h=1/0,d=1/0,f=1/0,g=-1/0,p=-1/0,m=-1/0,v=i!==null;for(let y=e*6,w=(e+t)*6;y<w;y+=6){let b=r[y+0],S=r[y+1],_=b-S,M=b+S;_<s&&(s=_),M>l&&(l=M),v&&b<h&&(h=b),v&&b>g&&(g=b);let x=r[y+2],T=r[y+3],E=x-T,C=x+T;E<o&&(o=E),C>u&&(u=C),v&&x<d&&(d=x),v&&x>p&&(p=x);let P=r[y+4],O=r[y+5],D=P-O,N=P+O;D<a&&(a=D),N>c&&(c=N),v&&P<f&&(f=P),v&&P>m&&(m=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,v&&(i[0]=h,i[1]=d,i[2]=f,i[3]=g,i[4]=p,i[5]=m)}function ez(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,h=(e+t)*6;c<h;c+=6){let d=r[c+0];d<i&&(i=d),d>a&&(a=d);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let g=r[c+4];g<o&&(o=g),g>u&&(u=g)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function tz(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 h=e[s*6+u*2+0];e[s*6+u*2+0]=e[o*6+u*2+0],e[o*6+u*2+0]=h;let d=e[s*6+u*2+1];e[s*6+u*2+1]=e[o*6+u*2+1],e[o*6+u*2+1]=d}s++,o--}else return s}}var As=32,nz=(r,e)=>r.candidate-e.candidate,lo=new Array(As).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Pp=new Float32Array(6);function rz(r,e,t,n,i,s){let o=-1,a=0;if(s===0)o=Tv(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===1)o=Tv(r),o!==-1&&(a=iz(t,n,i,o));else if(s===2){let l=rc(r),u=1.25*i,c=n*6,h=(n+i)*6;for(let d=0;d<3;d++){let f=e[d],m=(e[d+3]-f)/As;if(i<As/4){let v=[...lo];v.length=i;let y=0;for(let b=c;b<h;b+=6,y++){let S=v[y];S.candidate=t[b+2*d],S.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:x}=S;for(let T=0;T<3;T++)x[T]=1/0,x[T+3]=-1/0,M[T]=1/0,M[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0;ch(b,t,_)}v.sort(nz);let w=i;for(let b=0;b<w;b++){let S=v[b];for(;b+1<w&&v[b+1].candidate===S.candidate;)v.splice(b+1,1),w--}for(let b=c;b<h;b+=6){let S=t[b+2*d];for(let _=0;_<w;_++){let M=v[_];S>=M.candidate?ch(b,t,M.rightCacheBounds):(ch(b,t,M.leftCacheBounds),M.count++)}}for(let b=0;b<w;b++){let S=v[b],_=S.count,M=i-S.count,x=S.leftCacheBounds,T=S.rightCacheBounds,E=0;_!==0&&(E=rc(x)/l);let C=0;M!==0&&(C=rc(T)/l);let P=1+1.25*(E*_+C*M);P<u&&(o=d,u=P,a=S.candidate)}}else{for(let w=0;w<As;w++){let b=lo[w];b.count=0,b.candidate=f+m+w*m;let S=b.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let w=c;w<h;w+=6){let _=~~((t[w+2*d]-f)/m);_>=As&&(_=As-1);let M=lo[_];M.count++,ch(w,t,M.bounds)}let v=lo[As-1];Mv(v.bounds,v.rightCacheBounds);for(let w=As-2;w>=0;w--){let b=lo[w],S=lo[w+1];Ev(b.bounds,S.rightCacheBounds,b.rightCacheBounds)}let y=0;for(let w=0;w<As-1;w++){let b=lo[w],S=b.count,_=b.bounds,x=lo[w+1].rightCacheBounds;S!==0&&(y===0?Mv(_,Pp):Ev(_,Pp,Pp)),y+=S;let T=0,E=0;y!==0&&(T=rc(Pp)/l);let C=i-y;C!==0&&(E=rc(x)/l);let P=1+1.25*(T*y+E*C);P<u&&(o=d,u=P,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function iz(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 sz(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,h=u*6,d=i[c+0]*l+a,f=i[c+1]*l+a,g=i[c+2]*l+a;for(let p=0;p<3;p++){let m=n[d+p],v=n[f+p],y=n[g+p],w=m;v<w&&(w=v),y<w&&(w=y);let b=m;v>b&&(b=v),y>b&&(b=y);let S=(b-w)/2,_=p*2;o[h+_+0]=w+S,o[h+_+1]=S+(Math.abs(w)+S)*h_,w<e[p]&&(e[p]=w),b>e[p+3]&&(e[p+3]=b)}}return o}function oz(r,e){function t(v){d&&d(v/f)}function n(v,y,w,b=null,S=0){if(!g&&S>=l&&(g=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),w<=c||S>=l)return t(y+w),v.offset=y,v.count=w,v;let _=rz(v.boundingData,b,o,y,w,h);if(_.axis===-1)return t(y+w),v.offset=y,v.count=w,v;let M=tz(a,o,y,w,_);if(M===y||M===y+w)t(y+w),v.offset=y,v.count=w;else{v.splitAxis=_.axis;let x=new ua,T=y,E=M-y;v.left=x,x.boundingData=new Float32Array(6),Pv(o,T,E,x.boundingData,s),n(x,T,E,s,S+1);let C=new ua,P=M,O=w-E;v.right=C,C.boundingData=new Float32Array(6),Pv(o,P,O,C.boundingData,s),n(C,P,O,s,S+1)}return v}JG(r,e);let i=new Float32Array(6),s=new Float32Array(6),o=sz(r,i),a=r.index.array,l=e.maxDepth,u=e.verbose,c=e.maxLeafTris,h=e.strategy,d=e.onProgress,f=r.index.count/3,g=!1,p=[],m=$G(r);if(m.length===1){let v=m[0],y=new ua;y.boundingData=i,ez(o,v.offset,v.count,s),n(y,v.offset,v.count,s),p.push(y)}else for(let v of m){let y=new ua;y.boundingData=new Float32Array(6),Pv(o,v.offset,v.count,y.boundingData,s),n(y,v.offset,v.count,s),p.push(y)}return p}function p_(r,e){let t=oz(r,e),n,i,s,o=[],a=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<t.length;c++){let h=t[c],d=l(h),f=new a(32*d);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,g=!!h.count,p=h.boundingData;for(let m=0;m<6;m++)n[d+m]=p[m];if(g){let m=h.offset,v=h.count;return i[d+6]=m,s[f+14]=v,s[f+15]=65535,c+32}else{let m=h.left,v=h.right,y=h.splitAxis,w;if(w=u(c+32,m),w/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=w/4,w=u(w,v),i[d+7]=y,w}}}var mr=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}};mr.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 h=t.dot(r);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var xJ=function(){let r=new mr;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 h=o[c],d=s[c];if(r.setFromPoints(d,a),h.isSeparated(r))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(r.setFromPoints(d,i),h.isSeparated(r))return!1}}}();var az=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 h=t.dot(c),d=c.dot(l),f=c.dot(c),g=t.dot(l),m=l.dot(l)*f-d*d,v,y;m!==0?v=(h*d-g*f)/m:v=0,y=(h+v*d)/f,o.x=v,o.y=y}}(),uh=function(){let r=new B,e=new A,t=new A;return function(i,s,o,a){az(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 h;u<0?h=s.start:h=s.end;let d=e,f=t;if(i.closestPointToPoint(h,!0,e),s.closestPointToPoint(c,!0,t),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),m_=function(){let r=new A,e=new A,t=new mn,n=new gn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){let v=p.projectPoint(l,e);if(o.containsPoint(v))return!0}return!1}}();var lz=1e-15;function ic(r){return Math.abs(r)<lz}var gr=class extends Tn{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new mr),this.points=[this.a,this.b,this.c],this.sphere=new Mn,this.plane=new mn,this.needsUpdate=!0}intersectsSphere(e){return m_(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 h=s[2],d=o[2];h.subVectors(t,n),d.setFromPoints(h,i);let f=s[3],g=o[3];f.subVectors(n,e),g.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};gr.prototype.closestPointToSegment=function(){let r=new A,e=new A,t=new gn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;t.start.copy(u[d]),t.end.copy(u[f]),uh(t,i,r,e),c=r.distanceToSquared(e),c<h&&(h=c,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(h)}}();gr.prototype.intersectsTriangle=function(){let r=new gr,e=new Array(3),t=new Array(3),n=new mr,i=new mr,s=new A,o=new A,a=new A,l=new A,u=new gn,c=new gn,h=new gn;return function(f,g=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,m=f.plane;if(Math.abs(p.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;t[0]=f.a,t[1]=f.b,t[2]=f.c;for(let S=0;S<4;S++){let _=v[S],M=y[S];if(n.setFromPoints(M,t),_.isSeparated(n))return!1}let w=f.satBounds,b=f.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let S=0;S<4;S++){let _=w[S],M=b[S];if(n.setFromPoints(M,e),_.isSeparated(n))return!1}for(let S=0;S<4;S++){let _=y[S];for(let M=0;M<4;M++){let x=b[M];if(s.crossVectors(_,x),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return g&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let v=this.points,y=!1,w=0;for(let O=0;O<3;O++){let D=v[O],N=v[(O+1)%3];u.start.copy(D),u.end.copy(N),u.delta(o);let F=y?c.start:c.end,z=ic(m.distanceToPoint(D));if(ic(m.normal.dot(o))&&z){c.copy(u),w=2;break}if((m.intersectLine(u,F)||z)&&!ic(F.distanceTo(N))){if(w++,y)break;y=!0}}if(w===1&&this.containsPoint(c.start))return g&&(g.start.copy(c.start),g.end.copy(c.start)),!0;if(w!==2)return!1;let b=f.points,S=!1,_=0;for(let O=0;O<3;O++){let D=b[O],N=b[(O+1)%3];u.start.copy(D),u.end.copy(N),u.delta(a);let F=S?h.start:h.end,z=ic(p.distanceToPoint(D));if(ic(p.normal.dot(a))&&z){h.copy(u),_=2;break}if((p.intersectLine(u,F)||z)&&!ic(F.distanceTo(N))){if(_++,S)break;S=!0}}if(_===1&&this.containsPoint(h.start))return g&&(g.start.copy(h.start),g.end.copy(h.start)),!0;if(_!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let O=h.start;h.start=h.end,h.end=O}let M=c.start.dot(o),x=c.end.dot(o),T=h.start.dot(o),E=h.end.dot(o),C=x<T,P=M<E;return M!==E&&T!==x&&C===P?!1:(g&&(l.subVectors(c.start,h.start),l.dot(o)>0?g.start.copy(c.start):g.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?g.end.copy(c.end):g.end.copy(h.end)),!0)}}}();gr.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();gr.prototype.distanceToTriangle=function(){let r=new A,e=new A,t=["a","b","c"],n=new gn,i=new gn;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 h=0;h<3;h++){let d,f=t[h],g=o[f];this.closestPointToPoint(g,r),d=g.distanceToSquared(r),d<c&&(c=d,a&&a.copy(r),l&&l.copy(g));let p=this[f];o.closestPointToPoint(p,r),d=p.distanceToSquared(r),d<c&&(c=d,a&&a.copy(p),l&&l.copy(r))}for(let h=0;h<3;h++){let d=t[h],f=t[(h+1)%3];n.set(this[d],this[f]);for(let g=0;g<3;g++){let p=t[g],m=t[(g+1)%3];i.set(o[p],o[m]),uh(n,i,r,e);let v=r.distanceToSquared(e);v<c&&(c=v,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(c)}}();var yr=class extends Mt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new be,this.invMatrix=new be,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 mr),this.alignedSatBounds=new Array(3).fill().map(()=>new mr),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}};yr.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 h=0;h<=1;h++){let d=1*u|2*c|4*h,f=i[d];f.x=u?n.x:t.x,f.y=c?n.y:t.y,f.z=h?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],h=s[u],d=1<<u,f=i[d];c.subVectors(a,f),h.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}}();yr.prototype.intersectsBox=function(){let r=new mr;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}}();yr.prototype.intersectsTriangle=function(){let r=new gr,e=new Array(3),t=new mr,n=new mr,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 d=0;d<3;d++){let f=a[d],g=l[d];if(t.setFromPoints(g,e),f.isSeparated(t))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],g=c[d];if(t.setFromPoints(g,h),f.isSeparated(t))return!1}for(let d=0;d<3;d++){let f=l[d];for(let g=0;g<4;g++){let p=c[g];if(i.crossVectors(f,p),t.setFromPoints(i,e),n.setFromPoints(i,h),t.isSeparated(n))return!1}}return!0}}();yr.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}}();yr.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();yr.prototype.distanceToBox=function(){let r=["x","y","z"],e=new Array(12).fill().map(()=>new gn),t=new Array(12).fill().map(()=>new gn),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,h=o.min,d=o.max,f=this.points,g=1/0;for(let m=0;m<8;m++){let v=f[m];i.copy(v).clamp(h,d);let y=v.distanceToSquared(i);if(y<g&&(g=y,l&&l.copy(v),u&&u.copy(i),y<c))return Math.sqrt(y)}let p=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){let w=(m+1)%3,b=(m+2)%3,S=v<<w|y<<b,_=1<<m|v<<w|y<<b,M=f[S],x=f[_];e[p].set(M,x);let E=r[m],C=r[w],P=r[b],O=t[p],D=O.start,N=O.end;D[E]=h[E],D[C]=v?h[C]:d[C],D[P]=y?h[P]:d[C],N[E]=d[E],N[C]=v?h[C]:d[C],N[P]=y?h[P]:d[C],p++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){i.x=m?d.x:h.x,i.y=v?d.y:h.y,i.z=y?d.z:h.z,this.closestPointToPoint(i,n);let w=i.distanceToSquared(n);if(w<g&&(g=w,l&&l.copy(n),u&&u.copy(i),w<c))return Math.sqrt(w)}for(let m=0;m<12;m++){let v=e[m];for(let y=0;y<12;y++){let w=t[y];uh(v,w,n,i);let b=n.distanceToSquared(i);if(b<g&&(g=b,l&&l.copy(n),u&&u.copy(i),b<c))return Math.sqrt(b)}}return Math.sqrt(g)}}();var Ip=new A,Lp=new A,Op=new A,g_=new B,y_=new B,v_=new B,x_=new A;function cz(r,e,t,n,i,s){let o;return s===un?o=r.intersectTriangle(n,t,e,!0,i):o=r.intersectTriangle(e,t,n,s!==er,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function uz(r,e,t,n,i,s,o){Ip.fromBufferAttribute(e,n),Lp.fromBufferAttribute(e,i),Op.fromBufferAttribute(e,s);let a=cz(r,Ip,Lp,Op,x_,o);if(a){t&&(g_.fromBufferAttribute(t,n),y_.fromBufferAttribute(t,i),v_.fromBufferAttribute(t,s),a.uv=Tn.getUV(x_,Ip,Lp,Op,g_,y_,v_,new B));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};Tn.getNormal(Ip,Lp,Op,l.normal),a.face=l,a.faceIndex=n}return a}function Iv(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=uz(t,r.attributes.position,r.attributes.uv,o,a,l,e);return u?(u.faceIndex=n,i&&i.push(u),u):null}function b_(r,e,t,n,i,s){for(let o=n,a=n+i;o<a;o++)Iv(r,e,t,o,s)}function w_(r,e,t,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Iv(r,e,t,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Lv(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 Xr(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 Ov(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(Xr(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var sc=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 _s(r,e){return e[r+15]===65535}function ha(r,e){return e[r+6]}function oc(r,e){return e[r+14]}function ac(r){return r+8}function lc(r,e){return e[r+6]}function S_(r,e){return e[r+7]}var cc=new Mt,Np=new A,dz=["x","y","z"];function Bp(r,e,t,n,i){let s=r*2,o=uc,a=co,l=uo;if(_s(s,a)){let c=ha(r,l),h=oc(s,a);b_(e,t,n,c,h,i)}else{let c=ac(r);Up(c,o,n,Np)&&Bp(c,e,t,n,i);let h=lc(r,l);Up(h,o,n,Np)&&Bp(h,e,t,n,i)}}function Fp(r,e,t,n){let i=r*2,s=uc,o=co,a=uo;if(_s(i,o)){let u=ha(r,a),c=oc(i,o);return w_(e,t,n,u,c)}else{let u=S_(r,a),c=dz[u],d=n.direction[c]>=0,f,g;d?(f=ac(r),g=lc(r,a)):(f=lc(r,a),g=ac(r));let m=Up(f,s,n,Np)?Fp(f,e,t,n):null;if(m){let w=m.point[c];if(d?w<=s[g+u]:w>=s[g+u+3])return m}let y=Up(g,s,n,Np)?Fp(g,e,t,n):null;return m&&y?m.distance<=y.distance?m:y:m||y||null}}var A_=function(){let r,e,t=[],n=new sc(()=>new Mt);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,h=0){function d(w){let b=w*2,S=co,_=uo;for(;!_s(b,S);)w=ac(w),b=w*2;return ha(w,_)}function f(w){let b=w*2,S=co,_=uo;for(;!_s(b,S);)w=lc(w,_),b=w*2;return ha(w,_)+oc(b,S)}let g=s*2,p=uc,m=co,v=uo;if(_s(g,m)){let w=ha(s,v),b=oc(g,m);return qr(s,p,r),l(w,b,!1,h,c+s,r)}else{let w=ac(s),b=lc(s,v),S=w,_=b,M,x,T,E;if(u&&(T=r,E=e,qr(S,p,T),qr(_,p,E),M=u(T),x=u(E),x<M)){S=b,_=w;let z=M;M=x,x=z,T=E}T||(T=r,qr(S,p,T));let C=_s(S*2,m),P=a(T,C,M,h+1,c+S),O;if(P===2){let z=d(S),U=f(S)-z;O=l(z,U,!0,h+1,c+S,T)}else O=P&&i(S,o,a,l,u,c,h+1);if(O)return!0;E=e,qr(_,p,E);let D=_s(_*2,m),N=a(E,D,x,h+1,c+_),F;if(N===2){let z=d(_),U=f(_)-z;F=l(z,U,!0,h+1,c+_,E)}else F=N&&i(_,o,a,l,u,c,h+1);return!!F}}}(),__=function(){let r=new gr,e=new gr,t=new be,n=new yr,i=new yr;return function s(o,a,l,u,c=null){let h=o*2,d=uc,f=co,g=uo;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),_s(h,f)){let m=a,v=m.index,y=m.attributes.position,w=l.index,b=l.attributes.position,S=ha(o,g),_=oc(h,f);if(t.copy(u).invert(),l.boundsTree)return qr(o,d,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 T=S*3,E=(_+S)*3;T<E;T+=3)if(Xr(e,T,v,y),e.needsUpdate=!0,x.intersectsTriangle(e))return!0;return!1}});for(let M=S*3,x=_+S*3;M<x;M+=3){Xr(r,M,v,y),r.a.applyMatrix4(t),r.b.applyMatrix4(t),r.c.applyMatrix4(t),r.needsUpdate=!0;for(let T=0,E=w.count;T<E;T+=3)if(Xr(e,T,w,b),e.needsUpdate=!0,r.intersectsTriangle(e))return!0}}else{let m=o+8,v=g[o+6];return qr(m,d,cc),!!(c.intersectsBox(cc)&&s(m,a,l,u,c)||(qr(v,d,cc),c.intersectsBox(cc)&&s(v,a,l,u,c)))}}}();function Up(r,e,t,n){return qr(r,e,cc),t.intersectBox(cc,n)}var Rv=[],Rp,uc,co,uo;function hc(r){Rp&&Rv.push(Rp),Rp=r,uc=new Float32Array(r),co=new Uint16Array(r),uo=new Uint32Array(r)}function hh(){Rp=null,uc=null,co=null,uo=null,Rv.length&&hc(Rv.pop())}var Nv=Symbol("skip tree generation"),Bv=new Mt,Fv=new Mt,dc=new be,da=new yr,dh=new yr,fh=new A,Gp=new A,fz=new A,pz=new A,mz=new A,T_=new Mt,Fi=new sc(()=>new gr),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,[Nv]:!0});if(o._roots=s,n.setIndex){let a=t.getIndex();if(a===null){let l=new Ge(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,[Nv]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Nv]||(this._roots=p_(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Mt))),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,h,d=0,f=this._roots;for(let p=0,m=f.length;p<m;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),h=new Float32Array(l),g(0,d),d+=l.byteLength;function g(p,m,v=!1){let y=p*2;if(c[y+15]===65535){let b=u[p+6],S=c[y+14],_=1/0,M=1/0,x=1/0,T=-1/0,E=-1/0,C=-1/0;for(let P=3*b,O=3*(b+S);P<O;P++){let D=n[P]*a+o,N=s[D+0],F=s[D+1],z=s[D+2];N<_&&(_=N),N>T&&(T=N),F<M&&(M=F),F>E&&(E=F),z<x&&(x=z),z>C&&(C=z)}return h[p+0]!==_||h[p+1]!==M||h[p+2]!==x||h[p+3]!==T||h[p+4]!==E||h[p+5]!==C?(h[p+0]=_,h[p+1]=M,h[p+2]=x,h[p+3]=T,h[p+4]=E,h[p+5]=C,!0):!1}else{let b=p+8,S=u[p+6],_=b+m,M=S+m,x=v,T=!1,E=!1;e?x||(T=e.has(_),E=e.has(M),x=!T&&!E):(T=!0,E=!0);let C=x||T,P=x||E,O=!1;C&&(O=g(b,m,x));let D=!1;P&&(D=g(S,m,x));let N=O||D;if(N)for(let F=0;F<3;F++){let z=b+F,Y=S+F,U=h[z],G=h[z+3],Q=h[Y],V=h[Y+3];h[p+F]=U<Q?U:Q,h[p+F+3]=G>V?G:V}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 h=i[a+6],d=s[u+14];e(l,c,new Float32Array(n,a*4,6),h,d)}else{let h=a+32/4,d=i[a+6],f=i[a+7];e(l,c,new Float32Array(n,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(e,t=Gr){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,h=n.length;c<h;c++){let d=a?t[l[c].materialIndex].side:u,f=s.length;if(hc(n[c]),Bp(0,i,d,e,s),hh(),a){let g=l[c].materialIndex;for(let p=f,m=s.length;p<m;p++)s[p].face.materialIndex=g}}return s}raycastFirst(e,t=Gr){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,h=n.length;c<h;c++){let d=o?t[l[c].materialIndex].side:u;hc(n[c]);let f=Fp(0,i,d,e);hh(),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(hc(s),i=__(0,n,e,t),hh(),i)break;return i}shapecast(e,t,n){let i=this.geometry;if(e instanceof Function){if(t){let d=t;t=(f,g,p,m)=>{let v=g*3;return d(f,v,v+1,v+2,p,m)}}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=Fi.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=e;if(l&&u){let d=l;l=(f,g,p,m,v)=>d(f,g,p,m,v)?!0:Ov(f,g,i,u,p,m,s)}else l||(u?l=(d,f,g,p)=>Ov(d,f,i,u,g,p,s):l=(d,f,g)=>g);let c=!1,h=0;for(let d of this._roots){if(hc(d),c=A_(0,i,a,l,o,h),hh(),c)break;h+=d.byteLength}return Fi.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;dc.copy(t).invert();let c=Fi.getPrimitive(),h=Fi.getPrimitive();if(s){let f=function(g,p,m,v,y,w,b,S){for(let _=m,M=m+v;_<M;_++){Xr(h,_*3,l,u),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let x=g,T=g+p;x<T;x++)if(Xr(c,x*3,o,a),c.needsUpdate=!0,s(c,h,x,_,y,w,b,S))return!0}return!1};if(i){let g=i;i=function(p,m,v,y,w,b,S,_){return g(p,m,v,y,w,b,S,_)?!0:f(p,m,v,y,w,b,S,_)}}else i=f}e.getBoundingBox(Fv),Fv.applyMatrix4(t);let d=this.shapecast({intersectsBounds:f=>Fv.intersectsBox(f),intersectsRange:(f,g,p,m,v,y)=>(Bv.copy(y),Bv.applyMatrix4(dc),e.shapecast({intersectsBounds:w=>Bv.intersectsBox(w),intersectsRange:(w,b,S,_,M)=>i(f,g,w,b,m,v,_,M)}))});return Fi.releasePrimitive(c),Fi.releasePrimitive(h),d}intersectsBox(e,t){return da.set(e.min,e.max,t),da.needsUpdate=!0,this.shapecast({intersectsBounds:n=>da.intersectsBox(n),intersectsTriangle:n=>da.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(),da.set(e.boundingBox.min,e.boundingBox.max,t),da.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=e.attributes.position,h=e.index,d=Fi.getPrimitive(),f=Fi.getPrimitive(),g=Gp,p=fz,m=null,v=null;i&&(m=pz,v=mz);let y=1/0,w=null,b=null;return dc.copy(t).invert(),dh.matrix.copy(dc),this.shapecast({boundsTraverseOrder:S=>da.distanceToBox(S),intersectsBounds:(S,_,M)=>M<y&&M<o?(_&&(dh.min.copy(S.min),dh.max.copy(S.max),dh.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>dh.distanceToBox(M),intersectsBounds:(M,x,T)=>T<y&&T<o,intersectsRange:(M,x)=>{for(let T=M*3,E=(M+x)*3;T<E;T+=3){Xr(f,T,h,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){Xr(d,C,u,l),d.needsUpdate=!0;let O=d.distanceToTriangle(f,g,m);if(O<y&&(p.copy(g),v&&v.copy(m),y=O,w=C/3,b=T/3),O<s)return!0}}}});{let M=h?h.count:c.count;for(let x=0,T=M;x<T;x+=3){Xr(f,x,h,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){Xr(d,E,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,g,m);if(P<y&&(p.copy(g),v&&v.copy(m),y=P,w=E/3,b=x/3),P<s)return!0}}}}}),Fi.releasePrimitive(d),Fi.releasePrimitive(f),y===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=y,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(dc),p.applyMatrix4(dc),i.distance=p.sub(i.point).length(),i.faceIndex=b),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=>(fh.copy(e).clamp(c.min,c.max),fh.distanceToSquared(e)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(e,fh);let d=e.distanceToSquared(fh);return d<a&&(Gp.copy(fh),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return t.point?t.point.copy(Gp):t.point=Gp.clone(),t.distance=u,t.faceIndex=l,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{qr(0,new Float32Array(n),T_),e.union(T_)}),e}},M_=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 M_.call(this,n,e.material).forEach(o=>{o=Lv(o,e,t),o&&i.push(o)}),i}else return M_.apply(this,r)};var E_=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 Lv(E_.call(this,n,e.material),e,t)}else return E_.apply(this,r)};var C_=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,C_.apply(this,r),e&&e.copy(t.point),t.distance}else return C_.apply(this,r)};var P_=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,P_.apply(this,r),e&&e.copy(n.point),t&&t.copy(i.point).applyMatrix4(s),n.distance}else return P_.apply(this,r)};var D_=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)),D_.call(this,n)}else D_.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 Uv=class extends ht{},zp=class extends Uv{constructor(t){super();this.object=t;this.matrixAutoUpdate=!0}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return!0}get isLight(){return!1}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){return this.object.geometry}get material(){return this.object.material}};var ph=class extends ht{constructor(t,n={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=dp.defaultData(i.toArray(),s),$o(this.parameters,n),this.update(),this.setHideBase(this.parameters.hideBase)}setHideBase(t){this.parameters.hideBase=t}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let n=0,i=t-this.children.length;n<i;++n){let s=new zp(this.object);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let n=0,i=this.children.length-t;n<i;++n)this.remove(this.children[0])}_updateRadial(t){let n=t.radial,i=n.start*Be.DEG2RAD,s=n.end*Be.DEG2RAD,o=i-s,a=new Qt(n.rotation[0]*Be.DEG2RAD,n.rotation[1]*Be.DEG2RAD,n.rotation[2]*Be.DEG2RAD),l;switch(n.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[u,c]of this.children.entries()){c.scale.x=n.scale[0],c.scale.y=n.scale[1],c.scale.z=n.scale[2],c.position.setScalar(0);let h=o/t.count*u-i;switch(n.axis){case"x":c.rotation.set(0,h,0);break;case"y":c.rotation.set(0,0,h);break;case"z":c.rotation.set(h,0,0);break}c.translateOnAxis(l,n.radius),c.position.x+=n.position[0],c.position.y+=n.position[1],c.position.z+=n.position[2],n.alignment===!0?(c.rotation.x+=a.x,c.rotation.y+=a.y,c.rotation.z+=a.z):c.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let n=t.linear,i=new Qt(n.rotation[0]*Be.DEG2RAD,n.rotation[1]*Be.DEG2RAD,n.rotation[2]*Be.DEG2RAD);for(let[s,o]of this.children.entries())o.scale.x=1+(n.scale[0]-1)*s,o.scale.y=1+(n.scale[1]-1)*s,o.scale.z=1+(n.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=n.position[0]*s,o.position.y=n.position[1]*s,o.position.z=n.position[2]*s}_updateGrid(t){let n=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let u=0;u<i.count[2];u++){let c=this.children[n++];c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=i.size[0]*a-o.x,c.position.y=i.size[1]*l-o.y,c.position.z=i.size[2]*u-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[n++];l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),$o(this.parameters,t),this.update(),this}};var Ui=r=>{var e;return e=class extends r{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new ur(30,30,30),e};var kp=new ai,Gv=new Mn,I_=new be,Gi=(r,e,t,n,i=!1)=>{let s=e,o=r.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Gv.copy(s.boundingSphere),Gv.applyMatrix4(o),t.ray.intersectsSphere(Gv)===!1||(I_.copy(o).invert(),kp.copy(t.ray).applyMatrix4(I_),s.boundingBox!==null&&kp.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,d=s.attributes.position,f=s.drawRange,g,p;if(i===!1){let v=Math.max(0,f.start),y=Math.min(h.count,f.start+f.count);for(g=v,p=y;g<p;g+=3)if(l=h.getX(g),u=h.getX(g+1),c=h.getX(g+2),a=m(r,t,kp,d,l,u,c),a){a.faceIndex=Math.floor(g/3),n.push(a);return}}else{let y=s.attributes.position,w=new A,b=new A,S=new A,_=new A,M=2,T=1/((r.scale.x+r.scale.y+r.scale.z)/3),E=T*T,C=Math.max(0,f.start),P=Math.min(y.count,f.start+f.count);for(let O=C,D=P-1;O<D;O+=M){if(w.fromBufferAttribute(y,O),b.fromBufferAttribute(y,O+1),kp.distanceSqToSegment(w,b,_,S)>E)continue;_.applyMatrix4(r.matrixWorld);let F=t.ray.origin.distanceTo(_);F<t.near||F>t.far||n.push({distance:F,point:S.clone().applyMatrix4(r.matrixWorld),object:r})}}function m(v,y,w,b,S,_,M){let x=new A,T=new A,E=new A,C=new A,P=new A;if(x.fromBufferAttribute(b,S),T.fromBufferAttribute(b,_),E.fromBufferAttribute(b,M),w.intersectTriangle(x,T,E,!1,C)===null)return null;P.copy(C),P.applyMatrix4(v.matrixWorld);let D=y.ray.origin.distanceTo(P);return D<y.near||D>y.far?null:{faceIndex:1,distance:D,point:P.clone(),object:v}}};var Vp=new A,Yr=new li,zv=class extends Ws{constructor(t){let n=new De,i=new zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Le(15711266),u=new Le(15711266),c=new Le(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);function h(f,g,p){d(f,p),d(g,p)}function d(f,g){s.push(0,0,0),o.push(g.r,g.g,g.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}n.setAttribute("position",new Ae(s,3)),n.setAttribute("color",new Ae(o,3));super(n,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,n=this.pointMap,i=!0;Yr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;fi("n1",n,t,Yr,-s,-o,a),fi("n2",n,t,Yr,s,-o,a),fi("n3",n,t,Yr,-s,o,a),fi("n4",n,t,Yr,s,o,a);let l=a;fi("f1",n,t,Yr,-s,-o,l),fi("f2",n,t,Yr,s,-o,l),fi("f3",n,t,Yr,-s,o,l),fi("f4",n,t,Yr,s,o,l);let u=l,c=.5;fi("u1",n,t,Yr,s*.7*c,o*1.1,u),fi("u2",n,t,Yr,-s*.7*c,o*1.1,u),fi("u3",n,t,Yr,0,o*(1.1+.9*c),u),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function fi(r,e,t,n,i,s,o){Vp.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],Vp.x,Vp.y,Vp.z)}}var Hp=class extends Ui(zv){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,n){Gi(this.object,this.geometry,t,n,!0)}};var fc=class extends Ui(hf){constructor(t,n=15,i=10066329){super(t,n,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,n){Gi(this.object,fc.geometryHelper,t,n)}};var pc=class extends Ui(df){constructor(t,n=15){super(n);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,n){Gi(this.object,pc.geometryHelper,t,n)}update(){}};var mc=class extends Ui(uf){constructor(t,n=15,i=6710886){super(t,n,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,n){Gi(this.object,mc.geometryHelper,t,n)}};var Wp=class extends Ui(cf){constructor(t,n=6710886){super(t,n);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,n){Gi(this.object,Wp.geometryHelper,t,n)}update(){if(this.object!==void 0){let t=Wp._vector,n=this.object.distance?this.object.distance:1e3,i=n*Math.tan(this.object.angle);this.cone.scale.set(i,i,n),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},mh=Wp;mh._vector=new A;var gh=1e-12,gc=class{constructor(e){this.position=new B;this.startPosition=new B;this.uuid=Be.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 gc(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},yc=class extends gc{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new yc(this.parent).copy(this)}},pi=class extends gc{constructor(t,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new yc(this),new yc(this))}static create(t,n){let i=new pi(t,new B(...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 pi(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 B,n=new B){let[i,s]=this.computeTangents();return i&&s&&(L_(i,t),L_(s,n)),[t,n]}computeTangent(t=new B){let[n,i]=this.computeTangents();return n&&i&&t.copy(n).add(i).normalize(),t}computeNormal(t=new B){let[n,i]=this.computeNormals();return t.copy(n).add(i).normalize(),t}};function L_(r,e=new B){let t=r.length();return e.set(-r.y/t,r.x/t)}var Vv=r=>r,vc=new B,jp=new B,yz=new B,vz=new B,xz=new B,bz=new B,R_=new A,N_=new A;function B_(r){let e=new B;e.addVectors(r.v0,vc.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new B;return t.addVectors(r.v2,jp.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new Wn(r.v0,e,t,r.v2)}function yh(r,e,t=Number.EPSILON){return Math.abs(r-e)<t}function wz(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function Sz(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function Hv(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 F_(r,e,t){return O_(r,e)&&O_(e,t)&&kv(r.position,e.position,t.position)}function kv(r,e,t){return vc.copy(e).sub(r).cross(jp.copy(t).sub(r))===0}function U_(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 G_(r,e,t){let n=r.distanceTo(t),i=e.distanceTo(t);return n<i?e:r}function z_(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)),h;return Hv(e,r,t)>Math.PI&&(c*=-1),yh(u,a)?h=(a+u)*(n/c-.5)*8/3/(o-l):h=(o+l)*(n/c-.5)*8/3/(u-a),i.set(e.x-h*a,e.y+h*o),s.set(t.x+h*u,t.y-h*l),[i,s]}function Wv(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function O_(r,e){return kv(r.position,r.controls[1].position,e.position)&&kv(r.position,e.controls[0].position,e.position)}function k_(r,e,t,n,i=.5){let s=vc.subVectors(e,r).multiplyScalar(i).add(r),o=jp.subVectors(t,e).multiplyScalar(i).add(e),a=yz.subVectors(n,t).multiplyScalar(i).add(t),l=s,u=vz.subVectors(o,s).multiplyScalar(i).add(s),c=xz.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=bz.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,n.x,n.y]}function V_(r,e,t=12,n=!0){let i=N_.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let u=Vv(e[l]),c=vc,h=ho(u,t);a.push(h);for(let d=0;d<=h;d++)if(u instanceof Wn||u instanceof Cr||u instanceof jn){if(u.getPoint(d/h,c),i.set(c.x,c.y,0),s!==void 0&&Sz(s,i))continue;s===void 0&&(s=R_),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 H_(r,e,t,n=12,i=!0){let s=N_.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let u,c=Vv(e[l]),h=vc,d=ho(c,n);a.push(d);for(let f=0;f<=d;f++)if(c instanceof Wn||c instanceof Cr||c instanceof jn){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=R_:(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 jv(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=ho(o.roundedCurveCorner,e)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=ho(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=ho(r[0].roundedCurveCorner,e)*.5),n}function ho(r,e=12){return r&&r instanceof Vo?e*2:r&&(r instanceof jn||r instanceof Cu)?1:r&&r instanceof Ja?e*r.points.length:e}function W_(r,e,t=12,n=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=Vv(e[o]),l=ho(a,t),u=vc;for(let c=0;c<=l;c++)if(a instanceof Wn||a instanceof Cr||a instanceof jn){if(a.getPoint(c/l,u),i!==void 0&&wz(i,u,gh))continue;i===void 0&&(i=jp),i.copy(u),r.push(u.x,u.y),s++}}return yh(r[0],r[r.length-2],gh)&&yh(r[1],r[r.length-1],gh)&&(r.pop(),r.pop()),n&&s>1&&!(yh(r[s-1],r[1],gh)&&yh(r[s-2],r[0],gh))&&(r.push(r[0],r[1]),s++),r}var qv=new B,Az=new B,_z=new B,Tz=new B,Mz=new B,Ez=new B,gt=class extends ms{constructor(t=100,n=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Lt;this.plane=new mn(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=Be.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=n}static createFromState(t,n,i){let s=new gt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>pi.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>gt.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=qv.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(!1)}createPoint(t,n=0,i=Be.generateUUID()){let s;t instanceof B?s=t:s=new B(t,n);let o=new pi(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(t=!0){for(let n=0,i=this.shapeHoles.length;n<i;n++)this.shapeHoles[n].update(!1);this._update(t)}extractShapePointsToBuffer(t,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return V_(t,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=jv(this.points,t,!1),this.roundedCurveDivisions=jv(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,n,i=12){return H_(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),W_(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=ho(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(Wv(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(qv.set(i.x,i.y))/h}let u=0;for(let h=0;h<t;h++)u+=a[h];return(n-u)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,n){Wv(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(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let n=this.getLastPoint();if(n?.curveAfter&&(n.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],u=this.points[s+1]??this.points[0],c=a.roundness,h=l&&u&&F_(l,a,u);if(!a.controlsMoved()&&c>0&&!h){let d=a.curveBefore,f=a.curveAfter;if(d===void 0||f===void 0)continue;let g=a.roundedCurveBefore,p=a.roundedCurveAfter,m=d.getLength(),v=f.getLength(),y=Math.min(c,m*.499),w=Math.min(c,v*.499),b=Math.min(y,w),S=1-b/m,_=b/v,M=d.getPointAt(S,qv),x=f.getPointAt(_,Az);this._subSplitCurve(d,g,S,M,void 0),this._subSplitCurve(f,p,_,void 0,x);let T;if(this.useCubicForRoundedCorners){let E=Hv(M,a.position,x)/2,C=Math.tan(E)*M.distanceTo(a.position),[P,O]=U_(M,x,C,_z,Tz),D=G_(P,O,a.position),[N,F]=z_(D,M,x,C,Mz,Ez);T=new Wn(M.clone(),N.clone(),F.clone(),x.clone())}else T=new Cr(M.clone(),a.position.clone(),x.clone());a.roundedCurveCorner=T,this.roundedCurves.splice(s+i,0,T),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,n,i,s,o){if(t instanceof jn)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=k_(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 gt(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],h=t.points[s+5],d=t.points[s+6],f=new pi(Be.generateUUID(),new B(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new gt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let n=(s,o)=>{o instanceof Wn&&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 Cr&&(s[a]=B_(s[a]));for(a=0,l=s.length;a<l;a++){let h=s[a],d=a>0?s[a-1]:null,f;h instanceof Wn?(f=this.createPoint(h.v0),f.controls[1].position.copy(h.v1)):h instanceof jn&&(f=this.createPoint(h.v1)),f!==void 0&&(d!==null&&n(f,d),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof Wn?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof jn&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(t.curves),t instanceof ms&&(this.shapeHoles=t.holes.map(s=>{let o=new gt;return o.fromShape(s),o})),this.update(),this}};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 xn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(xn||(xn={}));function We(r,e){if(!r)throw e||"Assertion Failed!"}var ze=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}(),vh=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}(),qp=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}(),xc=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}(),j_=function(){function r(){var e=new xc,t=new vh,n=new qp(0),i=new qp(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 qp(0),n=new qp(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 xc,t=new xc,n=new vh,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 xc;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!n){var o=new vh;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 vh;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 xc;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 vh;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&&ze.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&ze.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}(),q_=function(){function r(){this.handle=null}return r}(),X_=function(){function r(){this.key=null,this.node=0}return r}(),Cz=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 q_,this.handles[n]=new X_;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 q_;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new X_}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}(),Xv=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}(),Y_=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),Pz=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new Y_,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 Y_;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}(),Dz=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?ze.vertLeq(s.Org,o.Org)?ze.edgeSign(o.Dst,s.Org,o.Org)<=0:ze.edgeSign(s.Dst,o.Org,s.Org)>=0:ze.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ze.edgeSign(s.Dst,i,s.Org)>=0;var a=ze.edgeEval(s.Dst,i,s.Org),l=ze.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 Xv;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,h=!0;u=n;do We(ze.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,!h&&r.checkForRightSplice(e,l)&&(r.addWinding(u,c),r.deleteRegion(e,l),e.mesh.delete(c)),h=!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=ze.vertL1dist(t,e),s=ze.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(ze.vertLeq(i.Org,s.Org)){if(ze.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ze.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(ze.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(!ze.vertEq(i.Dst,s.Dst)),ze.vertLeq(i.Dst,s.Dst)){if(ze.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(ze.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,h,d=new xc,f,g;if(We(!ze.vertEq(u,l)),We(ze.edgeSign(l,e.event,o)<=0),We(ze.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),h=Math.max(a.t,u.t),c>h))return!1;if(ze.vertLeq(o,a)){if(ze.edgeSign(u,o,a)>0)return!1}else if(ze.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),ze.intersect(l,o,u,a,d),We(Math.min(o.t,l.t)<=d.t),We(d.t<=Math.max(a.t,u.t)),We(Math.min(u.s,l.s)<=d.s),We(d.s<=Math.max(a.s,o.s)),ze.vertLeq(d,e.event)&&(d.s=e.event.s,d.t=e.event.t),f=ze.vertLeq(o,a)?o:a,ze.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ze.vertEq(d,o)||ze.vertEq(d,a)?(r.checkForRightSplice(e,t),!1):!ze.vertEq(l,e.event)&&ze.edgeSign(l,e.event,d)>=0||!ze.vertEq(u,e.event)&&ze.edgeSign(u,e.event,d)<=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),g=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,g,!0),!0):(ze.edgeSign(l,e.event,d)>=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),ze.edgeSign(u,e.event,d)<=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=d.s,i.Org.t=d.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),ze.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),ze.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}ze.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,ze.vertEq(i.Org,n)){We(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!ze.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),ze.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 Xv;if(u.eUp=t.anEdge.Sym,n=e.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,ze.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=ze.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 Xv,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 Pz(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,ze.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 Cz(s,ze.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||!ze.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}(),Iz=function(){function r(){this.mesh=new j_,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],h=[0,0,0],d=[0,0,0],f=[null,null,null],g=[null,null,null],p=this.mesh.vHead;t=p.next;for(var m=0;m<3;++m)s=t.coords[m],u[m]=s,g[m]=t,l[m]=s,f[m]=t;for(t=p.next;t!==p;t=t.next)for(var v=0;v<3;++v)s=t.coords[v],s<u[v]&&(u[v]=s,g[v]=t),s>l[v]&&(l[v]=s,f[v]=t);var y=0;if(l[1]-u[1]>l[0]-u[0]&&(y=1),l[2]-u[2]>l[y]-u[y]&&(y=2),u[y]>=l[y]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=g[y],i=f[y],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)h[0]=t.coords[0]-i.coords[0],h[1]=t.coords[1]-i.coords[1],h[2]=t.coords[2]-i.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,e[0]=d[0],e[1]=d[1],e[2]=d[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(;ze.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;ze.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(ze.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(ze.edgeGoesLeft(i.Lnext)||ze.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&&(ze.edgeGoesRight(n.Lprev)||ze.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===xn.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 h=u.n*i;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],i>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=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[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[d++]=-1;if(t===xn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var g=l;g<n;++g)this.elements[d++]=-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 j_),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=xn.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_(),Dz.computeInterior(this,o);var a=this.mesh;return t===xn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===xn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function fa(r){var e=r.windingRule,t=e===void 0?It.ODD:e,n=r.elementType,i=n===void 0?xn.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,h=r.contours,d=h===void 0?[]:h,f=r.strict,g=f===void 0?!0:f,p=r.debug,m=p===void 0?!1:p;if(!d&&g)throw new Error("Contours can't be empty");if(!!d){var v=new Iz;r.edgeCreateCallback&&(v.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(v.vertexIdCallback=r.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(t,i,o,l,c,g),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}var Iee=It.ODD,Lee=It.NONZERO,Oee=It.POSITIVE,Ree=It.NEGATIVE,Nee=It.ABS_GEQ_TWO,Bee=xn.POLYGONS,Fee=xn.CONNECTED_POLYGONS,Uee=xn.BOUNDARY_CONTOURS;var bc=class extends De{constructor(t,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=It.ODD;this.elementType=xn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:It.ODD,elementType:xn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(g=>g.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let g=0,p=s.length/2;g<p;g++){let m=g*2,v=s[m+0],y=s[m+1];if(c!==void 0&&v!==c&&(l=!1),h!==void 0&&y!==h&&(u=!1),c=v,h=y,!l&&!u)break}!l&&!u&&(a=fa({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let g=1/0,p=-1/0,m=1/0,v=-1/0;for(let b=0,S=d;b<S;b++){let _=b*2,M=a.vertices[_+0],x=a.vertices[_+1];M<g&&(g=M),M>p&&(p=M),x<m&&(m=x),x>v&&(v=x)}let y=p-g,w=v-m;for(let b=0,S=d;b<S;b++){let _=b*2,M=a.vertices[_+0],x=a.vertices[_+1],T=(M-g)/y,E=(x-m)/w;this._positionAttribute.setXYZ(b,M,x,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,E)}for(let b=0,S=f;b<S;b++){let _=b*3,M=a.elements[_+0],x=a.elements[_+1],T=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,x),this._indexAttribute.setX(_+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new bc(this._shape,this._curveSegments);return t.userData=ju(this.userData),t}};var Xp=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*Xp.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*Xp.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)}},xh=Xp;xh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Yv=(r,e)=>([t,n])=>(n<t&&(n+=e),(r>=t?r:r+e)<=n),wc=class extends De{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 T=x.extractShapePointsToFlatArray([],s),E=[];for(let C=T.length-1;C>=1;C-=2){let P=T[C-1],O=T[C-0];E.push(P,O)}return E}),c=fa({windingRule:a,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),h=fa({windingRule:It.ODD,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]});if(!c)throw new Error("error generating geometry");let d=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let x=0;x<h.elements.length;x++){let T=h.elements[x],E=x%2===0?c.vertexCount:0;c.elements.push(T+E)}for(let x=0;x<h.vertexIndices.length;x++){let T=h.vertexIndices[x],E=c.vertexCount;c.vertexIndices.push(T+E)}for(let x=0;x<h.vertices.length;x++){let T=h.vertices[x];c.vertices.push(T)}}let f=1/0,g=-1/0,p=1/0,m=-1/0;for(let x=0,T=c.vertexCount;x<T;x++){let E=x*2,C=c.vertices[E+0],P=c.vertices[E+1];C<f&&(f=C),C>g&&(g=C),P<p&&(p=P),P>m&&(m=P)}this._minX=f,this._minY=p,this._width=g-f,this._height=m-p;let v=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new xh(v);let y=[],w=[];for(let x=c.elementCount-1;x>=0;x--){let T=x>=d,E=x*2,C=c.elements[E+0],P=c.elements[E+1],O=C+P,D={start:C,count:P,normals:[],continuous:[],concave:[]},N=C,F=O-1,z=C+1,Y=this._shape.roundedCurves.length;do{let V=N-C,k=c.vertices[F*2+0],j=c.vertices[F*2+1],q=c.vertices[N*2+0],W=c.vertices[N*2+1],he=c.vertices[z*2+0],ie=c.vertices[z*2+1],K=q-k,X=W-j,ne=Math.sqrt(K*K+X*X);K/=ne,X/=ne;let ce=q-he,oe=W-ie,Te=Math.sqrt(ce*ce+oe*oe);ce/=Te,oe/=Te,D.normals[V*2+0]=-oe,D.normals[V*2+1]=ce,D.concave[V]=K*oe-X*ce>0;let me=c.vertexIndices[N];if(Array.isArray(me))D.continuous[V]=!1;else{let[ge,ye]=this._shape.getCurveIndexFromVertexId(me-1,!0);if(ye>0&&ye<1)D.continuous[V]=!0;else{let de=ye===1?ge+1:ge-1;de=(de+Y)%Y;let Pe=ye===1?0:1,Ne=this._shape.roundedCurves[ge].getTangent(ye),Ze=this._shape.roundedCurves[de].getTangent(Pe);D.continuous[V]=Ne.dot(Ze)>.95}}T&&(D.normals[V*2+0]*=-1,D.normals[V*2+1]*=-1),[F,N,z]=[N,z,z+1],z>=O&&(z-=P)}while(z!==C+1);let U=[];U.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((V,k)=>[k,k]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(C*2,O*2)});for(let V=1;V<=this._bevelSegments;V++){let k=V/this._bevelSegments*Math.PI/2,j=(1-Math.cos(k))*this._bevelSize,q=[],W=[],he=[],ie=[],K=0;for(let ne=0;ne<P;ne++){let ce=ne*2,oe=(ne-1+P)%P*2,Te=c.vertices[D.start*2+ce+0],me=c.vertices[D.start*2+ce+1],ge=-D.normals[oe+0]*j,ye=-D.normals[oe+1]*j,de=-D.normals[ce+0]*j,Pe=-D.normals[ce+1]*j;if(D.concave[ne]||!D.concave[ne]&&T){let Ne=Math.atan2(ye,ge),Ze=Math.atan2(Pe,de);Ze>Ne&&(Ze-=Math.PI*2);let R=Ze-Ne;if(D.continuous[ne]||T){let I=Ne+R/2,J=Math.cos(I)*j,le=Math.sin(I)*j;q[2*K+0]=Te+J*(T?-1:1),q[2*K+1]=me+le*(T?-1:1),ie[K]=ne,K++}else{let I=Math.max(1,Math.floor(s/4*Math.abs(R)/Math.PI));for(let J=0;J<=I;J++){let le=Ne+R*(J/I),fe=Math.cos(le)*j,Ee=Math.sin(le)*j;q[2*K+0]=Te+fe,q[2*K+1]=me+Ee,ie[K]=ne,K++}}}else q[2*K+0]=Te+ge,q[2*K+1]=me+ye,ie[K]=ne,W[ne]=K,K++,q[2*K+0]=Te,q[2*K+1]=me,ie[K]=ne,K++,q[2*K+0]=Te+de,q[2*K+1]=me+Pe,ie[K]=ne,he[ne]=K,K++}let X=fa({windingRule:It.POSITIVE,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[q],edgeCreateCallback:ne=>{let oe=ne.Org.idx,Te=ie[oe],me=ie[(oe+1)%ie.length];ne.idx=[Te,me],ne.Sym.idx=[me,Te]},vertexIdCallback:ne=>{let ce=ne.Lprev.idx;return[ce?ce[1]:0,ne.idx[0]]}});if(!X)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!X.vertexCount)break;for(let ne=0;ne<X.vertexIndices.length;ne++){let[ce,oe]=X.vertexIndices[ne];if(ce===oe)continue;let Te=oe;oe<ce&&(Te+=P);for(let me=ce;me<Te;me++){let ge=me%P,ye=(me+1)%P;if(!D.continuous[ge]||!D.continuous[ye]){X.vertexIndices[ne]=[ce,ge],X.vertexIndices.splice(ne+1,0,[ye,oe]),X.vertices.splice((ne+1)*2,0,X.vertices[ne*2],X.vertices[ne*2+1]);break}}}U.push({bevelI:V,angle:k,size:j,boundary:X,reverseMap:ie,insetPoints:q})}let G=(V,k,j)=>{let q=0,W=V.boundary.vertexIndices.length;for(;q<W&&j(V.boundary.vertexIndices[k]);)k=(k+1)%W,q++;return q},Q=y.length;for(let V=1;V<U.length;V++){let k=U[V-1],j=U[V],q=k.boundary.vertexIndices.length,W=j.boundary.vertexIndices.length;if(!q||!W)break;let he=D.concave.length,ie=0,K=Yv(ie,P);for(;!k.boundary.vertexIndices.filter(K).length||!j.boundary.vertexIndices.filter(K).length;)ie++,K=Yv(ie,P);let X=k.boundary.vertexIndices.findIndex(K),ne=j.boundary.vertexIndices.findIndex(K);do X=(X+1)%q;while(K(k.boundary.vertexIndices[X]));do ne=(ne+1)%W;while(K(j.boundary.vertexIndices[ne]));ie=(ie+1)%P;let ce=ie,oe=this.buildBevelVert(D,k,(X-1+q)%q),Te=this.buildBevelVert(D,j,(ne-1+W)%W),me=oe,ge=Te,ye,de,Pe=!1;do{K=Yv(ie,P);let Ne=G(k,X,K),Ze=G(j,ne,K),R=Pe;if(Pe=!1,Ne&&!Ze){for(let I=0;I<Ne;I++)ye=this.buildBevelVert(D,k,(X+I)%q,I/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye;Pe=!0}else if(!Ne&&Ze)for(let I=0;I<Ze;I++)de=this.buildBevelVert(D,j,(ne+I)%W,I/(Ze-1)),y.push(ge.topN,me.topP,de.topP),y.push(me.bottomP,ge.bottomN,de.bottomP),ge=de;else if(Ne&&Ze)if(ye=this.buildBevelVert(D,k,X,0),de=this.buildBevelVert(D,j,ne,0),R?(y.push(me.topN,de.topP,ge.topN),y.push(me.topN,ye.topP,de.topP),y.push(de.bottomP,me.bottomN,ge.bottomN),y.push(de.bottomP,ye.bottomP,me.bottomN)):(y.push(ge.topN,me.topN,ye.topP),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,me.bottomN,ge.bottomN),y.push(ye.bottomP,ge.bottomN,de.bottomP)),me=ye,ge=de,Ne===Ze)for(let I=1;I<Ne;I++)ye=this.buildBevelVert(D,k,(X+I)%q,I/(Ne-1)),de=this.buildBevelVert(D,j,(ne+I)%W,I/(Ze-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,me.bottomN,ge.bottomN),y.push(ye.bottomP,ge.bottomN,de.bottomP),me=ye,ge=de;else if(Ne>Ze){let I=Ne/Ze,J=0;for(let le=1;le<Ne;le++)ye=this.buildBevelVert(D,k,(X+le)%q,le/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye,le>(J+1)*I&&(J++,de=this.buildBevelVert(D,j,(ne+J)%W,J/(Ze-1)),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,de.bottomP),ge=de)}else{let I=Ze/Ne,J=0;for(let le=1;le<Ze;le++)de=this.buildBevelVert(D,j,(ne+le)%W,le/(Ze-1)),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,de.bottomP),ge=de,le>(J+1)*I&&(J++,ye=this.buildBevelVert(D,k,(X+J)%q,J/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye)}X=(X+Ne)%q,ne=(ne+Ze)%W,ie=(ie+1)%he}while(ie!==ce)}{let V=U[0];for(let k=0,j=V.boundary.vertexCount;k<j;k++){let q=this.buildBevelVert(D,V,k),W=this.buildBevelVert(D,V,(k+1)%j);y.push(W.topP,q.topN,q.bottomN),y.push(W.topP,q.bottomN,W.bottomP)}}if(T){let V=[];for(let k=y.length-1;k>=Q+2;k-=3){let j=y[k-2],q=y[k-1],W=y[k-0];V.push(W,q,j)}y.splice(Q,y.length-Q,...V)}if(T){let V=[];for(let k=U[U.length-1].boundary.vertices.length-1;k>=1;k-=2){let j=U[U.length-1].boundary.vertices[k-1],q=U[U.length-1].boundary.vertices[k-0];V.push(j,q)}w.push(V)}if(!T){let V=U[U.length-1],k=fa({windingRule:U.length>1?It.POSITIVE:It.ODD,elementType:xn.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...w]});if(!k)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let j=0;j<k.elementCount*3;j+=3){let q=this.buildSurfaceVert(k,k.elements[j+0]),W=this.buildSurfaceVert(k,k.elements[j+1]),he=this.buildSurfaceVert(k,k.elements[j+2]);y.push(q.top,W.top,he.top),y.push(he.bottom,W.bottom,q.bottom)}}this.vertexCache={}}this._buffer.shrink();let b=new Ge(Uint32Array.from(y),1),S=new Ge(this._buffer.positions,3),_=new Ge(this._buffer.normals,3),M=new Ge(this._buffer.uvs,2);S.needsUpdate=!0,_.needsUpdate=!0,M.needsUpdate=!0,b.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",_),this.setAttribute("uv",M),this.setIndex(b)}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,h=u*2,d={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[h+0]=a,this._buffer.uvs[h+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[h+2]=a,this._buffer.uvs[h+3]=l,this.vertexCache[i]=d,d}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,h,d;a!==l?(c=a,u=l,d=!1,h=t.continuous[c]&&t.continuous[u]):(u=a,c=(u-1+t.count)%t.count,d=t.concave[u]&&n.bevelI>0,h=t.continuous[u]||d);let f=Math.cos(n.angle),g=Math.sin(n.angle),p=i*2,m=u*2,v=c*2,y=n.boundary.vertices[p+0],w=n.boundary.vertices[p+1],b=(1-g)*this._bevelSize,S=(y-this._minX)/this._width,_=(w-this._minY)/this._height,M=t.normals[m+0],x=t.normals[m+1],T=t.normals[v+0],E=t.normals[v+1];if(d){let N=T-M,F=E-x;M=M+N*(1-s),x=x+F*(1-s);let z=Math.sqrt(M*M+x*x);M/=z,x/=z}let C=this._buffer.get(h?2:4),P=C*3,O=C*2,D={i,fi:u,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=w,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=M*f,this._buffer.normals[P+1]=x*f,this._buffer.normals[P+2]=g,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=w,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=M*f,this._buffer.normals[P+4]=x*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S,h||(C+=2,P+=6,O+=4,D.topP=C+0,D.bottomP=C+1,this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=w,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=T*f,this._buffer.normals[P+1]=E*f,this._buffer.normals[P+2]=g,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=w,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=E*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S),this.vertexCache[o]=D,D}clone(){let t=new wc(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=ju(this.userData),t}};var Fn=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 gt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new gt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update(!1));let l=o??new gt(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 bc(r.shape,i,{windingRule:o}):a=new wc(r.shape,e,t,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var Z_=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:h,cornerSegments:d,hollow:f}=r.parameters,g;return h||f?g=new bh(u,c,n,i,s,o,a,l*Math.PI/180,h,h,d,f):g=new Wo(u,c,n,i,s,o,a,l*Math.PI/180),g.scale(1,1,t/e),Object.assign(g,{userData:{...r,type:"CylinderGeometry"}})}};function fo(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function Q_(r){return new B(r.y,-r.x)}var bh=class extends De{constructor(e,t,n,i,s,o,a,l,u,c,h,d,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 g=[],p=[],m=[],v=[],y=0,w=n/2,b=new A,S=new A;f&&e==0&&(e=u),f&&t==0&&(t=c);let _=new B(e,w),M=new B(t,-w),x=null,T=null,E=null,C=null,P=_.clone().sub(M),O=0,D=0,N=0;d>0&&(O=Math.min(e,t)*(1-d),D=e-O,N=t-O);let F=_.clone();F.x-=O;let z=Math.PI-P.angle(),Y=P.angle(),U=Math.tan(Y/2),G=Math.tan(z/2),Q=U+G,V=d?Q:G,k=d?Q:U;if(u=Math.min(u,(e-D)/V,P.length()/Q),c=Math.min(c,(t-N)/k,P.length()/Q),u>0){let K=u/U;x=_.clone().sub(new B(K,u)),d&&(E=x.clone(),E.x-=O-Q*u),_.sub(P.clone().setLength(K))}if(c>0){let K=c/G;T=M.clone().sub(new B(K,-c)),M.add(P.clone().setLength(K)),d&&(C=T.clone(),C.x-=O-Q*c,F.sub(P.clone().setLength(K)))}P=_.clone().sub(M);let j=P.length()<.5,q=[];for(let K=0;K<=i;K++){let X=[],ne=K/i,ce=ne*l+a,oe=new B(Math.sin(ce),Math.cos(ce));C&&T?(W(X,ne,oe,z,c,C,-1,!0),W(X,ne,oe,Y,c,T,-1,!1)):T?(he(X,oe,T.x,0,-1),W(X,ne,oe,Y,c,T,-1,!1)):o||he(X,oe,t,N,-1);let Te=Q_(P).normalize();if(fo(Te,oe,b),!j)for(let me=0;me<=s;me++){let ge=me/s,ye=P.clone().multiplyScalar(ge).add(M);fo(ye,oe,S),p.push(S.x,S.y,S.z),m.push(b.x,b.y,b.z),v.push(ne,.5+S.y/n),X.push(y++)}if(E&&x?(W(X,ne,oe,z,u,x,1,!1),W(X,ne,oe,Y,u,E,1,!0)):x?(W(X,ne,oe,z,u,x,1,!1),he(X,oe,x.x,0,1)):o||he(X,oe,e,D,1),d&&!j){let me=Q_(P).multiplyScalar(-1).normalize();fo(me,oe,b);for(let ge=0;ge<=s;ge++){let ye=ge/s,de=P.clone().multiplyScalar(-ye).add(F);fo(de,oe,S),p.push(S.x,S.y,S.z),m.push(b.x,b.y,b.z),v.push(ne,.5+S.y/n),X.push(y++)}}d&&!o&&X.push(X[0]),q.push(X)}for(let K=0;K<q.length-1;K++)for(let X=0;X<q[0].length-1;X++){if(o&&d&&X==s)continue;let ne=q[K][X],ce=q[K+1][X],oe=q[K+1][X+1],Te=q[K][X+1],me=p[oe*3+0],ge=p[oe*3+2];g.push(ne,ce,Te),(me!=0||ge!=0)&&g.push(ce,oe,Te)}l<Math.PI*2&&(ie(-1,q[0],a),ie(1,q[q.length-1],a+l)),this.setIndex(g),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(m,3)),this.setAttribute("uv",new Ae(v,2));function W(K,X,ne,ce,oe,Te,me,ge){for(let ye=0;ye<h+1;ye++){let de=ye/h,Pe=me<0?de:1-de;ge&&(Pe-=1),Pe*=ce;let Ne=new B(Math.sin(Pe),Math.cos(Pe)*me),Ze=Ne.clone().multiplyScalar(oe).add(Te);fo(Ze,ne,S),p.push(S.x,S.y,S.z),fo(Ne,ne,b),m.push(b.x,b.y,b.z),v.push(X,.5+S.y/n),K.push(y++)}}function he(K,X,ne,ce,oe){let Te=new A,me=new B,ge=[ne,ce];oe<0&&ge.reverse();for(let ye of ge)me.set(ye,w*oe),fo(me,X,Te),p.push(Te.x,Te.y,Te.z),m.push(0,oe,0),v.push(.5,.5),K.push(y++)}function ie(K,X,ne){let ce=new B(Math.sin(ne),Math.cos(ne)),oe=new B(-Math.cos(ne),Math.sin(ne)),Te=new A,me=K<0?(de,Pe,Ne)=>g.push(de,Pe,Ne):(de,Pe,Ne)=>g.push(de,Ne,Pe),ge=new B((e+t+D+N)/4,0);fo(ge,ce,Te),p.push(Te.x,Te.y,Te.z),m.push(oe.x,0,oe.y),v.push(.5,.5);let ye=y++;for(let de of X){let Pe=p.slice(de*3,de*3+3);p.push(...Pe),m.push(oe.x,0,oe.y);let Ne=v.slice(de*2,de*2+2);v.push(...Ne),y++}for(let de=ye+1;de<y-1;de++)me(ye,de,de+1);me(ye,y-1,ye+1)}}};var K_=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:h}=r.parameters,d;return u>0||c>0||l<360?d=new bh(0,e/2,n,i,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new el(e/2,n,i,s,o),d.scale(1,1,t/e),Object.assign(d,{userData:{...r,type:"ConeGeometry"}})}};var J_=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 ur(e,t,n,i,s,o):u=new Zv(e,t,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},Qv=Math.PI/2,Zv=class extends De{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=[],h=[],d=[],f=[],g=0,p=0;m("z","y","x",-1,-1,n,t,e,o,s,0),m("z","y","x",1,-1,n,t,-e,o,s,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(v("z","y","x",-1,-1,1,n,t,e,o,0),v("z","y","x",1,-1,-1,n,t,e,o,1),v("z","y","x",-1,1,-1,n,t,e,o,1),v("z","y","x",1,1,1,n,t,e,o,0),v("x","y","z",-1,-1,-1,e,t,n,i,0),v("x","y","z",1,-1,1,e,t,n,i,1),v("x","y","z",-1,1,1,e,t,n,i,0),v("x","y","z",1,1,-1,e,t,n,i,1),v("y","x","z",-1,-1,1,t,e,n,s,0),v("y","x","z",1,-1,-1,t,e,n,s,1),v("y","x","z",1,1,1,t,e,n,s,1),v("y","x","z",-1,1,-1,t,e,n,s,0),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(d,3)),this.setAttribute("uv",new Ae(f,2));function m(w,b,S,_,M,x,T,E,C,P,O){let D=(x-2*a)/C,N=(T-2*a)/P,F=x/2-a,z=T/2-a,Y=E/2,U=C+1,G=P+1,Q=0,V=0,k=new A;for(let j=0;j<G;j++){let q=j*N-z;for(let W=0;W<U;W++){let he=W*D-F;k[w]=he*_,k[b]=q*M,k[S]=Y,h.push(k.x,k.y,k.z),k[w]=0,k[b]=0,k[S]=E>0?1:-1,d.push(k.x,k.y,k.z),f.push(W/C),f.push(1-j/P),Q+=1}}for(let j=0;j<P;j++)for(let q=0;q<C;q++){let W=g+q+U*j,he=g+q+U*(j+1),ie=g+(q+1)+U*(j+1),K=g+(q+1)+U*j;c.push(W,he,K),c.push(he,ie,K),V+=6}u.addGroup(p,V,O),p+=V,g+=Q}function v(w,b,S,_,M,x,T,E,C,P,O){let D=(T-2*a)/P,N=T/2-a,F=E/2-a,z=C/2,Y=P+1,U=0,G=0,Q=new A,V=new A;for(let k=0;k<l+1;k++){let j=k/l*Qv,q=Math.sin(j)*a,W=(1-Math.cos(j))*a,he=Math.sin(j),ie=Math.cos(j);Q[b]=(F+q)*M,Q[S]=(z-W)*x,V[w]=0,V[b]=he*Math.sign(Q[b]),V[S]=ie*Math.sign(Q[S]);for(let K=0;K<Y;K++){let X=K*D-N;Q[w]=X*_,h.push(Q.x,Q.y,Q.z),d.push(V.x,V.y,V.z),f.push(K/P),f.push(0),U+=1}}for(let k=0;k<l;k++)for(let j=0;j<P;j++){let q=g+j+Y*k,W=g+j+Y*(k+1),he=g+(j+1)+Y*(k+1),ie=g+(j+1)+Y*k;c.push(q,W,ie),c.push(W,he,ie),G+=6}u.addGroup(p,G,O),p+=G,g+=U}function y(w,b,S){let _=new A,M=new A(e/2,t/2,n/2);M.subScalar(a);let x=[],T=w*b*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=Qv*(1-C/l),D=Math.cos(O),N=Math.sin(O),F=0;for(let z=0;z<=C;z++){let Y=Math.cos(F),U=Math.sin(F);_.x=D*Y,_.y=N,_.z=D*U;let G=M.clone().addScaledVector(_,a);h.push(w*G.x,b*G.y,S*G.z),d.push(w*_.x,b*_.y,S*_.z),f.push(0,0),P.push(g++),F+=Qv/C}x.push(P)}let E=x.length-1;for(let C=0;C<E;C++){let P=x[C],O=x[C+1],D=P.length-1;T(P[0],O[1],O[0]);for(let N=1;N<=D;N++)T(P[N-1],P[N],O[N]),T(P[N],O[N+1],O[N])}}}};var po=class extends De{constructor(e=[],t=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),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],g=new A,p=g.clone(),m=new Tn,v=s*i,y=i-v,w=o+1,b=new A,S=(U,G)=>b.subVectors(U,G).normalize(),_=(U,G)=>Array(U).fill(void 0).map(G),M=_(e.length/3,(U,G)=>new A().fromArray(e,G*3).setLength(i)),x=[],T=1e6;for(let U=0;U<M.length;U++){let G=M[U],Q=[],V,k,j,q=1e10,W=-1;for(;(W=t.indexOf(U,W+1))!=-1;){let X=W-W%3;V=t[X+(W+1)%3],k=t[X+(W+2)%3],j=G.distanceToSquared(M[V]),q=Math.min(q,j),Q.push([V,k,j])}q+=1e-6;let he=[],ie=0,K=Q.length;for(let X=0;X<K;X++){[V,k,j]=Q[ie];let ne=x[V]?.includes(U)==!0;j<=q&&he.push(V+ +ne*T),ie=Q.findIndex(ce=>ce[0]==k)}x.push(he)}let E=[];{let U=0,G=0,Q,V,k=f==3;for(let j=0;j<=o;j++){Q=j*(j+1)/2,V=(j+1)*(j+2)/2;for(let q=0;q<o-j;q++)[U,G]=[Q+q+j+2,V+q+j+3],E.push(Q,V,...k?[G,Q]:[U,V],G,U),[Q,V]=[U,G];E.push(Q,V,Q+o+2)}}let C=g.clone(),P=g.clone(),O=g.clone(),D=g.clone(),N=g.clone(),F=[],z=_(M.length,()=>_(f,()=>g.clone()));for(let U=0;U<M.length;U++){g.copy(M[U]).normalize(),C.copy(g).multiplyScalar(y);let G=x[U];for(let he=0;he<G.length;he++){let ie=G[he],K=G[(he+1)%f];m.setFromPointsAndIndices(M,U,ie%T,K%T),m.b.sub(m.a).setLength(1e10).add(m.a),m.c.sub(m.a).setLength(1e10).add(m.a),m.closestPointToPoint(C,z[U][he])}let Q=[],V=[],k=[],j=new A;o==0&&[...z[U]].reduce((he,ie)=>he.add(ie),j).multiplyScalar(1/f);for(let he=0;he<f;he++){let ie=[],K=(he-1+f)%f,X=z[U][K],ne=z[U][he];g.copy(X).sub(C),p.copy(ne).sub(C);let ce=C.angleTo(g),oe=g.angleTo(p),Te=Math.cos(ce)*v;o==0?P.copy(j):P.copy(C).setLength(y+Te),V.push(Te);let me=[P,X,ne];for(let ge=0;ge<2;ge++){let ye=me[ge],de=me[ge+1];D.subVectors(ye,C),N.subVectors(de,C),O.crossVectors(D,N).normalize();for(let Pe=0;Pe<w;Pe++){let Ne=[ce,oe][ge]*Pe/w;g.copy(D).applyAxisAngle(O,Ne).add(C),Q.push(g.clone()),ge&&(S(g,C),ie.push([Pe==0?ye:g.clone(),b.clone()]))}ge&&(S(de,C),ie.push([de,b.clone()]))}k.push(ie)}F.push(k);let q=2*w,W=2;for(let he=0;he<f;he++){let ie=q*he,K=q*((he+1)%f),X=[Q[ie]];for(let ce=1;ce<w;ce++){D=Q[ie+ce],N=Q[K+ce],X.push(D);for(let oe=1,Te=ce-W+1;oe<=Te;oe++)g.lerpVectors(D,N,oe/(Te+1)),g.sub(C).setLength(V[he]).add(C),X.push(g.clone());X.push(N)}for(let ce=0;ce<w;ce++)X.push(Q[ce+w+ie]);X.push(Q[K+w]);let ne=E.map(ce=>X[ce]);a.push(...ne.map(ce=>[ce.x,ce.y,ce.z]).flat()),u.push(...ne.map(ce=>(S(ce,C),[b.x,b.y,b.z])).flat())}}let Y=[];for(let U=0;U<x.length;U++)for(let G=0;G<f;G++){let Q=x[U][G];if(Q<T){let V=x[Q].findIndex(q=>q%T==U),k=F[U][G],j=F[Q][V];for(let q=0;q<w;q++){let W=k[q],he=j[w-q],ie=k[q+1],K=j[w-(q+1)];[W,he,ie,ie,he,K].forEach(X=>{a.push(X[0].x,X[0].y,X[0].z),u.push(X[1].x,X[1].y,X[1].z)})}Y.push(k[0][0],j[w][0],k[w][0],j[0][0])}}for(;Y.length;){let U,G,Q,V;[U,G]=Y.splice(0,2);let k=[U];for(;U!=G;)k.push(G),Q=Y.indexOf(G),V=Q%2,G=Y.splice(Q-V,2)[1-V];b.subVectors(k[0],k[1]).cross(g.subVectors(k[0],k[2])).normalize();let j=b.dot(k[0])<0;j&&b.negate();for(let q=1;q<=k.length-2;q++)[k[q+ +j],k[q+1-+j],k[0]].forEach(W=>{a.push(W.x,W.y,W.z),u.push(b.x,b.y,b.z)})}}function h(){let d=new A;for(let M=0;M<a.length;M+=3){d.x=a[M+0],d.y=a[M+1],d.z=a[M+2];let x=S(d)/2/Math.PI+.5,T=_(d)/Math.PI+.5;l.push(x,1-T)}let f=new A,g=new A,p=new A,m=new A,v=new B,y=new B,w=new B,b=(M,x,T,E)=>{E<0&&M.x===1&&(l[x]=M.x-1),T.x===0&&T.z===0&&(l[x]=E/2/Math.PI+.5)};for(let M=0,x=0;M<a.length;M+=9,x+=6){f.set(a[M+0],a[M+1],a[M+2]),g.set(a[M+3],a[M+4],a[M+5]),p.set(a[M+6],a[M+7],a[M+8]),v.set(l[x+0],l[x+1]),y.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),m.copy(f).add(g).add(p).divideScalar(3);let T=S(m);b(v,x+0,f,T),b(y,x+2,g,T),b(w,x+4,p,T)}for(let M=0;M<l.length;M+=6){let x=l[M+0],T=l[M+2],E=l[M+4],C=Math.max(x,T,E),P=Math.min(x,T,E);C>.9&&P<.1&&(x<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),E<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(e){return new po(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var $_=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 wh(e*.5,s,o):new nl(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},wh=class extends po{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 wh(e.radius,e.corner,e.cornerSides)}};var Jv=Math.PI*2;function Kv({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function Lz(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 eT(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 Oz(r,e,t,n,i,s,o,a,l,u){let c=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),g=c*h-c*f-h*d;g<0&&(g=0),g/=c*f+h*d,g=Math.sqrt(g)*(l===u?-1:1);let p=g*i/s*a,m=g*-s/i*o,v=p+(r+t)/2,y=m+(e+n)/2,w=(o-p)/i,b=(a-m)/s,S=(-o-p)/i,_=(-a-m)/s,M=eT(1,0,w,b),x=eT(w,b,S,_);return!u&&x>0&&(x-=Jv),u&&x<0&&(x+=Jv),{centerx:v,centery:y,ang1:M,ang2:x}}function tT({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 h=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=Oz(r,e,t,n,i,s,u,c,o,a),{ang1:f,ang2:g}=d,{centerx:p,centery:m}=d,v=Math.abs(g)/(Jv/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);g/=y;for(let w=0;w<y;w++)l.push(Lz(f,g)),f+=g;return l.map(w=>{let{x:b,y:S}=Kv(w[0],i,s,p,m),{x:_,y:M}=Kv(w[1],i,s,p,m),{x,y:T}=Kv(w[2],i,s,p,m);return{x1:b,y1:S,x2:_,y2:M,x,y:T}})}var rT=Math.PI*2,iT=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 gt?r.shape:new gt,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,h=t*.5,d=Rz(u,c,h,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Fn.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function Rz(r,e,t,n,i,s){if(n>=rT)return i>30||i%4===0?(Bz(r,e,t,s),Math.round(i/4)):nT(r,n,i,e,t,s);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},u=tT({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?Nz(r,o.x,o.y,u,i,e,t,s):nT(r,n,i,e,t,s)}function Nz(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(Sc(e,t));for(let u=0,c=n.length;u<c;u++){let h=n[u],d=r.points[u],f=Sc(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),r.addPoint(f)}return a>0?sT(r,s,o,a):r.addPoint(Sc(0,0)),l}function nT(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(Sc(u,c))}return e<rT?s>0?sT(r,n,i,s):r.addPoint(Sc(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&oT(r,n,i,s)),1}function Bz(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(Yp(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(Yp(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(Yp(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(Yp(i,s-t,i+a,s-t,i-a,s-t)),n>0&&oT(r,e,t,n)}function Sc(r,e){return new pi(Be.generateUUID(),new B(r,e))}function Yp(r,e,t,n,i,s){let o=Sc(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function sT(r,e,t,n){aT(r,e,t,n).forEach(s=>r.addPoint(s))}function oT(r,e,t,n){let i=aT(r,e,t,n),s=new gt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function aT(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new B(i/e,s/t),a=r.points.map(l=>{let u=l.clone();return u.uuid=Be.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 lT=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:h}=r.parameters,d=new Sh(!1,e,t,n,i,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...r,type:"HelixGeometry"}})}},Sh=class extends De{constructor(e=!0,t=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){super();let f=e&&o===1;f&&(d=0),h>100&&(h=100);let g=()=>new A,p=new A,m=g(),v=g(),y=g(),w,b,S,_,M,x,T,E,C=g(),P=g(),O=g(),D=g(),N=g(),F=g(),z=g(),Y=g(),U=n-2*l+.001,G=U/o,Q=Math.ceil(a*o),V=Q+1,k=U/Q,j=-U/2,q=c+1,W=2*Math.PI/c,he=Math.PI/2/d,ie=.01,K=Math.min((1-h/100)*l,l-ie),X=l-K,ne=0,ce=2,oe=d*ce+ce,Te=q*oe/ce,me=Te+q*V,ge=q*(V+oe),[ye,de,Pe]=[3,3,2].map(ve=>Array(ge*ve).fill(0)),Ne=[],Ze=s-l;function R(ve,H){let xe=Math.PI/2;x=H*k,E=2*Math.PI*(x%G)/G+xe,x+=j,T=Math.sin(E)*Ze,M=Math.cos(E)*Ze,e?ve.set(M,T,x):ve.set(M,x,T)}R(p,-1e-10),R(m,0),C.copy(p),R(p,1);let I=p.distanceTo(m),J=X+K,le=I*Q+2*J,fe=K,Ee=le-J;for(let ve=0;ve<=Q;ve++){R(v,ve),Y.subVectors(v,C).normalize(),C.copy(v),F.copy(v).setComponent(+e+1,0).normalize(),z.crossVectors(Y,F).normalize();let H=ve===0,xe=ve===Q,_e=H?3*Math.PI/2:he,Qe=H?fe:Ee,Re=H?q:me,Ke=H?0:ge-q,we=Y.clone().multiplyScalar(H?-X:X).add(v),Je=Y.clone().multiplyScalar(H?-1:1).normalize();for(let it=0;it<q;it++){let yt=it*W;if(P.addVectors(p.copy(F).multiplyScalar(l*Math.cos(yt)),m.copy(z).multiplyScalar(l*Math.sin(yt))),O.copy(P).normalize(),H||xe){f||(ne=Ke+it,[0,1,2].forEach(At=>{ye[ne*3+At]=we.getComponent(At),de[ne*3+At]=Je.getComponent(At)}),Pe[ne*2]=+xe,Pe[ne*2+1]=it/c),m.copy(O).multiplyScalar(K),y.addVectors(v,m);for(let At=0;At<d;At++){let cr=At*he+_e;D.addVectors(p.copy(Y).multiplyScalar(X*Math.sin(cr)),m.copy(O).multiplyScalar(X*Math.cos(cr))),N.copy(D).normalize(),m.addVectors(y,D),D.normalize(),ne=Re+At*q+it,[0,1,2].forEach(Ta=>{ye[ne*3+Ta]=m.getComponent(Ta),de[ne*3+Ta]=N.getComponent(Ta)});let md=+H+Math.sin(cr);Pe[ne*2]=(Qe+X*md)/le,Pe[ne*2+1]=it/c}}m.addVectors(v,P),ne=Te+ve*q+it,[0,1,2].forEach(At=>{ye[ne*3+At]=m.getComponent(At),de[ne*3+At]=O.getComponent(At)}),Pe[ne*2]=(J+ve*I)/le,Pe[ne*2+1]=it/c}}let Ue=V+2*d+ce,re=1,[Fe,Oe]=f?[re,re+V-1]:[0,Ue-1];for(let ve=Fe;ve<=Oe-1;ve++){let H=f&&ve===Oe-1;for(let xe=0;xe<q-1;xe++)w=ve*q+xe,b=w+1,S=(H?xe:w)+q,_=(H?xe+1:b)+q,ve===0?Ne.push(b,_,S):ve===Ue-2?Ne.push(w,b,S):Ne.push(w,b,S,b,_,S)}this.setIndex(Ne),this.setAttribute("position",new Ae(ye,3)),this.setAttribute("normal",new Ae(de,3)),this.setAttribute("uv",new Ae(Pe,2))}};var cT=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 Ah(e*.5,s,o):new il(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},Ah=class extends po{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 Ah(e.radius,e.corner,e.cornerSides)}};var uT=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 ms;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 $a(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var zi=new be,$v=new ht,Qp=new A,mo=class extends Lt{constructor(){super(),this.uuid=Be.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 jt().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 zi.makeRotationX(e),this.applyMatrix4(zi),this}rotateY(e){return zi.makeRotationY(e),this.applyMatrix4(zi),this}rotateZ(e){return zi.makeRotationZ(e),this.applyMatrix4(zi),this}translate(e,t,n){return zi.makeTranslation(e,t,n),this.applyMatrix4(zi),this}scale(e,t,n){return zi.makeScale(e,t,n),this.applyMatrix4(zi),this}lookAt(e){return $v.lookAt(e),$v.updateMatrix(),this.applyMatrix4($v.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 d=0;d<s.count;d++)t.vertices.push(new A().fromBufferAttribute(s,d)),a!==void 0&&t.colors.push(new Le().fromBufferAttribute(a,d));function c(d,f,g,p){let m=a===void 0?[]:[t.colors[d].clone(),t.colors[f].clone(),t.colors[g].clone()],v=o===void 0?[]:[new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,g)],y=new Ac(d,f,g,v,m,p);t.faces.push(y),l!==void 0&&t.faceVertexUvs[0].push([new B().fromBufferAttribute(l,d),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,g)]),u!==void 0&&t.faceVertexUvs[1].push([new B().fromBufferAttribute(u,d),new B().fromBufferAttribute(u,f),new B().fromBufferAttribute(u,g)])}let h=e.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],g=f.start,p=f.count;for(let m=g,v=g+p;m<v;m+=3)n!==void 0?c(n.getX(m),n.getX(m+1),n.getX(m+2),f.materialIndex):c(m,m+1,m+2,f.materialIndex)}else if(n!==void 0)for(let d=0;d<n.count;d+=3)c(n.getX(d),n.getX(d+1),n.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qp).negate(),this.translate(Qp.x,Qp.y,Qp.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,i=new be;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 mo;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 Mt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Mn),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,h=e.colors;t!==void 0&&(i=new jt().getNormalMatrix(t));for(let d=0,f=a.length;d<f;d++){let p=a[d].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let g=u[d],p,m,v=g.vertexNormals,y=g.vertexColors,w=new Ac(g.a+s,g.b+s,g.c+s);w.normal.copy(g.normal),i!==void 0&&w.normal.applyMatrix3(i).normalize();for(let b=0,S=v.length;b<S;b++)p=v[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),w.vertexNormals.push(p);w.color.copy(g.color);for(let b=0,S=y.length;b<S;b++)m=y[b],w.vertexColors.push(m.clone());w.materialIndex=g.materialIndex+n,l.push(w)}for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let g=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,m=g.length;p<m;p++){let v=g[p],y=[];for(let w=0,b=v.length;w<b;w++)y.push(v[w].clone());this.faceVertexUvs[d].push(y)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},n=[],i=[],s=Math.pow(10,e);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);t[h]===void 0?(t[h]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[t[h]]}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 h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;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 g=this.parameters;for(let p in g)g[p]!==void 0&&(e[p]=g[p]);return e}let t=[];for(let g=0;g<this.vertices.length;g++){let p=this.vertices[g];t.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let g=0;g<this.faces.length;g++){let p=this.faces[g],m=!0,v=!1,y=this.faceVertexUvs[0][g]!==void 0,w=p.normal.length()>0,b=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,M=0;if(M=c(M,0,0),M=c(M,1,m),M=c(M,2,v),M=c(M,3,y),M=c(M,4,w),M=c(M,5,b),M=c(M,6,S),M=c(M,7,_),n.push(M),n.push(p.a,p.b,p.c),n.push(p.materialIndex),y){let x=this.faceVertexUvs[0][g];n.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&n.push(h(p.normal)),b){let x=p.vertexNormals;n.push(h(x[0]),h(x[1]),h(x[2]))}if(S&&n.push(d(p.color)),_){let x=p.vertexColors;n.push(d(x[0]),d(x[1]),d(x[2]))}}function c(g,p,m){return m?g|1<<p:g&~(1<<p)}function h(g){let p=g.x.toString()+g.y.toString()+g.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(g.x,g.y,g.z)),s[p]}function d(g){let p=g.r.toString()+g.g.toString()+g.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(g.getHex())),a[p]}function f(g){let p=g.x.toString()+g.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(g.x,g.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 mo().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let d=0,f=t.length;d<f;d++)this.vertices.push(t[d].clone());let n=e.colors;for(let d=0,f=n.length;d<f;d++)this.colors.push(n[d].clone());let i=e.faces;for(let d=0,f=i.length;d<f;d++)this.faces.push(i[d].clone());for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let g=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,m=g.length;p<m;p++){let v=g[p],y=[];for(let w=0,b=v.length;w<b;w++){let S=v[w];y.push(S.clone())}this.faceVertexUvs[d].push(y)}}let s=e.morphTargets;for(let d=0,f=s.length;d<f;d++){let g={};if(g.name=s[d].name,s[d].vertices!==void 0){g.vertices=[];for(let p=0,m=s[d].vertices.length;p<m;p++)g.vertices.push(s[d].vertices[p].clone())}if(s[d].normals!==void 0){g.normals=[];for(let p=0,m=s[d].normals.length;p<m;p++)g.normals.push(s[d].normals[p].clone())}this.morphTargets.push(g)}let o=e.morphNormals;for(let d=0,f=o.length;d<f;d++){let g={};if(o[d].vertexNormals!==void 0){g.vertexNormals=[];for(let p=0,m=o[d].vertexNormals.length;p<m;p++){let v=o[d].vertexNormals[p],y={};y.a=v.a.clone(),y.b=v.b.clone(),y.c=v.c.clone(),g.vertexNormals.push(y)}}if(o[d].faceNormals!==void 0){g.faceNormals=[];for(let p=0,m=o[d].faceNormals.length;p<m;p++)g.faceNormals.push(o[d].faceNormals[p].clone())}this.morphNormals.push(g)}let a=e.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=e.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=e.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=e.boundingSphere;return h!==null&&(this.boundingSphere=h.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 e0().fromGeometry(this),t=new De,n=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Ge(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Ge(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Ge(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Ge(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Ge(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 De,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}};mo.prototype.isGeometry=!0;var e0=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 v=0;v<l;v++)u[v]={name:a[v].name,data:[]};this.morphTargets.position=u}let c=e.morphNormals,h=c.length,d;if(h>0){d=[];for(let v=0;v<h;v++)d[v]={name:c[v].name,data:[]};this.morphTargets.normal=d}let f=e.skinIndices,g=e.skinWeights,p=f.length===n.length,m=g.length===n.length;n.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let v=0;v<t.length;v++){let y=t[v];this.vertices.push(n[y.a],n[y.b],n[y.c]);let w=y.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=y.normal;this.normals.push(S,S,S)}let b=y.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=y.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][v];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",v),this.uvs.push(new B,new B,new B))}if(o===!0){let S=i[1][v];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",v),this.uvs2.push(new B,new B,new B))}for(let S=0;S<l;S++){let _=a[S].vertices;u[S].data.push(_[y.a],_[y.b],_[y.c])}for(let S=0;S<h;S++){let _=c[S].vertexNormals[v];d[S].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[y.a],f[y.b],f[y.c]),m&&this.skinWeights.push(g[y.a],g[y.b],g[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Ac=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 Le,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 Fz=["a","b","c"];function Uz(r,e){switch(e){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function t0(r,e,t){let n=Math.min(r,e),i=Math.max(r,e),s=n+"_"+i;return t.get(s)}function n0(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],h=t[a];u={a:c,b:h,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[e].edges.push(u)}function Gz(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],n0(o.a,o.b,r,n,o,t),n0(o.b,o.c,r,n,o,t),n0(o.c,o.a,r,n,o,t)}function Zp(r,e,t,n,i){r.push(new Ac(e,t,n,void 0,void 0,i))}function _c(r,e){return Math.abs(e-r)/2+Math.min(r,e)}function Kp(r,e,t,n){r.push([e.clone(),t.clone(),n.clone()])}var Jp=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof De?e=new mo().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],h=c!==void 0&&c.length>0,d=[],f=new Map;Gz(l,u,d,f);let g=[],p,m,v,y,w,b,S;for(let ie of Array.from(f.keys())){for(m=f.get(ie),v=new A,w=3/8,b=1/8,S=m.faces.length,S!=2&&(w=.5,b=0,S!=1),v.addVectors(m.a,m.b).multiplyScalar(w),t.set(0,0,0),o=0;o<S;o++){for(y=m.faces[o],a=0;a<3&&(p=l[Uz(y,Fz[a])],!(p!==m.a&&p!==m.b));a++);p&&t.add(p)}t.multiplyScalar(b),v.add(t),m.newEdge=g.length,g.push(v)}let _,M,x,T,E,C,P,O=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=d[i].edges,n=E.length,n==3?_=3/16:n>3&&(_=3/(8*n)),M=1-n*Number(_),x=_,n<=2&&(n==2?(M=3/4,x=1/8):n==1||n==0),P=C.clone().multiplyScalar(M),t.set(0,0,0),o=0;o<n;o++)T=E[o],p=T.a!==C?T.a:T.b,t.add(p);t.multiplyScalar(Number(x)),P.add(t),O.push(P)}let D=O.concat(g),N=O.length,F,z,Y,U=[],G=[],Q,V,k,j,q=new B,W=new B,he=new B;for(i=0,s=u.length;i<s;i++)y=u[i],F=Number(t0(y.a,y.b,f).newEdge)+N,z=Number(t0(y.b,y.c,f).newEdge)+N,Y=Number(t0(y.c,y.a,f).newEdge)+N,Zp(U,F,z,Y,y.materialIndex),Zp(U,y.a,F,Y,y.materialIndex),Zp(U,y.b,z,F,y.materialIndex),Zp(U,y.c,Y,z,y.materialIndex),h&&(Q=c[i],V=Q[0],k=Q[1],j=Q[2],q.set(_c(V.x,k.x),_c(V.y,k.y)),W.set(_c(k.x,j.x),_c(k.y,j.y)),he.set(_c(V.x,j.x),_c(V.y,j.y)),Kp(G,q,W,he),Kp(G,V,q,he),Kp(G,k,W,q),Kp(G,j,he,W));e.vertices=D,e.faces=U,h&&(e.faceVertexUvs[0]=G)}};var bn=new A,hT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=r.geometry??e?.geometry??new De().copy(new ur(100,100,100)),n;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(bn),n={width:bn.x,height:bn.y,depth:bn.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 De().copy(new ur(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(bn)):bn.set(o.width,o.height,o.depth),(e!==bn.x||t!==bn.y||n!==bn.z)&&s.scale(bn.x===0?1:e/bn.x,bn.y===0?1:t/bn.y,bn.z===0?1:n/bn.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Jp(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 ul(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(bn);let o=100/bn.x;Object.assign(s.parameters,{width:100,height:bn.y*o,depth:bn.z*o}),e(this.build(s))})}};var dT=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 gt?r.shape:new gt,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,h=0,d=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let m=f*p,v=h+Math.sin(m)*u,y=d+Math.cos(m)*c;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let p=0,m=l.points.length;p<m;p++)l.points[p].roundness=i;l.roundness=i,l.update();let g=Fn.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(g,{userData:{...r,type:"PolygonGeometry"}})}};var fT=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 i0(e*.5,t,i,s,o,a,l);return u.scale(1,1,n/e),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function _h(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function r0(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 zz(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.projectOnVector(i),n.add(e)}var i0=class extends De{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=[],h=[],d=0,f=t/2,g=Math.PI/n,p=e*Math.cos(Math.PI/n),m=2*Math.PI/n,v=(n-2)*Math.PI/n,y=Math.PI-v,w=new A(0,-f,0),b=new A(0,f,0),S=new B(e,-f),_=new B(p,-f),M=new B(0,b.y).sub(_),x=new B(0,b.y).sub(S),T=new B(M.y,-M.x).normalize(),E=new B(x.y,-x.x).normalize(),P=e*Math.cos(Math.PI/n)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,P);let O;{let G=new A(T.x,T.y,0),Q=new A(Math.cos(m)*G.x,G.y,Math.sin(m)*G.x);O=G.angleTo(Q)}let D=o/Math.tan((Math.PI-M.angle())/2),N=o/Math.tan((Math.PI-O)/2),F=new A;if(!s){u.push(w.x,w.y,w.z),c.push(0,-1,0),h.push(0,0);let G=d++,Q=[],V=S.clone(),k=D/Math.cos(Math.PI/n);V.x-=k;for(let j=0;j<n;j++){let q=j/n*Math.PI*2+g,W=new B(Math.sin(q),Math.cos(q));_h(V,W,F),u.push(F.x,F.y,F.z),c.push(0,-1,0),h.push(0,0),Q.push(d++)}for(let j=0;j<Q.length;j++)l.push(Q[j],G,Q[(j+1)%Q.length])}let z=[];{let G=new A,Q=new A,V=new A,k=new A,j=new A,q=new A;for(let W=0;W<n;W++){let he=W/n*Math.PI*2+g,ie=(W+.5)/n*Math.PI*2+g,K=(W+1)/n*Math.PI*2+g,X=new B(Math.sin(he),Math.cos(he)),ne=new B(Math.sin(ie),Math.cos(ie)),ce=new B(Math.sin(K),Math.cos(K));_h(S,X,Q),_h(S,ce,V),_h(T,ne,G),r0(b,Q,V,N,N,k),u.push(k.x,k.y,k.z),r0(Q,b,V,N,D,j),u.push(j.x,j.y,j.z),r0(V,Q,b,D,N,q),u.push(q.x,q.y,q.z),c.push(G.x,G.y,G.z),c.push(G.x,G.y,G.z),c.push(G.x,G.y,G.z),h.push(0,0),h.push(0,0),h.push(0,0);let oe=d++,Te=d++,me=d++;if(l.push(oe,Te,me),o>0){{let de=Q.clone().add(V).multiplyScalar(.5),Pe=b.clone().sub(de).normalize(),Ze=w.clone().sub(de).normalize().add(Pe).normalize().multiplyScalar(-1),R=q.clone().sub(j);Y(de,R,Ze,M.angle())}let ge,ye;{let de=new A;_h(E,ce,de);let Pe=q.clone().add(k).multiplyScalar(.5);Pe=zz(Pe,V,b);let Ne=q.clone().sub(k);[ge,ye]=Y(Pe,Ne,de,O,k.y)}{let de=ge,Pe=de.clone().setY(0).normalize(),Ne=new A(0,-1,0),Ze=Pe.clone().cross(Ne);U(de,Pe,Ne,Ze)}z.concat(ye);{let de=M.angle(),Pe=Math.PI-de,Ne=b.clone();Ne.y-=o/Math.sin(de-Math.PI/2);let Ze=new A,R=[];for(let J=0;J<a;J++){let le=[],fe=Math.PI/2-Pe*J/a,Ee=Math.cos(fe),Ue=Math.sin(fe),re=ie;for(let Fe=0;Fe<=J;Fe++){let Oe=Math.cos(re),ve=Math.sin(re);G.x=Ee*ve,G.y=Ue,G.z=Ee*Oe,Ze.copy(Ne).addScaledVector(G,o),u.push(Ze.x,Ze.y,Ze.z),c.push(G.x,G.y,G.z),h.push(0,0),le.push(d++),re+=Math.PI*2/J/n}R.push(le)}ye.reverse(),R.push(ye);let I=R.length-1;for(let J=0;J<I;J++){let le=R[J],fe=R[J+1],Ee=le.length-1;l.push(fe[1],le[0],fe[0]);for(let Ue=1;Ue<=Ee;Ue++)l.push(le[Ue],le[Ue-1],fe[Ue]),l.push(fe[Ue+1],le[Ue],fe[Ue])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(h,2));function Y(G,Q,V,k,j){let q=-k/2,W=(Math.PI-k)/2,he=Q.clone().normalize().cross(V);G.addScaledVector(V,-o/Math.sin(W));let ie=new A,K=new A,X=1,ne=d,ce=[];for(let oe=0;oe<=a;oe++){let Te=q+oe/a*k;K.set(0,0,0),K.addScaledVector(he,Math.sin(Te)),K.addScaledVector(V,Math.cos(Te));for(let me=0;me<=X;me++){let ge=me/X-.5;if(ie.copy(G),ie.addScaledVector(Q,ge),ie.addScaledVector(K,o),j!=null){let ye=Math.max(0,ie.y-j);ie.addScaledVector(Q,-ye/Q.y)}u.push(ie.x,ie.y,ie.z),c.push(K.x,K.y,K.z),h.push(0,0),me===0&&ce.push(d),d++}}for(let oe=0;oe<a;oe++)for(let Te=0;Te<X;Te++){let me=ne+Te+(X+1)*oe,ge=me+(X+1),ye=ge+1,de=me+1;l.push(me,ge,de),l.push(ge,ye,de)}return[G.clone().addScaledVector(Q,.5),ce]}function U(G,Q,V,k){let j=Math.PI/2,q=x.angle()-j,W=[],he=new A,ie=new A;for(let X=0;X<=a;X++){let ne=[],ce=X/a;for(let oe=0;oe<=X;oe++){let me=((X?oe/X:0)-.5)*y,ge=Math.cos(me),ye=Math.sin(me),de=Math.atan(Math.tan(q)*ge),Pe=(j+de)*ce,Ne=Math.cos(Pe),Ze=Math.sin(Pe);he.set(0,0,0),he.addScaledVector(Q,Ze*ge),he.addScaledVector(V,Ne),he.addScaledVector(k,Ze*ye),ie.copy(G).addScaledVector(he,o),u.push(ie.x,ie.y,ie.z),c.push(he.x,he.y,he.z),h.push(0,0),ne.push(d++)}W.push(ne)}let K=W.length-1;for(let X=0;X<K;X++){let ne=W[X],ce=W[X+1],oe=ne.length-1;l.push(ne[0],ce[1],ce[0]);for(let Te=1;Te<=oe;Te++)l.push(ne[Te-1],ne[Te],ce[Te]),l.push(ne[Te],ce[Te+1],ce[Te])}}}};var pT=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 gt?r.shape:new gt,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},h={x:u.x,y:u.y};function d(b,S,_){return S>t&&_>n?Math.min(b*t/S,b*n/_):S>t?b*t/S:_>n?b*n/_:b}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let g=c.x,p=h.x,m=h.y,v=c.y;e.addPoint(e.createPoint(g,m)),e.addPoint(e.createPoint(p,m)),e.addPoint(e.createPoint(p,v)),e.addPoint(e.createPoint(g,v)),e.isClosed=!0;let y=!0;for(let b=0,S=e.points.length;b<S;b++)e.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(y=!1);y&&(e.roundness=f[0]),e.useCubicForRoundedCorners=s!==1,e.update();let w=Fn.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...r,type:"RectangleGeometry"}})}};var mT=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 jo(.5*e,i,s,o,a,l,u);return c.scale(1,t/e,n/e),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var gT=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 ps(e,t,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var yT=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 s0(e,t,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},s0=class extends De{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 h=[],d=Math.PI/2,f=(ie=0,K=0,X=0)=>new A(ie,K,X),g=f(),p=f(),[m,v,y]=[t/2,e/2,n/2],w=-v,b=+v,[S,_,M]=[f(w,-m,+y),f(w,-m,-y),f(w,+m,-y)],x=(ie,K=!1)=>Math.sin(ie-Math.PI/(1+ +K)),T=(ie,K=!1)=>Math.cos(ie-Math.PI/(1+ +K));M.y=Math.sin(i)*t-m;let E=Math.cos(i)*t-y,C=S.z-c;i<=d?(M.z=Math.min(E,C),M.z==C&&(M.y-=(E-C)/Math.tan(d-i))):_.z=Math.min(_.z-E-y,S.z-c),g.subVectors(S,_),p.subVectors(M,_);let P=Math.min(g.length(),p.length())*s/100,O=P*Math.tan(i/2),D=P/Math.cos(i/2),N=g.clone().normalize().add(p.normalize()).setLength(D).add(_);g.set(0,x(i,!0),T(i,!0)),h.push([M,g.clone()]);let F=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let K=d+i+ie*F;g.set(0,Math.sin(K)*O,Math.cos(K)*O),g.add(N),p.set(0,x(K),T(K)),h.push([g.clone(),p.clone()])}h.push([S,f(0,1,0)]);let z=Math.sin(F/2)*O*2,Y=h.length-1,U=h[0][0].distanceTo(h[1][0]),G=h[Y-1][0].distanceTo(h[Y][0]),Q=U+z*o+G;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(U+ie*z)/Q);h[Y].push(0);let[V,k,j]=h[0],q,W,he;for(let ie=1;ie<h.length;ie++)[q,W,he]=h[ie],a.push(w,V.y,V.z,w,q.y,q.z,b,V.y,V.z,b,V.y,V.z,w,q.y,q.z,b,q.y,q.z),l.push(0,k.y,k.z,0,W.y,W.z,0,k.y,k.z,0,k.y,k.z,0,W.y,W.z,0,W.y,W.z),u.push(0,j,0,he,1,j,1,j,0,he,1,he),[V,k,j]=[q,W,he];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var vT=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 gt?r.shape:new gt,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,h=e*.5,d=t*.5,f=0,g=0,p=o*Math.PI/360/i,m=Math.PI/2*3*-1,v=h*n/100,y=d*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let S=p*b,_=f+Math.sin(S)*h,M=g+Math.cos(S)*d;c.addPoint(c.createPoint(_,M))}}else for(let b=0;b<i;b++){let S=f+Math.cos(m)*h,_=g+Math.sin(m)*d;c.addPoint(c.createPoint(S,_)),m+=p,S=f+Math.cos(m)*v,_=g+Math.sin(m)*y,b<=i,c.addPoint(c.createPoint(S,_)),m+=p}c.isClosed=!0;for(let b=0,S=c.points.length;b<S;b++)c.points[b].roundness=s;c.roundness=s,c.update();let w=Fn.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...r,type:"StarGeometry"}})}};var xT=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 ps(e,t);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var bT=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=kz(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 kz(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 Sh(!0,r,e,t,n,i,s,o,a,l,u,c)}var wT=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 sl(a,t,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var ST=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 gt?r.shape:new gt,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 d=0,f=l.points.length;d<f;d++)l.points[d].roundness=n;l.roundness=n,l.update();let h=Fn.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...r,type:"TriangleGeometry"}})}};function AT(){let r=new De;return r.setAttribute("position",new Ge(new Float32Array([]),3)),r.setIndex(new Ge(new Uint16Array([]),1)),r}var Vz=12;var Tc=class extends De{constructor(t,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.vectorShapes=[];let i=AT();Object.entries(i.attributes).forEach(([s,o])=>{this.setAttribute(s,o)}),this.setIndex(i.index),this.updateFont(t.font,n),this.update(t)}async updateFont(t,n){let i=n.getFont(t);i&&(this.font=i,await i.loadingPromise)}async update(t){let n=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!n||!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,subdivisions:h}=t;await n.loadingPromise;let d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,f=Hz(t,n,d),{shapes:g,charWidths:p,charCoords:m}=await n.generateShapes(f,t),v=i*.5,y=s*.5,w=g.map(_=>new gt().fromShape(_));this.vectorShapes=w;let b=w.map(_=>Fn.create({shape:_,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?It.NONZERO:It.ODD,subdivisions:h??Vz}})),S=b.length?Ss(b):AT();S.translate(-v,y,0),this.dispose(),this.wrappedText=f,this.charCoords=m,this.charWidths=p,Object.entries(S.attributes).forEach(([_,M])=>{this.setAttribute(_,M)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let t=la(new De,Tc.prototype);return t.copy(this),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 Hz(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 TT,$p=new Promise(r=>{TT=r}),_T=!1;async function MT(){if(_T)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.137/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});TT(s),_T=!0}function em(r,e){return jz(r)}function jz(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=gt.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new ul().parse(r));let t;try{t=Th(e)}catch(n){console.error(n)}if(!t){let n=gt.createFromState(Ql.defaultData(),100,100);e.shape=n,t=Th(e)}return t}var qe;$p.then(r=>{qe=r});var ET=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),CT=new Uint32Array([0,1,2,3]),PT=new Uint8Array([4]),Qr=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(qe.free_bvh(t),qe.free_subdivision_surface(t));try{s=Qr.allocate(r,i)}catch(u){console.error(u,r),s=Qr.allocate({positionWASM:ET,indexWASM:CT,verticesPerFaceWASM:PT},i)}qe.set_destination_refinement_level(s,0),o=Qr.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=Qr.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(qe.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=Qr.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:em(r),n,i,s,o;({positions:n,triIndices:o}=Mh(t.getAttribute("position"),t.getIndex()));let a;if(r.type==="CylinderGeometry"&&r.cornerRadius===0&&r.hollow===0&&r.openEnded===!1){let l=r.radialSegments*r.heightSegments*3*2,u=l+r.radialSegments*3;a=[l,u]}return{indices:i,verticesPerFace:s}=c0(n,o,t,a),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=ET,n=CT,i=PT);let a=t.length,l=n.length,u=i.length,c=t.length+s.length+o.length,h=n.length+i.length,d=c*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,f=c*Float32Array.BYTES_PER_ELEMENT,g=h*Uint32Array.BYTES_PER_ELEMENT,p=qe._malloc(d),m=new Float32Array(qe.HEAPF32.buffer,p,c),v=new Uint32Array(qe.HEAPU32.buffer,p+f,h);m.set(t,0),m.set(s,t.length),m.set(o,t.length+s.length),v.set(n,0),v.set(i,n.length);let y;r?.scaleBaked?.some(b=>b!==1)&&(y=new be().makeScale(...r.scaleBaked)),e&&(y?y.premultiply(e):y=e);let w=y?qe.alloc_subdivision_surface2(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u,y.elements):qe.alloc_subdivision_surface(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u);return qe._free(p),w}static buildLevel(r,e,t,n,i){let s=i?qe.get_mesh_data2(r,e?qe.Level.CONTROL:qe.Level.REFINED,t,i.elements):qe.get_mesh_data(r,e?qe.Level.CONTROL:qe.Level.REFINED,t),o=8,a=qe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),u=0,c=qe.HEAPU32[a[u]>>2],h=qe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=qe.HEAPU32[a[u]>>2],f=qe.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let g=qe.HEAPU32[a[u]>>2],p=qe.HEAPU32.subarray(g>>2,(g>>2)+l[u]);u++;let m=qe.HEAPU32[a[u]>>2],v=qe.HEAPU32.subarray(m>>2,(m>>2)+l[u]);if(u++,n===void 0){let y=new De;if(y.setIndex(new Vs(v,1)),y.setAttribute("position",new Ae(h,3)),y.setAttribute("normal",new Ae(f,3)),e){y.setAttribute("faceMap",new Vs(p,1));let w=new Float32Array(f.length/3*4).fill(0);y.setAttribute("color",new Ge(w,4))}return qe.free_mesh_data(s),y.userData.type="SubdivGeometry",y}n.getAttribute("position").copyArray(h),n.getAttribute("normal").copyArray(f),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,qe.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=qe.get_wireframe_data_for_base_level(r),i=4,s=qe.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=qe.HEAPU32[s[a]>>2],u=qe.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let c=qe.HEAPU32[s[a]>>2],h=qe.HEAPU32.subarray(c>>2,(c>>2)+o[a]);if(e===void 0){let d=new De;d.setAttribute("position",new Ae(u,3));let f=new Float32Array(u.length);for(let g=0,p=u.length;g<p;)f[g++]=t.r,f[g++]=t.g,f[g++]=t.b;return d.setAttribute("color",new Ge(f,3)),d.setIndex(new Vs(h,1)),qe.free_wireframe_data_for_base_level(n),d}e.getAttribute("position").copyArray(u),e.attributes.position.needsUpdate=!0,qe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){let n=e===0;n||qe.set_destination_refinement_level(r,e);let i=t?qe.get_topological_data2(r,n?qe.Level.CONTROL:qe.Level.REFINED,t.elements):qe.get_topological_data(r,n?qe.Level.CONTROL:qe.Level.REFINED),s=6,o=qe.HEAPU32.subarray(i>>2,(i>>2)+s),a=o.subarray(3,3+3),l=0,u=qe.HEAPU32[o[l]>>2],c=new Float32Array(qe.HEAPF32.subarray(u>>2,(u>>2)+a[l]));l++;let h=qe.HEAPU32[o[l]>>2],d=new Uint32Array(qe.HEAPU32.subarray(h>>2,(h>>2)+a[l]));l++;let f=qe.HEAPU32[o[l]>>2],g=new Uint8Array(qe.HEAPU32.subarray(f>>2,(f>>2)+a[l]));return qe.free_topological_data(i),{positions:c,indices:d,verticesPerFace:g}}};var DT=["getX","getY","getZ"];function Mh(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,h="";for(let d=0;d<3;d++)h+=`${~~(r[DT[d]](c)*a)},`;if(h in t)s.push(t[h]);else{for(let d=0;d<3;d++)o.push(r[DT[d]](c));t[h]=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 tm=new A,o0=new A,a0=new A,l0=new A;function c0(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((h,d)=>Math.floor(d/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]){tm.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),o0.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),a0.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),l0.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),o0.sub(tm).normalize(),a0.sub(tm).normalize(),l0.sub(tm).normalize();let l=o0.cross(a0).dot(l0);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,h=0;c<r.length;c+=3,h++)r[c+2]===0&&(o.push(h),l++),r[c+2]===u&&a.push(h);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 mi={};IC(mi,{calcBoolean:()=>Yz,calcBooleanTopological:()=>Xz,freeMeshSet:()=>Kz,getMeshSet:()=>Qz,transformMeshSet:()=>Zz});var LT,OT=new Promise(r=>{LT=r}),IT=!1;async function RT(){if(IT)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.137/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});LT(s),IT=!0}var lt,Mc;OT.then(r=>lt=r);function qz(r,e,t){let n,{positions:i,triIndices:s}=Mh(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=c0(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let h=0;h<l[u];h++)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 NT(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=lt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(lt.HEAPU32.buffer,s,e):new Float32Array(lt.HEAPF32.buffer,s,e)).set(r,0),s}function BT(r){switch(r){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function Xz(r,e){Mc===void 0&&(Mc=lt.init_csg());let t=NT(r),n=lt.csg_calc_topological(Mc,t,r.length,BT(e));lt._free(t);let i=6,s=lt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=lt.HEAPU32[s[a]>>2],u=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=lt.HEAPU32[s[a]>>2],h=new Uint32Array(lt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=lt.HEAPU32[s[a]>>2],f=new Uint8Array(lt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return lt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:f}}function Yz(r,e,t,n){Mc===void 0&&(Mc=lt.init_csg());let i=NT(r),s=lt.csg_calc(Mc,i,r.length,n,BT(e));lt._free(i);let o=5,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=lt.HEAPU32[a[u]>>2],h=lt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=lt.HEAPU32[a[u]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let g=l[u];t.setAttribute("position",new Ae(h,3)),t.setAttribute("normal",new Ae(f,3));let p=lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Mn),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},lt.free_mesh_data(s),g}function Qz(r,e,t){if(lt===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let m=r.userData;s=m.verticesPerFace.length,n=m.positions,i=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+s);for(let v=0,y=0,w=0;v<m.verticesPerFace.length;v++){i[w++]=m.verticesPerFace[v];for(let b=0;b<m.verticesPerFace[v];b++)i[w++]=m.indices[y++]}}else({positions:n,faceIndices:i,nFaces:s}=qz(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,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=lt._malloc(c),g=new Float32Array(lt.HEAPF32.buffer,f,l),p=new Uint32Array(lt.HEAPU32.buffer,f+h,u);return g.set(n,0),p.set(i,0),lt.get_csg_mesh(f,o,f+h,a,s)}function Zz(r,e){lt.transform_csg_mesh(r,e.elements)}function Kz(r){lt.free_csg_mesh(r)}var u0={ConeGeometry:K_,CubeGeometry:J_,CylinderGeometry:Z_,DodecahedronGeometry:$_,EllipseGeometry:iT,HelixGeometry:lT,IcosahedronGeometry:cT,LatheGeometry:uT,NonParametricGeometry:hT,PolygonGeometry:dT,PyramidGeometry:fT,RectangleGeometry:pT,SphereGeometry:mT,PlaneGeometry:gT,BackdropGeometry:yT,StarGeometry:vT,TextFrameGeometry:xT,TorusGeometry:bT,TorusKnotGeometry:wT,TriangleGeometry:ST,VectorGeometry:Fn},Th=r=>u0[r.type].create(r);function Dn(r,e){return e.color(r)}var Zr=r=>"isEntity"in r,Ft=r=>"isAbstractMesh"in r,Vt=r=>r!==null&&r.objectType==="BooleanObject",FT=r=>r.objectType==="CombinedCamera",UT=r=>Zr(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var h0=r=>r.objectType==="EmptyObject",nm=r=>"objectHelper"in r;function d0(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??oo.identity)),t&&(r.updateMatrix(),Vt(r.parent)&&Ft(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function Jz(r,e){d0(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.visible=e.visible)}function GT(r,e,t){Jz(r,e),e.color!==void 0&&(r.color=Dn(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof Yo)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof Yo)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0)}function zT(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var rm=r=>class extends r{hasEntityChild(){return this.children.some(t=>Zr(t))}isDescendantOf(t){t instanceof ht&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Zr(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var Ec=new Mt,Kr=new A,ki=new A,Cc=new be,VT=[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)],$z=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],ek=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function tk(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t;c<n;c++){let h=e.getX(c),d=e.getY(c),f=e.getZ(c);h<i&&(i=h),d<s&&(s=d),f<o&&(o=f),h>a&&(a=h),d>l&&(l=d),f>u&&(u=f)}return r.min.set(i,s,o),r.max.set(a,l,u),r}var kT=(r,e,t)=>{if(Ft(r)){let n=r.geometry.userData.parameters,i=r.geometry.getAttribute("position"),s=r.geometry.userData.type;s==="SubdivGeometry"?Kr.copy(r.originalGeometry.boundingSphere.center):s==="TextGeometry"||Zl.is2DParametricMesh(s)?Kr.set(0,0,n.depth*.5):s==="ConeGeometry"||s==="CubeGeometry"||s==="CylinderGeometry"||s==="DodecahedronGeometry"||s==="HelixGeometry"||s==="IcosahedronGeometry"||s==="PyramidGeometry"||s==="SphereGeometry"||s==="PlaneGeometry"||s==="BackdropGeometry"||s==="TorusGeometry"||s==="TorusKnotGeometry"?Kr.set(0,0,0):i!==void 0&&(tk(Ec,i,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:i.count),Ec.getCenter(Kr)),r.forceComputeSize?Ec.getSize(ki).multiplyScalar(.5):ki.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}else if(nm(r)&&r.objectHelper.visible){let n=r.geometryHelper.getAttribute("position");Ec.setFromArray(n.array),Ec.getCenter(Kr),Ec.getSize(ki).multiplyScalar(.5)}else Kr.setScalar(0),ki.setScalar(0);Cc.copy(e).multiply(r.matrixWorld),ki.x===0&&ki.y===0&&ki.z===0?t.push(new A(Kr.x,Kr.y,Kr.z).applyMatrix4(Cc)):VT.forEach(n=>{t.push(n.clone().multiply(ki).add(Kr).applyMatrix4(Cc))})},Eh=class extends Mt{constructor(){super(...arguments);this.matrix=new be;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 be().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&&kT(o,n,s)}):kT(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(Cc.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(ki).multiplyScalar(.5),this.getCenter(Kr),Cc.copy(this.matrix).setPosition(Kr),this.vertices=VT.map(t=>t.clone().multiply(ki).applyMatrix4(Cc))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=$z.map(([t,n])=>new gn(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=ek.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Vi=r=>"isEntity"in r,HT=r=>"isAbstractMesh"in r,Jr=r=>class extends rm(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new be;this._singleBBox=new Eh;this._recursiveBBox=new Eh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1;this.currentState=null;this.currentTransitionAction=null}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{Vi(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)Vi(i)&&i.traverseEntity(n)}traverseVisibleEntity(n){n(this);for(let i of this.children)Vi(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.dispatchEvent({type:"updateMatrix"})}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)}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)Vi(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)Vi(s)&&s.hiddenMatrix.premultiply(n)}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 kl(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return kl(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visible=n.visible),this.fromObjectTransformState(n),this}};var Ch=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 In=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Be.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 In&&(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 f0=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}},wn=new f0;var ke=class extends In{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=Be.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 Ot=class extends ke{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 Ln=class extends Ot{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof B?t:new B(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 Un=class extends Ot{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 Le{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 $r=class extends Ot{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 nk=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,WT=/[a-z_0-9]+/gi,Me=class extends ke{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 h=0;h<this.includes.length;h++)t.include(this.includes[h],this);for(let h in this.extensions)t.extensions[h]=!0;let c=[];for(;a=WT.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],g=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&g&&wn.containsKeyword(f)){let m=this.keywords[f];if(!m){let v=wn.getKeywordData(f);v.cache&&(m=t.keywords[f]),m=m||wn.getKeyword(f,t),v.cache&&(t.keywords[f]=m)}p=m.build(t)}f!==p&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+p+u.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&wn.contains(p)&&t.include(wn.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=nk.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(WT);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 h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var rk=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,p0=class extends ke{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||p0.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=rk.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)}},ft=p0;ft.PI="PI",ft.PI2="PI2",ft.RECIPROCAL_PI="RECIPROCAL_PI",ft.RECIPROCAL_PI2="RECIPROCAL_PI2",ft.LOG2="LOG2",ft.EPSILON="EPSILON";var ik=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 TT,$p=new Promise(r=>{TT=r}),_T=!1;async function MT(){if(_T)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.138/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});TT(s),_T=!0}function em(r,e){return jz(r)}function jz(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=gt.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new ul().parse(r));let t;try{t=Th(e)}catch(n){console.error(n)}if(!t){let n=gt.createFromState(Ql.defaultData(),100,100);e.shape=n,t=Th(e)}return t}var qe;$p.then(r=>{qe=r});var ET=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),CT=new Uint32Array([0,1,2,3]),PT=new Uint8Array([4]),Qr=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(qe.free_bvh(t),qe.free_subdivision_surface(t));try{s=Qr.allocate(r,i)}catch(u){console.error(u,r),s=Qr.allocate({positionWASM:ET,indexWASM:CT,verticesPerFaceWASM:PT},i)}qe.set_destination_refinement_level(s,0),o=Qr.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=Qr.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(qe.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=Qr.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:em(r),n,i,s,o;({positions:n,triIndices:o}=Mh(t.getAttribute("position"),t.getIndex()));let a;if(r.type==="CylinderGeometry"&&r.cornerRadius===0&&r.hollow===0&&r.openEnded===!1){let l=r.radialSegments*r.heightSegments*3*2,u=l+r.radialSegments*3;a=[l,u]}return{indices:i,verticesPerFace:s}=c0(n,o,t,a),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=ET,n=CT,i=PT);let a=t.length,l=n.length,u=i.length,c=t.length+s.length+o.length,h=n.length+i.length,d=c*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,f=c*Float32Array.BYTES_PER_ELEMENT,g=h*Uint32Array.BYTES_PER_ELEMENT,p=qe._malloc(d),m=new Float32Array(qe.HEAPF32.buffer,p,c),v=new Uint32Array(qe.HEAPU32.buffer,p+f,h);m.set(t,0),m.set(s,t.length),m.set(o,t.length+s.length),v.set(n,0),v.set(i,n.length);let y;r?.scaleBaked?.some(b=>b!==1)&&(y=new be().makeScale(...r.scaleBaked)),e&&(y?y.premultiply(e):y=e);let w=y?qe.alloc_subdivision_surface2(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u,y.elements):qe.alloc_subdivision_surface(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u);return qe._free(p),w}static buildLevel(r,e,t,n,i){let s=i?qe.get_mesh_data2(r,e?qe.Level.CONTROL:qe.Level.REFINED,t,i.elements):qe.get_mesh_data(r,e?qe.Level.CONTROL:qe.Level.REFINED,t),o=8,a=qe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),u=0,c=qe.HEAPU32[a[u]>>2],h=qe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=qe.HEAPU32[a[u]>>2],f=qe.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let g=qe.HEAPU32[a[u]>>2],p=qe.HEAPU32.subarray(g>>2,(g>>2)+l[u]);u++;let m=qe.HEAPU32[a[u]>>2],v=qe.HEAPU32.subarray(m>>2,(m>>2)+l[u]);if(u++,n===void 0){let y=new De;if(y.setIndex(new Vs(v,1)),y.setAttribute("position",new Ae(h,3)),y.setAttribute("normal",new Ae(f,3)),e){y.setAttribute("faceMap",new Vs(p,1));let w=new Float32Array(f.length/3*4).fill(0);y.setAttribute("color",new Ge(w,4))}return qe.free_mesh_data(s),y.userData.type="SubdivGeometry",y}n.getAttribute("position").copyArray(h),n.getAttribute("normal").copyArray(f),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,qe.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=qe.get_wireframe_data_for_base_level(r),i=4,s=qe.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=qe.HEAPU32[s[a]>>2],u=qe.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let c=qe.HEAPU32[s[a]>>2],h=qe.HEAPU32.subarray(c>>2,(c>>2)+o[a]);if(e===void 0){let d=new De;d.setAttribute("position",new Ae(u,3));let f=new Float32Array(u.length);for(let g=0,p=u.length;g<p;)f[g++]=t.r,f[g++]=t.g,f[g++]=t.b;return d.setAttribute("color",new Ge(f,3)),d.setIndex(new Vs(h,1)),qe.free_wireframe_data_for_base_level(n),d}e.getAttribute("position").copyArray(u),e.attributes.position.needsUpdate=!0,qe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){let n=e===0;n||qe.set_destination_refinement_level(r,e);let i=t?qe.get_topological_data2(r,n?qe.Level.CONTROL:qe.Level.REFINED,t.elements):qe.get_topological_data(r,n?qe.Level.CONTROL:qe.Level.REFINED),s=6,o=qe.HEAPU32.subarray(i>>2,(i>>2)+s),a=o.subarray(3,3+3),l=0,u=qe.HEAPU32[o[l]>>2],c=new Float32Array(qe.HEAPF32.subarray(u>>2,(u>>2)+a[l]));l++;let h=qe.HEAPU32[o[l]>>2],d=new Uint32Array(qe.HEAPU32.subarray(h>>2,(h>>2)+a[l]));l++;let f=qe.HEAPU32[o[l]>>2],g=new Uint8Array(qe.HEAPU32.subarray(f>>2,(f>>2)+a[l]));return qe.free_topological_data(i),{positions:c,indices:d,verticesPerFace:g}}};var DT=["getX","getY","getZ"];function Mh(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,h="";for(let d=0;d<3;d++)h+=`${~~(r[DT[d]](c)*a)},`;if(h in t)s.push(t[h]);else{for(let d=0;d<3;d++)o.push(r[DT[d]](c));t[h]=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 tm=new A,o0=new A,a0=new A,l0=new A;function c0(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((h,d)=>Math.floor(d/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]){tm.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),o0.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),a0.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),l0.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),o0.sub(tm).normalize(),a0.sub(tm).normalize(),l0.sub(tm).normalize();let l=o0.cross(a0).dot(l0);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,h=0;c<r.length;c+=3,h++)r[c+2]===0&&(o.push(h),l++),r[c+2]===u&&a.push(h);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 mi={};IC(mi,{calcBoolean:()=>Yz,calcBooleanTopological:()=>Xz,freeMeshSet:()=>Kz,getMeshSet:()=>Qz,transformMeshSet:()=>Zz});var LT,OT=new Promise(r=>{LT=r}),IT=!1;async function RT(){if(IT)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.138/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});LT(s),IT=!0}var lt,Mc;OT.then(r=>lt=r);function qz(r,e,t){let n,{positions:i,triIndices:s}=Mh(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=c0(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let h=0;h<l[u];h++)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 NT(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=lt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(lt.HEAPU32.buffer,s,e):new Float32Array(lt.HEAPF32.buffer,s,e)).set(r,0),s}function BT(r){switch(r){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function Xz(r,e){Mc===void 0&&(Mc=lt.init_csg());let t=NT(r),n=lt.csg_calc_topological(Mc,t,r.length,BT(e));lt._free(t);let i=6,s=lt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=lt.HEAPU32[s[a]>>2],u=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=lt.HEAPU32[s[a]>>2],h=new Uint32Array(lt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=lt.HEAPU32[s[a]>>2],f=new Uint8Array(lt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return lt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:f}}function Yz(r,e,t,n){Mc===void 0&&(Mc=lt.init_csg());let i=NT(r),s=lt.csg_calc(Mc,i,r.length,n,BT(e));lt._free(i);let o=5,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=lt.HEAPU32[a[u]>>2],h=lt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=lt.HEAPU32[a[u]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let g=l[u];t.setAttribute("position",new Ae(h,3)),t.setAttribute("normal",new Ae(f,3));let p=lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Mn),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},lt.free_mesh_data(s),g}function Qz(r,e,t){if(lt===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let m=r.userData;s=m.verticesPerFace.length,n=m.positions,i=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+s);for(let v=0,y=0,w=0;v<m.verticesPerFace.length;v++){i[w++]=m.verticesPerFace[v];for(let b=0;b<m.verticesPerFace[v];b++)i[w++]=m.indices[y++]}}else({positions:n,faceIndices:i,nFaces:s}=qz(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,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=lt._malloc(c),g=new Float32Array(lt.HEAPF32.buffer,f,l),p=new Uint32Array(lt.HEAPU32.buffer,f+h,u);return g.set(n,0),p.set(i,0),lt.get_csg_mesh(f,o,f+h,a,s)}function Zz(r,e){lt.transform_csg_mesh(r,e.elements)}function Kz(r){lt.free_csg_mesh(r)}var u0={ConeGeometry:K_,CubeGeometry:J_,CylinderGeometry:Z_,DodecahedronGeometry:$_,EllipseGeometry:iT,HelixGeometry:lT,IcosahedronGeometry:cT,LatheGeometry:uT,NonParametricGeometry:hT,PolygonGeometry:dT,PyramidGeometry:fT,RectangleGeometry:pT,SphereGeometry:mT,PlaneGeometry:gT,BackdropGeometry:yT,StarGeometry:vT,TextFrameGeometry:xT,TorusGeometry:bT,TorusKnotGeometry:wT,TriangleGeometry:ST,VectorGeometry:Fn},Th=r=>u0[r.type].create(r);function Dn(r,e){return e.color(r)}var Zr=r=>"isEntity"in r,Ft=r=>"isAbstractMesh"in r,Vt=r=>r!==null&&r.objectType==="BooleanObject",FT=r=>r.objectType==="CombinedCamera",UT=r=>Zr(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var h0=r=>r.objectType==="EmptyObject",nm=r=>"objectHelper"in r;function d0(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??oo.identity)),t&&(r.updateMatrix(),Vt(r.parent)&&Ft(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function Jz(r,e){d0(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.visible=e.visible)}function GT(r,e,t){Jz(r,e),e.color!==void 0&&(r.color=Dn(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof Yo)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof Yo)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0)}function zT(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var rm=r=>class extends r{hasEntityChild(){return this.children.some(t=>Zr(t))}isDescendantOf(t){t instanceof ht&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Zr(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var Ec=new Mt,Kr=new A,ki=new A,Cc=new be,VT=[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)],$z=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],ek=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function tk(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t;c<n;c++){let h=e.getX(c),d=e.getY(c),f=e.getZ(c);h<i&&(i=h),d<s&&(s=d),f<o&&(o=f),h>a&&(a=h),d>l&&(l=d),f>u&&(u=f)}return r.min.set(i,s,o),r.max.set(a,l,u),r}var kT=(r,e,t)=>{if(Ft(r)){let n=r.geometry.userData.parameters,i=r.geometry.getAttribute("position"),s=r.geometry.userData.type;s==="SubdivGeometry"?Kr.copy(r.originalGeometry.boundingSphere.center):s==="TextGeometry"||Zl.is2DParametricMesh(s)?Kr.set(0,0,n.depth*.5):s==="ConeGeometry"||s==="CubeGeometry"||s==="CylinderGeometry"||s==="DodecahedronGeometry"||s==="HelixGeometry"||s==="IcosahedronGeometry"||s==="PyramidGeometry"||s==="SphereGeometry"||s==="PlaneGeometry"||s==="BackdropGeometry"||s==="TorusGeometry"||s==="TorusKnotGeometry"?Kr.set(0,0,0):i!==void 0&&(tk(Ec,i,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:i.count),Ec.getCenter(Kr)),r.forceComputeSize?Ec.getSize(ki).multiplyScalar(.5):ki.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}else if(nm(r)&&r.objectHelper.visible){let n=r.geometryHelper.getAttribute("position");Ec.setFromArray(n.array),Ec.getCenter(Kr),Ec.getSize(ki).multiplyScalar(.5)}else Kr.setScalar(0),ki.setScalar(0);Cc.copy(e).multiply(r.matrixWorld),ki.x===0&&ki.y===0&&ki.z===0?t.push(new A(Kr.x,Kr.y,Kr.z).applyMatrix4(Cc)):VT.forEach(n=>{t.push(n.clone().multiply(ki).add(Kr).applyMatrix4(Cc))})},Eh=class extends Mt{constructor(){super(...arguments);this.matrix=new be;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 be().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&&kT(o,n,s)}):kT(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(Cc.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(ki).multiplyScalar(.5),this.getCenter(Kr),Cc.copy(this.matrix).setPosition(Kr),this.vertices=VT.map(t=>t.clone().multiply(ki).applyMatrix4(Cc))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=$z.map(([t,n])=>new gn(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=ek.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Vi=r=>"isEntity"in r,HT=r=>"isAbstractMesh"in r,Jr=r=>class extends rm(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new be;this._singleBBox=new Eh;this._recursiveBBox=new Eh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1;this.currentState=null;this.currentTransitionAction=null}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{Vi(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)Vi(i)&&i.traverseEntity(n)}traverseVisibleEntity(n){n(this);for(let i of this.children)Vi(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.dispatchEvent({type:"updateMatrix"})}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)}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)Vi(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)Vi(s)&&s.hiddenMatrix.premultiply(n)}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 kl(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return kl(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visible=n.visible),this.fromObjectTransformState(n),this}};var Ch=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 In=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Be.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 In&&(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 f0=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}},wn=new f0;var ke=class extends In{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=Be.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 Ot=class extends ke{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 Ln=class extends Ot{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof B?t:new B(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 Un=class extends Ot{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 Le{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 $r=class extends Ot{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 nk=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,WT=/[a-z_0-9]+/gi,Me=class extends ke{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 h=0;h<this.includes.length;h++)t.include(this.includes[h],this);for(let h in this.extensions)t.extensions[h]=!0;let c=[];for(;a=WT.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],g=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&g&&wn.containsKeyword(f)){let m=this.keywords[f];if(!m){let v=wn.getKeywordData(f);v.cache&&(m=t.keywords[f]),m=m||wn.getKeyword(f,t),v.cache&&(t.keywords[f]=m)}p=m.build(t)}f!==p&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+p+u.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&wn.contains(p)&&t.include(wn.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=nk.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(WT);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 h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var rk=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,p0=class extends ke{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||p0.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=rk.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)}},ft=p0;ft.PI="PI",ft.PI2="PI2",ft.RECIPROCAL_PI="RECIPROCAL_PI",ft.RECIPROCAL_PI2="RECIPROCAL_PI2",ft.LOG2="LOG2",ft.EPSILON="EPSILON";var ik=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3140
3140
|
)*?)}`,"gim"),sk=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Pc=class extends ke{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=ik.exec(t);if(n){let i=n[2],s;for(;s=sk.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Dc=class extends ke{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)}};wn.addKeyword("uv",function(){return new Dc});wn.addKeyword("uv2",function(){return new Dc(1)});var pa=class extends ke{constructor(t,n){super("v4");this.nodeType="ColorSpace";this.input=t,this.method=n??pa.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(t){switch(t){case Er:return["Linear"];case Xe:return["sRGB"];default:return[]}}generate(t,n){let i=this.input.build(t,"v4"),s=this.getType(t),o=pa.Nodes[this.method],a=t.include(o);if(a===pa.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=pa.getEncodingComponents(t);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(t){let n=pa.getEncodingComponents(t);this.method=n[0]+"ToLinear",this.factor=n[1]}},lr=pa;lr.Nodes={LinearToLinear:new Me(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3141
3141
|
`)),sRGBToLinear:new Me(["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 Me(["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(`
|