@splinetool/viewer 0.9.339 → 0.9.341
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/spline-viewer.cjs
CHANGED
|
@@ -3137,7 +3137,7 @@ void main() {
|
|
|
3137
3137
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3138
3138
|
}`;function bD(e,t,i){let r=new _g,s=new G,n=new G,a=new $e,o=new Xb({depthPacking:Rb}),l=new yD,h={},d=i.maxTextureSize,c={[Qr]:di,[di]:Qr,[sr]:sr},u=new ni({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new G},radius:{value:4}},vertexShader:xD,fragmentShader:wD}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new He;f.setAttribute("position",new Ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new nr(f,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yg,this.render=function(w,_,S){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let A=e.getRenderTarget(),b=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(yi),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,P=w.length;T<P;T++){let O=w[T],D=O.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;s.copy(D.mapSize);let N=D.getFrameExtents();if(s.multiply(N),n.copy(D.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(n.x=Math.floor(d/N.x),s.x=n.x*N.x,D.mapSize.x=n.x),s.y>d&&(n.y=Math.floor(d/N.y),s.y=n.y*N.y,D.mapSize.y=n.y)),D.map===null){let q=this.type!==Ql?{minFilter:Bt,magFilter:Bt}:{};D.map=new si(s.x,s.y,q),D.map.texture.name=O.name+".shadowMap",D.camera.updateProjectionMatrix()}e.setRenderTarget(D.map),e.clear();let W=D.getViewportCount();for(let q=0;q<W;q++){let z=D.getViewport(q);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),D.updateMatrices(O,q),r=D.getFrustum(),x(_,S,D.camera,O,this.type)}D.isPointLightShadow!==!0&&this.type===Ql&&v(D,S),D.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(A,b,M)};function v(w,_){let S=t.update(m);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new si(s.x,s.y)),u.uniforms.shadow_pass.value=w.map.texture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,e.setRenderTarget(w.mapPass),e.clear(),e.renderBufferDirect(_,null,S,u,m,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,e.setRenderTarget(w.map),e.clear(),e.renderBufferDirect(_,null,S,p,m,null)}function y(w,_,S,A,b,M){let C=null,T=S.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(T!==void 0)C=T;else if(C=S.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let P=C.uuid,O=_.uuid,D=h[P];D===void 0&&(D={},h[P]=D);let N=D[O];N===void 0&&(N=C.clone(),D[O]=N),C=N}return C.visible=_.visible,C.wireframe=_.wireframe,M===Ql?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:c[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,S.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(S.matrixWorld),C.nearDistance=A,C.farDistance=b),C}function x(w,_,S,A,b){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===Ql)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,w.matrixWorld);let C=t.update(w),T=w.material;if(Array.isArray(T)){let P=C.groups;for(let O=0,D=P.length;O<D;O++){let N=P[O],W=T[N.materialIndex];if(W&&W.visible){let q=y(w,W,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,q,w,N)}}}else if(T.visible){let P=y(w,T,A,S.near,S.far,b);e.renderBufferDirect(S,null,C,P,w,null)}}let M=w.children;for(let C=0,T=M.length;C<T;C++)x(M[C],_,S,A,b)}}function _D(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,se=new $e,ue=null,ye=new $e(0,0,0,0);return{setMask:function(Ue){ue!==Ue&&!Y&&(e.colorMask(Ue,Ue,Ue,Ue),ue=Ue)},setLocked:function(Ue){Y=Ue},setClear:function(Ue,dt,Rt,bi,Yn){Yn===!0&&(Ue*=bi,dt*=bi,Rt*=bi),se.set(Ue,dt,Rt,bi),ye.equals(se)===!1&&(e.clearColor(Ue,dt,Rt,bi),ye.copy(se))},reset:function(){Y=!1,ue=null,ye.set(-1,0,0,0)}}}function n(){let Y=!1,se=null,ue=null,ye=null;return{setTest:function(Ue){Ue?ne(2929):j(2929)},setMask:function(Ue){se!==Ue&&!Y&&(e.depthMask(Ue),se=Ue)},setFunc:function(Ue){if(ue!==Ue){switch(Ue){case GM:e.depthFunc(512);break;case VM:e.depthFunc(519);break;case HM:e.depthFunc(513);break;case Zf:e.depthFunc(515);break;case WM:e.depthFunc(514);break;case qM:e.depthFunc(518);break;case XM:e.depthFunc(516);break;case YM:e.depthFunc(517);break;default:e.depthFunc(515)}ue=Ue}},setLocked:function(Ue){Y=Ue},setClear:function(Ue){ye!==Ue&&(e.clearDepth(Ue),ye=Ue)},reset:function(){Y=!1,se=null,ue=null,ye=null}}}function a(){let Y=!1,se=null,ue=null,ye=null,Ue=null,dt=null,Rt=null,bi=null,Yn=null;return{setTest:function(Ot){Y||(Ot?ne(2960):j(2960))},setMask:function(Ot){se!==Ot&&!Y&&(e.stencilMask(Ot),se=Ot)},setFunc:function(Ot,Rs,dr){(ue!==Ot||ye!==Rs||Ue!==dr)&&(e.stencilFunc(Ot,Rs,dr),ue=Ot,ye=Rs,Ue=dr)},setOp:function(Ot,Rs,dr){(dt!==Ot||Rt!==Rs||bi!==dr)&&(e.stencilOp(Ot,Rs,dr),dt=Ot,Rt=Rs,bi=dr)},setLocked:function(Ot){Y=Ot},setClear:function(Ot){Yn!==Ot&&(e.clearStencil(Ot),Yn=Ot)},reset:function(){Y=!1,se=null,ue=null,ye=null,Ue=null,dt=null,Rt=null,bi=null,Yn=null}}}let o=new s,l=new n,h=new a,d=new WeakMap,c=new WeakMap,u={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,M=!1,C=null,T=null,P=null,O=null,D=null,N=e.getParameter(35661),W=!1,q=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(z)[1]),W=q>=1):z.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),W=q>=2);let V=null,k={},U=e.getParameter(3088),B=e.getParameter(2978),H=new $e().fromArray(U),X=new $e().fromArray(B);function Z(Y,se,ue){let ye=new Uint8Array(4),Ue=e.createTexture();e.bindTexture(Y,Ue),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let dt=0;dt<ue;dt++)e.texImage2D(se+dt,0,6408,1,1,0,6408,5121,ye);return Ue}let F={};F[3553]=Z(3553,3553,1),F[34067]=Z(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ne(2929),l.setFunc(Zf),Te(!1),we(u0),ne(2884),de(yi);function ne(Y){u[Y]!==!0&&(e.enable(Y),u[Y]=!0)}function j(Y){u[Y]!==!1&&(e.disable(Y),u[Y]=!1)}function $(Y,se){return p[Y]!==se?(e.bindFramebuffer(Y,se),p[Y]=se,r&&(Y===36009&&(p[36160]=se),Y===36160&&(p[36009]=se)),!0):!1}function Q(Y,se){let ue=m,ye=!1;if(Y)if(ue=f.get(se),ue===void 0&&(ue=[],f.set(se,ue)),Y.isWebGLMultipleRenderTargets){let Ue=Y.texture;if(ue.length!==Ue.length||ue[0]!==36064){for(let dt=0,Rt=Ue.length;dt<Rt;dt++)ue[dt]=36064+dt;ue.length=Ue.length,ye=!0}}else ue[0]!==36064&&(ue[0]=36064,ye=!0);else ue[0]!==1029&&(ue[0]=1029,ye=!0);ye&&(i.isWebGL2?e.drawBuffers(ue):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ue))}function me(Y){return g!==Y?(e.useProgram(Y),g=Y,!0):!1}let re={[vo]:32774,[OM]:32778,[LM]:32779};if(r)re[g0]=32775,re[v0]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(re[g0]=Y.MIN_EXT,re[v0]=Y.MAX_EXT)}let oe={[IM]:0,[RM]:1,[BM]:768,[Pb]:770,[jM]:776,[FM]:774,[zM]:772,[NM]:769,[Db]:771,[kM]:775,[UM]:773};function de(Y,se,ue,ye,Ue,dt,Rt,bi){if(Y===yi){v===!0&&(j(3042),v=!1);return}if(v===!1&&(ne(3042),v=!0),Y!==DM){if(Y!==y||bi!==M){if((x!==vo||S!==vo)&&(e.blendEquation(32774),x=vo,S=vo),bi)switch(Y){case Lo:e.blendFuncSeparate(1,771,1,771);break;case p0:e.blendFunc(1,1);break;case f0:e.blendFuncSeparate(0,769,0,1);break;case m0:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Lo:e.blendFuncSeparate(770,771,1,771);break;case p0:e.blendFunc(770,1);break;case f0:e.blendFuncSeparate(0,769,0,1);break;case m0:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}w=null,_=null,A=null,b=null,y=Y,M=bi}return}Ue=Ue||se,dt=dt||ue,Rt=Rt||ye,(se!==x||Ue!==S)&&(e.blendEquationSeparate(re[se],re[Ue]),x=se,S=Ue),(ue!==w||ye!==_||dt!==A||Rt!==b)&&(e.blendFuncSeparate(oe[ue],oe[ye],oe[dt],oe[Rt]),w=ue,_=ye,A=dt,b=Rt),y=Y,M=!1}function xe(Y,se){Y.side===sr?j(2884):ne(2884);let ue=Y.side===di;se&&(ue=!ue),Te(ue),Y.blending===Lo&&Y.transparent===!1?de(yi):de(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),o.setMask(Y.colorWrite);let ye=Y.stencilWrite;h.setTest(ye),ye&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),Re(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ne(32926):j(32926)}function Te(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function we(Y){Y!==TM?(ne(2884),Y!==T&&(Y===u0?e.cullFace(1029):Y===PM?e.cullFace(1028):e.cullFace(1032))):j(2884),T=Y}function be(Y){Y!==P&&(W&&e.lineWidth(Y),P=Y)}function Re(Y,se,ue){Y?(ne(32823),(O!==se||D!==ue)&&(e.polygonOffset(se,ue),O=se,D=ue)):j(32823)}function We(Y){Y?ne(3089):j(3089)}function ot(Y){Y===void 0&&(Y=33984+N-1),V!==Y&&(e.activeTexture(Y),V=Y)}function I(Y,se,ue){ue===void 0&&(V===null?ue=33984+N-1:ue=V);let ye=k[ue];ye===void 0&&(ye={type:void 0,texture:void 0},k[ue]=ye),(ye.type!==Y||ye.texture!==se)&&(V!==ue&&(e.activeTexture(ue),V=ue),e.bindTexture(Y,se||F[Y]),ye.type=Y,ye.texture=se)}function L(){let Y=k[V];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ie(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function pe(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function fe(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function _e(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function qe(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Se(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ce(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Me(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ge(Y){H.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),H.copy(Y))}function Ne(Y){X.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),X.copy(Y))}function lt(Y,se){let ue=c.get(se);ue===void 0&&(ue=new WeakMap,c.set(se,ue));let ye=ue.get(Y);ye===void 0&&(ye=e.getUniformBlockIndex(se,Y.name),ue.set(Y,ye))}function Ct(Y,se){let ue=c.get(se).get(Y);d.get(se)!==ue&&(e.uniformBlockBinding(se,ue,Y.__bindingPointIndex),d.set(se,ue))}function qt(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),u={},V=null,k={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,w=null,_=null,S=null,A=null,b=null,M=!1,C=null,T=null,P=null,O=null,D=null,H.set(0,0,e.canvas.width,e.canvas.height),X.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ne,disable:j,bindFramebuffer:$,drawBuffers:Q,useProgram:me,setBlending:de,setMaterial:xe,setFlipSided:Te,setCullFace:we,setLineWidth:be,setPolygonOffset:Re,setScissorTest:We,activeTexture:ot,bindTexture:I,unbindTexture:L,compressedTexImage2D:ie,compressedTexImage3D:pe,texImage2D:De,texImage3D:Ee,updateUBOMapping:lt,uniformBlockBinding:Ct,texStorage2D:ce,texStorage3D:Me,texSubImage2D:fe,texSubImage3D:_e,compressedTexSubImage2D:qe,compressedTexSubImage3D:Se,scissor:Ge,viewport:Ne,reset:qt}}function SD(e,t,i,r,s,n,a){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,d=s.maxTextureSize,c=s.maxSamples,u=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,m,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(I,L){return v?new OffscreenCanvas(I,L):Td("canvas")}function x(I,L,ie,pe){let fe=1;if((I.width>pe||I.height>pe)&&(fe=pe/Math.max(I.width,I.height)),fe<1||L===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){let _e=L?Cd:Math.floor,qe=_e(fe*I.width),Se=_e(fe*I.height);m===void 0&&(m=y(qe,Se));let ce=ie?y(qe,Se):m;return ce.width=qe,ce.height=Se,ce.getContext("2d").drawImage(I,0,0,qe,Se),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+qe+"x"+Se+")."),ce}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function w(I){return tm(I.width)&&tm(I.height)}function _(I){return o?!1:I.wrapS!==ir||I.wrapT!==ir||I.minFilter!==Bt&&I.minFilter!==gt}function S(I,L){return I.generateMipmaps&&L&&I.minFilter!==Bt&&I.minFilter!==gt}function A(I){e.generateMipmap(I)}function b(I,L,ie,pe,fe=!1){if(o===!1)return L;if(I!==null){if(e[I]!==void 0)return e[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let _e=L;return L===6403&&(ie===5126&&(_e=33326),ie===5131&&(_e=33325),ie===5121&&(_e=33321)),L===33319&&(ie===5126&&(_e=33328),ie===5131&&(_e=33327),ie===5121&&(_e=33323)),L===6408&&(ie===5126&&(_e=34836),ie===5131&&(_e=34842),ie===5121&&(_e=pe===Ke&&fe===!1?35907:32856),ie===32819&&(_e=32854),ie===32820&&(_e=32855)),(_e===33325||_e===33326||_e===33327||_e===33328||_e===34842||_e===34836)&&t.get("EXT_color_buffer_float"),_e}function M(I,L,ie){return S(I,ie)===!0||I.isFramebufferTexture&&I.minFilter!==Bt&&I.minFilter!==gt?Math.log2(Math.max(L.width,L.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?L.mipmaps.length:1}function C(I){return I===Bt||I===y0||I===rp?9728:9729}function T(I){let L=I.target;L.removeEventListener("dispose",T),O(L),L.isVideoTexture&&f.delete(L)}function P(I){let L=I.target;L.removeEventListener("dispose",P),N(L)}function O(I){let L=r.get(I);if(L.__webglInit===void 0)return;let ie=I.source,pe=g.get(ie);if(pe){let fe=pe[L.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&D(I),Object.keys(pe).length===0&&g.delete(ie)}r.remove(I)}function D(I){let L=r.get(I);e.deleteTexture(L.__webglTexture);let ie=I.source,pe=g.get(ie);delete pe[L.__cacheKey],a.memory.textures--}function N(I){let L=I.texture,ie=r.get(I),pe=r.get(L);if(pe.__webglTexture!==void 0&&(e.deleteTexture(pe.__webglTexture),a.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let fe=0;fe<6;fe++)e.deleteFramebuffer(ie.__webglFramebuffer[fe]),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer[fe]);else{if(e.deleteFramebuffer(ie.__webglFramebuffer),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let fe=0;fe<ie.__webglColorRenderbuffer.length;fe++)ie.__webglColorRenderbuffer[fe]&&e.deleteRenderbuffer(ie.__webglColorRenderbuffer[fe]);ie.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ie.__webglDepthRenderbuffer)}if(I.isWebGLMultipleRenderTargets)for(let fe=0,_e=L.length;fe<_e;fe++){let qe=r.get(L[fe]);qe.__webglTexture&&(e.deleteTexture(qe.__webglTexture),a.memory.textures--),r.remove(L[fe])}r.remove(L),r.remove(I)}let W=0;function q(){W=0}function z(){let I=W;return I>=l&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l),W+=1,I}function V(I){let L=[];return L.push(I.wrapS),L.push(I.wrapT),L.push(I.wrapR||0),L.push(I.magFilter),L.push(I.minFilter),L.push(I.anisotropy),L.push(I.internalFormat),L.push(I.format),L.push(I.type),L.push(I.generateMipmaps),L.push(I.premultiplyAlpha),L.push(I.flipY),L.push(I.unpackAlignment),L.push(I.encoding),L.join()}function k(I,L){let ie=r.get(I);if(I.isVideoTexture&&We(I),I.isRenderTargetTexture===!1&&I.version>0&&ie.__version!==I.version){let pe=I.image;if(pe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{j(ie,I,L);return}}i.bindTexture(3553,ie.__webglTexture,33984+L)}function U(I,L){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){j(ie,I,L);return}i.bindTexture(35866,ie.__webglTexture,33984+L)}function B(I,L){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){j(ie,I,L);return}i.bindTexture(32879,ie.__webglTexture,33984+L)}function H(I,L){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){$(ie,I,L);return}i.bindTexture(34067,ie.__webglTexture,33984+L)}let X={[xh]:10497,[ir]:33071,[Jf]:33648},Z={[Bt]:9728,[y0]:9984,[rp]:9986,[gt]:9729,[iE]:9985,[Ho]:9987};function F(I,L,ie){if(ie?(e.texParameteri(I,10242,X[L.wrapS]),e.texParameteri(I,10243,X[L.wrapT]),(I===32879||I===35866)&&e.texParameteri(I,32882,X[L.wrapR]),e.texParameteri(I,10240,Z[L.magFilter]),e.texParameteri(I,10241,Z[L.minFilter])):(e.texParameteri(I,10242,33071),e.texParameteri(I,10243,33071),(I===32879||I===35866)&&e.texParameteri(I,32882,33071),(L.wrapS!==ir||L.wrapT!==ir)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(I,10240,C(L.magFilter)),e.texParameteri(I,10241,C(L.minFilter)),L.minFilter!==Bt&&L.minFilter!==gt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let pe=t.get("EXT_texture_filter_anisotropic");if(L.magFilter===Bt||L.minFilter!==rp&&L.minFilter!==Ho||L.type===Pn&&t.has("OES_texture_float_linear")===!1||o===!1&&L.type===wh&&t.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(e.texParameterf(I,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,s.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function ne(I,L){let ie=!1;I.__webglInit===void 0&&(I.__webglInit=!0,L.addEventListener("dispose",T));let pe=L.source,fe=g.get(pe);fe===void 0&&(fe={},g.set(pe,fe));let _e=V(L);if(_e!==I.__cacheKey){fe[_e]===void 0&&(fe[_e]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),fe[_e].usedTimes++;let qe=fe[I.__cacheKey];qe!==void 0&&(fe[I.__cacheKey].usedTimes--,qe.usedTimes===0&&D(L)),I.__cacheKey=_e,I.__webglTexture=fe[_e].texture}return ie}function j(I,L,ie){let pe=3553;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(pe=35866),L.isData3DTexture&&(pe=32879);let fe=ne(I,L),_e=L.source;i.bindTexture(pe,I.__webglTexture,33984+ie);let qe=r.get(_e);if(_e.version!==qe.__version||fe===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,L.flipY),e.pixelStorei(37441,L.premultiplyAlpha),e.pixelStorei(3317,L.unpackAlignment),e.pixelStorei(37443,0);let Se=_(L)&&w(L.image)===!1,ce=x(L.image,Se,!1,d);ce=ot(L,ce);let Me=w(ce)||o,De=n.convert(L.format,L.encoding),Ee=n.convert(L.type),Ge=b(L.internalFormat,De,Ee,L.encoding,L.isVideoTexture);F(pe,L,Me);let Ne,lt=L.mipmaps,Ct=o&&L.isVideoTexture!==!0,qt=qe.__version===void 0||fe===!0,Y=M(L,ce,Me);if(L.isDepthTexture)Ge=6402,o?L.type===Pn?Ge=36012:L.type===Tn?Ge=33190:L.type===xa?Ge=35056:Ge=33189:L.type===Pn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===wa&&Ge===6402&&L.type!==Ib&&L.type!==Tn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Tn,Ee=n.convert(L.type)),L.format===Pa&&Ge===6402&&(Ge=34041,L.type!==xa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=xa,Ee=n.convert(L.type))),qt&&(Ct?i.texStorage2D(3553,1,Ge,ce.width,ce.height):i.texImage2D(3553,0,Ge,ce.width,ce.height,0,De,Ee,null));else if(L.isDataTexture)if(lt.length>0&&Me){Ct&&qt&&i.texStorage2D(3553,Y,Ge,lt[0].width,lt[0].height);for(let se=0,ue=lt.length;se<ue;se++)Ne=lt[se],Ct?i.texSubImage2D(3553,se,0,0,Ne.width,Ne.height,De,Ee,Ne.data):i.texImage2D(3553,se,Ge,Ne.width,Ne.height,0,De,Ee,Ne.data);L.generateMipmaps=!1}else Ct?(qt&&i.texStorage2D(3553,Y,Ge,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,ce.width,ce.height,De,Ee,ce.data)):i.texImage2D(3553,0,Ge,ce.width,ce.height,0,De,Ee,ce.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){Ct&&qt&&i.texStorage3D(35866,Y,Ge,lt[0].width,lt[0].height,ce.depth);for(let se=0,ue=lt.length;se<ue;se++)Ne=lt[se],L.format!==Vr?De!==null?Ct?i.compressedTexSubImage3D(35866,se,0,0,0,Ne.width,Ne.height,ce.depth,De,Ne.data,0,0):i.compressedTexImage3D(35866,se,Ge,Ne.width,Ne.height,ce.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ct?i.texSubImage3D(35866,se,0,0,0,Ne.width,Ne.height,ce.depth,De,Ee,Ne.data):i.texImage3D(35866,se,Ge,Ne.width,Ne.height,ce.depth,0,De,Ee,Ne.data)}else{Ct&&qt&&i.texStorage2D(3553,Y,Ge,lt[0].width,lt[0].height);for(let se=0,ue=lt.length;se<ue;se++)Ne=lt[se],L.format!==Vr?De!==null?Ct?i.compressedTexSubImage2D(3553,se,0,0,Ne.width,Ne.height,De,Ne.data):i.compressedTexImage2D(3553,se,Ge,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ct?i.texSubImage2D(3553,se,0,0,Ne.width,Ne.height,De,Ee,Ne.data):i.texImage2D(3553,se,Ge,Ne.width,Ne.height,0,De,Ee,Ne.data)}else if(L.isDataArrayTexture)Ct?(qt&&i.texStorage3D(35866,Y,Ge,ce.width,ce.height,ce.depth),i.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,De,Ee,ce.data)):i.texImage3D(35866,0,Ge,ce.width,ce.height,ce.depth,0,De,Ee,ce.data);else if(L.isData3DTexture)Ct?(qt&&i.texStorage3D(32879,Y,Ge,ce.width,ce.height,ce.depth),i.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,De,Ee,ce.data)):i.texImage3D(32879,0,Ge,ce.width,ce.height,ce.depth,0,De,Ee,ce.data);else if(L.isFramebufferTexture){if(qt)if(Ct)i.texStorage2D(3553,Y,Ge,ce.width,ce.height);else{let se=ce.width,ue=ce.height;for(let ye=0;ye<Y;ye++)i.texImage2D(3553,ye,Ge,se,ue,0,De,Ee,null),se>>=1,ue>>=1}}else if(lt.length>0&&Me){Ct&&qt&&i.texStorage2D(3553,Y,Ge,lt[0].width,lt[0].height);for(let se=0,ue=lt.length;se<ue;se++)Ne=lt[se],Ct?i.texSubImage2D(3553,se,0,0,De,Ee,Ne):i.texImage2D(3553,se,Ge,De,Ee,Ne);L.generateMipmaps=!1}else Ct?(qt&&i.texStorage2D(3553,Y,Ge,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,De,Ee,ce)):i.texImage2D(3553,0,Ge,De,Ee,ce);S(L,Me)&&A(pe),qe.__version=_e.version,L.onUpdate&&L.onUpdate(L)}I.__version=L.version}function $(I,L,ie){if(L.image.length!==6)return;let pe=ne(I,L),fe=L.source;i.bindTexture(34067,I.__webglTexture,33984+ie);let _e=r.get(fe);if(fe.version!==_e.__version||pe===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,L.flipY),e.pixelStorei(37441,L.premultiplyAlpha),e.pixelStorei(3317,L.unpackAlignment),e.pixelStorei(37443,0);let qe=L.isCompressedTexture||L.image[0].isCompressedTexture,Se=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let se=0;se<6;se++)!qe&&!Se?ce[se]=x(L.image[se],!1,!0,h):ce[se]=Se?L.image[se].image:L.image[se],ce[se]=ot(L,ce[se]);let Me=ce[0],De=w(Me)||o,Ee=n.convert(L.format,L.encoding),Ge=n.convert(L.type),Ne=b(L.internalFormat,Ee,Ge,L.encoding),lt=o&&L.isVideoTexture!==!0,Ct=_e.__version===void 0||pe===!0,qt=M(L,Me,De);F(34067,L,De);let Y;if(qe){lt&&Ct&&i.texStorage2D(34067,qt,Ne,Me.width,Me.height);for(let se=0;se<6;se++){Y=ce[se].mipmaps;for(let ue=0;ue<Y.length;ue++){let ye=Y[ue];L.format!==Vr?Ee!==null?lt?i.compressedTexSubImage2D(34069+se,ue,0,0,ye.width,ye.height,Ee,ye.data):i.compressedTexImage2D(34069+se,ue,Ne,ye.width,ye.height,0,ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):lt?i.texSubImage2D(34069+se,ue,0,0,ye.width,ye.height,Ee,Ge,ye.data):i.texImage2D(34069+se,ue,Ne,ye.width,ye.height,0,Ee,Ge,ye.data)}}}else{Y=L.mipmaps,lt&&Ct&&(Y.length>0&&qt++,i.texStorage2D(34067,qt,Ne,ce[0].width,ce[0].height));for(let se=0;se<6;se++)if(Se){lt?i.texSubImage2D(34069+se,0,0,0,ce[se].width,ce[se].height,Ee,Ge,ce[se].data):i.texImage2D(34069+se,0,Ne,ce[se].width,ce[se].height,0,Ee,Ge,ce[se].data);for(let ue=0;ue<Y.length;ue++){let ye=Y[ue].image[se].image;lt?i.texSubImage2D(34069+se,ue+1,0,0,ye.width,ye.height,Ee,Ge,ye.data):i.texImage2D(34069+se,ue+1,Ne,ye.width,ye.height,0,Ee,Ge,ye.data)}}else{lt?i.texSubImage2D(34069+se,0,0,0,Ee,Ge,ce[se]):i.texImage2D(34069+se,0,Ne,Ee,Ge,ce[se]);for(let ue=0;ue<Y.length;ue++){let ye=Y[ue];lt?i.texSubImage2D(34069+se,ue+1,0,0,Ee,Ge,ye.image[se]):i.texImage2D(34069+se,ue+1,Ne,Ee,Ge,ye.image[se])}}}S(L,De)&&A(34067),_e.__version=fe.version,L.onUpdate&&L.onUpdate(L)}I.__version=L.version}function Q(I,L,ie,pe,fe){let _e=n.convert(ie.format,ie.encoding),qe=n.convert(ie.type),Se=b(ie.internalFormat,_e,qe,ie.encoding);r.get(L).__hasExternalTextures||(fe===32879||fe===35866?i.texImage3D(fe,0,Se,L.width,L.height,L.depth,0,_e,qe,null):i.texImage2D(fe,0,Se,L.width,L.height,0,_e,qe,null)),i.bindFramebuffer(36160,I),Re(L)?u.framebufferTexture2DMultisampleEXT(36160,pe,fe,r.get(ie).__webglTexture,0,be(L)):(fe===3553||fe>=34069&&fe<=34074)&&e.framebufferTexture2D(36160,pe,fe,r.get(ie).__webglTexture,0),i.bindFramebuffer(36160,null)}function me(I,L,ie){if(e.bindRenderbuffer(36161,I),L.depthBuffer&&!L.stencilBuffer){let pe=33189;if(ie||Re(L)){let fe=L.depthTexture;fe&&fe.isDepthTexture&&(fe.type===Pn?pe=36012:fe.type===Tn&&(pe=33190));let _e=be(L);Re(L)?u.renderbufferStorageMultisampleEXT(36161,_e,pe,L.width,L.height):e.renderbufferStorageMultisample(36161,_e,pe,L.width,L.height)}else e.renderbufferStorage(36161,pe,L.width,L.height);e.framebufferRenderbuffer(36160,36096,36161,I)}else if(L.depthBuffer&&L.stencilBuffer){let pe=be(L);ie&&Re(L)===!1?e.renderbufferStorageMultisample(36161,pe,35056,L.width,L.height):Re(L)?u.renderbufferStorageMultisampleEXT(36161,pe,35056,L.width,L.height):e.renderbufferStorage(36161,34041,L.width,L.height),e.framebufferRenderbuffer(36160,33306,36161,I)}else{let pe=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let fe=0;fe<pe.length;fe++){let _e=pe[fe],qe=n.convert(_e.format,_e.encoding),Se=n.convert(_e.type),ce=b(_e.internalFormat,qe,Se,_e.encoding),Me=be(L);ie&&Re(L)===!1?e.renderbufferStorageMultisample(36161,Me,ce,L.width,L.height):Re(L)?u.renderbufferStorageMultisampleEXT(36161,Me,ce,L.width,L.height):e.renderbufferStorage(36161,ce,L.width,L.height)}}e.bindRenderbuffer(36161,null)}function re(I,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,I),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),k(L.depthTexture,0);let ie=r.get(L.depthTexture).__webglTexture,pe=be(L);if(L.depthTexture.format===wa)Re(L)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,ie,0,pe):e.framebufferTexture2D(36160,36096,3553,ie,0);else if(L.depthTexture.format===Pa)Re(L)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,ie,0,pe):e.framebufferTexture2D(36160,33306,3553,ie,0);else throw new Error("Unknown depthTexture format")}function oe(I){let L=r.get(I),ie=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!L.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");re(L.__webglFramebuffer,I)}else if(ie){L.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)i.bindFramebuffer(36160,L.__webglFramebuffer[pe]),L.__webglDepthbuffer[pe]=e.createRenderbuffer(),me(L.__webglDepthbuffer[pe],I,!1)}else i.bindFramebuffer(36160,L.__webglFramebuffer),L.__webglDepthbuffer=e.createRenderbuffer(),me(L.__webglDepthbuffer,I,!1);i.bindFramebuffer(36160,null)}function de(I,L,ie){let pe=r.get(I);L!==void 0&&Q(pe.__webglFramebuffer,I,I.texture,36064,3553),ie!==void 0&&oe(I)}function xe(I){let L=I.texture,ie=r.get(I),pe=r.get(L);I.addEventListener("dispose",P),I.isWebGLMultipleRenderTargets!==!0&&(pe.__webglTexture===void 0&&(pe.__webglTexture=e.createTexture()),pe.__version=L.version,a.memory.textures++);let fe=I.isWebGLCubeRenderTarget===!0,_e=I.isWebGLMultipleRenderTargets===!0,qe=w(I)||o;if(fe){ie.__webglFramebuffer=[];for(let Se=0;Se<6;Se++)ie.__webglFramebuffer[Se]=e.createFramebuffer()}else{if(ie.__webglFramebuffer=e.createFramebuffer(),_e)if(s.drawBuffers){let Se=I.texture;for(let ce=0,Me=Se.length;ce<Me;ce++){let De=r.get(Se[ce]);De.__webglTexture===void 0&&(De.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&I.samples>0&&Re(I)===!1){let Se=_e?L:[L];ie.__webglMultisampledFramebuffer=e.createFramebuffer(),ie.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ie.__webglMultisampledFramebuffer);for(let ce=0;ce<Se.length;ce++){let Me=Se[ce];ie.__webglColorRenderbuffer[ce]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ie.__webglColorRenderbuffer[ce]);let De=n.convert(Me.format,Me.encoding),Ee=n.convert(Me.type),Ge=b(Me.internalFormat,De,Ee,Me.encoding,I.isXRRenderTarget===!0),Ne=be(I);e.renderbufferStorageMultisample(36161,Ne,Ge,I.width,I.height),e.framebufferRenderbuffer(36160,36064+ce,36161,ie.__webglColorRenderbuffer[ce])}e.bindRenderbuffer(36161,null),I.depthBuffer&&(ie.__webglDepthRenderbuffer=e.createRenderbuffer(),me(ie.__webglDepthRenderbuffer,I,!0)),i.bindFramebuffer(36160,null)}}if(fe){i.bindTexture(34067,pe.__webglTexture),F(34067,L,qe);for(let Se=0;Se<6;Se++)Q(ie.__webglFramebuffer[Se],I,L,36064,34069+Se);S(L,qe)&&A(34067),i.unbindTexture()}else if(_e){let Se=I.texture;for(let ce=0,Me=Se.length;ce<Me;ce++){let De=Se[ce],Ee=r.get(De);i.bindTexture(3553,Ee.__webglTexture),F(3553,De,qe),Q(ie.__webglFramebuffer,I,De,36064+ce,3553),S(De,qe)&&A(3553)}i.unbindTexture()}else{let Se=3553;(I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(o?Se=I.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Se,pe.__webglTexture),F(Se,L,qe),Q(ie.__webglFramebuffer,I,L,36064,Se),S(L,qe)&&A(Se),i.unbindTexture()}I.depthBuffer&&oe(I)}function Te(I){let L=w(I)||o,ie=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let pe=0,fe=ie.length;pe<fe;pe++){let _e=ie[pe];if(S(_e,L)){let qe=I.isWebGLCubeRenderTarget?34067:3553,Se=r.get(_e).__webglTexture;i.bindTexture(qe,Se),A(qe),i.unbindTexture()}}}function we(I){if(o&&I.samples>0&&Re(I)===!1){let L=I.isWebGLMultipleRenderTargets?I.texture:[I.texture],ie=I.width,pe=I.height,fe=16384,_e=[],qe=I.stencilBuffer?33306:36096,Se=r.get(I),ce=I.isWebGLMultipleRenderTargets===!0;if(ce)for(let Me=0;Me<L.length;Me++)i.bindFramebuffer(36160,Se.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Me,36161,null),i.bindFramebuffer(36160,Se.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Me,3553,null,0);i.bindFramebuffer(36008,Se.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Se.__webglFramebuffer);for(let Me=0;Me<L.length;Me++){_e.push(36064+Me),I.depthBuffer&&_e.push(qe);let De=Se.__ignoreDepthValues!==void 0?Se.__ignoreDepthValues:!1;if(De===!1&&(I.depthBuffer&&(fe|=256),I.stencilBuffer&&(fe|=1024)),ce&&e.framebufferRenderbuffer(36008,36064,36161,Se.__webglColorRenderbuffer[Me]),De===!0&&(e.invalidateFramebuffer(36008,[qe]),e.invalidateFramebuffer(36009,[qe])),ce){let Ee=r.get(L[Me]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Ee,0)}e.blitFramebuffer(0,0,ie,pe,0,0,ie,pe,fe,9728),p&&e.invalidateFramebuffer(36008,_e)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ce)for(let Me=0;Me<L.length;Me++){i.bindFramebuffer(36160,Se.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Me,36161,Se.__webglColorRenderbuffer[Me]);let De=r.get(L[Me]).__webglTexture;i.bindFramebuffer(36160,Se.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Me,3553,De,0)}i.bindFramebuffer(36009,Se.__webglMultisampledFramebuffer)}}function be(I){return Math.min(c,I.samples)}function Re(I){let L=r.get(I);return o&&I.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function We(I){let L=a.render.frame;f.get(I)!==L&&(f.set(I,L),I.update())}function ot(I,L){let ie=I.encoding,pe=I.format,fe=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===em||ie!==Es&&(ie===Ke?o===!1?t.has("EXT_sRGB")===!0&&pe===Vr?(I.format=em,I.minFilter=gt,I.generateMipmaps=!1):L=zb.sRGBToLinear(L):(pe!==Vr||fe!==Ti)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ie)),L}this.allocateTextureUnit=z,this.resetTextureUnits=q,this.setTexture2D=k,this.setTexture2DArray=U,this.setTexture3D=B,this.setTextureCube=H,this.rebindTextures=de,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=we,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=Q,this.useMultisampledRTT=Re}function AD(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Ti)return 5121;if(n===aE)return 32819;if(n===oE)return 32820;if(n===rE)return 5120;if(n===sE)return 5122;if(n===Ib)return 5123;if(n===nE)return 5124;if(n===Tn)return 5125;if(n===Pn)return 5126;if(n===wh)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===lE)return 6406;if(n===Vr)return 6408;if(n===hE)return 6409;if(n===cE)return 6410;if(n===wa)return 6402;if(n===Pa)return 34041;if(n===em)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===dE)return 6403;if(n===uE)return 36244;if(n===pE)return 33319;if(n===fE)return 33320;if(n===mE)return 36249;if(n===sp||n===np||n===ap||n===op)if(a===Ke)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===sp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===np)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ap)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===op)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===sp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===np)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ap)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===op)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===x0||n===w0||n===b0||n===_0)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===x0)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===w0)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===b0)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===_0)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===gE)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===S0||n===A0)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===S0)return a===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===A0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===M0||n===E0||n===C0||n===T0||n===P0||n===D0||n===O0||n===L0||n===I0||n===R0||n===B0||n===N0||n===z0||n===U0)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===M0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===E0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===C0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===T0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===P0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===D0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===O0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===L0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===I0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===R0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===B0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===N0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===z0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===U0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===lp)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===lp)return a===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===vE||n===F0||n===k0||n===j0)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===lp)return o.COMPRESSED_RED_RGTC1_EXT;if(n===F0)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===k0)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===j0)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===xa?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[n]!==void 0?e[n]:null}return{convert:s}}var MD=class extends Ei{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ao=class extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}},ED={type:"move"},Rp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ao,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 Ao,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ao,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let f of e.hand.values()){let m=t.getJointPose(f,i),g=this._getHandJoint(l,f);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],c=h.position.distanceTo(d.position),u=.02,p=.005;l.inputState.pinching&&c>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=u-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(ED)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Ao;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ag=class extends ui{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:wa,h!==wa&&h!==Pa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===wa&&(i=Tn),i===void 0&&h===Pa&&(i=xa),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Bt,this.minFilter=o!==void 0?o:Bt,this.flipY=!1,this.generateMipmaps=!1}},CD=class extends Ui{constructor(e,t){super();let i=this,r=null,s=1,n=null,a="local-floor",o=1,l=null,h=null,d=null,c=null,u=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new Set,w=new Map,_=new Ei;_.layers.enable(1),_.viewport=new $e;let S=new Ei;S.layers.enable(2),S.viewport=new $e;let A=[_,S],b=new MD;b.layers.enable(1),b.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let B=v[U];return B===void 0&&(B=new Rp,v[U]=B),B.getTargetRaySpace()},this.getControllerGrip=function(U){let B=v[U];return B===void 0&&(B=new Rp,v[U]=B),B.getGripSpace()},this.getHand=function(U){let B=v[U];return B===void 0&&(B=new Rp,v[U]=B),B.getHandSpace()};function T(U){let B=y.indexOf(U.inputSource);if(B===-1)return;let H=v[B];H!==void 0&&H.dispatchEvent({type:U.type,data:U.inputSource})}function P(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",O);for(let U=0;U<v.length;U++){let B=y[U];B!==null&&(y[U]=null,v[U].disconnect(B))}M=null,C=null,e.setRenderTarget(m),u=null,c=null,d=null,r=null,g=null,k.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(U){l=U},this.getBaseLayer=function(){return c!==null?c:u},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(U){if(r=U,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",P),r.addEventListener("inputsourceschange",O),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let B={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(r,t,B),r.updateRenderState({baseLayer:u}),g=new si(u.framebufferWidth,u.framebufferHeight,{format:Vr,type:Ti,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let B=null,H=null,X=null;f.depth&&(X=f.stencil?35056:33190,B=f.stencil?Pa:wa,H=f.stencil?xa:Tn);let Z={colorFormat:32856,depthFormat:X,scaleFactor:s};d=new XRWebGLBinding(r,t),c=d.createProjectionLayer(Z),r.updateRenderState({layers:[c]}),g=new si(c.textureWidth,c.textureHeight,{format:Vr,type:Ti,depthTexture:new Ag(c.textureWidth,c.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,B),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let F=e.properties.get(g);F.__ignoreDepthValues=c.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),k.setContext(r),k.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function O(U){for(let B=0;B<U.removed.length;B++){let H=U.removed[B],X=y.indexOf(H);X>=0&&(y[X]=null,v[X].disconnect(H))}for(let B=0;B<U.added.length;B++){let H=U.added[B],X=y.indexOf(H);if(X===-1){for(let F=0;F<v.length;F++)if(F>=y.length){y.push(H),X=F;break}else if(y[F]===null){y[F]=H,X=F;break}if(X===-1)break}let Z=v[X];Z&&Z.connect(H)}}let D=new E,N=new E;function W(U,B,H){D.setFromMatrixPosition(B.matrixWorld),N.setFromMatrixPosition(H.matrixWorld);let X=D.distanceTo(N),Z=B.projectionMatrix.elements,F=H.projectionMatrix.elements,ne=Z[14]/(Z[10]-1),j=Z[14]/(Z[10]+1),$=(Z[9]+1)/Z[5],Q=(Z[9]-1)/Z[5],me=(Z[8]-1)/Z[0],re=(F[8]+1)/F[0],oe=ne*me,de=ne*re,xe=X/(-me+re),Te=xe*-me;B.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(Te),U.translateZ(xe),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();let we=ne+xe,be=j+xe,Re=oe-Te,We=de+(X-Te),ot=$*j/be*we,I=Q*j/be*we;U.projectionMatrix.makePerspective(Re,We,ot,I,we,be)}function q(U,B){B===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(B.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(r===null)return;b.near=S.near=_.near=U.near,b.far=S.far=_.far=U.far,(M!==b.near||C!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),M=b.near,C=b.far);let B=U.parent,H=b.cameras;q(b,B);for(let Z=0;Z<H.length;Z++)q(H[Z],B);b.matrixWorld.decompose(b.position,b.quaternion,b.scale),U.matrix.copy(b.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale);let X=U.children;for(let Z=0,F=X.length;Z<F;Z++)X[Z].updateMatrixWorld(!0);H.length===2?W(b,_,S):b.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return b},this.getFoveation=function(){if(!(c===null&&u===null))return o},this.setFoveation=function(U){o=U,c!==null&&(c.fixedFoveation=U),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=U)},this.getPlanes=function(){return x};let z=null;function V(U,B){if(h=B.getViewerPose(l||n),p=B,h!==null){let H=h.views;u!==null&&(e.setRenderTargetFramebuffer(g,u.framebuffer),e.setRenderTarget(g));let X=!1;H.length!==b.cameras.length&&(b.cameras.length=0,X=!0);for(let Z=0;Z<H.length;Z++){let F=H[Z],ne=null;if(u!==null)ne=u.getViewport(F);else{let $=d.getViewSubImage(c,F);ne=$.viewport,Z===0&&(e.setRenderTargetTextures(g,$.colorTexture,c.ignoreDepthValues?void 0:$.depthStencilTexture),e.setRenderTarget(g))}let j=A[Z];j===void 0&&(j=new Ei,j.layers.enable(Z),j.viewport=new $e,A[Z]=j),j.matrix.fromArray(F.transform.matrix),j.projectionMatrix.fromArray(F.projectionMatrix),j.viewport.set(ne.x,ne.y,ne.width,ne.height),Z===0&&b.matrix.copy(j.matrix),X===!0&&b.cameras.push(j)}}for(let H=0;H<v.length;H++){let X=y[H],Z=v[H];X!==null&&Z!==void 0&&Z.update(X,B,l||n)}if(z&&z(U,B),B.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:B.detectedPlanes});let H=null;for(let X of x)B.detectedPlanes.has(X)||(H===null&&(H=[]),H.push(X));if(H!==null)for(let X of H)x.delete(X),w.delete(X),i.dispatchEvent({type:"planeremoved",data:X});for(let X of B.detectedPlanes)if(!x.has(X))x.add(X),w.set(X,B.lastChangedTime),i.dispatchEvent({type:"planeadded",data:X});else{let Z=w.get(X);X.lastChangedTime>Z&&(w.set(X,X.lastChangedTime),i.dispatchEvent({type:"planechanged",data:X}))}}p=null}let k=new Gb;k.setAnimationLoop(V),this.setAnimationLoop=function(U){z=U},this.dispose=function(){}}};function TD(e,t){function i(m,g){g.color.getRGB(m.fogColor.value,jb(e)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,v,y,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(m,g):g.isMeshToonMaterial?(s(m,g),d(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g)):g.isMeshStandardMaterial?(s(m,g),c(m,g),g.isMeshPhysicalMaterial&&u(m,g,x)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),f(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(n(m,g),g.isLineDashedMaterial&&a(m,g)):g.isPointsMaterial?o(m,g,v,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===di&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===di&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v=t.get(g).envMap;if(v&&(m.envMap.value=v,m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let w=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function n(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function a(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,v,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*v,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix))}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function c(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function u(m,g,v){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===di&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function f(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function PD(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let w=x.program;r.uniformBlockBinding(y,w)}function h(y,x){let w=s[y.id];w===void 0&&(f(y),w=d(y),s[y.id]=w,y.addEventListener("dispose",g));let _=x.program;r.updateUBOMapping(y,_);let S=t.render.frame;n[y.id]!==S&&(u(y),n[y.id]=S)}function d(y){let x=c();y.__bindingPointIndex=x;let w=e.createBuffer(),_=y.__size,S=y.usage;return e.bindBuffer(35345,w),e.bufferData(35345,_,S),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,w),w}function c(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let x=s[y.id],w=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let S=0,A=w.length;S<A;S++){let b=w[S];if(p(b,S,_)===!0){let M=b.__offset,C=Array.isArray(b.value)?b.value:[b.value],T=0;for(let P=0;P<C.length;P++){let O=C[P],D=m(O);typeof O=="number"?(b.__data[0]=O,e.bufferSubData(35345,M+T,b.__data)):O.isMatrix3?(b.__data[0]=O.elements[0],b.__data[1]=O.elements[1],b.__data[2]=O.elements[2],b.__data[3]=O.elements[0],b.__data[4]=O.elements[3],b.__data[5]=O.elements[4],b.__data[6]=O.elements[5],b.__data[7]=O.elements[0],b.__data[8]=O.elements[6],b.__data[9]=O.elements[7],b.__data[10]=O.elements[8],b.__data[11]=O.elements[0]):(O.toArray(b.__data,T),T+=D.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,b.__data)}}e.bindBuffer(35345,null)}function p(y,x,w){let _=y.value;if(w[x]===void 0){if(typeof _=="number")w[x]=_;else{let S=Array.isArray(_)?_:[_],A=[];for(let b=0;b<S.length;b++)A.push(S[b].clone());w[x]=A}return!0}else if(typeof _=="number"){if(w[x]!==_)return w[x]=_,!0}else{let S=Array.isArray(w[x])?w[x]:[w[x]],A=Array.isArray(_)?_:[_];for(let b=0;b<S.length;b++){let M=S[b];if(M.equals(A[b])===!1)return M.copy(A[b]),!0}}return!1}function f(y){let x=y.uniforms,w=0,_=16,S=0;for(let A=0,b=x.length;A<b;A++){let M=x[A],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let P=0,O=T.length;P<O;P++){let D=T[P],N=m(D);C.boundary+=N.boundary,C.storage+=N.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=w,A>0){S=w%_;let P=_-S;S!==0&&P-C.boundary<0&&(w+=_-S,M.__offset=w)}w+=C.storage}return S=w%_,S>0&&(w+=_-S),y.__size=w,y.__cache={},this}function m(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function g(y){let x=y.target;x.removeEventListener("dispose",g);let w=a.indexOf(x.__bindingPointIndex);a.splice(w,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete n[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function DD(){let e=Td("canvas");return e.style.display="block",e}function Yb(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:DD(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,n=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,d;i!==null?d=i.getContextAttributes().alpha:d=e.alpha!==void 0?e.alpha:!1;let c=null,u=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Es,this.physicallyCorrectLights=!1,this.toneMapping=Ks,this.toneMappingExposure=1;let m=this,g=!1,v=0,y=0,x=null,w=-1,_=null,S=new $e,A=new $e,b=null,M=t.width,C=t.height,T=1,P=null,O=null,D=new $e(0,0,M,C),N=new $e(0,0,M,C),W=!1,q=new _g,z=!1,V=!1,k=null,U=new ge,B=new G,H=new E,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Z(){return x===null?T:1}let F=i;function ne(R,ee){for(let ae=0;ae<R.length;ae++){let J=R[ae],he=t.getContext(J,ee);if(he!==null)return he}return null}try{let R={alpha:!0,depth:r,stencil:s,antialias:n,premultipliedAlpha:a,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${el}`),t.addEventListener("webglcontextlost",Ge,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",lt,!1),F===null){let ee=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ee.shift(),F=ne(ee,R),F===null)throw ne(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}F.getShaderPrecisionFormat===void 0&&(F.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(R){throw console.error("THREE.WebGLRenderer: "+R.message),R}let j,$,Q,me,re,oe,de,xe,Te,we,be,Re,We,ot,I,L,ie,pe,fe,_e,qe,Se,ce,Me;function De(){j=new V3(F),$=new z3(F,j,e),j.init($),Se=new AD(F,j,$),Q=new _D(F,j,$),me=new q3,re=new hD,oe=new SD(F,j,Q,re,$,Se,me),de=new F3(m),xe=new G3(m),Te=new tC(F,$),ce=new B3(F,j,Te,$),we=new H3(F,Te,me,ce),be=new Q3(F,we,Te,me),fe=new Z3(F,$,oe),L=new U3(re),Re=new lD(m,de,xe,j,$,ce,L),We=new TD(m,re),ot=new dD,I=new vD(j,$),pe=new R3(m,de,xe,Q,be,d,a),ie=new bD(m,be,$),Me=new PD(F,me,$,Q),_e=new N3(F,j,me,$),qe=new W3(F,j,me,$),me.programs=Re.programs,m.capabilities=$,m.extensions=j,m.properties=re,m.renderLists=ot,m.shadowMap=ie,m.state=Q,m.info=me}De();let Ee=new CD(m,F);this.xr=Ee,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){let R=j.get("WEBGL_lose_context");R&&R.loseContext()},this.forceContextRestore=function(){let R=j.get("WEBGL_lose_context");R&&R.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(R){R!==void 0&&(T=R,this.setSize(M,C,!1))},this.getSize=function(R){return R.set(M,C)},this.setSize=function(R,ee,ae){if(Ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=R,C=ee,t.width=Math.floor(R*T),t.height=Math.floor(ee*T),ae!==!1&&(t.style.width=R+"px",t.style.height=ee+"px"),this.setViewport(0,0,R,ee)},this.getDrawingBufferSize=function(R){return R.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(R,ee,ae){M=R,C=ee,T=ae,t.width=Math.floor(R*ae),t.height=Math.floor(ee*ae),this.setViewport(0,0,R,ee)},this.getCurrentViewport=function(R){return R.copy(S)},this.getViewport=function(R){return R.copy(D)},this.setViewport=function(R,ee,ae,J){R.isVector4?D.set(R.x,R.y,R.z,R.w):D.set(R,ee,ae,J),Q.viewport(S.copy(D).multiplyScalar(T).floor())},this.getScissor=function(R){return R.copy(N)},this.setScissor=function(R,ee,ae,J){R.isVector4?N.set(R.x,R.y,R.z,R.w):N.set(R,ee,ae,J),Q.scissor(A.copy(N).multiplyScalar(T).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(R){Q.setScissorTest(W=R)},this.setOpaqueSort=function(R){P=R},this.setTransparentSort=function(R){O=R},this.getClearColor=function(R){return R.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(R=!0,ee=!0,ae=!0){let J=0;R&&(J|=16384),ee&&(J|=256),ae&&(J|=1024),F.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ge,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ot.dispose(),I.dispose(),re.dispose(),de.dispose(),xe.dispose(),be.dispose(),ce.dispose(),Me.dispose(),Re.dispose(),Ee.dispose(),Ee.removeEventListener("sessionstart",ye),Ee.removeEventListener("sessionend",Ue),k&&(k.dispose(),k=null),dt.stop()};function Ge(R){R.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let R=me.autoReset,ee=ie.enabled,ae=ie.autoUpdate,J=ie.needsUpdate,he=ie.type;De(),me.autoReset=R,ie.enabled=ee,ie.autoUpdate=ae,ie.needsUpdate=J,ie.type=he}function lt(R){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function Ct(R){let ee=R.target;ee.removeEventListener("dispose",Ct),qt(ee)}function qt(R){Y(R),re.remove(R)}function Y(R){let ee=re.get(R).programs;ee!==void 0&&(ee.forEach(function(ae){Re.releaseProgram(ae)}),R.isShaderMaterial&&Re.releaseShaderCache(R))}this.renderBufferDirect=function(R,ee,ae,J,he,Ie){ee===null&&(ee=X);let Je=he.isMesh&&he.matrixWorld.determinant()<0,rt=lM(R,ee,ae,J,he);Q.setMaterial(J,Je);let nt=ae.index,St=1;J.wireframe===!0&&(nt=we.getWireframeAttribute(ae),St=2);let ut=ae.drawRange,ht=ae.attributes.position,_i=ut.start*St,Yi=(ut.start+ut.count)*St;Ie!==null&&(_i=Math.max(_i,Ie.start*St),Yi=Math.min(Yi,(Ie.start+Ie.count)*St)),nt!==null?(_i=Math.max(_i,0),Yi=Math.min(Yi,nt.count)):ht!=null&&(_i=Math.max(_i,0),Yi=Math.min(Yi,ht.count));let Bs=Yi-_i;if(Bs<0||Bs===1/0)return;ce.setup(he,J,rt,ae,nt);let Zn,Xt=_e;if(nt!==null&&(Zn=Te.get(nt),Xt=qe,Xt.setIndex(Zn)),he.isMesh)J.wireframe===!0?(Q.setLineWidth(J.wireframeLinewidth*Z()),Xt.setMode(1)):Xt.setMode(4);else if(he.isLine){let ct=J.linewidth;ct===void 0&&(ct=1),Q.setLineWidth(ct*Z()),he.isLineSegments?Xt.setMode(1):he.isLineLoop?Xt.setMode(2):Xt.setMode(3)}else he.isPoints?Xt.setMode(0):he.isSprite&&Xt.setMode(4);if(he.isInstancedMesh)Xt.renderInstances(_i,Bs,he.count);else if(ae.isInstancedBufferGeometry){let ct=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,Ju=Math.min(ae.instanceCount,ct);Xt.renderInstances(_i,Bs,Ju)}else Xt.render(_i,Bs)},this.compile=function(R,ee){function ae(J,he,Ie){J.transparent===!0&&J.side===sr&&J.forceSinglePass===!1?(J.side=di,J.needsUpdate=!0,dr(J,he,Ie),J.side=Qr,J.needsUpdate=!0,dr(J,he,Ie),J.side=sr):dr(J,he,Ie)}u=I.get(R),u.init(),f.push(u),R.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(u.pushLight(J),J.castShadow&&u.pushShadow(J))}),u.setupLights(m.physicallyCorrectLights),R.traverse(function(J){let he=J.material;if(he)if(Array.isArray(he))for(let Ie=0;Ie<he.length;Ie++){let Je=he[Ie];ae(Je,R,J)}else ae(he,R,J)}),f.pop(),u=null};let se=null;function ue(R){se&&se(R)}function ye(){dt.stop()}function Ue(){dt.start()}let dt=new Gb;dt.setAnimationLoop(ue),typeof self<"u"&&dt.setContext(self),this.setAnimationLoop=function(R){se=R,Ee.setAnimationLoop(R),R===null?dt.stop():dt.start()},Ee.addEventListener("sessionstart",ye),Ee.addEventListener("sessionend",Ue),this.render=function(R,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Ee.enabled===!0&&Ee.isPresenting===!0&&(Ee.cameraAutoUpdate===!0&&Ee.updateCamera(ee),ee=Ee.getCamera()),R.isScene===!0&&R.onBeforeRender(m,R,ee,x),u=I.get(R,f.length),u.init(),f.push(u),U.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),q.setFromProjectionMatrix(U),V=this.localClippingEnabled,z=L.init(this.clippingPlanes,V),c=ot.get(R,p.length),c.init(),p.push(c),Rt(R,ee,0,m.sortObjects),c.finish(),m.sortObjects===!0&&c.sort(P,O),z===!0&&L.beginShadows();let ae=u.state.shadowsArray;if(ie.render(ae,R,ee),z===!0&&L.endShadows(),this.info.autoReset===!0&&this.info.reset(),pe.render(c,R),u.setupLights(m.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let he=0,Ie=J.length;he<Ie;he++){let Je=J[he];bi(c,R,Je,Je.viewport)}}else bi(c,R,ee);x!==null&&(oe.updateMultisampleRenderTarget(x),oe.updateRenderTargetMipmap(x)),R.isScene===!0&&R.onAfterRender(m,R,ee),ce.resetDefaultState(),w=-1,_=null,f.pop(),f.length>0?u=f[f.length-1]:u=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function Rt(R,ee,ae,J){if(R.visible===!1)return;if(R.layers.test(ee.layers)){if(R.isGroup)ae=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update(ee);else if(R.isLight)u.pushLight(R),R.castShadow&&u.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||q.intersectsSprite(R)){J&&H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(U);let Ie=be.update(R),Je=R.material;Je.visible&&c.push(R,Ie,Je,ae,H.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(R.isSkinnedMesh&&R.skeleton.frame!==me.render.frame&&(R.skeleton.update(),R.skeleton.frame=me.render.frame),!R.frustumCulled||q.intersectsObject(R))){J&&H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(U);let Ie=be.update(R),Je=R.material;if(Array.isArray(Je)){let rt=Ie.groups;for(let nt=0,St=rt.length;nt<St;nt++){let ut=rt[nt],ht=Je[ut.materialIndex];ht&&ht.visible&&c.push(R,Ie,ht,ae,H.z,ut)}}else Je.visible&&c.push(R,Ie,Je,ae,H.z,null)}}let he=R.children;for(let Ie=0,Je=he.length;Ie<Je;Ie++)Rt(he[Ie],ee,ae,J)}function bi(R,ee,ae,J){let he=R.opaque,Ie=R.transmissive,Je=R.transparent;u.setupLightsView(ae),z===!0&&L.setGlobalState(m.clippingPlanes,ae),Ie.length>0&&Yn(he,ee,ae),J&&Q.viewport(S.copy(J)),he.length>0&&Ot(he,ee,ae),Ie.length>0&&Ot(Ie,ee,ae),Je.length>0&&Ot(Je,ee,ae),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function Yn(R,ee,ae){let J=$.isWebGL2;k===null&&(k=new si(1,1,{generateMipmaps:!0,type:j.has("EXT_color_buffer_half_float")?wh:Ti,minFilter:Ho,samples:J&&n===!0?4:0})),m.getDrawingBufferSize(B),J?k.setSize(B.x,B.y):k.setSize(Cd(B.x),Cd(B.y));let he=m.getRenderTarget();m.setRenderTarget(k),m.clear();let Ie=m.toneMapping;m.toneMapping=Ks,Ot(R,ee,ae),m.toneMapping=Ie,oe.updateMultisampleRenderTarget(k),oe.updateRenderTargetMipmap(k),m.setRenderTarget(he)}function Ot(R,ee,ae){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let he=0,Ie=R.length;he<Ie;he++){let Je=R[he],rt=Je.object,nt=Je.geometry,St=J===null?Je.material:J,ut=Je.group;rt.layers.test(ae.layers)&&Rs(rt,ee,ae,nt,St,ut)}}function Rs(R,ee,ae,J,he,Ie){R.onBeforeRender(m,ee,ae,J,he,Ie),R.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),he.onBeforeRender(m,ee,ae,J,R,Ie),he.transparent===!0&&he.side===sr&&he.forceSinglePass===!1?(he.side=di,he.needsUpdate=!0,m.renderBufferDirect(ae,ee,J,he,R,Ie),he.side=Qr,he.needsUpdate=!0,m.renderBufferDirect(ae,ee,J,he,R,Ie),he.side=sr):m.renderBufferDirect(ae,ee,J,he,R,Ie),R.onAfterRender(m,ee,ae,J,he,Ie)}function dr(R,ee,ae){ee.isScene!==!0&&(ee=X);let J=re.get(R),he=u.state.lights,Ie=u.state.shadowsArray,Je=he.state.version,rt=Re.getParameters(R,he.state,Ie,ee,ae),nt=Re.getProgramCacheKey(rt),St=J.programs;J.environment=R.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(R.isMeshStandardMaterial?xe:de).get(R.envMap||J.environment),St===void 0&&(R.addEventListener("dispose",Ct),St=new Map,J.programs=St);let ut=St.get(nt);if(ut!==void 0){if(J.currentProgram===ut&&J.lightsStateVersion===Je)return o0(R,rt),ut}else rt.uniforms=Re.getUniforms(R),R.onBuild(ae,rt,m),R.onBeforeCompile(rt,m),ut=Re.acquireProgram(rt,nt),St.set(nt,ut),J.uniforms=rt.uniforms;let ht=J.uniforms;(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)&&(ht.clippingPlanes=L.uniform),o0(R,rt),J.needsLights=cM(R),J.lightsStateVersion=Je,J.needsLights&&(ht.ambientLightColor.value=he.state.ambient,ht.lightProbe.value=he.state.probe,ht.directionalLights.value=he.state.directional,ht.directionalLightShadows.value=he.state.directionalShadow,ht.spotLights.value=he.state.spot,ht.spotLightShadows.value=he.state.spotShadow,ht.rectAreaLights.value=he.state.rectArea,ht.ltc_1.value=he.state.rectAreaLTC1,ht.ltc_2.value=he.state.rectAreaLTC2,ht.pointLights.value=he.state.point,ht.pointLightShadows.value=he.state.pointShadow,ht.hemisphereLights.value=he.state.hemi,ht.directionalShadowMap.value=he.state.directionalShadowMap,ht.directionalShadowMatrix.value=he.state.directionalShadowMatrix,ht.spotShadowMap.value=he.state.spotShadowMap,ht.spotLightMatrix.value=he.state.spotLightMatrix,ht.spotLightMap.value=he.state.spotLightMap,ht.pointShadowMap.value=he.state.pointShadowMap,ht.pointShadowMatrix.value=he.state.pointShadowMatrix);let _i=ut.getUniforms(),Yi=dd.seqWithValue(_i.seq,ht);return J.currentProgram=ut,J.uniformsList=Yi,ut}function o0(R,ee){let ae=re.get(R);ae.outputEncoding=ee.outputEncoding,ae.instancing=ee.instancing,ae.skinning=ee.skinning,ae.morphTargets=ee.morphTargets,ae.morphNormals=ee.morphNormals,ae.morphColors=ee.morphColors,ae.morphTargetsCount=ee.morphTargetsCount,ae.numClippingPlanes=ee.numClippingPlanes,ae.numIntersection=ee.numClipIntersection,ae.vertexAlphas=ee.vertexAlphas,ae.vertexTangents=ee.vertexTangents,ae.toneMapping=ee.toneMapping}function lM(R,ee,ae,J,he){ee.isScene!==!0&&(ee=X),oe.resetTextureUnits();let Ie=ee.fog,Je=J.isMeshStandardMaterial?ee.environment:null,rt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Es,nt=(J.isMeshStandardMaterial?xe:de).get(J.envMap||Je),St=J.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,ut=!!J.normalMap&&!!ae.attributes.tangent,ht=!!ae.morphAttributes.position,_i=!!ae.morphAttributes.normal,Yi=!!ae.morphAttributes.color,Bs=J.toneMapped?m.toneMapping:Ks,Zn=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Xt=Zn!==void 0?Zn.length:0,ct=re.get(J),Ju=u.state.lights;if(z===!0&&(V===!0||R!==_)){let Zi=R===_&&J.id===w;L.setState(J,R,Zi)}let $u=!1;J.version===ct.__version?(ct.needsLights&&ct.lightsStateVersion!==Ju.state.version||ct.outputEncoding!==rt||he.isInstancedMesh&&ct.instancing===!1||!he.isInstancedMesh&&ct.instancing===!0||he.isSkinnedMesh&&ct.skinning===!1||!he.isSkinnedMesh&&ct.skinning===!0||ct.envMap!==nt||J.fog===!0&&ct.fog!==Ie||ct.numClippingPlanes!==void 0&&(ct.numClippingPlanes!==L.numPlanes||ct.numIntersection!==L.numIntersection)||ct.vertexAlphas!==St||ct.vertexTangents!==ut||ct.morphTargets!==ht||ct.morphNormals!==_i||ct.morphColors!==Yi||ct.toneMapping!==Bs||$.isWebGL2===!0&&ct.morphTargetsCount!==Xt)&&($u=!0):($u=!0,ct.__version=J.version);let Qn=ct.currentProgram;$u===!0&&(Qn=dr(J,ee,he));let l0=!1,yl=!1,ep=!1,Pi=Qn.getUniforms(),Kn=ct.uniforms;if(Q.useProgram(Qn.program)&&(l0=!0,yl=!0,ep=!0),J.id!==w&&(w=J.id,yl=!0),l0||_!==R){if(Pi.setValue(F,"projectionMatrix",R.projectionMatrix),$.logarithmicDepthBuffer&&Pi.setValue(F,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),_!==R&&(_=R,yl=!0,ep=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let Zi=Pi.map.cameraPosition;Zi!==void 0&&Zi.setValue(F,H.setFromMatrixPosition(R.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Pi.setValue(F,"isOrthographic",R.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||he.isSkinnedMesh)&&Pi.setValue(F,"viewMatrix",R.matrixWorldInverse)}if(he.isSkinnedMesh){Pi.setOptional(F,he,"bindMatrix"),Pi.setOptional(F,he,"bindMatrixInverse");let Zi=he.skeleton;Zi&&($.floatVertexTextures?(Zi.boneTexture===null&&Zi.computeBoneTexture(),Pi.setValue(F,"boneTexture",Zi.boneTexture,oe),Pi.setValue(F,"boneTextureSize",Zi.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 tp=ae.morphAttributes;if((tp.position!==void 0||tp.normal!==void 0||tp.color!==void 0&&$.isWebGL2===!0)&&fe.update(he,ae,J,Qn),(yl||ct.receiveShadow!==he.receiveShadow)&&(ct.receiveShadow=he.receiveShadow,Pi.setValue(F,"receiveShadow",he.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(Kn.envMap.value=nt,Kn.flipEnvMap.value=nt.isCubeTexture&&nt.isRenderTargetTexture===!1?-1:1),yl&&(Pi.setValue(F,"toneMappingExposure",m.toneMappingExposure),ct.needsLights&&hM(Kn,ep),Ie&&J.fog===!0&&We.refreshFogUniforms(Kn,Ie),We.refreshMaterialUniforms(Kn,J,T,C,k),dd.upload(F,ct.uniformsList,Kn,oe)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(dd.upload(F,ct.uniformsList,Kn,oe),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Pi.setValue(F,"center",he.center),Pi.setValue(F,"modelViewMatrix",he.modelViewMatrix),Pi.setValue(F,"normalMatrix",he.normalMatrix),Pi.setValue(F,"modelMatrix",he.matrixWorld),J.isShaderMaterial||J.isRawShaderMaterial){let Zi=J.uniformsGroups;for(let ip=0,dM=Zi.length;ip<dM;ip++)if($.isWebGL2){let h0=Zi[ip];Me.update(h0,Qn),Me.bind(h0,Qn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Qn}function hM(R,ee){R.ambientLightColor.needsUpdate=ee,R.lightProbe.needsUpdate=ee,R.directionalLights.needsUpdate=ee,R.directionalLightShadows.needsUpdate=ee,R.pointLights.needsUpdate=ee,R.pointLightShadows.needsUpdate=ee,R.spotLights.needsUpdate=ee,R.spotLightShadows.needsUpdate=ee,R.rectAreaLights.needsUpdate=ee,R.hemisphereLights.needsUpdate=ee}function cM(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(R,ee,ae){re.get(R.texture).__webglTexture=ee,re.get(R.depthTexture).__webglTexture=ae;let J=re.get(R);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=ae===void 0,J.__autoAllocateDepthBuffer||j.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(R,ee){let ae=re.get(R);ae.__webglFramebuffer=ee,ae.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(R,ee=0,ae=0){x=R,v=ee,y=ae;let J=!0,he=null,Ie=!1,Je=!1;if(R){let rt=re.get(R);rt.__useDefaultFramebuffer!==void 0?(Q.bindFramebuffer(36160,null),J=!1):rt.__webglFramebuffer===void 0?oe.setupRenderTarget(R):rt.__hasExternalTextures&&oe.rebindTextures(R,re.get(R.texture).__webglTexture,re.get(R.depthTexture).__webglTexture);let nt=R.texture;(nt.isData3DTexture||nt.isDataArrayTexture||nt.isCompressedArrayTexture)&&(Je=!0);let St=re.get(R).__webglFramebuffer;R.isWebGLCubeRenderTarget?(he=St[ee],Ie=!0):$.isWebGL2&&R.samples>0&&oe.useMultisampledRTT(R)===!1?he=re.get(R).__webglMultisampledFramebuffer:he=St,S.copy(R.viewport),A.copy(R.scissor),b=R.scissorTest}else S.copy(D).multiplyScalar(T).floor(),A.copy(N).multiplyScalar(T).floor(),b=W;if(Q.bindFramebuffer(36160,he)&&$.drawBuffers&&J&&Q.drawBuffers(R,he),Q.viewport(S),Q.scissor(A),Q.setScissorTest(b),Ie){let rt=re.get(R.texture);F.framebufferTexture2D(36160,36064,34069+ee,rt.__webglTexture,ae)}else if(Je){let rt=re.get(R.texture),nt=ee||0;F.framebufferTextureLayer(36160,36064,rt.__webglTexture,ae||0,nt)}w=-1},this.readRenderTargetPixels=function(R,ee,ae,J,he,Ie,Je){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let rt=re.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Je!==void 0&&(rt=rt[Je]),rt){Q.bindFramebuffer(36160,rt);try{let nt=R.texture,St=nt.format,ut=nt.type;if(St!==Vr&&Se.convert(St)!==F.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ht=ut===wh&&(j.has("EXT_color_buffer_half_float")||$.isWebGL2&&j.has("EXT_color_buffer_float"));if(ut!==Ti&&Se.convert(ut)!==F.getParameter(35738)&&!(ut===Pn&&($.isWebGL2||j.has("OES_texture_float")||j.has("WEBGL_color_buffer_float")))&&!ht){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=R.width-J&&ae>=0&&ae<=R.height-he&&F.readPixels(ee,ae,J,he,Se.convert(St),Se.convert(ut),Ie)}finally{let nt=x!==null?re.get(x).__webglFramebuffer:null;Q.bindFramebuffer(36160,nt)}}},this.copyFramebufferToTexture=function(R,ee,ae=0){let J=Math.pow(2,-ae),he=Math.floor(ee.image.width*J),Ie=Math.floor(ee.image.height*J);oe.setTexture2D(ee,0),F.copyTexSubImage2D(3553,ae,0,0,R.x,R.y,he,Ie),Q.unbindTexture()},this.copyTextureToTexture=function(R,ee,ae,J=0){let he=ee.image.width,Ie=ee.image.height,Je=Se.convert(ae.format),rt=Se.convert(ae.type);oe.setTexture2D(ae,0),F.pixelStorei(37440,ae.flipY),F.pixelStorei(37441,ae.premultiplyAlpha),F.pixelStorei(3317,ae.unpackAlignment),ee.isDataTexture?F.texSubImage2D(3553,J,R.x,R.y,he,Ie,Je,rt,ee.image.data):ee.isCompressedTexture?F.compressedTexSubImage2D(3553,J,R.x,R.y,ee.mipmaps[0].width,ee.mipmaps[0].height,Je,ee.mipmaps[0].data):F.texSubImage2D(3553,J,R.x,R.y,Je,rt,ee.image),J===0&&ae.generateMipmaps&&F.generateMipmap(3553),Q.unbindTexture()},this.copyTextureToTexture3D=function(R,ee,ae,J,he=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ie=R.max.x-R.min.x+1,Je=R.max.y-R.min.y+1,rt=R.max.z-R.min.z+1,nt=Se.convert(J.format),St=Se.convert(J.type),ut;if(J.isData3DTexture)oe.setTexture3D(J,0),ut=32879;else if(J.isDataArrayTexture)oe.setTexture2DArray(J,0),ut=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(37440,J.flipY),F.pixelStorei(37441,J.premultiplyAlpha),F.pixelStorei(3317,J.unpackAlignment);let ht=F.getParameter(3314),_i=F.getParameter(32878),Yi=F.getParameter(3316),Bs=F.getParameter(3315),Zn=F.getParameter(32877),Xt=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;F.pixelStorei(3314,Xt.width),F.pixelStorei(32878,Xt.height),F.pixelStorei(3316,R.min.x),F.pixelStorei(3315,R.min.y),F.pixelStorei(32877,R.min.z),ae.isDataTexture||ae.isData3DTexture?F.texSubImage3D(ut,he,ee.x,ee.y,ee.z,Ie,Je,rt,nt,St,Xt.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(ut,he,ee.x,ee.y,ee.z,Ie,Je,rt,nt,Xt.data)):F.texSubImage3D(ut,he,ee.x,ee.y,ee.z,Ie,Je,rt,nt,St,Xt),F.pixelStorei(3314,ht),F.pixelStorei(32878,_i),F.pixelStorei(3316,Yi),F.pixelStorei(3315,Bs),F.pixelStorei(32877,Zn),he===0&&J.generateMipmaps&&F.generateMipmap(ut),Q.unbindTexture()},this.initTexture=function(R){R.isCubeTexture?oe.setTextureCube(R,0):R.isData3DTexture?oe.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?oe.setTexture2DArray(R,0):oe.setTexture2D(R,0),Q.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Q.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var OD=class extends Yb{};OD.prototype.isWebGL1Renderer=!0;var Zb=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new je(e),this.near=t,this.far=i}clone(){return new Zb(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},_a=class extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},LD=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=$f,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ss()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ss()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ss()),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}}},Oi=new E,rm=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Oi.fromBufferAttribute(this,t),Oi.applyMatrix4(e),this.setXYZ(t,Oi.x,Oi.y,Oi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Oi.fromBufferAttribute(this,t),Oi.applyNormalMatrix(e),this.setXYZ(t,Oi.x,Oi.y,Oi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Oi.fromBufferAttribute(this,t),Oi.transformDirection(e),this.setXYZ(t,Oi.x,Oi.y,Oi.z);return this}setX(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=At(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Zs(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Zs(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Zs(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Zs(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=At(t,this.array),i=At(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=At(t,this.array),i=At(i,this.array),r=At(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=At(t,this.array),i=At(i,this.array),r=At(r,this.array),s=At(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Ye(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 rm(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+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}}},ID=class extends Ye{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Vn=class extends kh{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new je(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}},My=new E,Ey=new E,Cy=new ge,Bp=new tl,Sc=new Tr,Dd=class extends _t{constructor(e=new He,t=new Vn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)My.fromBufferAttribute(t,r-1),Ey.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=My.distanceTo(Ey);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,n=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Sc.copy(i.boundingSphere),Sc.applyMatrix4(r),Sc.radius+=s,e.ray.intersectsSphere(Sc)===!1)return;Cy.copy(r).invert(),Bp.copy(e.ray).applyMatrix4(Cy);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new E,h=new E,d=new E,c=new E,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,n.start),g=Math.min(p.count,n.start+n.count);for(let v=m,y=g-1;v<y;v+=u){let x=p.getX(v),w=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,w),Bp.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(c);_<e.near||_>e.far||t.push({distance:_,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,n.start),g=Math.min(f.count,n.start+n.count);for(let v=m,y=g-1;v<y;v+=u){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),Bp.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}},Ty=new E,Py=new E,Gh=class extends Dd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Ty.fromBufferAttribute(t,r),Py.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ty.distanceTo(Py);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},RD=class extends ui{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isVideoTexture=!0,this.minFilter=n!==void 0?n:gt,this.magFilter=s!==void 0?s:gt,this.generateMipmaps=!1;let h=this;function d(){h.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Os=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],d=i[r+1]-h,c=(n-h)/d;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new G:new E);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],n=[],a=new E,o=new ge;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new E)}s[0]=new E,n[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),c<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),n[u]=n[u-1].clone(),a.crossVectors(r[u-1],r[u]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(ri(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(o.makeRotationAxis(a,p))}n[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(ri(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(u=-u);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}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}},bu=class extends Os{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t){let i=t||new G,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),c=o-this.aX,u=l-this.aY;o=c*h-u*d+this.aX,l=c*d+u*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},BD=class extends bu{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function Mg(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,d,c){let u=(a-n)/h-(o-n)/(h+d)+(o-a)/d,p=(o-a)/d-(l-a)/(d+c)+(l-o)/c;u*=d,p*=d,s(a,o,u,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var Ac=new E,Np=new Mg,zp=new Mg,Up=new Mg,ND=class extends Os{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new E){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(Ac.subVectors(r[0],r[1]).add(r[0]),l=Ac);let d=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(Ac.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Ac),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),u),f=Math.pow(d.distanceToSquared(c),u),m=Math.pow(c.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),Np.initNonuniformCatmullRom(l.x,d.x,c.x,h.x,p,f,m),zp.initNonuniformCatmullRom(l.y,d.y,c.y,h.y,p,f,m),Up.initNonuniformCatmullRom(l.z,d.z,c.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(Np.initCatmullRom(l.x,d.x,c.x,h.x,this.tension),zp.initCatmullRom(l.y,d.y,c.y,h.y,this.tension),Up.initCatmullRom(l.z,d.z,c.z,h.z,this.tension));return i.set(Np.calc(o),zp.calc(o),Up.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new E().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Dy(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function zD(e,t){let i=1-e;return i*i*t}function UD(e,t){return 2*(1-e)*e*t}function FD(e,t){return e*e*t}function oh(e,t,i,r){return zD(e,t)+UD(e,i)+FD(e,r)}function kD(e,t){let i=1-e;return i*i*i*t}function jD(e,t){let i=1-e;return 3*i*i*e*t}function GD(e,t){return 3*(1-e)*e*e*t}function VD(e,t){return e*e*e*t}function lh(e,t,i,r,s){return kD(e,t)+jD(e,i)+GD(e,r)+VD(e,s)}var Hr=class extends Os{constructor(e=new G,t=new G,i=new G,r=new G){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(lh(e,r.x,s.x,n.x,a.x),lh(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ud=class extends Os{constructor(e=new E,t=new E,i=new E,r=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(lh(e,r.x,s.x,n.x,a.x),lh(e,r.y,s.y,n.y,a.y),lh(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Zr=class extends Os{constructor(e=new G,t=new G){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new G){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new G;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Qb=class extends Os{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},kn=class extends Os{constructor(e=new G,t=new G,i=new G){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(oh(e,r.x,s.x,n.x),oh(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}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}},HD=class extends Os{constructor(e=new E,t=new E,i=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(oh(e,r.x,s.x,n.x),oh(e,r.y,s.y,n.y),oh(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}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}},Eg=class extends Os{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new G){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],d=r[n>r.length-3?r.length-1:n+2];return i.set(Dy(a,o.x,l.x,h.x,d.x),Dy(a,o.y,l.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new G().fromArray(r))}return this}},WD=Object.freeze({__proto__:null,ArcCurve:BD,CatmullRomCurve3:ND,CubicBezierCurve:Hr,CubicBezierCurve3:ud,EllipseCurve:bu,LineCurve:Zr,LineCurve3:Qb,QuadraticBezierCurve:kn,QuadraticBezierCurve3:HD,SplineCurve:Eg}),Kb=class extends Os{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 Zr(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,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 i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new WD[r.type]().fromJSON(r))}return this}},Od=class extends Kb{constructor(e){super(),this.type="Path",this.currentPoint=new G,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Zr(this.currentPoint.clone(),new G(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new kn(this.currentPoint.clone(),new G(e,t),new G(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new Hr(this.currentPoint.clone(),new G(e,t),new G(i,r),new G(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Eg(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new bu(e,t,i,r,s,n,a,o);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Jb=class extends He{constructor(e=[new G(0,-.5),new G(.5,0),new G(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=ri(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,d=new E,c=new G,u=new E,p=new E,f=new E,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,u.x=g*1,u.y=-m,u.z=g*0,f.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,u.x=g*1,u.y=-m,u.z=g*0,p.copy(u),u.x+=f.x,u.y+=f.y,u.z+=f.z,u.normalize(),o.push(u.x,u.y,u.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),w=Math.cos(y);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*x,d.y=e[_].y,d.z=e[_].x*w,n.push(d.x,d.y,d.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let S=o[3*_+0]*x,A=o[3*_+1],b=o[3*_+0]*w;l.push(S,A,b)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,w=x,_=x+e.length,S=x+e.length+1,A=x+1;s.push(w,_,A),s.push(S,A,_)}this.setIndex(s),this.setAttribute("position",new Ce(n,3)),this.setAttribute("uv",new Ce(a,2)),this.setAttribute("normal",new Ce(l,3))}static fromJSON(e){return new Jb(e.points,e.segments,e.phiStart,e.phiLength)}},Cg=class extends He{constructor(e=1,t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],d=[],c=[],u=[],p=0,f=[],m=i/2,g=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Ce(d,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(u,2));function v(){let x=new E,w=new E,_=0,S=(t-e)/i;for(let A=0;A<=s;A++){let b=[],M=A/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let P=T/r,O=P*o+a,D=Math.sin(O),N=Math.cos(O);w.x=C*D,w.y=-M*i+m,w.z=C*N,d.push(w.x,w.y,w.z),x.set(D,S,N).normalize(),c.push(x.x,x.y,x.z),u.push(P,1-M),b.push(p++)}f.push(b)}for(let A=0;A<r;A++)for(let b=0;b<s;b++){let M=f[b][A],C=f[b+1][A],T=f[b+1][A+1],P=f[b][A+1];h.push(M,C,P),h.push(C,T,P),_+=6}l.addGroup(g,_,0),g+=_}function y(x){let w=p,_=new G,S=new E,A=0,b=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)d.push(0,m*M,0),c.push(0,M,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let P=T/r*o+a,O=Math.cos(P),D=Math.sin(P);S.x=b*D,S.y=m*M,S.z=b*O,d.push(S.x,S.y,S.z),c.push(0,M,0),_.x=O*.5+.5,_.y=D*.5*M+.5,u.push(_.x,_.y),p++}for(let T=0;T<r;T++){let P=w+T,O=C+T;x===!0?h.push(O,O+1,P):h.push(O+1,O,P),A+=3}l.addGroup(g,A,x===!0?1:2),g+=A}}static fromJSON(e){return new Cg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},$b=class extends Cg{constructor(e=1,t=1,i=32,r=1,s=!1,n=0,a=Math.PI*2){super(0,e,t,i,r,s,n,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:n,thetaLength:a}}static fromJSON(e){return new $b(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Tg=class extends He{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],n=[];a(r),l(i),h(),this.setAttribute("position",new Ce(s,3)),this.setAttribute("normal",new Ce(s.slice(),3)),this.setAttribute("uv",new Ce(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new E,x=new E,w=new E;for(let _=0;_<t.length;_+=3)u(t[_+0],y),u(t[_+1],x),u(t[_+2],w),o(y,x,w,v)}function o(v,y,x,w){let _=w+1,S=[];for(let A=0;A<=_;A++){S[A]=[];let b=v.clone().lerp(x,A/_),M=y.clone().lerp(x,A/_),C=_-A;for(let T=0;T<=C;T++)T===0&&A===_?S[A][T]=b:S[A][T]=b.clone().lerp(M,T/C)}for(let A=0;A<_;A++)for(let b=0;b<2*(_-A)-1;b++){let M=Math.floor(b/2);b%2===0?(c(S[A][M+1]),c(S[A+1][M]),c(S[A][M])):(c(S[A][M+1]),c(S[A+1][M+1]),c(S[A+1][M]))}}function l(v){let y=new E;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new E;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=m(v)/2/Math.PI+.5,w=g(v)/Math.PI+.5;n.push(x,1-w)}p(),d()}function d(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],w=n[v+4],_=Math.max(y,x,w),S=Math.min(y,x,w);_>.9&&S<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),w<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function u(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,w=new E,_=new G,S=new G,A=new G;for(let b=0,M=0;b<s.length;b+=9,M+=6){v.set(s[b+0],s[b+1],s[b+2]),y.set(s[b+3],s[b+4],s[b+5]),x.set(s[b+6],s[b+7],s[b+8]),_.set(n[M+0],n[M+1]),S.set(n[M+2],n[M+3]),A.set(n[M+4],n[M+5]),w.copy(v).add(y).add(x).divideScalar(3);let C=m(w);f(_,M+0,v,C),f(S,M+2,y,C),f(A,M+4,x,C)}}function f(v,y,x,w){w<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=w/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Tg(e.vertices,e.indices,e.radius,e.details)}},e_=class extends Tg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,n,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new e_(e.radius,e.detail)}},Ld=class extends Od{constructor(e){super(e),this.uuid=Ss(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Od().fromJSON(r))}return this}},qD={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=t_(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,d,c,u,p;if(r&&(n=KD(e,t,n,i)),e.length>80*i){o=h=e[0],l=d=e[1];for(let f=i;f<s;f+=i)c=e[f],u=e[f+1],c<o&&(o=c),u<l&&(l=u),c>h&&(h=c),u>d&&(d=u);p=Math.max(h-o,d-l),p=p!==0?32767/p:0}return _h(n,a,i,o,l,p,0),a}};function t_(e,t,i,r,s){let n,a;if(s===lO(e,t,i,r)>0)for(n=t;n<i;n+=r)a=Oy(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=Oy(n,e[n],e[n+1],a);return a&&_u(a,a.next)&&(Ah(a),a=a.next),a}function Da(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(_u(i,i.next)||Nt(i.prev,i,i.next)===0)){if(Ah(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function _h(e,t,i,r,s,n,a){if(!e)return;!a&&n&&iO(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?YD(e,r,s,n):XD(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),Ah(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=ZD(Da(e),t,i),_h(e,t,i,r,s,n,2)):a===2&&QD(e,t,i,r,s,n):_h(Da(e),t,i,r,s,n,1);break}}}function XD(e){let t=e.prev,i=e,r=e.next;if(Nt(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,d=s<n?s<a?s:a:n<a?n:a,c=o<l?o<h?o:h:l<h?l:h,u=s>n?s>a?s:a:n>a?n:a,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=d&&f.x<=u&&f.y>=c&&f.y<=p&&Mo(s,o,n,l,a,h,f.x,f.y)&&Nt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function YD(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Nt(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,d=s.y,c=n.y,u=a.y,p=o<l?o<h?o:h:l<h?l:h,f=d<c?d<u?d:u:c<u?c:u,m=o>l?o>h?o:h:l>h?l:h,g=d>c?d>u?d:u:c>u?c:u,v=sm(p,f,t,i,r),y=sm(m,g,t,i,r),x=e.prevZ,w=e.nextZ;for(;x&&x.z>=v&&w&&w.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==a&&Mo(o,d,l,c,h,u,x.x,x.y)&&Nt(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=p&&w.x<=m&&w.y>=f&&w.y<=g&&w!==s&&w!==a&&Mo(o,d,l,c,h,u,w.x,w.y)&&Nt(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==a&&Mo(o,d,l,c,h,u,x.x,x.y)&&Nt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=y;){if(w.x>=p&&w.x<=m&&w.y>=f&&w.y<=g&&w!==s&&w!==a&&Mo(o,d,l,c,h,u,w.x,w.y)&&Nt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function ZD(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!_u(s,n)&&i_(s,r,r.next,n)&&Sh(s,n)&&Sh(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),Ah(r),Ah(r.next),r=e=n),r=r.next}while(r!==e);return Da(r)}function QD(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&nO(a,o)){let l=r_(a,o);a=Da(a,a.next),l=Da(l,l.next),_h(a,t,i,r,s,n,0),_h(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function KD(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=t_(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(sO(h));for(s.sort(JD),n=0;n<s.length;n++)i=$D(s[n],i);return i}function JD(e,t){return e.x-t.x}function $D(e,t){let i=eO(e,t);if(!i)return t;let r=r_(i,e);return Da(r,r.next),Da(i,i.next)}function eO(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let u=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=n&&u>r&&(r=u,s=i.x<i.next.x?i:i.next,u===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,d=1/0,c;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&Mo(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(c=Math.abs(a-i.y)/(n-i.x),Sh(i,e)&&(c<d||c===d&&(i.x>s.x||i.x===s.x&&tO(s,i)))&&(s=i,d=c)),i=i.next;while(i!==o);return s}function tO(e,t){return Nt(e.prev,e,t.prev)<0&&Nt(t.next,e,e.next)<0}function iO(e,t,i,r){let s=e;do s.z===0&&(s.z=sm(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,rO(s)}function rO(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function sm(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function sO(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Mo(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function nO(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!aO(e,t)&&(Sh(e,t)&&Sh(t,e)&&oO(e,t)&&(Nt(e.prev,e,t.prev)||Nt(e,t.prev,t))||_u(e,t)&&Nt(e.prev,e,e.next)>0&&Nt(t.prev,t,t.next)>0)}function Nt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function _u(e,t){return e.x===t.x&&e.y===t.y}function i_(e,t,i,r){let s=Ec(Nt(e,t,i)),n=Ec(Nt(e,t,r)),a=Ec(Nt(i,r,e)),o=Ec(Nt(i,r,t));return!!(s!==n&&a!==o||s===0&&Mc(e,i,t)||n===0&&Mc(e,r,t)||a===0&&Mc(i,e,r)||o===0&&Mc(i,t,r))}function Mc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Ec(e){return e>0?1:e<0?-1:0}function aO(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&i_(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Sh(e,t){return Nt(e.prev,e,e.next)<0?Nt(e,t,e.next)>=0&&Nt(e,e.prev,t)>=0:Nt(e,t,e.prev)<0||Nt(e,e.next,t)<0}function oO(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function r_(e,t){let i=new nm(e.i,e.x,e.y),r=new nm(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Oy(e,t,i,r){let s=new nm(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Ah(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function nm(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function lO(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var s_=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return s_.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Ly(e),Iy(i,e);let n=e.length;t.forEach(Ly);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,Iy(i,t[o]);let a=qD.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function Ly(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Iy(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var n_=class extends Tg{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n_(e.radius,e.detail)}},Pg=class extends He{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:n,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(n+a,Math.PI),l=0,h=[],d=new E,c=new E,u=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let v=[],y=g/i,x=0;g==0&&n==0?x=.5/t:g==i&&o==Math.PI&&(x=-.5/t);for(let w=0;w<=t;w++){let _=w/t;d.x=-e*Math.cos(r+_*s)*Math.sin(n+y*a),d.y=e*Math.cos(n+y*a),d.z=e*Math.sin(r+_*s)*Math.sin(n+y*a),p.push(d.x,d.y,d.z),c.copy(d).normalize(),f.push(c.x,c.y,c.z),m.push(_+x,1-y),v.push(l++)}h.push(v)}for(let g=0;g<i;g++)for(let v=0;v<t;v++){let y=h[g][v+1],x=h[g][v],w=h[g+1][v],_=h[g+1][v+1];(g!==0||n>0)&&u.push(y,x,_),(g!==i-1||o<Math.PI)&&u.push(x,w,_)}this.setIndex(u),this.setAttribute("position",new Ce(p,3)),this.setAttribute("normal",new Ce(f,3)),this.setAttribute("uv",new Ce(m,2))}static fromJSON(e){return new Pg(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},a_=class extends He{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:n},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],h=[],d=new E,c=new E,u=new E,p=new E,f=new E,m=new E,g=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,n,e,u),v(x+.01,s,n,e,p),m.subVectors(p,u),g.addVectors(p,u),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let w=0;w<=r;++w){let _=w/r*Math.PI*2,S=-t*Math.cos(_),A=t*Math.sin(_);d.x=u.x+(S*g.x+A*f.x),d.y=u.y+(S*g.y+A*f.y),d.z=u.z+(S*g.z+A*f.z),o.push(d.x,d.y,d.z),c.subVectors(d,u).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(w/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let w=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),S=(r+1)*y+x,A=(r+1)*(y-1)+x;a.push(w,_,A),a.push(_,S,A)}this.setIndex(a),this.setAttribute("position",new Ce(o,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(h,2));function v(y,x,w,_,S){let A=Math.cos(y),b=Math.sin(y),M=w/x*y,C=Math.cos(M);S.x=_*(2+C)*.5*A,S.y=_*(2+C)*b*.5,S.z=_*Math.sin(M)*.5}}static fromJSON(e){return new a_(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function un(e,t,i){return o_(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Cc(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function o_(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var Su=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];i:{e:{let n;t:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break e}n=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break e}n=i,i=0;break t}break i}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},hO=class extends Su{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:G0,endingEnd:G0}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case V0:s=e,a=2*t-i;break;case H0:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case V0:n=e,o=2*i-t;break;case H0:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,d=this._offsetNext,c=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-c*m+2*c*f-c*p,v=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-u)*m+(1.5+u)*f+.5*p,x=u*m-u*f;for(let w=0;w!==a;++w)s[w]=g*n[h+w]+v*n[l+w]+y*n[o+w]+x*n[d+w];return s}},cO=class extends Su{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),d=1-h;for(let c=0;c!==a;++c)s[c]=n[l+c]*d+n[o+c]*h;return s}},dO=class extends Su{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},sn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Cc(t,this.TimeBufferType),this.values=Cc(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Cc(e.times,Array),values:Cc(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new dO(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new cO(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new hO(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ad:t=this.InterpolantFactoryMethodDiscrete;break;case Md:t=this.InterpolantFactoryMethodLinear;break;case hp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ad;case this.InterpolantFactoryMethodLinear:return Md;case this.InterpolantFactoryMethodSmooth:return hp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=un(i,s,n),this.values=un(this.values,s*a,n*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 i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&o_(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=un(this.times),t=un(this.values),i=this.getValueSize(),r=this.getInterpolation()===hp,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let d=a*i,c=d-i,u=d+i;for(let p=0;p!==i;++p){let f=t[d+p];if(f!==t[c+p]||f!==t[u+p]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let d=a*i,c=n*i;for(let u=0;u!==i;++u)t[c+u]=t[d+u]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=un(e,0,n),this.values=un(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=un(this.times,0),t=un(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};sn.prototype.TimeBufferType=Float32Array;sn.prototype.ValueBufferType=Float32Array;sn.prototype.DefaultInterpolation=Md;var Vh=class extends sn{};Vh.prototype.ValueTypeName="bool";Vh.prototype.ValueBufferType=Array;Vh.prototype.DefaultInterpolation=Ad;Vh.prototype.InterpolantFactoryMethodLinear=void 0;Vh.prototype.InterpolantFactoryMethodSmooth=void 0;var uO=class extends sn{};uO.prototype.ValueTypeName="color";var pO=class extends sn{};pO.prototype.ValueTypeName="number";var fO=class extends Su{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)tt.slerpFlat(s,0,n,l-a,n,l,o);return s}},Dg=class extends sn{InterpolantFactoryMethodLinear(e){return new fO(this.times,this.values,this.getValueSize(),e)}};Dg.prototype.ValueTypeName="quaternion";Dg.prototype.DefaultInterpolation=Md;Dg.prototype.InterpolantFactoryMethodSmooth=void 0;var Hh=class extends sn{};Hh.prototype.ValueTypeName="string";Hh.prototype.ValueBufferType=Array;Hh.prototype.DefaultInterpolation=Ad;Hh.prototype.InterpolantFactoryMethodLinear=void 0;Hh.prototype.InterpolantFactoryMethodSmooth=void 0;var mO=class extends sn{};mO.prototype.ValueTypeName="vector";var Ry={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},l_=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,c=l.length;d<c;d+=2){let u=l[d],p=l[d+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},gO=new l_,Og=class{constructor(e){this.manager=e!==void 0?e:gO,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,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}},js={},vO=class extends Error{constructor(e,t){super(e),this.response=t}},am=class extends Og{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=Ry.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(js[e]!==void 0){js[e].push({onLoad:t,onProgress:i,onError:r});return}js[e]=[],js[e].push({onLoad:t,onProgress:i,onError:r});let n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=js[e],d=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=c?parseInt(c):0,p=u!==0,f=0,m=new ReadableStream({start(g){v();function v(){d.read().then(({done:y,value:x})=>{if(y)g.close();else{f+=x.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let _=0,S=h.length;_<S;_++){let A=h[_];A.onProgress&&A.onProgress(w)}g.enqueue(x),v()}})}}});return new Response(m)}else throw new vO(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(d);return l.arrayBuffer().then(u=>c.decode(u))}}}).then(l=>{Ry.add(e,l);let h=js[e];delete js[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=js[e];if(h===void 0)throw this.manager.itemError(e),l;delete js[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onError&&u.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Wh=class extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new je(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 Wh{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Fp=new ge,By=new E,Ny=new E,Lg=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new G(512,512),this.map=null,this.mapPass=null,this.matrix=new ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _g,this._frameExtents=new G(1,1),this._viewportCount=1,this._viewports=[new $e(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;By.setFromMatrixPosition(e.matrixWorld),t.position.copy(By),Ny.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ny),t.updateMatrixWorld(),Fp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fp),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Fp)}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}},xO=class extends Lg{constructor(){super(new Ei(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=bh*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},wO=class extends Wh{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new xO}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}},zy=new ge,Cl=new E,kp=new E,bO=class extends Lg{constructor(){super(new Ei(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new G(4,2),this._viewportCount=6,this._viewports=[new $e(2,1,1,1),new $e(0,1,1,1),new $e(3,1,1,1),new $e(1,1,1,1),new $e(3,0,1,1),new $e(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Cl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Cl),kp.copy(i.position),kp.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(kp),i.updateMatrixWorld(),r.makeTranslation(-Cl.x,-Cl.y,-Cl.z),zy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zy)}},_O=class extends Wh{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new bO}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}},SO=class extends Lg{constructor(){super(new Pd(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},AO=class extends Wh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new SO}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},MO=class extends He{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},h_=class extends Og{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new am(s.manager);n.setPath(s.path),n.setRequestHeader(s.requestHeader),n.setWithCredentials(s.withCredentials),n.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,u){if(t[u]!==void 0)return t[u];let p=c.interleavedBuffers[u],f=s(c,p.buffer),m=sc(p.type,f),g=new LD(m,p.stride);return g.uuid=p.uuid,t[u]=g,g}function s(c,u){if(i[u]!==void 0)return i[u];let p=c.arrayBuffers[u],f=new Uint32Array(p).buffer;return i[u]=f,f}let n=e.isInstancedBufferGeometry?new MO:new He,a=e.data.index;if(a!==void 0){let c=sc(a.type,a.array);n.setIndex(new Ye(c,1))}let o=e.data.attributes;for(let c in o){let u=o[c],p;if(u.isInterleavedBufferAttribute){let f=r(e.data,u.data);p=new rm(f,u.itemSize,u.offset,u.normalized)}else{let f=sc(u.type,u.array),m=u.isInstancedBufferAttribute?ID:Ye;p=new m(f,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),n.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let u=l[c],p=[];for(let f=0,m=u.length;f<m;f++){let g=u[f],v;if(g.isInterleavedBufferAttribute){let y=r(e.data,g.data);v=new rm(y,g.itemSize,g.offset,g.normalized)}else{let y=sc(g.type,g.array);v=new Ye(y,g.itemSize,g.normalized)}g.name!==void 0&&(v.name=g.name),p.push(v)}n.morphAttributes[c]=p}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,u=h.length;c!==u;++c){let p=h[c];n.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let c=new E;d.center!==void 0&&c.fromArray(d.center),n.boundingSphere=new Tr(c,d.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},EO=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Uy(),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=Uy();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Uy(){return(typeof performance>"u"?Date:performance).now()}var Ig="\\[\\]\\.:\\/",CO=new RegExp("["+Ig+"]","g"),Rg="[^"+Ig+"]",TO="[^"+Ig.replace("\\.","")+"]",PO=/((?:WC+[\/:])*)/.source.replace("WC",Rg),DO=/(WCOD+)?/.source.replace("WCOD",TO),OO=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Rg),LO=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Rg),IO=new RegExp("^"+PO+DO+OO+LO+"$"),RO=["material","materials","bones","map"],BO=class{constructor(e,t,i){let r=i||Mt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Mt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Mt.parseTrackName(t),this.node=Mt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Mt.Composite(e,t,i):new Mt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(CO,"")}static parseTrackName(e){let t=IO.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);RO.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let n=0;n<s.length;n++){let a=s[n];if(a.name===t||a.uuid===t)return a;let o=i(a.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Mt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let n=e[r];if(n===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=s}else n.fromArray!==void 0&&n.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Mt.Composite=BO;Mt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Mt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Mt.prototype.GetterByBindingType=[Mt.prototype._getValue_direct,Mt.prototype._getValue_array,Mt.prototype._getValue_arrayElement,Mt.prototype._getValue_toArray];Mt.prototype.SetterByBindingTypeAndVersioning=[[Mt.prototype._setValue_direct,Mt.prototype._setValue_direct_setNeedsUpdate,Mt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_array,Mt.prototype._setValue_array_setNeedsUpdate,Mt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_arrayElement,Mt.prototype._setValue_arrayElement_setNeedsUpdate,Mt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_fromArray,Mt.prototype._setValue_fromArray_setNeedsUpdate,Mt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var s7=new Float32Array(1),Oe=class{constructor(e){this.value=e}clone(){return new Oe(this.value.clone===void 0?this.value:this.value.clone())}},c_=class{constructor(e,t,i=0,r=1/0){this.ray=new tl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new wg,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return om(e,this,i,t),i.sort(Fy),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)om(e[r],this,i,t);return i.sort(Fy),i}};function Fy(e,t){return e.distance-t.distance}function om(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let n=0,a=s.length;n<a;n++)om(s[n],t,i,!0)}}var ky=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(ri(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},jy=new G,NO=class{constructor(e=new G(1/0,1/0),t=new G(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=jy.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return jy.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)}},Gy=new E,Tc=new E,Ar=class{constructor(e=new E,t=new E){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){Gy.subVectors(e,this.start),Tc.subVectors(this.end,this.start);let i=Tc.dot(Tc),r=Tc.dot(Gy)/i;return t&&(r=ri(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Vy=new E,zO=class extends _t{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new He,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let n=0,a=1,o=32;n<o;n++,a++){let l=n/o*Math.PI*2,h=a/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Ce(r,3));let s=new Vn({fog:!1,toneMapped:!1});this.cone=new Gh(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Vy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Vy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},UO=class extends nr{constructor(e,t,i){let r=new Pg(t,4,2),s=new jh({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Hy=new E,Pc=new E,Wy=new E,FO=class extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new He;r.setAttribute("position",new Ce([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Vn({fog:!1,toneMapped:!1});this.lightPlane=new Dd(r,s),this.add(this.lightPlane),r=new He,r.setAttribute("position",new Ce([0,0,0,0,0,1],3)),this.targetLine=new Dd(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Hy.setFromMatrixPosition(this.light.matrixWorld),Pc.setFromMatrixPosition(this.light.target.matrixWorld),Wy.subVectors(Pc,Hy),this.lightPlane.lookAt(Pc),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(Pc),this.targetLine.scale.z=Wy.length()}},Dc=new E,zt=new rl,Id=class extends Gh{constructor(e){let t=new He,i=new Vn({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),n[p]===void 0&&(n[p]=[]),n[p].push(r.length/3-1)}t.setAttribute("position",new Ce(r,3)),t.setAttribute("color",new Ce(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();let l=new je(16755200),h=new je(16711680),d=new je(43775),c=new je(16777215),u=new je(3355443);this.setColors(l,h,d,c,u)}setColors(e,t,i,r,s){let n=this.geometry.getAttribute("color");n.setXYZ(0,e.r,e.g,e.b),n.setXYZ(1,e.r,e.g,e.b),n.setXYZ(2,e.r,e.g,e.b),n.setXYZ(3,e.r,e.g,e.b),n.setXYZ(4,e.r,e.g,e.b),n.setXYZ(5,e.r,e.g,e.b),n.setXYZ(6,e.r,e.g,e.b),n.setXYZ(7,e.r,e.g,e.b),n.setXYZ(8,e.r,e.g,e.b),n.setXYZ(9,e.r,e.g,e.b),n.setXYZ(10,e.r,e.g,e.b),n.setXYZ(11,e.r,e.g,e.b),n.setXYZ(12,e.r,e.g,e.b),n.setXYZ(13,e.r,e.g,e.b),n.setXYZ(14,e.r,e.g,e.b),n.setXYZ(15,e.r,e.g,e.b),n.setXYZ(16,e.r,e.g,e.b),n.setXYZ(17,e.r,e.g,e.b),n.setXYZ(18,e.r,e.g,e.b),n.setXYZ(19,e.r,e.g,e.b),n.setXYZ(20,e.r,e.g,e.b),n.setXYZ(21,e.r,e.g,e.b),n.setXYZ(22,e.r,e.g,e.b),n.setXYZ(23,e.r,e.g,e.b),n.setXYZ(24,t.r,t.g,t.b),n.setXYZ(25,t.r,t.g,t.b),n.setXYZ(26,t.r,t.g,t.b),n.setXYZ(27,t.r,t.g,t.b),n.setXYZ(28,t.r,t.g,t.b),n.setXYZ(29,t.r,t.g,t.b),n.setXYZ(30,t.r,t.g,t.b),n.setXYZ(31,t.r,t.g,t.b),n.setXYZ(32,i.r,i.g,i.b),n.setXYZ(33,i.r,i.g,i.b),n.setXYZ(34,i.r,i.g,i.b),n.setXYZ(35,i.r,i.g,i.b),n.setXYZ(36,i.r,i.g,i.b),n.setXYZ(37,i.r,i.g,i.b),n.setXYZ(38,r.r,r.g,r.b),n.setXYZ(39,r.r,r.g,r.b),n.setXYZ(40,s.r,s.g,s.b),n.setXYZ(41,s.r,s.g,s.b),n.setXYZ(42,s.r,s.g,s.b),n.setXYZ(43,s.r,s.g,s.b),n.setXYZ(44,s.r,s.g,s.b),n.setXYZ(45,s.r,s.g,s.b),n.setXYZ(46,s.r,s.g,s.b),n.setXYZ(47,s.r,s.g,s.b),n.setXYZ(48,s.r,s.g,s.b),n.setXYZ(49,s.r,s.g,s.b),n.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;zt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),jt("c",t,e,zt,0,0,-1),jt("t",t,e,zt,0,0,1),jt("n1",t,e,zt,-i,-r,-1),jt("n2",t,e,zt,i,-r,-1),jt("n3",t,e,zt,-i,r,-1),jt("n4",t,e,zt,i,r,-1),jt("f1",t,e,zt,-i,-r,1),jt("f2",t,e,zt,i,-r,1),jt("f3",t,e,zt,-i,r,1),jt("f4",t,e,zt,i,r,1),jt("u1",t,e,zt,i*.7,r*1.1,-1),jt("u2",t,e,zt,-i*.7,r*1.1,-1),jt("u3",t,e,zt,0,r*2,-1),jt("cf1",t,e,zt,-i,0,1),jt("cf2",t,e,zt,i,0,1),jt("cf3",t,e,zt,0,-r,1),jt("cf4",t,e,zt,0,r,1),jt("cn1",t,e,zt,-i,0,-1),jt("cn2",t,e,zt,i,0,-1),jt("cn3",t,e,zt,0,-r,-1),jt("cn4",t,e,zt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function jt(e,t,i,r,s,n,a){Dc.set(s,n,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,d=o.length;h<d;h++)l.setXYZ(o[h],Dc.x,Dc.y,Dc.z)}}var Rd=class extends Gh{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new He;s.setIndex(new Ye(i,1)),s.setAttribute("position",new Ce(r,3)),super(s,new Vn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},kO=class extends Gh{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new He;r.setAttribute("position",new Ce(t,3)),r.setAttribute("color",new Ce(i,3));let s=new Vn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new je,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:el}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=el);var Tl=".",Bg=Symbol("target"),d_=Symbol("unsubscribe");function lm(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function jO(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var gs=Array.isArray;function Ng(e){return typeof e=="symbol"}var GO={after:(e,t)=>gs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>gs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Tl),Ng(t)?e+t.toString():e+t):e,initial:e=>{if(gs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Tl);return t===-1?"":e.slice(0,t)},last:e=>{if(gs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Tl);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(gs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Tl);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(Tl,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},yr=GO;function VO(e){return typeof e=="object"&&typeof e.next=="function"}function HO(e,t,i,r,s){let n=e.next;if(t.name==="entries")e.next=function(){let a=n.call(this);return a.done===!1&&(a.value[0]=s(a.value[0],t,a.value[0],r),a.value[1]=s(a.value[1],t,a.value[0],r)),a};else if(t.name==="values"){let a=i[Bg].keys();e.next=function(){let o=n.call(this);return o.done===!1&&(o.value=s(o.value,t,a.next().value,r)),o}}else e.next=function(){let a=n.call(this);return a.done===!1&&(a.value=s(a.value,t,a.value,r)),a};return e}function qy(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Ng(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var WO=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],n=s||e;this._pathCache.set(n,t);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(e,i):e,this._proxyCache.set(n,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,yr.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&"set"in n?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function hm(e){return toString.call(e)==="[object Object]"}function Oc(){return!0}function ro(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var u_=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),qO=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),p_={push:Oc,pop:Oc,shift:Oc,unshift:Oc,copyWithin:ro,reverse:ro,sort:ro,splice:ro,flat:ro,fill:ro},XO=new Set([...u_,...qO,...Object.keys(p_)]);function Lc(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var f_=["keys","values","entries"],m_=new Set(["has","toString"]),g_={add:Lc,clear:Lc,delete:Lc,forEach:Lc},YO=new Set([...m_,...Object.keys(g_),...f_]);function Ic(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var ZO=new Set([...m_,"get"]),v_={set:Ic,clear:Ic,delete:Ic,forEach:Ic},QO=new Set([...ZO,...Object.keys(v_),...f_]),jn=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return u_.has(e)}_shallowClone(e){let t=e;if(hm(e))t={...e};else if(gs(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(gs(r)?this._onIsChanged=p_[t]:r instanceof Set?this._onIsChanged=g_[t]:r instanceof Map&&(this._onIsChanged=v_[t]),r):i}update(e,t,i){let r=yr.after(e,this._path);if(t!=="length"){let s=this.clone;yr.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],yr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Xy=class extends jn{static isHandledMethod(e){return XO.has(e)}},KO=class extends jn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Yy=class extends jn{static isHandledMethod(e){return YO.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)}},Zy=class extends jn{static isHandledMethod(e){return QO.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},JO=class extends jn{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},$O=class extends jn{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},yo=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return hm(e)||gs(e)||lm(e)}static isHandledMethod(e,t){return hm(e)?jn.isHandledMethod(t):gs(e)?Xy.isHandledMethod(t):e instanceof Set?Yy.isHandledMethod(t):e instanceof Map?Zy.isHandledMethod(t):lm(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=jn;gs(e)?r=Xy:e instanceof Date?r=KO:e instanceof Set?r=Yy:e instanceof Map?r=Zy:e instanceof WeakSet?r=JO:e instanceof WeakMap&&(r=$O),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=yo.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},eL={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},zg=(e,t,i={})=>{i={...eL,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new WO(s),h=typeof i.onValidate=="function",d=new yo(h),c=(y,x,w,_,S)=>!h||d.isCloning||i.onValidate(yr.concat(l.getPath(y),x),w,_,S)===!0,u=(y,x,w,_)=>{!qy(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,w,_)},p=(y,x,w,_,S)=>{d.isCloning?d.update(y,x,_):t(yr.concat(y,x),w,_,S)},f=y=>y&&(y[r]||y),m=(y,x,w,_)=>jO(y)||w==="constructor"||n&&!yo.isHandledMethod(x,w)||qy(l,i,w)||l.isGetInvariant(x,w)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,yr.concat(_,w),g,r)),g={get(y,x,w){if(Ng(x)){if(x===r||x===Bg)return y;if(x===d_&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=lm(y)?Reflect.get(y,x):Reflect.get(y,x,w);return m(_,y,x)},set(y,x,w,_){w=f(w);let S=y[r]||y,A=S[x];if(s(A,w)&&x in y)return!0;let b=c(y,x,w,A);return b&&l.setProperty(S,x,w,_,A)?(u(y,x,y[x],A),!0):!b},defineProperty(y,x,w){if(!l.isSameDescriptor(w,y,x)){let _=y[x];c(y,x,w.value,_)&&l.defineProperty(y,x,w,_)&&u(y,x,w.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let w=Reflect.get(y,x),_=c(y,x,void 0,w);return _&&l.deleteProperty(y,x,w)?(u(y,x,void 0,w),!0):!_},apply(y,x,w){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,w);if((o===!1||o!==!0&&!o.includes(y.name))&&yo.isHandledType(_)){let S=yr.initial(l.getPath(y)),A=yo.isHandledMethod(_,y.name);d.start(_,S,w);let b=Reflect.apply(y,d.preferredThisArg(y,x,_),A?w.map(T=>f(T)):w),M=d.isChanged(_,s),C=d.stop();if(yo.isHandledType(b)&&A&&(x instanceof Map&&y.name==="get"&&(S=yr.concat(S,w[0])),b=l.getProxy(b,S,g)),M){let T={name:y.name,args:w,result:b},P=d.isCloning?yr.initial(S):S,O=d.isCloning?yr.last(S):"";c(yr.get(e,P),O,_,C,T)?p(P,O,_,C,T):d.undo(_)}return(x instanceof Map||x instanceof Set)&&VO(b)?HO(b,y,x,S,m):b}return Reflect.apply(y,x,w)}},v=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};zg.target=e=>e&&e[Bg]||e;zg.unsubscribe=e=>e[d_]||e;var Qy=zg,tL=typeof global=="object"&&global&&global.Object===Object&&global,y_=tL,iL=typeof self=="object"&&self&&self.Object===Object&&self,rL=y_||iL||Function("return this")(),$r=rL,sL=$r.Symbol,Pr=sL,x_=Object.prototype,nL=x_.hasOwnProperty,aL=x_.toString,Pl=Pr?Pr.toStringTag:void 0;function oL(e){var t=nL.call(e,Pl),i=e[Pl];try{e[Pl]=void 0;var r=!0}catch{}var s=aL.call(e);return r&&(t?e[Pl]=i:delete e[Pl]),s}var lL=oL,hL=Object.prototype,cL=hL.toString;function dL(e){return cL.call(e)}var uL=dL,pL="[object Null]",fL="[object Undefined]",Ky=Pr?Pr.toStringTag:void 0;function mL(e){return e==null?e===void 0?fL:pL:Ky&&Ky in Object(e)?lL(e):uL(e)}var Ra=mL;function gL(e){return e!=null&&typeof e=="object"}var en=gL,vL="[object Symbol]";function yL(e){return typeof e=="symbol"||en(e)&&Ra(e)==vL}var Au=yL;function xL(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var w_=xL,wL=Array.isArray,Ts=wL,bL=1/0,Jy=Pr?Pr.prototype:void 0,$y=Jy?Jy.toString:void 0;function b_(e){if(typeof e=="string")return e;if(Ts(e))return w_(e,b_)+"";if(Au(e))return $y?$y.call(e):"";var t=e+"";return t=="0"&&1/e==-bL?"-0":t}var _L=b_,SL=/\s/;function AL(e){for(var t=e.length;t--&&SL.test(e.charAt(t)););return t}var ML=AL,EL=/^\s+/;function CL(e){return e&&e.slice(0,ML(e)+1).replace(EL,"")}var TL=CL;function PL(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Kr=PL,e1=0/0,DL=/^[-+]0x[0-9a-f]+$/i,OL=/^0b[01]+$/i,LL=/^0o[0-7]+$/i,IL=parseInt;function RL(e){if(typeof e=="number")return e;if(Au(e))return e1;if(Kr(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Kr(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=TL(e);var i=OL.test(e);return i||LL.test(e)?IL(e.slice(2),i?2:8):DL.test(e)?e1:+e}var t1=RL;function BL(e){return e}var NL=BL,zL="[object AsyncFunction]",UL="[object Function]",FL="[object GeneratorFunction]",kL="[object Proxy]";function jL(e){if(!Kr(e))return!1;var t=Ra(e);return t==UL||t==FL||t==zL||t==kL}var __=jL,GL=$r["__core-js_shared__"],jp=GL,i1=function(){var e=/[^.]+$/.exec(jp&&jp.keys&&jp.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function VL(e){return!!i1&&i1 in e}var HL=VL,WL=Function.prototype,qL=WL.toString;function XL(e){if(e!=null){try{return qL.call(e)}catch{}try{return e+""}catch{}}return""}var Ba=XL,YL=/[\\^$.*+?()[\]{}|]/g,ZL=/^\[object .+?Constructor\]$/,QL=Function.prototype,KL=Object.prototype,JL=QL.toString,$L=KL.hasOwnProperty,eI=RegExp("^"+JL.call($L).replace(YL,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function tI(e){if(!Kr(e)||HL(e))return!1;var t=__(e)?eI:ZL;return t.test(Ba(e))}var iI=tI;function rI(e,t){return e?.[t]}var sI=rI;function nI(e,t){var i=sI(e,t);return iI(i)?i:void 0}var Na=nI,aI=Na($r,"WeakMap"),cm=aI,r1=Object.create,oI=function(){function e(){}return function(t){if(!Kr(t))return{};if(r1)return r1(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),lI=oI;function hI(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var cI=hI;function dI(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var uI=dI,pI=800,fI=16,mI=Date.now;function gI(e){var t=0,i=0;return function(){var r=mI(),s=fI-(r-i);if(i=r,s>0){if(++t>=pI)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var vI=gI;function yI(e){return function(){return e}}var xI=yI,wI=function(){try{var e=Na(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Bd=wI,bI=Bd?function(e,t){return Bd(e,"toString",{configurable:!0,enumerable:!1,value:xI(t),writable:!0})}:NL,_I=bI,SI=vI(_I),AI=SI;function MI(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var EI=MI,CI=9007199254740991,TI=/^(?:0|[1-9]\d*)$/;function PI(e,t){var i=typeof e;return t=t??CI,!!t&&(i=="number"||i!="symbol"&&TI.test(e))&&e>-1&&e%1==0&&e<t}var Ug=PI;function DI(e,t,i){t=="__proto__"&&Bd?Bd(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var S_=DI;function OI(e,t){return e===t||e!==e&&t!==t}var Fg=OI,LI=Object.prototype,II=LI.hasOwnProperty;function RI(e,t,i){var r=e[t];(!(II.call(e,t)&&Fg(r,i))||i===void 0&&!(t in e))&&S_(e,t,i)}var kg=RI;function BI(e,t,i,r){var s=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?S_(i,o,l):kg(i,o,l)}return i}var qh=BI,s1=Math.max;function NI(e,t,i){return t=s1(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=s1(r.length-t,0),a=Array(n);++s<n;)a[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(a),cI(e,this,o)}}var zI=NI,UI=9007199254740991;function FI(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=UI}var jg=FI;function kI(e){return e!=null&&jg(e.length)&&!__(e)}var A_=kI,jI=Object.prototype;function GI(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||jI;return e===i}var Gg=GI;function VI(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var HI=VI,WI="[object Arguments]";function qI(e){return en(e)&&Ra(e)==WI}var n1=qI,M_=Object.prototype,XI=M_.hasOwnProperty,YI=M_.propertyIsEnumerable,ZI=n1(function(){return arguments}())?n1:function(e){return en(e)&&XI.call(e,"callee")&&!YI.call(e,"callee")},Vg=ZI;function QI(){return!1}var KI=QI,E_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,a1=E_&&typeof module=="object"&&module&&!module.nodeType&&module,JI=a1&&a1.exports===E_,o1=JI?$r.Buffer:void 0,$I=o1?o1.isBuffer:void 0,eR=$I||KI,Nd=eR,tR="[object Arguments]",iR="[object Array]",rR="[object Boolean]",sR="[object Date]",nR="[object Error]",aR="[object Function]",oR="[object Map]",lR="[object Number]",hR="[object Object]",cR="[object RegExp]",dR="[object Set]",uR="[object String]",pR="[object WeakMap]",fR="[object ArrayBuffer]",mR="[object DataView]",gR="[object Float32Array]",vR="[object Float64Array]",yR="[object Int8Array]",xR="[object Int16Array]",wR="[object Int32Array]",bR="[object Uint8Array]",_R="[object Uint8ClampedArray]",SR="[object Uint16Array]",AR="[object Uint32Array]",Pt={};Pt[gR]=Pt[vR]=Pt[yR]=Pt[xR]=Pt[wR]=Pt[bR]=Pt[_R]=Pt[SR]=Pt[AR]=!0;Pt[tR]=Pt[iR]=Pt[fR]=Pt[rR]=Pt[mR]=Pt[sR]=Pt[nR]=Pt[aR]=Pt[oR]=Pt[lR]=Pt[hR]=Pt[cR]=Pt[dR]=Pt[uR]=Pt[pR]=!1;function MR(e){return en(e)&&jg(e.length)&&!!Pt[Ra(e)]}var ER=MR;function CR(e){return function(t){return e(t)}}var Hg=CR,C_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hh=C_&&typeof module=="object"&&module&&!module.nodeType&&module,TR=hh&&hh.exports===C_,Gp=TR&&y_.process,PR=function(){try{var e=hh&&hh.require&&hh.require("util").types;return e||Gp&&Gp.binding&&Gp.binding("util")}catch{}}(),qo=PR,l1=qo&&qo.isTypedArray,DR=l1?Hg(l1):ER,T_=DR,OR=Object.prototype,LR=OR.hasOwnProperty;function IR(e,t){var i=Ts(e),r=!i&&Vg(e),s=!i&&!r&&Nd(e),n=!i&&!r&&!s&&T_(e),a=i||r||s||n,o=a?HI(e.length,String):[],l=o.length;for(var h in e)(t||LR.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Ug(h,l)))&&o.push(h);return o}var P_=IR;function RR(e,t){return function(i){return e(t(i))}}var D_=RR,BR=D_(Object.keys,Object),NR=BR,zR=Object.prototype,UR=zR.hasOwnProperty;function FR(e){if(!Gg(e))return NR(e);var t=[];for(var i in Object(e))UR.call(e,i)&&i!="constructor"&&t.push(i);return t}var kR=FR;function jR(e){return A_(e)?P_(e):kR(e)}var Wg=jR;function GR(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var VR=GR,HR=Object.prototype,WR=HR.hasOwnProperty;function qR(e){if(!Kr(e))return VR(e);var t=Gg(e),i=[];for(var r in e)r=="constructor"&&(t||!WR.call(e,r))||i.push(r);return i}var XR=qR;function YR(e){return A_(e)?P_(e,!0):XR(e)}var qg=YR,ZR=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,QR=/^\w*$/;function KR(e,t){if(Ts(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Au(e)?!0:QR.test(e)||!ZR.test(e)||t!=null&&e in Object(t)}var JR=KR,$R=Na(Object,"create"),Mh=$R;function e4(){this.__data__=Mh?Mh(null):{},this.size=0}var t4=e4;function i4(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var r4=i4,s4="__lodash_hash_undefined__",n4=Object.prototype,a4=n4.hasOwnProperty;function o4(e){var t=this.__data__;if(Mh){var i=t[e];return i===s4?void 0:i}return a4.call(t,e)?t[e]:void 0}var l4=o4,h4=Object.prototype,c4=h4.hasOwnProperty;function d4(e){var t=this.__data__;return Mh?t[e]!==void 0:c4.call(t,e)}var u4=d4,p4="__lodash_hash_undefined__";function f4(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Mh&&t===void 0?p4:t,this}var m4=f4;function nl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}nl.prototype.clear=t4;nl.prototype.delete=r4;nl.prototype.get=l4;nl.prototype.has=u4;nl.prototype.set=m4;var h1=nl;function g4(){this.__data__=[],this.size=0}var v4=g4;function y4(e,t){for(var i=e.length;i--;)if(Fg(e[i][0],t))return i;return-1}var Mu=y4,x4=Array.prototype,w4=x4.splice;function b4(e){var t=this.__data__,i=Mu(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():w4.call(t,i,1),--this.size,!0}var _4=b4;function S4(e){var t=this.__data__,i=Mu(t,e);return i<0?void 0:t[i][1]}var A4=S4;function M4(e){return Mu(this.__data__,e)>-1}var E4=M4;function C4(e,t){var i=this.__data__,r=Mu(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var T4=C4;function al(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}al.prototype.clear=v4;al.prototype.delete=_4;al.prototype.get=A4;al.prototype.has=E4;al.prototype.set=T4;var Eu=al,P4=Na($r,"Map"),Eh=P4;function D4(){this.size=0,this.__data__={hash:new h1,map:new(Eh||Eu),string:new h1}}var O4=D4;function L4(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var I4=L4;function R4(e,t){var i=e.__data__;return I4(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Cu=R4;function B4(e){var t=Cu(this,e).delete(e);return this.size-=t?1:0,t}var N4=B4;function z4(e){return Cu(this,e).get(e)}var U4=z4;function F4(e){return Cu(this,e).has(e)}var k4=F4;function j4(e,t){var i=Cu(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var G4=j4;function ol(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}ol.prototype.clear=O4;ol.prototype.delete=N4;ol.prototype.get=U4;ol.prototype.has=k4;ol.prototype.set=G4;var Tu=ol,V4="Expected a function";function Xg(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(V4);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],n=i.cache;if(n.has(s))return n.get(s);var a=e.apply(this,r);return i.cache=n.set(s,a)||n,a};return i.cache=new(Xg.Cache||Tu),i}Xg.Cache=Tu;var H4=Xg,W4=500;function q4(e){var t=H4(e,function(r){return i.size===W4&&i.clear(),r}),i=t.cache;return t}var X4=q4,Y4=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Z4=/\\(\\)?/g,Q4=X4(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Y4,function(i,r,s,n){t.push(s?n.replace(Z4,"$1"):r||i)}),t}),K4=Q4;function J4(e){return e==null?"":_L(e)}var $4=J4;function eB(e,t){return Ts(e)?e:JR(e,t)?[e]:K4($4(e))}var ll=eB,tB=1/0;function iB(e){if(typeof e=="string"||Au(e))return e;var t=e+"";return t=="0"&&1/e==-tB?"-0":t}var Pu=iB;function rB(e,t){t=ll(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Pu(t[i++])];return i&&i==r?e:void 0}var O_=rB;function sB(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Yg=sB,c1=Pr?Pr.isConcatSpreadable:void 0;function nB(e){return Ts(e)||Vg(e)||!!(c1&&e&&e[c1])}var aB=nB;function L_(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=aB),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?L_(o,t-1,i,r,s):Yg(s,o):r||(s[s.length]=o)}return s}var oB=L_;function lB(e){var t=e==null?0:e.length;return t?oB(e,1):[]}var hB=lB;function cB(e){return AI(zI(e,void 0,hB),e+"")}var I_=cB,dB=D_(Object.getPrototypeOf,Object),Zg=dB,uB="[object Object]",pB=Function.prototype,fB=Object.prototype,R_=pB.toString,mB=fB.hasOwnProperty,gB=R_.call(Object);function vB(e){if(!en(e)||Ra(e)!=uB)return!1;var t=Zg(e);if(t===null)return!0;var i=mB.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&R_.call(i)==gB}var yB=vB;function xB(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var n=Array(s);++r<s;)n[r]=e[r+t];return n}var wB=xB;function bB(){this.__data__=new Eu,this.size=0}var _B=bB;function SB(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var AB=SB;function MB(e){return this.__data__.get(e)}var EB=MB;function CB(e){return this.__data__.has(e)}var TB=CB,PB=200;function DB(e,t){var i=this.__data__;if(i instanceof Eu){var r=i.__data__;if(!Eh||r.length<PB-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Tu(r)}return i.set(e,t),this.size=i.size,this}var OB=DB;function hl(e){var t=this.__data__=new Eu(e);this.size=t.size}hl.prototype.clear=_B;hl.prototype.delete=AB;hl.prototype.get=EB;hl.prototype.has=TB;hl.prototype.set=OB;var pd=hl;function LB(e,t){return e&&qh(t,Wg(t),e)}var IB=LB;function RB(e,t){return e&&qh(t,qg(t),e)}var BB=RB,B_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,d1=B_&&typeof module=="object"&&module&&!module.nodeType&&module,NB=d1&&d1.exports===B_,u1=NB?$r.Buffer:void 0,p1=u1?u1.allocUnsafe:void 0;function zB(e,t){if(t)return e.slice();var i=e.length,r=p1?p1(i):new e.constructor(i);return e.copy(r),r}var UB=zB;function FB(e,t){for(var i=-1,r=e==null?0:e.length,s=0,n=[];++i<r;){var a=e[i];t(a,i,e)&&(n[s++]=a)}return n}var kB=FB;function jB(){return[]}var N_=jB,GB=Object.prototype,VB=GB.propertyIsEnumerable,f1=Object.getOwnPropertySymbols,HB=f1?function(e){return e==null?[]:(e=Object(e),kB(f1(e),function(t){return VB.call(e,t)}))}:N_,Qg=HB;function WB(e,t){return qh(e,Qg(e),t)}var qB=WB,XB=Object.getOwnPropertySymbols,YB=XB?function(e){for(var t=[];e;)Yg(t,Qg(e)),e=Zg(e);return t}:N_,z_=YB;function ZB(e,t){return qh(e,z_(e),t)}var QB=ZB;function KB(e,t,i){var r=t(e);return Ts(e)?r:Yg(r,i(e))}var U_=KB;function JB(e){return U_(e,Wg,Qg)}var dm=JB;function $B(e){return U_(e,qg,z_)}var F_=$B,eN=Na($r,"DataView"),um=eN,tN=Na($r,"Promise"),pm=tN,iN=Na($r,"Set"),fm=iN,m1="[object Map]",rN="[object Object]",g1="[object Promise]",v1="[object Set]",y1="[object WeakMap]",x1="[object DataView]",sN=Ba(um),nN=Ba(Eh),aN=Ba(pm),oN=Ba(fm),lN=Ba(cm),oa=Ra;(um&&oa(new um(new ArrayBuffer(1)))!=x1||Eh&&oa(new Eh)!=m1||pm&&oa(pm.resolve())!=g1||fm&&oa(new fm)!=v1||cm&&oa(new cm)!=y1)&&(oa=function(e){var t=Ra(e),i=t==rN?e.constructor:void 0,r=i?Ba(i):"";if(r)switch(r){case sN:return x1;case nN:return m1;case aN:return g1;case oN:return v1;case lN:return y1}return t});var Ch=oa,hN=Object.prototype,cN=hN.hasOwnProperty;function dN(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&cN.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var uN=dN,pN=$r.Uint8Array,zd=pN;function fN(e){var t=new e.constructor(e.byteLength);return new zd(t).set(new zd(e)),t}var Kg=fN;function mN(e,t){var i=t?Kg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var gN=mN,vN=/\w*$/;function yN(e){var t=new e.constructor(e.source,vN.exec(e));return t.lastIndex=e.lastIndex,t}var xN=yN,w1=Pr?Pr.prototype:void 0,b1=w1?w1.valueOf:void 0;function wN(e){return b1?Object(b1.call(e)):{}}var bN=wN;function _N(e,t){var i=t?Kg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var SN=_N,AN="[object Boolean]",MN="[object Date]",EN="[object Map]",CN="[object Number]",TN="[object RegExp]",PN="[object Set]",DN="[object String]",ON="[object Symbol]",LN="[object ArrayBuffer]",IN="[object DataView]",RN="[object Float32Array]",BN="[object Float64Array]",NN="[object Int8Array]",zN="[object Int16Array]",UN="[object Int32Array]",FN="[object Uint8Array]",kN="[object Uint8ClampedArray]",jN="[object Uint16Array]",GN="[object Uint32Array]";function VN(e,t,i){var r=e.constructor;switch(t){case LN:return Kg(e);case AN:case MN:return new r(+e);case IN:return gN(e,i);case RN:case BN:case NN:case zN:case UN:case FN:case kN:case jN:case GN:return SN(e,i);case EN:return new r;case CN:case DN:return new r(e);case TN:return xN(e);case PN:return new r;case ON:return bN(e)}}var HN=VN;function WN(e){return typeof e.constructor=="function"&&!Gg(e)?lI(Zg(e)):{}}var qN=WN,XN="[object Map]";function YN(e){return en(e)&&Ch(e)==XN}var ZN=YN,_1=qo&&qo.isMap,QN=_1?Hg(_1):ZN,KN=QN,JN="[object Set]";function $N(e){return en(e)&&Ch(e)==JN}var e5=$N,S1=qo&&qo.isSet,t5=S1?Hg(S1):e5,i5=t5,r5=1,s5=2,n5=4,k_="[object Arguments]",a5="[object Array]",o5="[object Boolean]",l5="[object Date]",h5="[object Error]",j_="[object Function]",c5="[object GeneratorFunction]",d5="[object Map]",u5="[object Number]",G_="[object Object]",p5="[object RegExp]",f5="[object Set]",m5="[object String]",g5="[object Symbol]",v5="[object WeakMap]",y5="[object ArrayBuffer]",x5="[object DataView]",w5="[object Float32Array]",b5="[object Float64Array]",_5="[object Int8Array]",S5="[object Int16Array]",A5="[object Int32Array]",M5="[object Uint8Array]",E5="[object Uint8ClampedArray]",C5="[object Uint16Array]",T5="[object Uint32Array]",Tt={};Tt[k_]=Tt[a5]=Tt[y5]=Tt[x5]=Tt[o5]=Tt[l5]=Tt[w5]=Tt[b5]=Tt[_5]=Tt[S5]=Tt[A5]=Tt[d5]=Tt[u5]=Tt[G_]=Tt[p5]=Tt[f5]=Tt[m5]=Tt[g5]=Tt[M5]=Tt[E5]=Tt[C5]=Tt[T5]=!0;Tt[h5]=Tt[j_]=Tt[v5]=!1;function fd(e,t,i,r,s,n){var a,o=t&r5,l=t&s5,h=t&n5;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!Kr(e))return e;var d=Ts(e);if(d){if(a=uN(e),!o)return uI(e,a)}else{var c=Ch(e),u=c==j_||c==c5;if(Nd(e))return UB(e,o);if(c==G_||c==k_||u&&!s){if(a=l||u?{}:qN(e),!o)return l?QB(e,BB(a,e)):qB(e,IB(a,e))}else{if(!Tt[c])return s?e:{};a=HN(e,c,o)}}n||(n=new pd);var p=n.get(e);if(p)return p;n.set(e,a),i5(e)?e.forEach(function(g){a.add(fd(g,t,i,g,e,n))}):KN(e)&&e.forEach(function(g,v){a.set(v,fd(g,t,i,v,e,n))});var f=h?l?F_:dm:l?qg:Wg,m=d?void 0:f(e);return EI(m||e,function(g,v){m&&(v=g,g=e[v]),kg(a,v,fd(g,t,i,v,e,n))}),a}var V_=fd,P5=1,D5=4;function O5(e){return V_(e,P5|D5)}var Du=O5,L5="__lodash_hash_undefined__";function I5(e){return this.__data__.set(e,L5),this}var R5=I5;function B5(e){return this.__data__.has(e)}var N5=B5;function Ud(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Tu;++t<i;)this.add(e[t])}Ud.prototype.add=Ud.prototype.push=R5;Ud.prototype.has=N5;var z5=Ud;function U5(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var F5=U5;function k5(e,t){return e.has(t)}var j5=k5,G5=1,V5=2;function H5(e,t,i,r,s,n){var a=i&G5,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var h=n.get(e),d=n.get(t);if(h&&d)return h==t&&d==e;var c=-1,u=!0,p=i&V5?new z5:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var f=e[c],m=t[c];if(r)var g=a?r(m,f,c,t,e,n):r(f,m,c,e,t,n);if(g!==void 0){if(g)continue;u=!1;break}if(p){if(!F5(t,function(v,y){if(!j5(p,y)&&(f===v||s(f,v,i,r,n)))return p.push(y)})){u=!1;break}}else if(!(f===m||s(f,m,i,r,n))){u=!1;break}}return n.delete(e),n.delete(t),u}var H_=H5;function W5(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var q5=W5;function X5(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var Y5=X5,Z5=1,Q5=2,K5="[object Boolean]",J5="[object Date]",$5="[object Error]",ez="[object Map]",tz="[object Number]",iz="[object RegExp]",rz="[object Set]",sz="[object String]",nz="[object Symbol]",az="[object ArrayBuffer]",oz="[object DataView]",A1=Pr?Pr.prototype:void 0,Vp=A1?A1.valueOf:void 0;function lz(e,t,i,r,s,n,a){switch(i){case oz:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case az:return!(e.byteLength!=t.byteLength||!n(new zd(e),new zd(t)));case K5:case J5:case tz:return Fg(+e,+t);case $5:return e.name==t.name&&e.message==t.message;case iz:case sz:return e==t+"";case ez:var o=q5;case rz:var l=r&Z5;if(o||(o=Y5),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=Q5,a.set(e,t);var d=H_(o(e),o(t),r,s,n,a);return a.delete(e),d;case nz:if(Vp)return Vp.call(e)==Vp.call(t)}return!1}var hz=lz,cz=1,dz=Object.prototype,uz=dz.hasOwnProperty;function pz(e,t,i,r,s,n){var a=i&cz,o=dm(e),l=o.length,h=dm(t),d=h.length;if(l!=d&&!a)return!1;for(var c=l;c--;){var u=o[c];if(!(a?u in t:uz.call(t,u)))return!1}var p=n.get(e),f=n.get(t);if(p&&f)return p==t&&f==e;var m=!0;n.set(e,t),n.set(t,e);for(var g=a;++c<l;){u=o[c];var v=e[u],y=t[u];if(r)var x=a?r(y,v,u,t,e,n):r(v,y,u,e,t,n);if(!(x===void 0?v===y||s(v,y,i,r,n):x)){m=!1;break}g||(g=u=="constructor")}if(m&&!g){var w=e.constructor,_=t.constructor;w!=_&&"constructor"in e&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof _=="function"&&_ instanceof _)&&(m=!1)}return n.delete(e),n.delete(t),m}var fz=pz,mz=1,M1="[object Arguments]",E1="[object Array]",Rc="[object Object]",gz=Object.prototype,C1=gz.hasOwnProperty;function vz(e,t,i,r,s,n){var a=Ts(e),o=Ts(t),l=a?E1:Ch(e),h=o?E1:Ch(t);l=l==M1?Rc:l,h=h==M1?Rc:h;var d=l==Rc,c=h==Rc,u=l==h;if(u&&Nd(e)){if(!Nd(t))return!1;a=!0,d=!1}if(u&&!d)return n||(n=new pd),a||T_(e)?H_(e,t,i,r,s,n):hz(e,t,l,i,r,s,n);if(!(i&mz)){var p=d&&C1.call(e,"__wrapped__"),f=c&&C1.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return n||(n=new pd),s(m,g,i,r,n)}}return u?(n||(n=new pd),fz(e,t,i,r,s,n)):!1}var yz=vz;function W_(e,t,i,r,s){return e===t?!0:e==null||t==null||!en(e)&&!en(t)?e!==e&&t!==t:yz(e,t,i,r,W_,s)}var xz=W_;function wz(e,t){return e!=null&&t in Object(e)}var bz=wz;function _z(e,t,i){t=ll(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=Pu(t[r]);if(!(n=e!=null&&i(e,a)))break;e=e[a]}return n||++r!=s?n:(s=e==null?0:e.length,!!s&&jg(s)&&Ug(a,s)&&(Ts(e)||Vg(e)))}var Sz=_z;function Az(e,t){return e!=null&&Sz(e,t,bz)}var Mz=Az,Ez=function(){return $r.Date.now()},Hp=Ez,Cz="Expected a function",Tz=Math.max,Pz=Math.min;function Dz(e,t,i){var r,s,n,a,o,l,h=0,d=!1,c=!1,u=!0;if(typeof e!="function")throw new TypeError(Cz);t=t1(t)||0,Kr(i)&&(d=!!i.leading,c="maxWait"in i,n=c?Tz(t1(i.maxWait)||0,t):n,u="trailing"in i?!!i.trailing:u);function p(S){var A=r,b=s;return r=s=void 0,h=S,a=e.apply(b,A),a}function f(S){return h=S,o=setTimeout(v,t),d?p(S):a}function m(S){var A=S-l,b=S-h,M=t-A;return c?Pz(M,n-b):M}function g(S){var A=S-l,b=S-h;return l===void 0||A>=t||A<0||c&&b>=n}function v(){var S=Hp();if(g(S))return y(S);o=setTimeout(v,m(S))}function y(S){return o=void 0,u&&r?p(S):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function w(){return o===void 0?a:y(Hp())}function _(){var S=Hp(),A=g(S);if(r=arguments,s=this,l=S,A){if(o===void 0)return f(l);if(c)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),a}return _.cancel=x,_.flush=w,_}var Jg=Dz;function Oz(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Lz=Oz;function Iz(e,t){return t.length<2?e:O_(e,wB(t,0,-1))}var Rz=Iz;function Bz(e,t){return xz(e,t)}var $g=Bz;function Nz(e,t){return t=ll(t,e),e=Rz(e,t),e==null||delete e[Pu(Lz(t))]}var zz=Nz;function Uz(e){return yB(e)?void 0:e}var Fz=Uz,kz=1,jz=2,Gz=4,Vz=I_(function(e,t){var i={};if(e==null)return i;var r=!1;t=w_(t,function(n){return n=ll(n,e),r||(r=n.length>1),n}),qh(e,F_(e),i),r&&(i=V_(i,kz|jz|Gz,Fz));for(var s=t.length;s--;)zz(i,t[s]);return i}),mm=Vz;function Hz(e,t,i,r){if(!Kr(e))return e;t=ll(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=Pu(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=a){var d=o[l];h=r?r(d,l,o):void 0,h===void 0&&(h=Kr(d)?d:Ug(t[s+1])?[]:{})}kg(o,l,h),o=o[l]}return e}var Wz=Hz;function qz(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=O_(e,a);i(o,a)&&Wz(n,ll(a,e),o)}return n}var Xz=qz;function Yz(e,t){return Xz(e,t,function(i,r){return Mz(e,r)})}var Zz=Yz,Qz=I_(function(e,t){return e==null?{}:Zz(e,t)}),Th=Qz,Kz="Expected a function";function Jz(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(Kz);return Kr(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),Jg(e,t,{leading:r,maxWait:t,trailing:s})}var $z=Jz,q_,eU=new Promise(e=>{q_=e}),T1=!1;async function tU(){if(T1)return;let e=await import("./physics.js");await e.init(),q_(e),T1=!0}var Qt=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Qt.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:n}=e,a={...t,[s]:n};return Object.setPrototypeOf(a,Qt.prototype),{data:a,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,Qt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function ev(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&ev(r)}return Object.freeze(e)}function iU(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var X_=class extends Error{};function Wp(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Dn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let n=e;e=t,t=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=e+(t-e)*(n+.75+Math.random()*.5)*s;r.push(a)}return r}function tv(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function rU(){return typeof process<"u"}function Y_(e,t){for(let i of e)t(i.id,i.data)!==!0&&Y_(i.children,t)}function Z_(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)Z_(i,t)}var Wi=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Wi.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ev(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&Z_(i,t)}}traverse(e){Y_(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);if(s<0)throw new Error("not expected");let n=r[s];return r=[...r],r[s]={...n,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let n=r,a=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===a);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:n}}Object.setPrototypeOf(r,Wi.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,d)=>h.fi-d.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===t);e.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...n,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new X_("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(c=>c.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=t,a=h.childrenArray(s);let d=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:e,reverse:{type:9,parent:n,fi:d,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>iU(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Dn(0,i,i);{let s=r[0].fi;return Dn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Dn(a,a+i,i)}else return Dn(s.fi,n.fi,i)}}},Fd;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,n={},a=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");n[l]=a[h],a[h]=s[l],o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let s=r.props,n={},a={...i},o=!1;if(s)for(let l of Object.keys(s)){n[l]=a[l];let h=s[l];h===void 0?delete a[l]:a[l]=h,o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}}e.runOp=t})(Fd||(Fd={}));var et=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,et.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ev(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,et.prototype);let t=e;return rU()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,n={fi:t,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(n=>n.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:t};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:n,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Dn(0,t,t);{let r=i[0].fi;return Dn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Dn(n,n+t,t)}else return Dn(r.fi,s.fi,t)}}};function Xo(e){return e&&typeof e=="object"&&e instanceof xi}var xi=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!Xo(i))return null;r+=1}i=i?Wp(i):new xi;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=Wp(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Wp(o);l[e.path[r-1]]=i,i=l}else{let l=new xi;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,xi.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},Sa;(e=>{function t(s,n){return Ph(s,n)??s}e.apply=t;function i(s,n){return rv(s,n)}e.merge=i;function r(s,n){let a=0,o=n.path,l=s;for(;a<o.length&&l!==void 0;){if(l=As.zoomOnce(l,o[a]),l===void 0)return n;if(!Xo(l))return;a+=1}if(l===void 0)return n;if(Xo(l))if(n.type===0){let h={...n.props};for(let d of Object.keys(l))delete h[d];return{...n,props:h}}else if(n.type===1||n.type===4||n.type===7){let h=iv([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(Sa||(Sa={}));function iv(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Ph(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=iv(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}else return{...s,id:n,data:a}});if(i)return r}function sU(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=Ph(s.data,t[n]);return i=i||a!==void 0,a===void 0&&(a=s.data),{...s,id:n,data:a}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function Ph(e,t){if(!Xo(t))return t;if(e instanceof Wi){let i=iv(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof et)return sU(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=Ph(s,t[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof xi)return rv(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=Ph(n,t[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function rv(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Xo(t))return t;if(!Xo(e))return Sa.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new xi;for(let s of i){let n=rv(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function nU(e,t){let i={cur:[],result:[],len:0};return e=Dh(e,t,i)??e,[e,i.result]}function kd(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function jd(e){e&&(e.len-=1)}function aU(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function Q_(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Dh(n.data,t,kd(i,a));jd(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=Q_(n.children,t,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function oU(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=Dh(n.data,t,kd(i,a));return jd(i),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function Dh(e,t,i){if(e instanceof Wi){let r=Q_(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof et)return oU(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=Dh(n,t,kd(i,a));return jd(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!tv(e)){let r={},s=!1;for(let[n,a]of Object.entries(e))if(n!=="name"&&n!=="text"){let o=t[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=Dh(a,t,kd(i,n));jd(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];if(r!==void 0){if(e.length!==36)throw new Error("for now you should only call this method when the key is a uuid");aU(i)}return r}else return}}var gm;(e=>{function t(i,r){let s=As.zoom(r,i.path);if(typeof s=="object"){let n={};for(let a of Object.keys(i.props))n[a]=s[a];return{...i,props:n}}else return{...i,props:{}}}e.replaceProps=t})(gm||(gm={}));var ar;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let d=h.path;for(var c=[];;){let u;if(l instanceof xi&&h.type===0&&(u=l.runOp({...h,path:d.slice(c.length)}),u===null&&(u=void 0)),u===void 0&&c.length===d.length&&(l instanceof Wi||l instanceof et||l instanceof Qt?u=l.runOp(h):u=Fd.runOp(l,h)),u!==void 0)if(u!==null){let m=u.data;for(let g=c.length-1;g>=0;g--){let v=d[g],y=c[g];if(y instanceof Wi){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof et){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof Qt){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof xi){let x={...y,[v]:m};m=Object.setPrototypeOf(x,xi.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 x=m;m=[...y],m[v]=x}else m={...y,[v]:m};else return null}return{data:m,actual:{...u.actual,path:d},reverse:{...u.reverse,path:d}}}else return null;let p=d[c.length],f;if(l instanceof Wi){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof et){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)c.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let d=0;d<l.length&&d<h.length;d++)if(l[d]!==h[d])return!0;return!1}e.pathDisjoint=s;function n(l,h){if(l.length!==h.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==h[d])return!1;return!0}e.pathEq=n;function a(l,h){return s(l.path,h.path)}e.commutative=a;function o(l,h){return l.type===0&&h.type===0&&n(l.path,h.path)?Object.keys(l.props).every(d=>h.props[d]!==void 0):!1}e.subsumed=o})(ar||(ar={}));var P1;(e=>{function t(){return[]}e.empty=t;function i(h,d){let c=[];for(let u of h){let[p,...f]=u.path;p===d&&c.push({...u,path:f})}return c}e.removePrefix=i;function r(h,d){return h.map(c=>({...c,path:[d,...c.path]}))}e.addPrefix=r;function s(h,d){return[...h,...d]}e.concat=s;function n(h,d){return[...h.filter(c=>!d.some(u=>ar.subsumed(c,u))),...d]}e.compress=n;function a(h,d){return h.every(c=>d.every(u=>ar.commutative(c,u)))}e.commutative=a;function o(h,d){for(let c of d){let u=l(h,c);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,d){var c=h;let u=[],p=[];for(let f of d)try{if(f.type===3){let m=As.zoom(c,[...f.path,f.id]),g=ar.apply(c,{...f,type:2});if(g!==null){c=g.data;let[v,y]=nU(c,{[f.id]:m});c=v;for(let x of y){let w=x[x.length-1];x.splice(x.length-1,1),u.push({type:0,path:x,props:{[w]:m}}),p.push({type:0,path:x,props:{[w]:f.id}})}p.push(g.reverse),u.push(g.actual)}}else{let m=ar.apply(c,f);m!==null&&(u.push(m.actual),c=m.data,p.push(m.reverse))}}catch(m){if(m instanceof X_)return null;throw m}return{data:c,actual:u,reverse:p.reverse()}}e.apply=l})(P1||(P1={}));var K_=Symbol(),lU=Symbol(),Ou=Symbol(),Xh=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof $_);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Ou];i&&i(),delete this._children[e]}}}},hU=class extends Xh{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Fd.runOp(this._current,e),e.path)}},cU=class extends Xh{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Qt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},J_={get(e,t){if(t===Ou)return()=>{e._parent=null};if(t===K_)return e._current;if(t===lU)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let n=i[t],a=Lu(e,t,n);return a!==n?(r===void 0&&(r={},e._children=r),r[t]=a,a):n},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},dU={...J_,set(e,t,i){let r={type:0,props:{[t]:Ci(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},uU={...J_,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},sv=class extends Xh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Ou]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Lu(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}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)}},nv=class extends Xh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Ou]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Lu(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function qp(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&As.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var $_=class extends Xh{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){qp(this.ts,t,e),qp(this.actual,i,e),qp(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Lu(e,t,i){return i instanceof Wi?new sv(e,t,i):i instanceof et?new nv(e,t,i):i instanceof Qt?new Proxy(new cU(e,t,i),uU):i!==null&&typeof i=="object"?tv(i)?i:new Proxy(new hU(e,t,i),dU):i}function eS(e){let t=new $_(e);return[Lu(t,"",e),t]}function Gd(e,t){let[i,r]=eS(e);return t(i),r.result()}function Ci(e){return e instanceof sv||e instanceof nv?e._current:e!==null&&typeof e=="object"?e[K_]:e}var As;(e=>{function t(n,a){if(a.length===n.length)for(var o=0;o<n.length;){if(n[o]!==a[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(n,a,o){let l=s(o,n);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...a};return Object.keys(l).forEach(d=>{delete h[d]}),h}else return a}e.removeOverridden=i;function r(n,a){if((n instanceof Wi||n instanceof sv)&&typeof a=="string"||(n instanceof et||n instanceof nv)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n)||typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}e.zoomOnce=r;function s(n,a,o=0){for(;o<a.length&&n!==void 0;)n=r(n,a[o]),o+=1;return n}e.zoom=s})(As||(As={}));function pU(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Mn(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var tS=class{},D1=class extends tS{constructor(e){super(),this.id=e}},O1=class extends tS{constructor(e){super(),this.data=e}},vm;try{vm=new TextDecoder}catch{}var Ae,zn,K=0,iS=[],ym=iS,xm=0,ji={},pt,On,xr=0,vs=0,$i,Js,zi=[],mt,L1={useRecords:!1,mapsAsObjects:!0},rS=class{},sS=new rS;sS.name="MessagePack 0xC1";var Yo=!1,Vd=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(Ae)return cS(()=>(bm(),this?this.unpack(e,t):Vd.prototype.unpack.call(L1,e,t)));zn=t>-1?t:e.length,K=0,xm=0,vs=0,On=null,ym=iS,$i=null,Ae=e;try{mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ae=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Vd){if(ji=this,this.structures)return pt=this.structures,Bc();(!pt||pt.length>0)&&(pt=[])}else ji=L1,(!pt||pt.length>0)&&(pt=[]);return Bc()}unpackMultiple(e,t){let i,r=0;try{Yo=!0;let s=e.length,n=this?this.unpack(e,s):Ru.unpack(e,s);if(t){for(t(n);K<s;)if(r=K,t(Bc())===!1)return}else{for(i=[n];K<s;)r=K,i.push(Bc());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Yo=!1,bm()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Bc(){try{if(!ji.trusted&&!Yo){let t=pt.sharedLength||0;t<pt.length&&(pt.length=t)}let e=Ut();if(K==zn)pt.restoreStructures&&I1(),pt=null,Ae=null,Js&&(Js=null);else if(K>zn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Yo)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw pt.restoreStructures&&I1(),bm(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function I1(){for(let e in pt.restoreStructures)pt[e]=pt.restoreStructures[e];pt.restoreStructures=null}function Ut(){let e=Ae[K++];if(e<160)if(e<128){if(e<64)return e;{let t=pt[e&63]||ji.getStructures&&nS()[e&63];return t?(t.read||(t.read=av(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,ji.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[oS()]=Ut();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Ut(),Ut());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Ut();return t}else if(e<192){let t=e-160;if(vs>=K)return On.slice(K-xr,(K+=t)-xr);if(vs==0&&zn<140){let i=t<16?ov(t):aS(t);if(i!=null)return i}return wm(t)}else{let t;switch(e){case 192:return null;case 193:return $i?(t=Ut(),t>0?$i[1].slice($i.position1,$i.position1+=t):$i[0].slice($i.position0,$i.position0-=t)):sS;case 194:return!1;case 195:return!0;case 196:return Xp(Ae[K++]);case 197:return t=mt.getUint16(K),K+=2,Xp(t);case 198:return t=mt.getUint32(K),K+=4,Xp(t);case 199:return ta(Ae[K++]);case 200:return t=mt.getUint16(K),K+=2,ta(t);case 201:return t=mt.getUint32(K),K+=4,ta(t);case 202:if(t=mt.getFloat32(K),ji.useFloat32>2){let i=lv[(Ae[K]&127)<<1|Ae[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=mt.getFloat64(K),K+=8,t;case 204:return Ae[K++];case 205:return t=mt.getUint16(K),K+=2,t;case 206:return t=mt.getUint32(K),K+=4,t;case 207:return ji.int64AsNumber?(t=mt.getUint32(K)*4294967296,t+=mt.getUint32(K+4)):t=mt.getBigUint64(K),K+=8,t;case 208:return mt.getInt8(K++);case 209:return t=mt.getInt16(K),K+=2,t;case 210:return t=mt.getInt32(K),K+=4,t;case 211:return ji.int64AsNumber?(t=mt.getInt32(K)*4294967296,t+=mt.getUint32(K+4)):t=mt.getBigInt64(K),K+=8,t;case 212:if(t=Ae[K++],t==114)return U1(Ae[K++]&63);{let i=zi[t];if(i)return i.read?(K++,i.read(Ut())):i.noBuffer?(K++,i()):i(Ae.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Ae[K],t==114?(K++,U1(Ae[K++]&63,Ae[K++])):ta(2);case 214:return ta(4);case 215:return ta(8);case 216:return ta(16);case 217:return t=Ae[K++],vs>=K?On.slice(K-xr,(K+=t)-xr):mU(t);case 218:return t=mt.getUint16(K),K+=2,vs>=K?On.slice(K-xr,(K+=t)-xr):gU(t);case 219:return t=mt.getUint32(K),K+=4,vs>=K?On.slice(K-xr,(K+=t)-xr):vU(t);case 220:return t=mt.getUint16(K),K+=2,B1(t);case 221:return t=mt.getUint32(K),K+=4,B1(t);case 222:return t=mt.getUint16(K),K+=2,N1(t);case 223:return t=mt.getUint32(K),K+=4,N1(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var fU=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function av(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>fU.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Ut);return e.highByte===0&&(e.read=R1(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=Ut()}return r}return i.count=0,e.highByte===0?R1(t,i):i}var R1=(e,t)=>function(){let i=Ae[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=pt[r]||nS()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=av(s,e)),s.read()};function nS(){let e=cS(()=>(Ae=null,ji.getStructures()));return pt=ji._mergeStructures(e,pt)}var wm=Iu,mU=Iu,gU=Iu,vU=Iu;function Iu(e){let t;if(e<16&&(t=ov(e)))return t;if(e>64&&vm)return vm.decode(Ae.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Ae[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Ae[K++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Ae[K++]&63,a=Ae[K++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Ae[K++]&63,a=Ae[K++]&63,o=Ae[K++]&63,l=(s&7)<<18|n<<12|a<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=ci.apply(String,r),r.length=0)}return r.length>0&&(t+=ci.apply(String,r)),t}function B1(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Ut();return t}function N1(e){if(ji.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[oS()]=Ut();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Ut(),Ut());return t}}var ci=String.fromCharCode;function aS(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Ae[K++];if((s&128)>0){K=t;return}i[r]=s}return ci.apply(String,i)}function ov(e){if(e<4)if(e<2){if(e===0)return"";{let t=Ae[K++];if((t&128)>1){K-=1;return}return ci(t)}}else{let t=Ae[K++],i=Ae[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return ci(t,i);let r=Ae[K++];if((r&128)>0){K-=3;return}return ci(t,i,r)}else{let t=Ae[K++],i=Ae[K++],r=Ae[K++],s=Ae[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return ci(t,i,r,s);{let n=Ae[K++];if((n&128)>0){K-=5;return}return ci(t,i,r,s,n)}}else if(e<8){let n=Ae[K++],a=Ae[K++];if((n&128)>0||(a&128)>0){K-=6;return}if(e<7)return ci(t,i,r,s,n,a);let o=Ae[K++];if((o&128)>0){K-=7;return}return ci(t,i,r,s,n,a,o)}else{let n=Ae[K++],a=Ae[K++],o=Ae[K++],l=Ae[K++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return ci(t,i,r,s,n,a,o,l);{let h=Ae[K++];if((h&128)>0){K-=9;return}return ci(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Ae[K++],d=Ae[K++];if((h&128)>0||(d&128)>0){K-=10;return}if(e<11)return ci(t,i,r,s,n,a,o,l,h,d);let c=Ae[K++];if((c&128)>0){K-=11;return}return ci(t,i,r,s,n,a,o,l,h,d,c)}else{let h=Ae[K++],d=Ae[K++],c=Ae[K++],u=Ae[K++];if((h&128)>0||(d&128)>0||(c&128)>0||(u&128)>0){K-=12;return}if(e<14){if(e===12)return ci(t,i,r,s,n,a,o,l,h,d,c,u);{let p=Ae[K++];if((p&128)>0){K-=13;return}return ci(t,i,r,s,n,a,o,l,h,d,c,u,p)}}else{let p=Ae[K++],f=Ae[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return ci(t,i,r,s,n,a,o,l,h,d,c,u,p,f);let m=Ae[K++];if((m&128)>0){K-=15;return}return ci(t,i,r,s,n,a,o,l,h,d,c,u,p,f,m)}}}}}function Xp(e){return ji.copyBuffers?Uint8Array.prototype.slice.call(Ae,K,K+=e):Ae.subarray(K,K+=e)}function ta(e){let t=Ae[K++];if(zi[t])return zi[t](Ae.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var z1=new Array(4096);function oS(){let e=Ae[K++];if(e>=160&&e<192){if(e=e-160,vs>=K)return On.slice(K-xr,(K+=e)-xr);if(!(vs==0&&zn<180))return wm(e)}else return K--,Ut();let t=(e<<5^(e>1?mt.getUint16(K):e>0?Ae[K]:0))&4095,i=z1[t],r=K,s=K+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=mt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Ae[r++],n!=i[a++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],z1[t]=i,i.bytes=e;r<s;)n=mt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Ae[r++],i.push(n);let o=e<16?ov(e):aS(e);return o!=null?i.string=o:i.string=wm(e)}var U1=(e,t)=>{var i=Ut();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=pt[e];return s&&s.isShared&&((pt.restoreStructures||(pt.restoreStructures=[]))[e]=s),pt[e]=i,i.read=av(i,r),i.read()},lS=typeof self=="object"?self:global;zi[0]=()=>{};zi[0].noBuffer=!0;zi[101]=()=>{let e=Ut();return(lS[e[0]]||Error)(e[1])};zi[105]=e=>{let t=mt.getUint32(K-4);Js||(Js=new Map);let i=Ae[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Js.set(t,s);let n=Ut();return s.used?Object.assign(r,n):(s.target=n,n)};zi[112]=e=>{let t=mt.getUint32(K-4),i=Js.get(t);return i.used=!0,i.target};zi[115]=()=>new Set(Ut());var hS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");zi[116]=e=>{let t=e[0],i=hS[t];if(!i)throw new Error("Could not find typed array for code "+t);return new lS[i](Uint8Array.prototype.slice.call(e,1).buffer)};zi[120]=()=>{let e=Ut();return new RegExp(e[0],e[1])};zi[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,$i=[Ut(),Ut()],$i.position0=0,$i.position1=0;let r=K;K=i;try{return Ut()}finally{K=r}};zi[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function cS(e){let t=zn,i=K,r=xm,s=xr,n=vs,a=On,o=ym,l=Js,h=$i,d=new Uint8Array(Ae.slice(0,zn)),c=pt,u=pt.slice(0,pt.length),p=ji,f=Yo,m=e();return zn=t,K=i,xm=r,xr=s,vs=n,On=a,ym=o,Js=l,$i=h,Ae=d,Yo=f,pt=c,pt.splice(0,pt.length,...u),ji=p,mt=new DataView(Ae.buffer,Ae.byteOffset,Ae.byteLength),m}function bm(){Ae=null,Js=null,pt=null}function yU(e){e.unpack?zi[e.type]=e.unpack:zi[e.type]=e}var lv=new Array(147);for(let e=0;e<256;e++)lv[e]=+("1e"+Math.floor(45.15-e*.30103));var Ru=new Vd({useRecords:!1}),n7=Ru.unpack,a7=Ru.unpackMultiple,o7=Ru.unpack,xU={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},wU=new Float32Array(1),l7=new Uint8Array(wU.buffer,0,4),md;try{md=new TextEncoder}catch{}var Hd,hv,Bu=typeof Buffer<"u",Yp=Bu?Buffer.allocUnsafeSlow:Uint8Array,dS=Bu?Buffer:Uint8Array,F1=Bu?4294967296:2144337920,le,Gt,te=0,ts,is=null,bU=/[\u0080-\uFFFF]/,Dl=Symbol("record-id"),uS=class extends Vd{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=dS.prototype.utf8Write?function(A,b,M){return le.utf8Write(A,b,M)}:md&&md.encodeInto?function(A,b){return md.encodeInto(A,le.subarray(b)).written}:!1,h=this;e||(e={});let d=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),d&&!e.saveStructures&&(this.structures=[]);let f=u>32||p+u>64,m=u+64,g=u+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(A,b){if(le||(le=new Yp(8192),Gt=new DataView(le.buffer,0,8192),te=0),ts=le.length-10,ts-te<2048?(le=new Yp(le.length),Gt=new DataView(le.buffer,0,le.length),ts=le.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(is=["",""],le[te++]=214,le[te++]=98,is.position=te-i,te+=4):is=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let M=r.sharedLength||0;if(M>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let T=r[C];if(!T)continue;let P,O=r.transitions;for(let D=0,N=T.length;D<N;D++){let W=T[D];P=O[W],P||(P=O[W]=Object.create(null)),O=P}O[Dl]=C+64}o=M}d||(r.nextId=M+64)}s&&(s=!1),n=r||[];try{if(w(A),is){Gt.setUint32(is.position+i,te-is.position-i);let M=is;is=null,w(M[0]),w(M[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>ts&&S(te),h.offset=te;let M=SU(le.subarray(i,te),a.idsToInsert);return a=null,M}return b&AU?(le.start=i,le.end=te,le):le.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,C=v.length;M<C;M++)v[M][Dl]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||u;r.length>M&&(r=r.slice(0,M));let C=le.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(A)):(o=M,C)}}b&MU&&(te=i)}};let w=A=>{te>ts&&(le=S(te));var b=typeof A,M;if(b==="string"){let C=A.length;if(is&&C>=8&&C<4096){let O=bU.test(A);is[O?0:1]+=A,le[te++]=193,w(O?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let P=C*3;if(te+P>ts&&(le=S(te+P)),C<64||!l){let O,D,N,W=te+T;for(O=0;O<C;O++)D=A.charCodeAt(O),D<128?le[W++]=D:D<2048?(le[W++]=D>>6|192,le[W++]=D&63|128):(D&64512)===55296&&((N=A.charCodeAt(O+1))&64512)===56320?(D=65536+((D&1023)<<10)+(N&1023),O++,le[W++]=D>>18|240,le[W++]=D>>12&63|128,le[W++]=D>>6&63|128,le[W++]=D&63|128):(le[W++]=D>>12|224,le[W++]=D>>6&63|128,le[W++]=D&63|128);M=W-te-T}else M=l(A,te+T,P);M<32?le[te++]=160|M:M<256?(T<2&&le.copyWithin(te+2,te+1,te+1+M),le[te++]=217,le[te++]=M):M<65536?(T<3&&le.copyWithin(te+3,te+2,te+2+M),le[te++]=218,le[te++]=M>>8,le[te++]=M&255):(T<5&&le.copyWithin(te+5,te+3,te+3+M),le[te++]=219,Gt.setUint32(te,M),te+=4),te+=M}else if(b==="number")if(A>>>0===A)A<64?le[te++]=A:A<256?(le[te++]=204,le[te++]=A):A<65536?(le[te++]=205,le[te++]=A>>8,le[te++]=A&255):(le[te++]=206,Gt.setUint32(te,A),te+=4);else if(A>>0===A)A>=-32?le[te++]=256+A:A>=-128?(le[te++]=208,le[te++]=A+256):A>=-32768?(le[te++]=209,Gt.setInt16(te,A),te+=2):(le[te++]=210,Gt.setInt32(te,A),te+=4);else{let C;if((C=this.useFloat32)>0&&A<4294967296&&A>=-2147483648){le[te++]=202,Gt.setFloat32(te,A);let T;if(C<4||(T=A*lv[(le[te]&127)<<1|le[te+1]>>7])>>0===T){te+=4;return}else te--}le[te++]=203,Gt.setFloat64(te,A),te+=8}else if(b==="object")if(!A)le[te++]=192;else{if(a){let T=a.get(A);if(T){if(!T.id){let P=a.idsToInsert||(a.idsToInsert=[]);T.id=P.push(T)}le[te++]=214,le[te++]=112,Gt.setUint32(te,T.id),te+=4;return}else a.set(A,{offset:te-i})}let C=A.constructor;if(C===Object)_(A,!0);else if(C===Array){M=A.length,M<16?le[te++]=144|M:M<65536?(le[te++]=220,le[te++]=M>>8,le[te++]=M&255):(le[te++]=221,Gt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)w(A[T])}else if(C===Map){M=A.size,M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,Gt.setUint32(te,M),te+=4);for(let[T,P]of A)w(T),w(P)}else{for(let T=0,P=Hd.length;T<P;T++){let O=hv[T];if(A instanceof O){let D=Hd[T];if(D.write){D.type&&(le[te++]=212,le[te++]=D.type,le[te++]=0),w(D.write.call(this,A));return}let N=le,W=Gt,q=te;le=null;let z;try{z=D.pack.call(this,A,V=>(le=N,N=null,te+=V,te>ts&&S(te),{target:le,targetView:Gt,position:te-V}),w)}finally{N&&(le=N,Gt=W,te=q,ts=le.length-10)}z&&(z.length+te>ts&&S(z.length+te),te=_U(z,le,te,D.type));return}}_(A,!A.hasOwnProperty)}}else if(b==="boolean")le[te++]=A?195:194;else if(b==="bigint"){if(A<BigInt(1)<<BigInt(63)&&A>=-(BigInt(1)<<BigInt(63)))le[te++]=211,Gt.setBigInt64(te,A);else if(A<BigInt(1)<<BigInt(64)&&A>0)le[te++]=207,Gt.setBigUint64(te,A);else if(this.largeBigIntToFloat)le[te++]=203,Gt.setFloat64(te,Number(A));else throw new RangeError(A+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(b==="undefined")this.encodeUndefinedAsNil?le[te++]=192:(le[te++]=212,le[te++]=0,le[te++]=0);else if(b==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+b)},_=this.useRecords===!1?this.variableMapSize?A=>{let b=Object.keys(A),M=b.length;M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,Gt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)w(C=b[T]),w(A[C])}:(A,b)=>{le[te++]=222;let M=te-i;te+=2;let C=0;for(let T in A)(b||A.hasOwnProperty(T))&&(w(T),w(A[T]),C++);le[M+++i]=C>>8,le[M+i]=C&255}:A=>{let b=Object.keys(A),M,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let O=0,D=b.length;O<D;O++){let N=b[O];M=C[N],M||(M=C[N]=Object.create(null),T++),C=M}let P=C[Dl];if(P)P>=96&&f?(le[te++]=((P-=96)&31)+96,le[te++]=P>>5):le[te++]=P;else{P=n.nextId,P||(P=64),P<m&&this.shouldShareStructure&&!this.shouldShareStructure(b)?(P=n.nextOwnId,P<g||(P=m),n.nextOwnId=P+1):(P>=g&&(P=m),n.nextId=P+1);let O=b.highByte=P>=96&&f?P-96>>5:-1;C[Dl]=P,n[P-64]=b,P<m?(b.isShared=!0,n.sharedLength=P-63,s=!0,O>=0?(le[te++]=(P&31)+96,le[te++]=O):le[te++]=P):(O>=0?(le[te++]=213,le[te++]=114,le[te++]=(P&31)+96,le[te++]=O):(le[te++]=212,le[te++]=114,le[te++]=P),T&&(y+=x*T),v.length>=p&&(v.shift()[Dl]=0),v.push(C),w(b))}for(let O=0,D=b.length;O<D;O++)w(A[b[O]])},S=A=>{let b;if(A>16777216){if(A-i>F1)throw new Error("Packed buffer would be larger than maximum buffer size");b=Math.min(F1,Math.round(Math.max((A-i)*(A>67108864?1.25:2),4194304)/4096)*4096)}else b=(Math.max(A-i<<2,le.length-1)>>12)+1<<12;let M=new Yp(b);return Gt=new DataView(M.buffer,0,b),le.copy?le.copy(M,0,i,A):M.set(le.slice(i,A)),te-=i,i=0,ts=M.length-10,le=M}}useBuffer(e){le=e,Gt=new DataView(le.buffer,le.byteOffset,le.byteLength),te=0}};hv=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,rS];Hd=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:n,position:a}=t(6);s[a++]=214,s[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:s,targetView:n,position:a}=t(10);s[a++]=215,s[a++]=255,n.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:n,position:a}=t(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:n,position:a}=t(15);s[a++]=199,s[a++]=12,s[a++]=255,n.setUint32(a,e.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(s[n++]=212,s[n++]=115,s[n++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?k1(e,16,t):j1(Bu?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==dS&&this.structuredClone?k1(e,hS.indexOf(i.name),t):j1(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function k1(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:n,position:a}=i(4+s);n[a++]=199,n[a++]=s+1}else if(s+1<65536){var{target:n,position:a}=i(5+s);n[a++]=200,n[a++]=s+1>>8,n[a++]=s+1&255}else{var{target:n,position:a,targetView:o}=i(7+s);n[a++]=201,o.setUint32(a,s+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function j1(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:n}=t(i+5);r[s++]=198,n.setUint32(s,i),s+=4}r.set(e,s)}function _U(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function SU(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);i=t.pop();){let n=i.offset,a=i.id;e.copyWithin(n+r,n,s),r-=6;let o=n+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,s=n}return e}function cl(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");hv.unshift(e.Class),Hd.unshift(e)}yU(e)}var pS=new uS({useRecords:!1}),h7=pS.pack,c7=pS.pack,{NEVER:d7,ALWAYS:u7,DECIMAL_ROUND:p7,DECIMAL_FIT:f7}=xU,AU=512,MU=1024,G1=new uS({structuredClone:!0});cl({Class:Qt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Qt.prototype),e}});cl({Class:et.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,et.prototype),e}});cl({Class:Wi.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Wi.prototype),e}});cl({Class:D1.prototype.constructor,type:4,write(e){return e.id},read(e){return new D1(e)}});cl({Class:O1.prototype.constructor,type:5,write(e){return e.data},read(e){return new O1(e)}});cl({Class:xi.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,xi.prototype),e}});function EU(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function _m(e){if(tv(e))return e;if(Array.isArray(e))return e.map(_m);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=_m(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Sm;(e=>{function t(s){return G1.pack(s)}e.serialize=t;function i(s){return G1.unpack(s)}e.deserialize=i;function r(s){return EU(t(_m(s))).toString()}e.checksum=r})(Sm||(Sm={}));var pn={LookAt:[],Follow:["Create"],DragDrop:["Transition","Audio","Create"],MouseHover:["Transition","Create","Destroy","SwitchCamera"],Scroll:["Transition","Create"],Start:["Transition","Audio","Video","Create","Destroy","SwitchCamera"],Conditional:["Transition","Audio","Video","Create","Destroy","SwitchCamera","Reset"],MouseDown:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],MouseUp:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],MousePress:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],KeyDown:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],KeyUp:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],KeyPress:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],GameControl:["Transition","Audio","Video","Create"],Collision:["Transition","Audio","Video","Create","Destroy","Reset"]},V1;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,toggle:!1,actions:new et}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new et}}e.defaultData=i})(V1||(V1={}));var Wd;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Wd||(Wd={}));var Am;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Wd.propertyDefaultData(s),rOperand:{...Wd.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,n){return{type:"State",object:s??null,state:n??null}}e.stateDefaultData=r})(Am||(Am={}));var H1;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new et,outActions:new et,condition:Am.distanceDefaultData(r)}}e.defaultData=i})(H1||(H1={}));var W1;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new et,drop:new et}})(W1||(W1={}));var Mm;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new et})(Mm||(Mm={}));var Em;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Em||(Em={}));var q1;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new et}}e.defaultData=i})(q1||(q1={}));var X1;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new et}}e.defaultData=i})(X1||(X1={}));var Y1;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new et}}e.defaultData=i})(Y1||(Y1={}));var Z1;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new et}}e.defaultData=i})(Z1||(Z1={}));var Eo;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n]}e.lerp=i})(Eo||(Eo={}));var Aa;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function n(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=n;function a(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=a;function o(l,h,d){return[l[0]+(h[0]-l[0])*d,l[1]+(h[1]-l[1])*d,l[2]+(h[2]-l[2])*d]}e.lerp=o})(Aa||(Aa={}));var qd;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]}e.lerp=i})(qd||(qd={}));var Zo;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,n){for(let a=0;a<16;a++)if(s[a]!==n[a])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,n){let a=n.slice(0);for(var o=0,l=n.length;o<l;o+=3){let h=s[3]*n[o]+s[7]*n[o+1]+s[11]*n[o+2]+s[15];a[o]=(s[0]*n[o]+s[4]*n[o+1]+s[8]*n[o+2]+s[12])/h,a[o+1]=(s[1]*n[o]+s[5]*n[o+1]+s[9]*n[o+2]+s[13])/h,a[o+2]=(s[2]*n[o]+s[6]*n[o+1]+s[10]*n[o+2]+s[14])/h}return a}e.applyMatrix4=r})(Zo||(Zo={}));var rr;(e=>{function t(o){return typeof o=="object"&&typeof o.r=="number"&&typeof o.g=="number"&&typeof o.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(o){return{r:Math.round(o.r*255),g:Math.round(o.g*255),b:Math.round(o.b*255),a:1}}e.toRgb255a1=i;function r(o){return{r:o.r,g:o.g,b:o.b}}e.clone=r;function s(o){return o=Math.floor(o),{r:(o>>16&255)/255,g:(o>>8&255)/255,b:(o&255)/255}}e.fromHex=s;function n(o,l){return o.r===l.r&&o.g===l.g&&o.b===l.b}e.equals=n;function a(o,l,h){return{r:o.r+(l.r-o.r)*h,g:o.g+(l.g-o.g)*h,b:o.b+(l.b-o.b)*h}}e.lerp=a})(rr||(rr={}));var Wr;(e=>{e.white={...rr.white,a:1},e.transparent={...rr.white,a:0};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}e.from0to1=t;function i(a,o){return{...rr.fromHex(a),a:o}}e.fromHexAndA=i;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}e.toRgb255a1=r;function s(a,o){return rr.equals(a,o)&&a.a===o.a}e.equals=s;function n(a,o,l){return{r:a.r+(o.r-a.r)*l,g:a.g+(o.g-a.g)*l,b:a.b+(o.b-a.b)*l,a:a.a+(o.a-a.a)*l}}e.lerp=n})(Wr||(Wr={}));var Cm;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Cm||(Cm={}));var Q1;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Q1||(Q1={}));var K1;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(K1||(K1={}));var Oa;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Oa||(Oa={}));var Oh;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Oh||(Oh={}));var Ln;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(n=>n*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let n={...r};if(fS.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;mS.forEach(l=>{Object.assign(n.radial,{[l]:o[l]??a[l]})})}if(n.linear={...r.linear},s.linear){let a=r.linear,o=s.linear;gS.forEach(l=>{Object.assign(n.linear,{[l]:o[l]??a[l]})})}if(n.grid={...r.grid},s.grid){let a=r.grid,o=s.grid;vS.forEach(l=>{Object.assign(n.grid,{[l]:o[l]??a[l]})})}if(n.toObject={...r.toObject},s.toObject){let a=r.toObject,o=s.toObject;yS.forEach(l=>{Object.assign(n.toObject,{[l]:o[l]??a[l]})})}if(n.randomnessObject={...r.randomnessObject},s.randomnessObject){let a=r.randomnessObject,o=s.randomnessObject;xS.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(Ln||(Ln={}));var Tm;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of t){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}e.toOps=i})(Tm||(Tm={}));var fS=["count"],mS=["radius","start","end","position","scale","rotation"],gS=["position","scale","rotation"],vS=["count","size"],yS=["count","position","scale","rotation"],xS=["strength","scale","rotation","position","movement","seed","freqScale"],Lh;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(Lh||(Lh={}));var Pm;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Pm||(Pm={}));var Dm;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Wr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(r==="SpotLight")return{type:r,color:Wr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Wr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Dm||(Dm={}));var Om;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Om||(Om={}));var Lm;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Lm||(Lm={}));var Im;(e=>e.defaultData={...Lm.defaultData,...Om.defaultData})(Im||(Im={}));var Xd;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Xd||(Xd={}));var J1;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="light"}e.is=t})(J1||(J1={}));var $1;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})($1||($1={}));var wS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],CU=["wrapping","image","video"],br;(e=>{function t(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let h=n.texture;h&&Object.assign(h,o)}}e.patch=t;function i(n,a){return n==="light"&&a?r(a):s(n)}e.defaultData=i;function r(n){switch(n){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 s(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:Xd.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:rr.fromHex(5526619)};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:{...rr.fromHex(6710886),a:1},colorB:{...rr.fromHex(6710886),a:1},colorC:{...rr.fromHex(16777215),a:1},colorD:{...rr.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:Wr.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:Wr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:Wr.fromHexAndA(0,1),contourColor:Wr.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}}}})(br||(br={}));var hr;(e=>{function t(h){return!h.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}e.isMergable=t;function i(h){let d="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([u,p])=>{d+=`${u}${p}`,Array.isArray(p)?p.forEach(f=>d+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?d+=`${f.toFixed(4)}`:d+=`${f}`}):d+=`${p}`})}),d}e.getHash=i;function r(){return{layers:new et}}e.defaultEmptyData=r;function s(h="layer1",d="layer2"){return a("phong",h,d)}e.defaultData=s;function n(h,d){return{...h,name:d}}e.withName=n;function a(h,d="layer1",c="layer2"){let u=new et;return u.push({fi:0,data:br.defaultData("light",h),id:d}),u.push({fi:1,data:br.defaultData("color"),id:c}),{layers:u}}e.defaultTwoLayerData=a;function o(h,d="phong",c="layer1",u="layer2"){let p=br.defaultData("texture");Object.assign(p.texture,{image:h});let f=new et;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:br.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,d="phong",c="layer1",u="layer2"){let p=br.defaultData("video");Object.assign(p.texture,{video:h});let f=new et;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:br.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(hr||(hr={}));var Yd;(e=>{function t(){return{points:new et,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Yd||(Yd={}));var Zd;(e=>{function t(){return{points:new et,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Zd||(Zd={}));var bS={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0},Rm;(e=>{function t(i,r){let s={...i};return SS.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(Rm||(Rm={}));var _S={shape:bS,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},SS=["depth","offset","angle","twist","startScale","endScale"],Qd;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(Qd||(Qd={}));var Bm;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,Rm.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Bm||(Bm={}));var Io;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Zd.defaultData(),extrusion:_S};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Yd.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,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=t})(Io||(Io={}));var ex=["width","height","depth"];function TU(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function La(e,t){return Object.setPrototypeOf(e,t),e}var PU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),DU=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),OU=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Nu&&"ontouchend"in document,LU=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,IU=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,RU=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},BU=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},m7=PU(),Nu=DU(),AS=OU(),NU=LU(),or=IU(),tx=RU(),ix=Number(BU());function MS(e){return Array.isArray(e)?e:[e]}function zU(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Nc(e){return Nu?e.metaKey:e.ctrlKey}var Ve=[],Kd={},Jl={},gd={};function ES(e){Ve.includes(e)||Ve.push(e)}function Ro(e){delete Kd[e.pointerId];for(let t=0;t<Ve.length;t++)if(Ve[t].pointerId===e.pointerId){Ve.splice(t,1);break}}function UU(){Ve.splice(0,Ve.length)}function Jd(e){if(e.pointerType!=="touch")return;let t=Kd[e.pointerId];t===void 0&&(t={x:0,y:0},Kd[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Zp(e){let t=e.pointerId===Ve[0].pointerId?Ve[1]:Ve[0];return Kd[t.pointerId]}function CS(e){Jl[e.key]=!0,gd[e.key]=gd[e.key]===void 0?1:gd[e.key]+1}function TS(e){if(Nu&&Jl.Meta)for(let t in Jl)Jl[t]=!1;else Jl[e.key]=!1;gd={}}function FU(e){e.addEventListener("pointerdown",ES,!0),e.addEventListener("pointerdown",Jd,!0),e.addEventListener("pointermove",Jd,!0),e.addEventListener("pointerup",Ro,!0),e.addEventListener("pointercancel",Ro,!0),e.addEventListener("pointerleave",Ro,!0),window.addEventListener("keydown",CS,!0),window.addEventListener("keyup",TS,!0)}function kU(e){e.removeEventListener("pointerdown",ES,!0),e.removeEventListener("pointerdown",Jd,!0),e.removeEventListener("pointermove",Jd,!0),e.removeEventListener("pointerup",Ro,!0),e.removeEventListener("pointercancel",Ro,!0),e.removeEventListener("pointerleave",Ro,!0),window.removeEventListener("keydown",CS,!0),window.removeEventListener("keyup",TS,!0)}var rx;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(rx||(rx={}));var Qo;(e=>{e.identity={...Cm.identity,hiddenMatrix:Zo.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,n){return{position:n?.position||s.position,rotation:n?.rotation||s.rotation,scale:n?.scale||s.scale,hiddenMatrix:n?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,n){return TU({position:Aa.isEqual(s.position,n.position)?void 0:n.position,rotation:Aa.isEqual(s.rotation,n.rotation)?void 0:n.rotation,scale:Aa.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:Zo.isEqual(s.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})}e.diff=r})(Qo||(Qo={}));var sx;(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]})(sx||(sx={}));var Mr;(e=>e.defaultData={states:new et,events:new et,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Qo.identity,cloner:null})(Mr||(Mr={}));var nx;(e=>e.defaultData={type:"Empty",...Mr.defaultData})(nx||(nx={}));var ax;(e=>e.defaultData={type:"Component",...Mr.defaultData})(ax||(ax={}));var Bo;(e=>e.defaultData={type:"Mesh",...Mr.defaultData,...Im.defaultData})(Bo||(Bo={}));var $d;(e=>e.defaultData={...Mr.defaultData,...Qo.identity,...Oh.defaultData})($d||($d={}));var Nm;(e=>{function t(i){return{...Mr.defaultData,...Dm.defaultData(i)}}e.defaultData=t})(Nm||(Nm={}));var eu;(e=>{function t(r,s,n=0){for(;n<s.length;){let a=r?r[s[n]]:void 0;if(s.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=t;function i(r,s,n=0){let a=t(r,s,n);if(a){let o=Object.keys(a);if(o.length===1&&o[0]==="descendants")return}return a}e.resolve=i})(eu||(eu={}));var Ko;(e=>{e.rootOverrideProps=["physics"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Mr.defaultData,...s,component:r,overrides:new xi,physics:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Qo.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Ko||(Ko={}));var zm;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Zo.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new et,events:new et,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Oh.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Mr.defaultData,...Bo.defaultData,geometry:Io.defaultData("RectangleGeometry"),material:hr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Mr.defaultData,...Bo.defaultData,geometry:Io.defaultData("BooleanGeometry"),material:hr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Mr.defaultData,...Bo.defaultData,geometry:Io.defaultData("TextGeometry"),material:hr.defaultTwoLayerData("phong","layer1","layer2")}))(zm||(zm={}));var ma;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new xi}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new xi})))):Oa.is(n.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(n,a){if(a===void 0)return n;let o={...n};return"material"in o&&"material"in a&&a.material&&(o.material=Gd(o.material,l=>{if(typeof l!="string")for(let[h,d]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&br.patch(c,d)}}).data),o.materials&&a.materials&&(o.materials=Gd(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let d=a.materials[h];if(typeof d!="string")for(let[c,u]of Object.entries(d.layers)){let p=l[h]?.layers?.data(c);p&&br.patch(p,u)}}}).data),o}function r(n,a){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function d(c,u){for(let[p,f]of Object.entries(u.layers)){let{texture:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let v={path:[...c,"layers",p,"texture"],props:m,type:0};l.push(v)}if(Object.keys(g).length>0){let v={path:[...c,"layers",p],props:g,type:0};l.push(v)}}}for(let[c,u]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...Tm.toOps(u,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:u.slide,offset:u.offset},type:0});else if(c==="material")d(["material"],u);else if(c==="materials")for(let[p,f]of Object.entries(u))d(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&u.extrusion!==void 0){let p={path:[c,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[c],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=u;return l}e.toOps=r;function s(n,a){if(a===void 0)return n;let o={...n};if(Object.assign(o,Qo.merge(o,a)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:a.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Oa.is(n.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=a;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(o,{geometry:Bm.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Ln.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Ln.merge(o.cloner,a.cloner)});else if(Pm.is(n.type)){let l=a;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=rr.clone(l.color))}return o}e.patch=s})(ma||(ma={}));var tu;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:rr.white,near:.1,far:2e3})(tu||(tu={}));var iu;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(iu||(iu={}));var Jo;(e=>e.defaultData={orbitControls:iu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),gameControlObject:null})(Jo||(Jo={}));var tr;(e=>e.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(tr||(tr={}));var Um;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=new Wi,a=zm.defaultMeshObject;return s.withLight===!0&&n.push({fi:-1,data:{...Nm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]}),n}e.defaultData={backgroundColor:Wr.fromHexAndA(2960946,1),postprocessing:Lh.defaultData,fog:tu.defaultData,objects:t(),environment:tr.defaultData,publish:Jo.defaultData},e.emptyData=function(s){return{backgroundColor:Wr.fromHexAndA(2960946,1),postprocessing:Lh.defaultData,fog:tu.defaultData,objects:s?t(s):new Wi,environment:tr.defaultData,publish:Jo.defaultData}};function i(s){return{...e.defaultData,objects:La(s,Wi.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(Um||(Um={}));var ru;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(ru||(ru={}));var su;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},La(s,Qt.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...ru.emptyImage,name:"AI generated image"}),La(n,Qt.prototype)}e.defaultImages=i;function r(){return{materials:new Qt,images:new Qt,videos:new Qt,colors:new Qt,audios:new Qt,fonts:new Qt,penumbraSize:[2,2,2]}}e.emptyData=r})(su||(su={}));function ox(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...Th(Ci(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Ci(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function vd(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function yd(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach(s=>{typeof s!="string"&&t(s)}):"material"in r&&typeof r.material!="string"&&t(r.material)})}function jU(e){Object.assign(e.scene.publish,{orbitControls:{...iu.defaultData,...Ci(e.scene.publish.orbitControls)}})}function GU(e){Object.assign(e.scene.publish.settings,{video:{...Jo.defaultData.settings.video,...Ci(e.scene.publish.settings.video)}})}function VU(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,n]of Object.entries(r))if((wS.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(CU.includes(a)||typeof o=="boolean")&&delete n[a]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let n=s;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function HU(e){e.scene.publish.withBackground=!0}function WU(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function qU(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function XU(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function YU(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=Ci(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Ci(i).booleanExclude!==!0)}})}function ZU(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function QU(e){function t(r){Object.setPrototypeOf(r,xi.prototype),r.texture&&Object.setPrototypeOf(r.texture,xi.prototype)}function i(r){Object.setPrototypeOf(r,xi.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(n=>{let a=n;if(a.material){let o=Ci(a.material).layers;i(o),a.material.layers=o}if(a.materials)for(let o=0;o<a.materials.length;o++){let l=a.materials[o],h=Ci(l).layers;i(h),l.layers=h}})})}function lx(e){e.layers===void 0&&Object.assign(e,hr.defaultTwoLayerData("lambert"))}function Qp(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...Ci(t),colors:i,steps:r};Object.assign(t,s)}})}function KU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function hx(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Qp(r)}):"material"in i&&typeof i.material!="string"&&Qp(i.material)}),Object.values(e.shared.materials).forEach(t=>Qp(t))}function JU(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function $U(e){e.shared.audios=La({},Qt.prototype)}function eF(e){e.shared.videos=La({},Qt.prototype)}function tF(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function iF(e){Object.entries(Ci(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Ci(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function rF(e){e.scene.publish.settings.web.preload=!1}function cx(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function sF(e){e.shared.fonts=La({},Qt.prototype)}function nF(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function aF(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=hr.defaultTwoLayerData("phong"),a=typeof s.color=="string"?e.shared.colors[s.color]:s.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=s.alpha;let o=nF(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Mr.defaultData,...Bo.defaultData,flatShading:!1,wireframe:!1,geometry:{...Io.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:Ci(s.states),events:Ci(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Ci(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function oF(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new et,move:new et,jump:new et}});else{let n=new et;Object.assign(s,{actions:n}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&n.push({fi:0,id:it.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((a,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},d={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(d,Th(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(d,{control1:{...a.control1},control2:{...a.control2}});let c={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},u={state:a.state,...c,...d},p={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new et({fi:0,id:it.generateUUID(),data:h},{fi:1,id:it.generateUUID(),data:u})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function lF(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new et,o=[];if(i.events.forEach((l,h,d)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...Th(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")&&(c={...Th(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&a.push({fi:d,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),a.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):i.events.insertBefore(null,[{id:it.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function dx(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=br.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function ux(e){vd(e,dx),yd(e,dx)}function hF(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function cF(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function dF(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=hr.defaultTwoLayerData("phong"))})}function uF(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function pF(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function fF(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function mF(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function gF(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function vF(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}var px=37;function yF(e){let t=e.schema??0;t!==px&&(console.warn("updating from ",t,"to ",px),t<1&&(yd(e,ox),vd(e,ox),e.schema=1),t<2&&(jU(e),e.schema=2),t<3&&(VU(e),e.schema=3),t<4&&(HU(e),e.schema=4),t<5&&(WU(e),e.schema=5),t<6&&(qU(e),e.schema=6),t<7&&(XU(e),e.schema=7),t<8&&(e.schema=8),t<9&&(hx(e),e.schema=9),t<10&&(KU(e),e.schema=10),t<11&&(JU(e),e.schema=11),t<12&&(hx(e),e.schema=12),t<13&&($U(e),e.schema=13),t<14&&(tF(e),e.schema=14),t<15&&(iF(e),e.schema=15),t<16&&(rF(e),e.schema=16),t<17&&(yd(e,cx),vd(e,cx),e.schema=17),t<18&&(yd(e,lx),vd(e,lx),e.schema=18),t<19&&(GU(e),e.schema=19),t<20&&(sF(e),aF(e),e.schema=20),t<21&&(oF(e),lF(e),e.schema=21),t<22&&(ux(e),e.schema=22),t<23&&(hF(e),e.schema=23),t<24&&(cF(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(eF(e),t<25&&(e.schema=25)),t<26&&(YU(e),e.schema=26),t<27&&(ZU(e),e.schema=27),t<28&&(ux(e),e.schema=28),t<29&&(QU(e),e.schema=29),t<30&&(dF(e),e.schema=30),t<31&&(uF(e),e.schema=31),t<33&&(pF(e),e.schema=33),t<34&&(fF(e),e.schema=34),t<35&&(mF(e),e.schema=35),t<36&&(gF(e),e.schema=36),t<37&&(vF(e),e.schema=37))}function Co(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),n={},a={},o=e[0].morphTargetsRelative,l=new He,h=0;for(let d=0;d<e.length;++d){let c=e[d],u=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,d),h+=p}}if(i){let d=0,c=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+d);d+=e[u].attributes.position.count}l.setIndex(c)}for(let d in n){let c=fx(n[d]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,c)}for(let d in a){let c=a[d][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let u=0;u<c;++u){let p=[];for(let m=0;m<a[d].length;++m)p.push(a[d][m][u]);let f=fx(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(f)}}return l}function fx(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let n=new t(s),a=0;for(let o=0;o<e.length;++o)n.set(e[o].array,a),a+=e[o].array.length;return new Ye(n,i,r)}var Fm;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.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:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new et,move:new et,jump:new et}}))(Fm||(Fm={}));var xF=Math.pow(2,-24),zc=class{constructor(){}};function ys(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function mx(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function gx(e,t){t.set(e)}function vx(e,t,i){let r,s;for(let n=0;n<3;n++){let a=n+3;r=e[n],s=t[n],i[n]=r<s?r:s,r=e[a],s=t[a],i[a]=r>s?r:s}}function Uc(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],n=t[e+2*r+1],a=s-n,o=s+n;a<i[r]&&(i[r]=a),o>i[r+3]&&(i[r+3]=o)}}function Ol(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function wF(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new Ye(s,1));for(let n=0;n<i;n++)s[n]=n}}function bF(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,n)=>s-n);for(let s=0;s<r.length-1;s++){let n=r[s],a=r[s+1];t.push({offset:n/3,count:(a-n)/3})}return t}function Kp(e,t,i,r,s=null){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0,c=1/0,u=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let w=e[y+0],_=e[y+1],S=w-_,A=w+_;S<n&&(n=S),A>l&&(l=A),v&&w<c&&(c=w),v&&w>f&&(f=w);let b=e[y+2],M=e[y+3],C=b-M,T=b+M;C<a&&(a=C),T>h&&(h=T),v&&b<u&&(u=b),v&&b>m&&(m=b);let P=e[y+4],O=e[y+5],D=P-O,N=P+O;D<o&&(o=D),N>d&&(d=N),v&&P<p&&(p=P),v&&P>g&&(g=P)}r[0]=n,r[1]=a,r[2]=o,r[3]=l,r[4]=h,r[5]=d,v&&(s[0]=c,s[1]=u,s[2]=p,s[3]=f,s[4]=m,s[5]=g)}function _F(e,t,i,r){let s=1/0,n=1/0,a=1/0,o=-1/0,l=-1/0,h=-1/0;for(let d=t*6,c=(t+i)*6;d<c;d+=6){let u=e[d+0];u<s&&(s=u),u>o&&(o=u);let p=e[d+2];p<n&&(n=p),p>l&&(l=p);let f=e[d+4];f<a&&(a=f),f>h&&(h=f)}r[0]=s,r[1]=n,r[2]=a,r[3]=o,r[4]=l,r[5]=h}function SF(e,t,i,r,s){let n=i,a=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;n<=a&&t[n*6+l]<o;)n++;for(;n<=a&&t[a*6+l]>=o;)a--;if(n<a){for(let h=0;h<3;h++){let d=e[n*3+h];e[n*3+h]=e[a*3+h],e[a*3+h]=d;let c=t[n*6+h*2+0];t[n*6+h*2+0]=t[a*6+h*2+0],t[a*6+h*2+0]=c;let u=t[n*6+h*2+1];t[n*6+h*2+1]=t[a*6+h*2+1],t[a*6+h*2+1]=u}n++,a--}else return n}}var Xs=32,AF=(e,t)=>e.candidate-t.candidate,fn=new Array(Xs).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Fc=new Float32Array(6);function MF(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=mx(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=mx(e),a!==-1&&(o=EF(i,r,s,a));else if(n===2){let l=Ol(e),h=1.25*s,d=r*6,c=(r+s)*6;for(let u=0;u<3;u++){let p=t[u],f=(t[u+3]-p)/Xs;if(s<Xs/4){let m=[...fn];m.length=s;let g=0;for(let y=d;y<c;y+=6,g++){let x=m[g];x.candidate=i[y+2*u],x.count=0;let{bounds:w,leftCacheBounds:_,rightCacheBounds:S}=x;for(let A=0;A<3;A++)S[A]=1/0,S[A+3]=-1/0,_[A]=1/0,_[A+3]=-1/0,w[A]=1/0,w[A+3]=-1/0;Uc(y,i,w)}m.sort(AF);let v=s;for(let y=0;y<v;y++){let x=m[y];for(;y+1<v&&m[y+1].candidate===x.candidate;)m.splice(y+1,1),v--}for(let y=d;y<c;y+=6){let x=i[y+2*u];for(let w=0;w<v;w++){let _=m[w];x>=_.candidate?Uc(y,i,_.rightCacheBounds):(Uc(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=m[y],w=x.count,_=s-x.count,S=x.leftCacheBounds,A=x.rightCacheBounds,b=0;w!==0&&(b=Ol(S)/l);let M=0;_!==0&&(M=Ol(A)/l);let C=1+1.25*(b*w+M*_);C<h&&(a=u,h=C,o=x.candidate)}}else{for(let v=0;v<Xs;v++){let y=fn[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let w=0;w<3;w++)x[w]=1/0,x[w+3]=-1/0}for(let v=d;v<c;v+=6){let y=~~((i[v+2*u]-p)/f);y>=Xs&&(y=Xs-1);let x=fn[y];x.count++,Uc(v,i,x.bounds)}let m=fn[Xs-1];gx(m.bounds,m.rightCacheBounds);for(let v=Xs-2;v>=0;v--){let y=fn[v],x=fn[v+1];vx(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let g=0;for(let v=0;v<Xs-1;v++){let y=fn[v],x=y.count,w=y.bounds,_=fn[v+1].rightCacheBounds;x!==0&&(g===0?gx(w,Fc):vx(w,Fc,Fc)),g+=x;let S=0,A=0;g!==0&&(S=Ol(Fc)/l);let b=s-g;b!==0&&(A=Ol(_)/l);let M=1+1.25*(S*g+A*b);M<h&&(a=u,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function EF(e,t,i,r){let s=0;for(let n=t,a=t+i;n<a;n++)s+=e[n*6+r*2];return s/i}function CF(e,t){let i=e.attributes.position,r=i.array,s=e.index.array,n=s.length/3,a=new Float32Array(n*6),o=i.offset||0,l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);for(let h=0;h<n;h++){let d=h*3,c=h*6,u=s[d+0]*l+o,p=s[d+1]*l+o,f=s[d+2]*l+o;for(let m=0;m<3;m++){let g=r[u+m],v=r[p+m],y=r[f+m],x=g;v<x&&(x=v),y<x&&(x=y);let w=g;v>w&&(w=v),y>w&&(w=y);let _=(w-x)/2,S=m*2;a[c+S+0]=x+_,a[c+S+1]=_+(Math.abs(x)+_)*xF,x<t[m]&&(t[m]=x),w>t[m+3]&&(t[m+3]=w)}}return a}function TF(e,t){function i(v){u&&u(v/p)}function r(v,y,x,w=null,_=0){if(!f&&_>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=d||_>=l)return i(y+x),v.offset=y,v.count=x,v;let S=MF(v.boundingData,w,a,y,x,c);if(S.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let A=SF(o,a,y,x,S);if(A===y||A===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=S.axis;let b=new zc,M=y,C=A-y;v.left=b,b.boundingData=new Float32Array(6),Kp(a,M,C,b.boundingData,n),r(b,M,C,n,_+1);let T=new zc,P=A,O=x-C;v.right=T,T.boundingData=new Float32Array(6),Kp(a,P,O,T.boundingData,n),r(T,P,O,n,_+1)}return v}wF(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=CF(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,d=t.maxLeafTris,c=t.strategy,u=t.onProgress,p=e.index.count/3,f=!1,m=[],g=bF(e);if(g.length===1){let v=g[0],y=new zc;y.boundingData=s,_F(a,v.offset,v.count,n),r(y,v.offset,v.count,n),m.push(y)}else for(let v of g){let y=new zc;y.boundingData=new Float32Array(6),Kp(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),m.push(y)}return m}function PF(e,t){let i=TF(e,t),r,s,n,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let d=0;d<i.length;d++){let c=i[d],u=l(c),p=new o(32*u);r=new Float32Array(p),s=new Uint32Array(p),n=new Uint16Array(p),h(0,c),a.push(p)}return a;function l(d){return d.count?1:1+l(d.left)+l(d.right)}function h(d,c){let u=d/4,p=d/2,f=!!c.count,m=c.boundingData;for(let g=0;g<6;g++)r[u+g]=m[g];if(f){let g=c.offset,v=c.count;return s[u+6]=g,n[p+14]=v,n[p+15]=65535,d+32}else{let g=c.left,v=c.right,y=c.splitAxis,x;if(x=h(d+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=x/4,x=h(x,v),s[u+7]=y,x}}}var Ps=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,n=e.length;s<n;s++){let a=e[s][t];i=a<i?a:i,r=a>r?a:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,n=t.length;s<n;s++){let a=t[s],o=e.dot(a);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};Ps.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,n=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let d=t.dot(e);n=Math.min(d,n),a=Math.max(d,a)}this.min=n,this.max=a}}();var g7=function(){let e=new Ps;return function(t,i){let r=t.points,s=t.satAxes,n=t.satBounds,a=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let d=n[h],c=s[h];if(e.setFromPoints(c,a),d.isSeparated(e))return!1}for(let h=0;h<3;h++){let d=l[h],c=o[h];if(e.setFromPoints(c,r),d.isSeparated(e))return!1}}}(),DF=function(){let e=new E,t=new E,i=new E;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,s.start),t.subVectors(s.end,s.start);let d=i.dot(h),c=h.dot(o),u=h.dot(h),p=i.dot(o),f=o.dot(o)*u-c*c,m,g;f!==0?m=(d*c-p*u)/f:m=0,g=(d+m*c)/u,n.x=m,n.y=g}}(),cv=function(){let e=new G,t=new E,i=new E;return function(r,s,n,a){DF(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,n),s.at(l,a);return}else if(o>=0&&o<=1){l<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,n);return}else if(l>=0&&l<=1){o<0?r.at(0,n):r.at(1,n),s.closestPointToPoint(n,!0,a);return}else{let h;o<0?h=r.start:h=r.end;let d;l<0?d=s.start:d=s.end;let c=t,u=i;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(d)<=u.distanceToSquared(h)){n.copy(c),a.copy(d);return}else{n.copy(h),a.copy(u);return}}}}(),OF=function(){let e=new E,t=new E,i=new er,r=new Ar;return function(s,n){let{radius:a,center:o}=s,{a:l,b:h,c:d}=n;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a||(r.start=l,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a)||(r.start=h,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a))return!0;let c=n.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=a){let u=c.projectPoint(o,t);if(n.containsPoint(u))return!0}return!1}}(),LF=1e-15;function so(e){return Math.abs(e)<LF}var tn=class extends ki{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Ps),this.points=[this.a,this.b,this.c],this.sphere=new Tr,this.plane=new er,this.needsUpdate=!0}intersectsSphere(e){return OF(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,n=this.satBounds,a=s[0],o=n[0];this.getNormal(a),o.setFromPoints(a,r);let l=s[1],h=n[1];l.subVectors(e,t),h.setFromPoints(l,r);let d=s[2],c=n[2];d.subVectors(t,i),c.setFromPoints(d,r);let u=s[3],p=n[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};tn.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new Ar;return function(r,s=null,n=null){let{start:a,end:o}=r,l=this.points,h,d=1/0;for(let c=0;c<3;c++){let u=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[u]),cv(i,r,e,t),h=e.distanceToSquared(t),h<d&&(d=h,s&&s.copy(e),n&&n.copy(t))}return this.closestPointToPoint(a,e),h=a.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),n&&n.copy(a)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),n&&n.copy(o)),Math.sqrt(d)}}();tn.prototype.intersectsTriangle=function(){let e=new tn,t=new Array(3),i=new Array(3),r=new Ps,s=new Ps,n=new E,a=new E,o=new E,l=new E,h=new Ar,d=new Ar,c=new Ar;return function(u,p=null){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let f=this.plane,m=u.plane;if(Math.abs(f.normal.dot(m.normal))>1-1e-10){let g=this.satBounds,v=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let w=0;w<4;w++){let _=g[w],S=v[w];if(r.setFromPoints(S,i),_.isSeparated(r))return!1}let y=u.satBounds,x=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let _=y[w],S=x[w];if(r.setFromPoints(S,t),_.isSeparated(r))return!1}for(let w=0;w<4;w++){let _=v[w];for(let S=0;S<4;S++){let A=x[S];if(n.crossVectors(_,A),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let g=this.points,v=!1,y=0;for(let P=0;P<3;P++){let O=g[P],D=g[(P+1)%3];h.start.copy(O),h.end.copy(D),h.delta(a);let N=v?d.start:d.end,W=so(m.distanceToPoint(O));if(so(m.normal.dot(a))&&W){d.copy(h),y=2;break}if((m.intersectLine(h,N)||W)&&!so(N.distanceTo(D))){if(y++,v)break;v=!0}}if(y===1&&this.containsPoint(d.start))return p&&(p.start.copy(d.start),p.end.copy(d.start)),!0;if(y!==2)return!1;let x=u.points,w=!1,_=0;for(let P=0;P<3;P++){let O=x[P],D=x[(P+1)%3];h.start.copy(O),h.end.copy(D),h.delta(o);let N=w?c.start:c.end,W=so(f.distanceToPoint(O));if(so(f.normal.dot(o))&&W){c.copy(h),_=2;break}if((f.intersectLine(h,N)||W)&&!so(N.distanceTo(D))){if(_++,w)break;w=!0}}if(_===1&&this.containsPoint(c.start))return p&&(p.start.copy(c.start),p.end.copy(c.start)),!0;if(_!==2)return!1;if(d.delta(a),c.delta(o),a.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let S=d.start.dot(a),A=d.end.dot(a),b=c.start.dot(a),M=c.end.dot(a),C=A<b,T=S<M;return S!==M&&b!==A&&C===T?!1:(p&&(l.subVectors(d.start,c.start),l.dot(a)>0?p.start.copy(d.start):p.start.copy(c.start),l.subVectors(d.end,c.end),l.dot(a)<0?p.end.copy(d.end):p.end.copy(c.end)),!0)}}}();tn.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();tn.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new Ar,s=new Ar;return function(n,a=null,o=null){let l=a||o?r:null;if(this.intersectsTriangle(n,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let d=0;d<3;d++){let c,u=i[d],p=n[u];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,a&&a.copy(e),o&&o.copy(p));let f=this[u];n.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,a&&a.copy(f),o&&o.copy(e))}for(let d=0;d<3;d++){let c=i[d],u=i[(d+1)%3];r.set(this[c],this[u]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];s.set(n[f],n[m]),cv(r,s,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Ds=class extends Jt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new ge,this.invMatrix=new ge,this.points=new Array(8).fill().map(()=>new E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new Ps),this.alignedSatBounds=new Array(3).fill().map(()=>new Ps),this.needsUpdate=!1}set(e,t,i){super.set(e,t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Ds.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){let c=1*l|2*h|4*d,u=r[c];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=d?i.z:t.z,u.applyMatrix4(e)}let s=this.satBounds,n=this.satAxes,a=r[0];for(let l=0;l<3;l++){let h=n[l],d=s[l],c=1<<l,u=r[c];h.subVectors(a,u),d.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Ds.prototype.intersectsBox=function(){let e=new Ps;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,n=this.satAxes,a=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,a[0].isSeparated(e)||(e.min=i.y,e.max=r.y,a[1].isSeparated(e))||(e.min=i.z,e.max=r.z,a[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=n[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Ds.prototype.intersectsTriangle=function(){let e=new tn,t=new Array(3),i=new Ps,r=new Ps,s=new E;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);let a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let c=0;c<3;c++){let u=a[c],p=o[c];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=n.satBounds,h=n.satAxes,d=this.points;for(let c=0;c<3;c++){let u=l[c],p=h[c];if(i.setFromPoints(p,d),u.isSeparated(i))return!1}for(let c=0;c<3;c++){let u=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(u,f),i.setFromPoints(s,t),r.setFromPoints(s,d),i.isSeparated(r))return!1}}return!0}}();Ds.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}}();Ds.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ds.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Ar),i=new Array(12).fill().map(()=>new Ar),r=new E,s=new E;return function(n,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(s),this.closestPointToPoint(s,r),n.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=a*a,d=n.min,c=n.max,u=this.points,p=1/0;for(let m=0;m<8;m++){let g=u[m];s.copy(g).clamp(d,c);let v=g.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(g),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){let y=(m+1)%3,x=(m+2)%3,w=g<<y|v<<x,_=1<<m|g<<y|v<<x,S=u[w],A=u[_];t[f].set(S,A);let b=e[m],M=e[y],C=e[x],T=i[f],P=T.start,O=T.end;P[b]=d[b],P[M]=g?d[M]:c[M],P[C]=v?d[C]:c[M],O[b]=c[b],O[M]=g?d[M]:c[M],O[C]=v?d[C]:c[M],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){s.x=m?c.x:d.x,s.y=g?c.y:d.y,s.z=v?c.z:d.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let m=0;m<12;m++){let g=t[m];for(let v=0;v<12;v++){let y=i[v];cv(g,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var kc=new E,jc=new E,Gc=new E,yx=new G,xx=new G,wx=new G,bx=new E;function IF(e,t,i,r,s,n){let a;return n===di?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==sr,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function RF(e,t,i,r,s,n,a){kc.fromBufferAttribute(t,r),jc.fromBufferAttribute(t,s),Gc.fromBufferAttribute(t,n);let o=IF(e,kc,jc,Gc,bx,a);if(o){i&&(yx.fromBufferAttribute(i,r),xx.fromBufferAttribute(i,s),wx.fromBufferAttribute(i,n),o.uv=ki.getUV(bx,kc,jc,Gc,yx,xx,wx,new G));let l={a:r,b:s,c:n,normal:new E,materialIndex:0};ki.getNormal(kc,jc,Gc,l.normal),o.face=l,o.faceIndex=r}return o}function PS(e,t,i,r,s){let n=r*3,a=e.index.getX(n),o=e.index.getX(n+1),l=e.index.getX(n+2),h=RF(i,e.attributes.position,e.attributes.uv,a,o,l,t);return h?(h.faceIndex=r,s&&s.push(h),h):null}function BF(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)PS(e,t,i,a,n)}function NF(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=PS(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function DS(e,t,i){return e===null||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far)?null:e}function ms(e,t,i,r){let s=e.a,n=e.b,a=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),n.x=r.getX(l),n.y=r.getY(l),n.z=r.getZ(l),a.x=r.getX(h),a.y=r.getY(h),a.z=r.getZ(h)}function _x(e,t,i,r,s,n,a){let o=i.index,l=i.attributes.position;for(let h=e,d=t+e;h<d;h++)if(ms(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var OS=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 En(e,t){return t[e+15]===65535}function No(e,t){return t[e+6]}function Ih(e,t){return t[e+14]}function Rh(e){return e+8}function Bh(e,t){return t[e+6]}function zF(e,t){return t[e+7]}var To=new Jt,nu=new E,UF=["x","y","z"];function km(e,t,i,r,s){let n=e*2,a=dl,o=Un,l=Fn;if(En(n,o)){let h=No(e,l),d=Ih(n,o);BF(t,i,r,h,d,s)}else{let h=Rh(e);au(h,a,r,nu)&&km(h,t,i,r,s);let d=Bh(e,l);au(d,a,r,nu)&&km(d,t,i,r,s)}}function jm(e,t,i,r){let s=e*2,n=dl,a=Un,o=Fn;if(En(s,a)){let l=No(e,o),h=Ih(s,a);return NF(t,i,r,l,h)}else{let l=zF(e,o),h=UF[l],d=r.direction[h]>=0,c,u;d?(c=Rh(e),u=Bh(e,o)):(c=Bh(e,o),u=Rh(e));let p=au(c,n,r,nu)?jm(c,t,i,r):null;if(p){let m=p.point[h];if(d?m<=n[u+l]:m>=n[u+l+3])return p}let f=au(u,n,r,nu)?jm(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var FF=function(){let e,t,i=[],r=new OS(()=>new Jt);return function(...n){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let a=s(...n);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),a};function s(n,a,o,l,h=null,d=0,c=0){function u(y){let x=y*2,w=Un,_=Fn;for(;!En(x,w);)y=Rh(y),x=y*2;return No(y,_)}function p(y){let x=y*2,w=Un,_=Fn;for(;!En(x,w);)y=Bh(y,_),x=y*2;return No(y,_)+Ih(x,w)}let f=n*2,m=dl,g=Un,v=Fn;if(En(f,g)){let y=No(n,v),x=Ih(f,g);return ys(n,m,e),l(y,x,!1,c,d+n,e)}else{let y=Rh(n),x=Bh(n,v),w=y,_=x,S,A,b,M;if(h&&(b=e,M=t,ys(w,m,b),ys(_,m,M),S=h(b),A=h(M),A<S)){w=x,_=y;let W=S;S=A,A=W,b=M}b||(b=e,ys(w,m,b));let C=En(w*2,g),T=o(b,C,S,c+1,d+w),P;if(T===2){let W=u(w),q=p(w)-W;P=l(W,q,!0,c+1,d+w,b)}else P=T&&s(w,a,o,l,h,d,c+1);if(P)return!0;M=t,ys(_,m,M);let O=En(_*2,g),D=o(M,O,A,c+1,d+_),N;if(D===2){let W=u(_),q=p(_)-W;N=l(W,q,!0,c+1,d+_,M)}else N=D&&s(_,a,o,l,h,d,c+1);return!!N}}}(),kF=function(){let e=new tn,t=new tn,i=new ge,r=new Ds,s=new Ds;return function n(a,o,l,h,d=null){let c=a*2,u=dl,p=Un,f=Fn;if(d===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),d=r),En(c,p)){let m=o,g=m.index,v=m.attributes.position,y=l.index,x=l.attributes.position,w=No(a,f),_=Ih(c,p);if(i.copy(h).invert(),l.boundsTree)return ys(a,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>s.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(h),S.b.applyMatrix4(h),S.c.applyMatrix4(h),S.needsUpdate=!0;for(let A=w*3,b=(_+w)*3;A<b;A+=3)if(ms(t,A,g,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let S=w*3,A=_+w*3;S<A;S+=3){ms(e,S,g,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let b=0,M=y.count;b<M;b+=3)if(ms(t,b,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=a+8,g=f[a+6];return ys(m,u,To),!!(d.intersectsBox(To)&&n(m,o,l,h,d)||(ys(g,u,To),d.intersectsBox(To)&&n(g,o,l,h,d)))}}}();function au(e,t,i,r){return ys(e,t,To),i.intersectBox(To,r)}var Gm=[],xd,dl,Un,Fn;function $l(e){xd&&Gm.push(xd),xd=e,dl=new Float32Array(e),Un=new Uint16Array(e),Fn=new Uint32Array(e)}function Vc(){xd=null,dl=null,Un=null,Fn=null,Gm.length&&$l(Gm.pop())}var Jp=Symbol("skip tree generation"),$p=new Jt,ef=new Jt,no=new ge,ia=new Ds,Ll=new Ds,Il=new E,Hc=new E,jF=new E,GF=new E,VF=new E,Sx=new Jt,rs=new OS(()=>new tn),wi=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."),wi.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),n;return t.cloneBuffers?n={roots:r.map(a=>a.slice()),index:s.array.slice()}:n={roots:r,index:s.array},n}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),wi.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,n=new wi(t,{...i,[Jp]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new Ye(e.index,1,!1);t.setIndex(o)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return n}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,[Jp]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Jp]||(this._roots=PF(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Jt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s=r.array,n=r.offset||0,a=3;r.isInterleavedBufferAttribute&&(a=r.data.stride);let o,l,h,d,c=0,u=this._roots;for(let f=0,m=u.length;f<m;f++)o=u[f],l=new Uint32Array(o),h=new Uint16Array(o),d=new Float32Array(o),p(0,c),c+=o.byteLength;function p(f,m,g=!1){let v=f*2;if(h[v+15]===65535){let y=l[f+6],x=h[v+14],w=1/0,_=1/0,S=1/0,A=-1/0,b=-1/0,M=-1/0;for(let C=3*y,T=3*(y+x);C<T;C++){let P=i[C]*a+n,O=s[P+0],D=s[P+1],N=s[P+2];O<w&&(w=O),O>A&&(A=O),D<_&&(_=D),D>b&&(b=D),N<S&&(S=N),N>M&&(M=N)}return d[f+0]!==w||d[f+1]!==_||d[f+2]!==S||d[f+3]!==A||d[f+4]!==b||d[f+5]!==M?(d[f+0]=w,d[f+1]=_,d[f+2]=S,d[f+3]=A,d[f+4]=b,d[f+5]=M,!0):!1}else{let y=f+8,x=l[f+6],w=y+m,_=x+m,S=g,A=!1,b=!1;e?S||(A=e.has(w),b=e.has(_),S=!A&&!b):(A=!0,b=!0);let M=S||A,C=S||b,T=!1;M&&(T=p(y,m,S));let P=!1;C&&(P=p(x,m,S));let O=T||P;if(O)for(let D=0;D<3;D++){let N=y+D,W=x+D,q=d[N],z=d[N+3],V=d[W],k=d[W+3];d[f+D]=q<V?q:V,d[f+D+3]=z>k?z:k}return O}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);n(0);function n(a,o=0){let l=a*2,h=s[l+15]===65535;if(h){let d=r[a+6],c=s[l+14];e(o,h,new Float32Array(i,a*4,6),d,c)}else{let d=a+8,c=r[a+6],u=r[a+7];e(o,h,new Float32Array(i,a*4,6),u)||(n(d,o+1),n(c,o+1))}}}raycast(e,t=Qr){let i=this._roots,r=this.geometry,s=[],n=t.isMaterial,a=Array.isArray(t),o=r.groups,l=n?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=a?t[o[h].materialIndex].side:l,u=s.length;if($l(i[h]),km(0,r,c,e,s),Vc(),a){let p=o[h].materialIndex;for(let f=u,m=s.length;f<m;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=Qr){let i=this._roots,r=this.geometry,s=t.isMaterial,n=Array.isArray(t),a=null,o=r.groups,l=s?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=n?t[o[h].materialIndex].side:l;$l(i[h]);let u=jm(0,r,c,e);Vc(),u!=null&&(a==null||u.distance<a.distance)&&(a=u,n&&(u.face.materialIndex=o[h].materialIndex))}return a}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if($l(s),r=kF(0,i,e,t),Vc(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(u,p,f,m)=>{let g=p*3;return c(u,g,g+1,g+2,f,m)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=rs.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(u,p,f,m,g)=>c(u,p,f,m,g)?!0:_x(u,p,r,l,f,m,s)}else o||(l?o=(c,u,p,f)=>_x(c,u,r,l,p,f,s):o=(c,u,p)=>p);let h=!1,d=0;for(let c of this._roots){if($l(c),h=FF(0,r,a,o,n,d),Vc(),h)break;d+=c.byteLength}return rs.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,n=this.geometry.index,a=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;no.copy(t).invert();let h=rs.getPrimitive(),d=rs.getPrimitive();if(s){let u=function(p,f,m,g,v,y,x,w){for(let _=m,S=m+g;_<S;_++){ms(d,_*3,o,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=p,b=p+f;A<b;A++)if(ms(h,A*3,n,a),h.needsUpdate=!0,s(h,d,A,_,v,y,x,w))return!0}return!1};if(r){let p=r;r=function(f,m,g,v,y,x,w,_){return p(f,m,g,v,y,x,w,_)?!0:u(f,m,g,v,y,x,w,_)}}else r=u}e.getBoundingBox(ef),ef.applyMatrix4(t);let c=this.shapecast({intersectsBounds:u=>ef.intersectsBox(u),intersectsRange:(u,p,f,m,g,v)=>($p.copy(v),$p.applyMatrix4(no),e.shapecast({intersectsBounds:y=>$p.intersectsBox(y),intersectsRange:(y,x,w,_,S)=>r(u,p,y,x,m,g,_,S)}))});return rs.releasePrimitive(h),rs.releasePrimitive(d),c}intersectsBox(e,t){return ia.set(e.min,e.max,t),ia.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ia.intersectsBox(i),intersectsTriangle:i=>ia.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,n=1/0){e.boundingBox||e.computeBoundingBox(),ia.set(e.boundingBox.min,e.boundingBox.max,t),ia.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,d=e.index,c=rs.getPrimitive(),u=rs.getPrimitive(),p=Hc,f=jF,m=null,g=null;r&&(m=GF,g=VF);let v=1/0,y=null,x=null;return no.copy(t).invert(),Ll.matrix.copy(no),this.shapecast({boundsTraverseOrder:w=>ia.distanceToBox(w),intersectsBounds:(w,_,S)=>S<v&&S<n?(_&&(Ll.min.copy(w.min),Ll.max.copy(w.max),Ll.needsUpdate=!0),!0):!1,intersectsRange:(w,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>Ll.distanceToBox(S),intersectsBounds:(S,A,b)=>b<v&&b<n,intersectsRange:(S,A)=>{for(let b=S*3,M=(S+A)*3;b<M;b+=3){ms(u,b,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=w*3,T=(w+_)*3;C<T;C+=3){ms(c,C,l,o),c.needsUpdate=!0;let P=c.distanceToTriangle(u,p,m);if(P<v&&(f.copy(p),g&&g.copy(m),v=P,y=C/3,x=b/3),P<s)return!0}}}});{let S=d?d.count:h.count;for(let A=0,b=S;A<b;A+=3){ms(u,A,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let M=w*3,C=(w+_)*3;M<C;M+=3){ms(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(u,p,m);if(T<v&&(f.copy(p),g&&g.copy(m),v=T,y=M/3,x=A/3),T<s)return!0}}}}}),rs.releasePrimitive(c),rs.releasePrimitive(u),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(g):r.point=g.clone(),r.point.applyMatrix4(no),f.applyMatrix4(no),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,n=r*r,a=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Il.copy(e).clamp(h.min,h.max),Il.distanceToSquared(e)),intersectsBounds:(h,d,c)=>c<a&&c<n,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Il);let c=e.distanceToSquared(Il);return c<a&&(Hc.copy(Il),a=c,o=d),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Hc):t.point=Hc.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ys(0,new Float32Array(t),Sx),e.union(Sx)}),e}},Ax=wi.prototype.raycast;wi.prototype.raycast=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,i,r,s]=e;return Ax.call(this,r,t.material).forEach(n=>{n=DS(n,t,i),n&&s.push(n)}),s}else return Ax.apply(this,e)};var Mx=wi.prototype.raycastFirst;wi.prototype.raycastFirst=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,i,r]=e;return DS(Mx.call(this,r,t.material),t,i)}else return Mx.apply(this,e)};var Ex=wi.prototype.closestPointToPoint;wi.prototype.closestPointToPoint=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),e.unshift();let t=e[1],i={};return e[1]=i,Ex.apply(this,e),t&&t.copy(i.point),i.distance}else return Ex.apply(this,e)};var Cx=wi.prototype.closestPointToGeometry;wi.prototype.closestPointToGeometry=function(...e){let t=e[2],i=e[3];if(t&&t.isVector3||i&&i.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let r={},s={},n=e[1];return e[2]=r,e[3]=s,Cx.apply(this,e),t&&t.copy(r.point),i&&i.copy(s.point).applyMatrix4(n),r.distance}else return Cx.apply(this,e)};var Tx=wi.prototype.refit;wi.prototype.refit=function(...e){let t=e[0],i=e[1];if(i&&(i instanceof Set||Array.isArray(i))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let r=new Set;i.forEach(s=>r.add(s)),t&&t.forEach(s=>r.add(s)),Tx.call(this,r)}else Tx.apply(this,e)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(e=>{let t=wi.prototype[e];wi.prototype[e]=function(...i){return(i[0]===null||i[0].isMesh)&&(i.shift(),console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,i)}});var Rl=Uh(MM()),HF=.5*(Math.sqrt(3)-1),Bl=(3-Math.sqrt(3))/6,WF=1/3,ss=1/6,v7=(Math.sqrt(5)-1)/4,y7=(5-Math.sqrt(5))/20,ch=e=>Math.floor(e)|0,Px=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),tf=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function rf(e=Math.random){let t=LS(e),i=new Float64Array(t).map(s=>Px[s%12*2]),r=new Float64Array(t).map(s=>Px[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*HF,d=ch(s+h),c=ch(n+h),u=(d+c)*Bl,p=d-u,f=c-u,m=s-p,g=n-f,v,y;m>g?(v=1,y=0):(v=0,y=1);let x=m-v+Bl,w=g-y+Bl,_=m-1+2*Bl,S=g-1+2*Bl,A=d&255,b=c&255,M=.5-m*m-g*g;if(M>=0){let P=A+t[b],O=i[P],D=r[P];M*=M,a=M*M*(O*m+D*g)}let C=.5-x*x-w*w;if(C>=0){let P=A+v+t[b+y],O=i[P],D=r[P];C*=C,o=C*C*(O*x+D*w)}let T=.5-_*_-S*S;if(T>=0){let P=A+1+t[b+1],O=i[P],D=r[P];T*=T,l=T*T*(O*_+D*S)}return 70*(a+o+l)}}function qF(e=Math.random){let t=LS(e),i=new Float64Array(t).map(n=>tf[n%12*3]),r=new Float64Array(t).map(n=>tf[n%12*3+1]),s=new Float64Array(t).map(n=>tf[n%12*3+2]);return function(n,a,o){let l,h,d,c,u=(n+a+o)*WF,p=ch(n+u),f=ch(a+u),m=ch(o+u),g=(p+f+m)*ss,v=p-g,y=f-g,x=m-g,w=n-v,_=a-y,S=o-x,A,b,M,C,T,P;w>=_?_>=S?(A=1,b=0,M=0,C=1,T=1,P=0):w>=S?(A=1,b=0,M=0,C=1,T=0,P=1):(A=0,b=0,M=1,C=1,T=0,P=1):_<S?(A=0,b=0,M=1,C=0,T=1,P=1):w<S?(A=0,b=1,M=0,C=0,T=1,P=1):(A=0,b=1,M=0,C=1,T=1,P=0);let O=w-A+ss,D=_-b+ss,N=S-M+ss,W=w-C+2*ss,q=_-T+2*ss,z=S-P+2*ss,V=w-1+3*ss,k=_-1+3*ss,U=S-1+3*ss,B=p&255,H=f&255,X=m&255,Z=.6-w*w-_*_-S*S;if(Z<0)l=0;else{let $=B+t[H+t[X]];Z*=Z,l=Z*Z*(i[$]*w+r[$]*_+s[$]*S)}let F=.6-O*O-D*D-N*N;if(F<0)h=0;else{let $=B+A+t[H+b+t[X+M]];F*=F,h=F*F*(i[$]*O+r[$]*D+s[$]*N)}let ne=.6-W*W-q*q-z*z;if(ne<0)d=0;else{let $=B+C+t[H+T+t[X+P]];ne*=ne,d=ne*ne*(i[$]*W+r[$]*q+s[$]*z)}let j=.6-V*V-k*k-U*U;if(j<0)c=0;else{let $=B+1+t[H+1+t[X+1]];j*=j,c=j*j*(i[$]*V+r[$]*k+s[$]*U)}return 32*(l+h+d+c)}}function LS(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var zr=new ki,XF=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;zr.a.fromBufferAttribute(e,r),zr.b.fromBufferAttribute(e,r+1),zr.c.fromBufferAttribute(e,r+2),s*=zr.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||t[n-1]<=e&&t[n]>e){s=n;break}else e<t[n]?r=n-1:i=n+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),zr.a.fromBufferAttribute(this.positionAttribute,e*3),zr.b.fromBufferAttribute(this.positionAttribute,e*3+1),zr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(zr.a,r).addScaledVector(zr.b,s).addScaledVector(zr.c,1-(r+s)),zr.getNormal(i),this}},YF=Uh(Cb()),ZF=new ge,QF=new ge,KF=new ge,ou;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(ou||(ou={}));var dv=e=>class extends e{constructor(){super(...arguments),this.hiddenMatrix=new ge,this.matrixWorldRigid=new ge,this.shearScale=new ge,this.shearScaleInv=new ge}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof _t&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)ou.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:n}=(0,YF.SVD)(i),a=ZF.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=QF.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=KF.copy(o).transpose();this.shearScale.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,l).copyPosition(this.matrixWorld),n.every(h=>Math.abs(n[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new ge().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof ge?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}},JF=class extends dv(_t){},$F=e=>e.type==="Mesh",qr=class extends JF{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new qr(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return $F(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}},da=new E,ua=new E,zo=new ge,IS=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],e6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],t6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Dx=(e,t,i)=>{e.updateEntityBoxSize(da,ua),zo.copy(t).multiply(e.matrixWorld),ua.x===0&&ua.y===0&&ua.z===0?i.push(new E(da.x,da.y,da.z).applyMatrix4(zo)):IS.forEach(r=>{i.push(r.clone().multiply(ua).add(da).applyMatrix4(zo))})},Ox=class extends Jt{constructor(){super(...arguments),this.matrix=new ge,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new ge().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}Dx(s,t,r)}}):Dx(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(zo.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(ua).multiplyScalar(.5),this.getCenter(da),zo.copy(this.matrix).setPosition(da),this.vertices=IS.map(e=>e.clone().multiply(ua).applyMatrix4(zo))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=e6.map(([e,t])=>new Ar(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=t6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},In={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},i6=class extends Kb{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(e*l/s),d=o.getPoints(h);for(let c=0;c<d.length;c++){let u=d[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},Vm=.001;function Hm(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Vm}function sf(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),n=new E(...t.position);return Hm(i,r,n)&&Hm(i,s,n)}function RS(e){let t=e.points.map(d=>new E(...d.data.position)),i=[e.points[0]],r=new E(...i[0].data.position);for(let d=0;d<e.points.length-1;d++)Hm(r,t[d],t[d+1])||(i.push(e.points[d]),r=t[d]);i.push(e.points[e.points.length-1]);let s=e.isClosed,n=i.length-(s?0:1),a=i.length,o=[];for(let d=0;d<a;d++){let c=i[d].data,u=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),m={position:u,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(d===0||d===a-1)){o[d]={...m,removedLength:0};continue}let g=s&&d==0?a-1:d-1,v=s&&d==a-1?0:d+1,y=i[g].data,x=i[v].data,w=new E(...y.position),_=new E(...x.position),S=w.clone().sub(u).normalize(),A=_.clone().sub(u).normalize();Object.assign(m,{prevDir:S,nextDir:A});let b=sf(y,c),M=sf(c,x);if(!b||!M)o[d]={...m,removedLength:0};else{let C=S.clone().add(A).normalize(),T=C.clone().cross(S).length()/S.dot(C);o[d]={...m,tan:T,removedLength:c.roundness/T}}}for(let d=0;d<n;d++){let c=d,u=s&&d===a-1?0:d+1,p=o[c],f=o[u];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let d=0;d<n;d++){let c=d,u=s&&d===a-1?0:d+1,p=o[c],f=o[u],m=null;if(!sf(i[c].data,i[u].data))p.position.distanceTo(f.position)>Vm&&(m=new ud(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(v)>Vm&&(m=new ud(g,g.clone().lerp(v,.3),v.clone().lerp(g,.3),v))}l[2*d+1]=m}for(let d=0;d<a;d++){let c=o[d];if(c.removedLength===0){l[2*d]=null;continue}let u=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(u),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(u),m=c.tan*c.removedLength,g=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(y,2))).add(v),w=g.clone().multiplyScalar(-m).add(x),_=u.distanceTo(w)/u.distanceTo(v),S=c.prevDir.clone().multiplyScalar(_*u.distanceTo(p)).add(u),A=S.clone().lerp(w,2),b=p.clone().lerp(S,4/3),M=f.clone().lerp(A,4/3);l[2*d]=new ud(p,b,M,f)}let h=new i6;return l.forEach(d=>{d&&h.add(d)}),h}var xt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(xt||(xt={}));var Cn=e=>xt.is(e),r6={type:"completeState",isfromEntity:!0},BS=e=>class extends dv(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new Ox,this._recursiveBBox=new Ox,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(xt.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(xt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)ma.toOps(this.data,s.data).forEach(n=>{let a=gm.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=ma.patch(this.data,s),ma.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{Cn(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(xt.is(i[r]))return i[r];if(xt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&xt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)Cn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{xt.is(i)&&t(i)})}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Cn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Cn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>Cn(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return mm(i,t)}updateTransformState(t){let i=!1;return t.position&&(this.position.fromArray(t.position),i=!0),t.rotation&&(this.rotation.fromArray(t.rotation),i=!0),t.scale&&(i=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Zo.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)xt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{xt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return mm(i,t)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=Mn(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let c=As.zoom(d,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(h[u]=c[u])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:d,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:d,...c}=l;l=c}let h=As.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,ma.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Mn(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let d of Object.keys(t.props)){l[l.length-1]=d;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[d],c.updateState(Sa.apply(c.component.data,c.overrideData),r))}}else{let d=r.scene.findInstance([this.uuid,...l]);if(d){let c=As.zoom(d.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(u===t.props&&(u={...t.props}),u[p]=c[p]);t={...t,props:u}}d.overrideData=eu.resolve(i.overrides,l),d.updateByOp(t,ar.applySimple(d.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let d of Ko.rootOverrideProps)d in t.props&&(h===void 0&&(h={}),h[d]=t.props[d]);h&&(l={...t,props:h})}else for(let h of Ko.rootOverrideProps)if(Mn(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Sa.filterOp(h.overrideData,l);d&&h.updateByOp(d,ar.applySimple(h.data,d),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Sa.filterOp(h.overrideData,t);if(d){let c;n===h.data&&t===d?c=i:c=ar.applySimple(h.data,d),h.updateByOp(d,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Oa.is(t.props.type)&&In.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){In.changeEntityProptotype(this,i,r);for(let s of this.children)xt.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Mn(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Mn(t.path,["cloner"])!==null){let s=ar.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=a.data,l=RS(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let d=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new ge;a.updateMatrixWorld();let u=new ge().multiplyMatrices(c.clone().invert(),a.matrixWorld);d.applyMatrix4(u);let p={position:d.toArray(),rotation:o.rotation};if(n==="tangential"){let f=new ge().extractRotation(a.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(d),g=new ge().lookAt(d,m,new E(0,1,0)),v=new gi().setFromRotationMatrix(g);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(r6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof In.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new In.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}},s6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters),r=i.width/2,s=i.radiusTop??r,n=i.radiusBottom??r;return s===n?(s=r,n=r):s>n?(s=r,n=n*r/s):(s=s*r/n,n=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:n})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:u,hollow:p}=e.parameters,f;return c||p?f=new NS(h,d,r,s,n,a,o,l*Math.PI/180,c,c,u,p):f=new Cg(h,d,r,s,n,a,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function mn(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Lx(e){return new G(e.y,-e.x)}var NS=class extends He{constructor(e,t,i,r,s,n,a,o,l,h,d,c,u=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,o=o!==void 0?o:Math.PI*2,n&&(l=0,h=0);let p=[],f=[],m=[],g=[],v=0,y=i/2,x=new E,w=new E;u&&e==0&&(e=l),u&&t==0&&(t=h);let _=new G(e,y),S=new G(t,-y),A=null,b=null,M=null,C=null,T=_.clone().sub(S),P=0,O=0,D=0;c>0&&(P=Math.min(e,t)*(1-c),O=e-P,D=t-P);let N=_.clone();N.x-=P;let W=Math.PI-T.angle(),q=T.angle(),z=Math.tan(q/2),V=Math.tan(W/2),k=z+V,U=c?k:V,B=c?k:z;if(l=Math.min(l,(e-O)/U,T.length()/k),h=Math.min(h,(t-D)/B,T.length()/k),l>0){let j=l/z;A=_.clone().sub(new G(j,l)),c&&(M=A.clone(),M.x-=P-k*l),_.sub(T.clone().setLength(j))}if(h>0){let j=h/V;b=S.clone().sub(new G(j,-h)),S.add(T.clone().setLength(j)),c&&(C=b.clone(),C.x-=P-k*h,N.sub(T.clone().setLength(j)))}T=_.clone().sub(S);let H=T.length()<.5,X=[];for(let j=0;j<=r;j++){let $=[],Q=j/r,me=Q*o+a,re=new G(Math.sin(me),Math.cos(me));C&&b?(Z($,Q,re,W,h,C,-1,!0),Z($,Q,re,q,h,b,-1,!1)):b?(F($,re,b.x,0,-1),Z($,Q,re,q,h,b,-1,!1)):n||F($,re,t,D,-1);let oe=Lx(T).normalize();if(mn(oe,re,x),!H)for(let de=0;de<=s;de++){let xe=de/s,Te=T.clone().multiplyScalar(xe).add(S);mn(Te,re,w),f.push(w.x,w.y,w.z),m.push(x.x,x.y,x.z),g.push(Q,.5+w.y/i),$.push(v++)}if(M&&A?(Z($,Q,re,W,l,A,1,!1),Z($,Q,re,q,l,M,1,!0)):A?(Z($,Q,re,W,l,A,1,!1),F($,re,A.x,0,1)):n||F($,re,e,O,1),c&&!H){let de=Lx(T).multiplyScalar(-1).normalize();mn(de,re,x);for(let xe=0;xe<=s;xe++){let Te=xe/s,we=T.clone().multiplyScalar(-Te).add(N);mn(we,re,w),f.push(w.x,w.y,w.z),m.push(x.x,x.y,x.z),g.push(Q,.5+w.y/i),$.push(v++)}}c&&!n&&$.push($[0]),X.push($)}for(let j=0;j<X.length-1;j++)for(let $=0;$<X[0].length-1;$++){if(n&&c&&$==s)continue;let Q=X[j][$],me=X[j+1][$],re=X[j+1][$+1],oe=X[j][$+1],de=f[re*3+0],xe=f[re*3+2];p.push(Q,me,oe),(de!=0||xe!=0)&&p.push(me,re,oe)}o<Math.PI*2&&(ne(-1,X[0],a),ne(1,X[X.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Ce(f,3)),this.setAttribute("normal",new Ce(m,3)),this.setAttribute("uv",new Ce(g,2));function Z(j,$,Q,me,re,oe,de,xe){for(let Te=0;Te<d+1;Te++){let we=Te/d,be=de<0?we:1-we;xe&&(be-=1),be*=me;let Re=new G(Math.sin(be),Math.cos(be)*de),We=Re.clone().multiplyScalar(re).add(oe);mn(We,Q,w),f.push(w.x,w.y,w.z),mn(Re,Q,x),m.push(x.x,x.y,x.z),g.push($,.5+w.y/i),j.push(v++)}}function F(j,$,Q,me,re){let oe=new E,de=new G,xe=[Q,me];re<0&&xe.reverse();for(let Te of xe)de.set(Te,y*re),mn(de,$,oe),f.push(oe.x,oe.y,oe.z),m.push(0,re,0),g.push(.5,.5),j.push(v++)}function ne(j,$,Q){let me=new G(Math.sin(Q),Math.cos(Q)),re=new G(-Math.cos(Q),Math.sin(Q)),oe=new E,de=j<0?(we,be,Re)=>p.push(we,be,Re):(we,be,Re)=>p.push(we,Re,be),xe=new G((e+t+O+D)/4,0);mn(xe,me,oe),f.push(oe.x,oe.y,oe.z),m.push(re.x,0,re.y),g.push(.5,.5);let Te=v++;for(let we of $){let be=f.slice(we*3,we*3+3);f.push(...be),m.push(re.x,0,re.y);let Re=g.slice(we*2,we*2+2);g.push(...Re),v++}for(let we=Te+1;we<v-1;we++)de(Te,we,we+1);de(Te,v-1,Te+1)}}},n6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=e.parameters,u;return h>0||d>0||l<360?u=new NS(0,t/2,r,s,n,a,o,l*Math.PI/180,h,d,c,0,!0):u=new $b(t/2,r,s,n,a),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},a6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Cs(t,i,r,s,n,a):h=new o6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},nf=Math.PI/2,o6=class extends He{constructor(e=1,t=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o),a=Math.min(a,e/2,t/2,i/2);let h=[],d=[],c=[],u=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,n,s,0),m("z","y","x",1,-1,i,t,-e,n,s,1),m("x","z","y",1,1,e,i,t,r,n,2),m("x","z","y",1,-1,e,i,-t,r,n,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(g("z","y","x",-1,-1,1,i,t,e,n,0),g("z","y","x",1,-1,-1,i,t,e,n,1),g("z","y","x",-1,1,-1,i,t,e,n,1),g("z","y","x",1,1,1,i,t,e,n,0),g("x","y","z",-1,-1,-1,e,t,i,r,0),g("x","y","z",1,-1,1,e,t,i,r,1),g("x","y","z",-1,1,1,e,t,i,r,0),g("x","y","z",1,1,-1,e,t,i,r,1),g("y","x","z",-1,-1,1,t,e,i,s,0),g("y","x","z",1,-1,-1,t,e,i,s,1),g("y","x","z",1,1,1,t,e,i,s,1),g("y","x","z",-1,1,-1,t,e,i,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Ce(d,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(u,2));function m(y,x,w,_,S,A,b,M,C,T,P){let O=(A-2*a)/C,D=(b-2*a)/T,N=A/2-a,W=b/2-a,q=M/2,z=C+1,V=T+1,k=0,U=0,B=new E;for(let H=0;H<V;H++){let X=H*D-W;for(let Z=0;Z<z;Z++){let F=Z*O-N;B[y]=F*_,B[x]=X*S,B[w]=q,d.push(B.x,B.y,B.z),B[y]=0,B[x]=0,B[w]=M>0?1:-1,c.push(B.x,B.y,B.z),u.push(Z/C),u.push(1-H/T),k+=1}}for(let H=0;H<T;H++)for(let X=0;X<C;X++){let Z=p+X+z*H,F=p+X+z*(H+1),ne=p+(X+1)+z*(H+1),j=p+(X+1)+z*H;h.push(Z,F,j),h.push(F,ne,j),U+=6}l.addGroup(f,U,P),f+=U,p+=k}function g(y,x,w,_,S,A,b,M,C,T,P){let O=(b-2*a)/T,D=b/2-a,N=M/2-a,W=C/2,q=T+1,z=0,V=0,k=new E,U=new E;for(let B=0;B<o+1;B++){let H=B/o*nf,X=Math.sin(H)*a,Z=(1-Math.cos(H))*a,F=Math.sin(H),ne=Math.cos(H);k[x]=(N+X)*S,k[w]=(W-Z)*A,U[y]=0,U[x]=F*Math.sign(k[x]),U[w]=ne*Math.sign(k[w]);for(let j=0;j<q;j++){let $=j*O-D;k[y]=$*_,d.push(k.x,k.y,k.z),c.push(U.x,U.y,U.z),u.push(j/T),u.push(0),z+=1}}for(let B=0;B<o;B++)for(let H=0;H<T;H++){let X=p+H+q*B,Z=p+H+q*(B+1),F=p+(H+1)+q*(B+1),ne=p+(H+1)+q*B;h.push(X,Z,ne),h.push(Z,F,ne),V+=6}l.addGroup(f,V,P),f+=V,p+=z}function v(y,x,w){let _=new E,S=new E(e/2,t/2,i/2);S.subScalar(a);let A=[],b=y*x*w>0?(C,T,P)=>h.push(C,T,P):(C,T,P)=>h.push(C,P,T);for(let C=0;C<=o;C++){let T=[],P=nf*(1-C/o),O=Math.cos(P),D=Math.sin(P),N=0;for(let W=0;W<=C;W++){let q=Math.cos(N),z=Math.sin(N);_.x=O*q,_.y=D,_.z=O*z;let V=S.clone().addScaledVector(_,a);d.push(y*V.x,x*V.y,w*V.z),c.push(y*_.x,x*_.y,w*_.z),u.push(0,0),T.push(p++),N+=nf/C}A.push(T)}let M=A.length-1;for(let C=0;C<M;C++){let T=A[C],P=A[C+1],O=T.length-1;b(T[0],P[1],P[0]);for(let D=1;D<=O;D++)b(T[D-1],T[D],P[D]),b(T[D],P[D+1],P[D])}}}},uv=class extends He{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),d(),this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(n=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new E,p=u.clone(),f=new ki,m=s*r,g=r-m,v=n+1,y=new E,x=(q,z)=>y.subVectors(q,z).normalize(),w=(q,z)=>Array(q).fill(void 0).map(z),_=w(e.length/3,(q,z)=>new E().fromArray(e,z*3).setLength(r)),S=[],A=1e6;for(let q=0;q<_.length;q++){let z=_[q],V=[],k,U,B,H=1e10,X=-1;for(;(X=t.indexOf(q,X+1))!=-1;){let j=X-X%3;k=t[j+(X+1)%3],U=t[j+(X+2)%3],B=z.distanceToSquared(_[k]),H=Math.min(H,B),V.push([k,U,B])}H+=1e-6;let Z=[],F=0,ne=V.length;for(let j=0;j<ne;j++){[k,U,B]=V[F];let $=S[k]?.includes(q)==!0;B<=H&&Z.push(k+ +$*A),F=V.findIndex(Q=>Q[0]==U)}S.push(Z)}let b=[];{let q=0,z=0,V,k,U=c==3;for(let B=0;B<=n;B++){V=B*(B+1)/2,k=(B+1)*(B+2)/2;for(let H=0;H<n-B;H++)[q,z]=[V+H+B+2,k+H+B+3],b.push(V,k,...U?[z,V]:[q,k],z,q),[V,k]=[q,z];b.push(V,k,V+n+2)}}let M=u.clone(),C=u.clone(),T=u.clone(),P=u.clone(),O=u.clone(),D=[],N=w(_.length,()=>w(c,()=>u.clone()));for(let q=0;q<_.length;q++){u.copy(_[q]).normalize(),M.copy(u).multiplyScalar(g);let z=S[q];for(let Z=0;Z<z.length;Z++){let F=z[Z],ne=z[(Z+1)%c];f.setFromPointsAndIndices(_,q,F%A,ne%A),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,N[q][Z])}let V=[],k=[],U=[],B=new E;n==0&&[...N[q]].reduce((Z,F)=>Z.add(F),B).multiplyScalar(1/c);for(let Z=0;Z<c;Z++){let F=[],ne=(Z-1+c)%c,j=N[q][ne],$=N[q][Z];u.copy(j).sub(M),p.copy($).sub(M);let Q=M.angleTo(u),me=u.angleTo(p),re=Math.cos(Q)*m;n==0?C.copy(B):C.copy(M).setLength(g+re),k.push(re);let oe=[C,j,$];for(let de=0;de<2;de++){let xe=oe[de],Te=oe[de+1];P.subVectors(xe,M),O.subVectors(Te,M),T.crossVectors(P,O).normalize();for(let we=0;we<v;we++){let be=[Q,me][de]*we/v;u.copy(P).applyAxisAngle(T,be).add(M),V.push(u.clone()),de&&(x(u,M),F.push([we==0?xe:u.clone(),y.clone()]))}de&&(x(Te,M),F.push([Te,y.clone()]))}U.push(F)}D.push(U);let H=2*v,X=2;for(let Z=0;Z<c;Z++){let F=H*Z,ne=H*((Z+1)%c),j=[V[F]];for(let Q=1;Q<v;Q++){P=V[F+Q],O=V[ne+Q],j.push(P);for(let me=1,re=Q-X+1;me<=re;me++)u.lerpVectors(P,O,me/(re+1)),u.sub(M).setLength(k[Z]).add(M),j.push(u.clone());j.push(O)}for(let Q=0;Q<v;Q++)j.push(V[Q+v+F]);j.push(V[ne+v]);let $=b.map(Q=>j[Q]);a.push(...$.map(Q=>[Q.x,Q.y,Q.z]).flat()),l.push(...$.map(Q=>(x(Q,M),[y.x,y.y,y.z])).flat())}}let W=[];for(let q=0;q<S.length;q++)for(let z=0;z<c;z++){let V=S[q][z];if(V<A){let k=S[V].findIndex(H=>H%A==q),U=D[q][z],B=D[V][k];for(let H=0;H<v;H++){let X=U[H],Z=B[v-H],F=U[H+1],ne=B[v-(H+1)];[X,Z,F,F,Z,ne].forEach(j=>{a.push(j[0].x,j[0].y,j[0].z),l.push(j[1].x,j[1].y,j[1].z)})}W.push(U[0][0],B[v][0],U[v][0],B[0][0])}}for(;W.length;){let q,z,V,k;[q,z]=W.splice(0,2);let U=[q];for(;q!=z;)U.push(z),V=W.indexOf(z),k=V%2,z=W.splice(V-k,2)[1-k];y.subVectors(U[0],U[1]).cross(u.subVectors(U[0],U[2])).normalize();let B=y.dot(U[0])<0;B&&y.negate();for(let H=1;H<=U.length-2;H++)[U[H+ +B],U[H+1-+B],U[0]].forEach(X=>{a.push(X.x,X.y,X.z),l.push(y.x,y.y,y.z)})}}function d(){let c=new E;for(let S=0;S<a.length;S+=3){c.x=a[S+0],c.y=a[S+1],c.z=a[S+2];let A=w(c)/2/Math.PI+.5,b=_(c)/Math.PI+.5;o.push(A,1-b)}let u=new E,p=new E,f=new E,m=new E,g=new G,v=new G,y=new G,x=(S,A,b,M)=>{M<0&&S.x===1&&(o[A]=S.x-1),b.x===0&&b.z===0&&(o[A]=M/2/Math.PI+.5)};for(let S=0,A=0;S<a.length;S+=9,A+=6){u.set(a[S+0],a[S+1],a[S+2]),p.set(a[S+3],a[S+4],a[S+5]),f.set(a[S+6],a[S+7],a[S+8]),g.set(o[A+0],o[A+1]),v.set(o[A+2],o[A+3]),y.set(o[A+4],o[A+5]),m.copy(u).add(p).add(f).divideScalar(3);let b=w(m);x(g,A+0,u,b),x(v,A+2,p,b),x(y,A+4,f,b)}for(let S=0;S<o.length;S+=6){let A=o[S+0],b=o[S+2],M=o[S+4],C=Math.max(A,b,M),T=Math.min(A,b,M);C>.9&&T<.1&&(A<.2&&(o[S+0]+=1),b<.2&&(o[S+2]+=1),M<.2&&(o[S+4]+=1))}function w(S){return Math.atan2(S.z,-S.x)}function _(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}}static fromJSON(e){return new uv(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},l6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new zS(t*.5,n,a):new e_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},zS=class extends uv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(n,a,o,e,t,i),this.type=o}static fromJSON(e){return new zS(e.radius,e.corner,e.cornerSides)}},Nl=1e-12,pv=class{constructor(e){this.position=new G,this.startPosition=new G,this.uuid=it.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 pv(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Wm=class extends pv{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Wm(this.parent).copy(this)}},Uo=class extends pv{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Wm(this),new Wm(this))}static create(e,t){let i=new Uo(e,new G(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Uo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new G,t=new G){let[i,r]=this.computeTangents();return i&&r&&(Ix(i,e),Ix(r,t)),[e,t]}computeTangent(e=new G){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new G){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Ix(e,t=new G){let i=e.length();return t.set(-e.y/i,e.x/i)}var fv=e=>e,ul=new G,zu=new G,h6=new G,c6=new G,d6=new G,u6=new G,US=new E,FS=new E;function p6(e){let t=new G;t.addVectors(e.v0,ul.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new G;return i.addVectors(e.v2,zu.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Hr(e.v0,t,i,e.v2)}function eh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function f6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function m6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function kS(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function g6(e,t,i){return Bx(e,t)&&Bx(t,i)&&qm(e.position,t.position,i.position)}function qm(e,t,i){return ul.copy(t).sub(e).cross(zu.copy(i).sub(e))===0}function v6(e,t,i,r,s){let n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.y-t.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.x-e.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function y6(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function x6(e,t,i,r,s,n){let a=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,d=Math.sqrt((a+l)*(a+l)+(o+h)*(o+h)),c;return kS(t,e,i)>Math.PI&&(d*=-1),eh(h,o)?c=(o+h)*(r/d-.5)*8/3/(a-l):c=(a+l)*(r/d-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*a),n.set(i.x+c*h,i.y-c*l),[s,n]}function Rx(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Bx(e,t){return qm(e.position,e.controls[1].position,t.position)&&qm(e.position,t.controls[0].position,t.position)}function w6(e,t,i,r,s=.5){let n=ul.subVectors(t,e).multiplyScalar(s).add(e),a=zu.subVectors(i,t).multiplyScalar(s).add(t),o=h6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=c6.subVectors(a,n).multiplyScalar(s).add(n),d=d6.subVectors(o,a).multiplyScalar(s).add(a),c=o,u=u6.subVectors(d,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,d.x,d.y,c.x,c.y,r.x,r.y]}function b6(e,t,i=12,r=!0){let s=FS.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=fv(t[l]),d=ul,c=Ma(h,i);o.push(c);for(let u=0;u<=c;u++)if(h instanceof Hr||h instanceof kn||h instanceof Zr){if(h.getPoint(u/c,d),s.set(d.x,d.y,0),n!==void 0&&m6(n,s))continue;n===void 0&&(n=US),n.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}return r&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),e}function _6(e,t,i,r=12,s=!0){let n=FS.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,d=fv(t[l]),c=ul,u=Ma(d,r);o.push(u);for(let p=0;p<=u;p++)if(d instanceof Hr||d instanceof kn||d instanceof Zr){if(d.getPoint(p/u,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=US:(e.setXYZ(a,h.x,h.y,h.z),a++,e.setXYZ(a,n.x,n.y,n.z),a++),h.copy(n)}}return s&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),o}function Nx(e,t=12,i=!1){let r=[];for(let s=0,n=e.length;s<n;s++){let a=e[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=Ma(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Ma(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Ma(e[0].roundedCurveCorner,t)*.5),r}function Ma(e,t=12){return e&&e instanceof bu?t*2:e&&(e instanceof Zr||e instanceof Qb)?1:e&&e instanceof Eg?t*e.points.length:t}function S6(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=fv(t[a]),l=Ma(o,i),h=ul;for(let d=0;d<=l;d++)if(o instanceof Hr||o instanceof kn||o instanceof Zr){if(o.getPoint(d/l,h),s!==void 0&&f6(s,h,Nl))continue;s===void 0&&(s=zu),s.copy(h),e.push(h.x,h.y),n++}}return eh(e[0],e[e.length-2],Nl)&&eh(e[1],e[e.length-1],Nl)&&(e.pop(),e.pop()),r&&n>1&&!(eh(e[n-1],e[1],Nl)&&eh(e[n-2],e[0],Nl))&&(e.push(e[0],e[1]),n++),e}var af=new G,A6=new G,M6=new G,E6=new G,C6=new G,T6=new G,Ft=class extends Ld{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new er(new E(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=it.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Ft;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Uo.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Ft.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=e-t;if(n<=s.points.length-1)return s.points[n];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=af.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=it.generateUUID()){let r;e instanceof G?r=e:r=new G(e,t);let s=new Uo(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return b6(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Nx(this.points,e,!1),this.roundedCurveDivisions=Nx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return _6(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),S6(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Ma(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if(Rx(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(af.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=n[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){Rx(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&g6(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,d=s.curveAfter;if(h===void 0||d===void 0)continue;let c=s.roundedCurveBefore,u=s.roundedCurveAfter,p=h.getLength(),f=d.getLength(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),v=Math.min(m,g),y=1-v/p,x=v/f,w=h.getPointAt(y,af),_=d.getPointAt(x,A6);this._subSplitCurve(h,c,y,w,void 0),this._subSplitCurve(d,u,x,void 0,_);let S;if(this.useCubicForRoundedCorners){let A=kS(w,s.position,_)/2,b=Math.tan(A)*w.distanceTo(s.position),[M,C]=v6(w,_,b,M6,E6),T=y6(M,C,s.position),[P,O]=x6(T,w,_,b,C6,T6);S=new Hr(w.clone(),P.clone(),O.clone(),_.clone())}else S=new kn(w.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=S,this.roundedCurves.splice(i+t,0,S),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof Zr)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,o=n.getUtoTmapping(i,0),l=w6(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return t}clone(){let e=new Ft(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],n=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],d=e.points[r+6],c=new Uo(it.generateUUID(),new G(s,n));c.controls[0].position.set(a,o),c.controls[1].position.set(l,h),c.roundness=d,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Ft;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof Hr&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)},i=r=>{let s=[],n,a;for(n=0,a=r.length;n<a;n++)r[n]instanceof kn&&(r[n]=p6(r[n]));for(n=0,a=r.length;n<a;n++){let h=r[n],d=n>0?r[n-1]:null,c;h instanceof Hr?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof Zr&&(c=this.createPoint(h.v1)),c!==void 0&&(d!==null&&t(c,d),s.push(c))}let o=r[r.length-1],l=!1;return o instanceof Hr?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof Zr&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof Ld&&(this.shapeHoles=e.holes.map(r=>{let s=new Ft;return s.fromShape(r),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},Xm=Math.PI*2;function of({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function P6(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),n=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function zx(e,t,i,r){let s=e*r-t*i<0?-1:1,n=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(n)}function D6(e,t,i,r,s,n,a,o,l,h){let d=Math.pow(s,2),c=Math.pow(n,2),u=Math.pow(a,2),p=Math.pow(o,2),f=d*c-d*p-c*u;f<0&&(f=0),f/=d*p+c*u,f=Math.sqrt(f)*(l===h?-1:1);let m=f*s/n*o,g=f*-n/s*a,v=m+(e+i)/2,y=g+(t+r)/2,x=(a-m)/s,w=(o-g)/n,_=(-a-m)/s,S=(-o-g)/n,A=zx(1,0,x,w),b=zx(x,w,_,S);return!h&&b>0&&(b-=Xm),h&&b<0&&(b+=Xm),{centerx:v,centery:y,ang1:A,ang2:b}}function O6({px:e,py:t,cx:i,cy:r,rx:s,ry:n,largeArcFlag:a,sweepFlag:o}){let l=[];if(s===0||n===0)return[];let h=(e-i)/2,d=(t-r)/2;if(h===0&&d===0)return[];s=Math.abs(s),n=Math.abs(n);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(d,2)/Math.pow(n,2);c>1&&(s*=Math.sqrt(c),n*=Math.sqrt(c));let u=D6(e,t,i,r,s,n,h,d,a,o),{ang1:p,ang2:f}=u,{centerx:m,centery:g}=u,v=Math.abs(f)/(Xm/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push(P6(p,f)),p+=f;return l.map(x=>{let{x:w,y:_}=of(x[0],s,n,m,g),{x:S,y:A}=of(x[1],s,n,m,g),{x:b,y:M}=of(x[2],s,n,m,g);return{x1:w,y1:_,x2:S,y2:A,x:b,y:M}})}var wt;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(wt||(wt={}));var Kt;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Kt||(Kt={}));function Fe(e,t){if(!e)throw t||"Assertion Failed!"}var Be=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Fe(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?s<n?i.t-t.t+(t.t-r.t)*(s/(s+n)):i.t-r.t+(r.t-t.t)*(n/(s+n)):0},e.edgeSign=function(t,i,r){Fe(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?(i.t-r.t)*s+(i.t-t.t)*n:0},e.transEval=function(t,i,r){Fe(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?s<n?i.s-t.s+(t.s-r.s)*(s/(s+n)):i.s-r.s+(r.s-t.s)*(n/(s+n)):0},e.transSign=function(t,i,r){Fe(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?(i.s-r.s)*s+(i.s-t.s)*n:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,n){var a,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(a=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,i.s)):(a=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,s.s)):n.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(a=e.transEval(t,r,i),o=e.transEval(r,i,s),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,i.t)):(a=e.transSign(t,r,i),o=-e.transSign(t,s,i),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,s.t)):n.t=(r.t+i.t)/2},e}(),zl=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),Wc=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),xo=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),Ux=function(){function e(){var t=new xo,i=new zl,r=new Wc(0),s=new Wc(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new Wc(0),r=new Wc(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;Fe(s,"Vertex can't be null!");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i;var a=i;do a.Org=s,a=a.Onext;while(a!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Fe(s,"Face can't be null");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var a=i;do a.Lface=s,a=a.Lnext;while(a!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.makeEdge=function(){var t=new xo,i=new xo,r=new zl,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var n=new xo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new zl;this.makeFace_(a,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new zl;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new xo;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),n=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(n,i),s.Org=t.Dst,n.Org=i.Org,s.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new zl;this.makeFace_(a,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,n,a,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=i);a=t.prev,o=t.next,o.prev=a,a.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,n,a,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,a=r.Org;s=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(n.Lface),o+l-2<=t&&Be.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Be.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(s=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,n,a,o,l,h;for(n=t,n=t;(s=n.next)!==t;n=s){Fe(s.prev===n),l=s.anEdge;do Fe(l.Sym!==l),Fe(l.Sym.Sym===l),Fe(l.Lnext.Onext.Sym===l),Fe(l.Onext.Sym.Lnext===l),Fe(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Fe(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){Fe(a.prev===o),l=a.anEdge;do Fe(l.Sym!==l),Fe(l.Sym.Sym===l),Fe(l.Lnext.Onext.Sym===l),Fe(l.Onext.Sym.Lnext===l),Fe(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Fe(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Fe(l.Sym.next===h.Sym),Fe(l.Sym!==l),Fe(l.Sym.Sym===l),Fe(l.Org!==null),Fe(l.Dst!==null),Fe(l.Lnext.Onext.Sym===l),Fe(l.Onext.Sym.Lnext===l);Fe(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),Fx=function(){function e(){this.handle=null}return e}(),kx=function(){function e(){this.key=null,this.node=0}return e}(),L6=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Fx,this.handles[r]=new kx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[i[a+1].handle].key,r[i[a].handle].key)&&++a,Fe(a<=this.max),n=i[a].handle,a>this.size||this.leq(r[s].key,r[n].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t>>1,n=i[a].handle,a===0||this.leq(r[n].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,n;for(n=this.nodes.length,this.nodes.length=this.max+1,s=n;s<this.nodes.length;s++)this.nodes[s]=new Fx;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new kx}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;Fe(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),lf=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),jx=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),I6=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new jx,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new jx;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),R6=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,n=i.eUp,a=r.eUp;if(n.Dst===s)return a.Dst===s?Be.vertLeq(n.Org,a.Org)?Be.edgeSign(a.Dst,n.Org,a.Org)<=0:Be.edgeSign(n.Dst,a.Org,n.Org)>=0:Be.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Be.edgeSign(n.Dst,s,n.Org)>=0;var o=Be.edgeEval(n.Dst,s,n.Org),l=Be.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Fe(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Fe(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new lf;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case wt.ODD:return(i&1)!==0;case wt.NONZERO:return i!==0;case wt.POSITIVE:return i>0;case wt.NEGATIVE:return i<0;case wt.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,n=null,a=i,o=i.eUp;a!==r;){if(a.fixUpperEdge=!1,n=e.regionBelow(a),s=n.eUp,s.Org!=o.Org){if(!n.fixUpperEdge){e.finishRegion(t,a);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,n,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,a),o=n.eUp,a=n}return o},e.addRightEdges=function(t,i,r,s,n,a){var o,l,h,d,c=!0;h=r;do Fe(Be.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(n===null&&(n=e.regionBelow(i).eUp.Rprev),l=i,d=n;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(d.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,d),e.deleteRegion(t,l),t.mesh.delete(d)),c=!1,l=o,d=h;l.dirty=!0,Fe(l.windingNumber-h.winding===o.windingNumber),a&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Be.vertL1dist(i,t),n=Be.vertL1dist(r,t),a=.5*n/(s+n),o=.5*s/(s+n);t.coords[0]+=a*i.coords[0]+o*r.coords[0],t.coords[1]+=a*i.coords[1]+o*r.coords[1],t.coords[2]+=a*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,n,a){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,n,a)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp;if(Be.vertLeq(s.Org,n.Org)){if(Be.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Be.vertEq(s.Org,n.Org)?s.Org!==n.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,n.Oprev,s)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(s,n.Oprev),i.dirty=r.dirty=!0)}else{if(Be.edgeSign(s.Dst,n.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a;if(Fe(!Be.vertEq(s.Dst,n.Dst)),Be.vertLeq(s.Dst,n.Dst)){if(Be.edgeSign(s.Dst,n.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,a=t.mesh.splitEdge(s),t.mesh.splice(n.Sym,a),a.Lface.inside=i.inside}else{if(Be.edgeSign(n.Dst,s.Dst,n.Org)>0)return!1;i.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(s.Lnext,n.Sym),a.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a=s.Org,o=n.Org,l=s.Dst,h=n.Dst,d,c,u=new xo,p,f;if(Fe(!Be.vertEq(h,l)),Fe(Be.edgeSign(l,t.event,a)<=0),Fe(Be.edgeSign(h,t.event,o)>=0),Fe(a!==t.event&&o!==t.event),Fe(!i.fixUpperEdge&&!r.fixUpperEdge),a===o||(d=Math.min(a.t,l.t),c=Math.max(o.t,h.t),d>c))return!1;if(Be.vertLeq(a,o)){if(Be.edgeSign(h,a,o)>0)return!1}else if(Be.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Be.intersect(l,a,h,o,u),Fe(Math.min(a.t,l.t)<=u.t),Fe(u.t<=Math.max(o.t,h.t)),Fe(Math.min(h.s,l.s)<=u.s),Fe(u.s<=Math.max(o.s,a.s)),Be.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Be.vertLeq(a,o)?a:o,Be.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Be.vertEq(u,a)||Be.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Be.vertEq(l,t.event)&&Be.edgeSign(l,t.event,u)>=0||!Be.vertEq(h,t.event)&&Be.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Lnext,n.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=n.Oprev,n=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,n.Onext,s.Rprev,f,!0),!0):(Be.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Be.edgeSign(h,t.event,u)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,s),s.Org.s=u.s,s.Org.t=u.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,a,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,n;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,n=r.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(n),r=e.regionBelow(i),n=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==n.Org)if(s.Dst!==n.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||n.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,n=r.Onext,a=e.regionBelow(i),o=i.eUp,l=a.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Be.vertEq(o.Org,t.event)&&(t.mesh.splice(n.Oprev,o),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),h=!0),Be.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,a,null),h=!0),h){e.addRightEdges(t,i,r.Onext,n,n,!0);return}Be.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,n,a,o,l;if(s=i.eUp,Be.vertEq(s.Org,r)){Fe(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Be.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}Fe(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(Fe(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Be.edgeGoesLeft(n)||(n=null),e.addRightEdges(t,i,a.Onext,o,n,!0)},e.connectLeftVertex=function(t,i){var r,s,n,a,o,l,h=new lf;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Be.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Be.vertLeq(o.Dst,a.Dst)?r:s,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(i.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(o.Dnext,i.anEdge);l=d.Sym}n.fixUpperEdge?e.fixUpperEdge(t,n,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);Fe(s!==null);var n=e.regionBelow(s),a=n.eUp,o=e.finishLeftRegions(t,n,null);o.Onext===a?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,a,a,!0)},e.addSentinel=function(t,i,r,s){var n=new lf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=s,a.Dst.s=i,a.Dst.t=s,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new I6(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,n=t.bmax[0]+i,a=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,n,a),e.addSentinel(t,s,n,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Fe(i.fixUpperEdge),Fe(++r===1)),Fe(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,n=t.mesh.eHead;for(i=n.next;i!==n;i=r)r=i.next,s=i.Lnext,Be.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,n=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)n++;for(n+=8,i=t.pq=new L6(n,Be.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,n;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,n=r.anEdge,Fe(n.Lnext!==n),n.Lnext.Lnext===n&&(e.addWinding(n.Onext,n),t.mesh.delete(n));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Be.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),B6=function(){function e(){this.mesh=new Ux,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=wt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,n,a,o,l=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],u=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)n=i.coords[g],h[g]=n,f[g]=i,l[g]=n,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var v=0;v<3;++v)n=i.coords[v],n<h[v]&&(h[v]=n,f[v]=i),n>l[v]&&(l[v]=n,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[y],s=p[y],d[0]=r.coords[0]-s.coords[0],d[1]=r.coords[1]-s.coords[1],d[2]=r.coords[2]-s.coords[2],i=m.next;i!==m;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],u[0]=d[1]*c[2]-d[2]*c[1],u[1]=d[2]*c[0]-d[0]*c[2],u[2]=d[0]*c[1]-d[1]*c[0],a=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],a>o&&(o=a,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,n=0,a=t.next;a!==t;a=a.next)if(s=a.anEdge,!(s.winding<=0))do n+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==a.anEdge);if(n<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),n=!0),r=this.sUnit,s=this.tUnit;var a=this.longAxis_(i);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,s[a]=0,s[(a+1)%3]=0,s[(a+2)%3]=i[a]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);n&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Be.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Be.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Be.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Be.edgeGoesLeft(s.Lnext)||Be.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)n=t.connect(s.Lnext,s),s=n.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Be.edgeGoesRight(r.Lprev)||Be.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)n=t.connect(s.Lnext,s),s=n.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,n=t.eHead.next;n!==t.eHead;n=s)s=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?i:-i:r?t.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var n,a=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){n=d.anEdge,l=0;do{var h=n.Org;h.n===-1&&(h.n=o,o++),l++,n=n.Lnext}while(n!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,i===Kt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var u=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(d.inside){n=d.anEdge,l=0;do{var h=n.Org;this.elements[u++]=h.n,l++,n=n.Lnext}while(n!==d.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===Kt.CONNECTED_POLYGONS){n=d.anEdge;do this.elements[u++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==d.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,d=0;n=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==s);this.elements[d++]=n,this.elements[d++]=a,n+=a}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new Ux),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,n,a){if(t===void 0&&(t=wt.ODD),i===void 0&&(i=Kt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),R6.computeInterior(this,a);var o=this.mesh;return i===Kt.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===Kt.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Rn(e){var t=e.windingRule,i=t===void 0?wt.ODD:t,r=e.elementType,s=r===void 0?Kt.POLYGONS:r,n=e.polySize,a=n===void 0?3:n,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,d=h===void 0?[0,0,1]:h,c=e.contours,u=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,m=e.debug,g=m===void 0?!1:m;if(!u&&f)throw new Error("Contours can't be empty");if(u){var v=new B6;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<u.length;y++)v.addContour(l||2,u[y]);return v.tesselate(i,s,a,l,d,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var x7=wt.ODD,w7=wt.NONZERO,b7=wt.POSITIVE,_7=wt.NEGATIVE,S7=wt.ABS_GEQ_TWO,A7=Kt.POLYGONS,M7=Kt.CONNECTED_POLYGONS,E7=Kt.BOUNDARY_CONTOURS,Ym=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*Ym.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*Ym.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(r,n*s,3*e);n+=3*e;let o=new Float32Array(r,n*s,3*e);n+=3*e;let l=new Float32Array(r,n*s,2*e);a.set(this.positions.slice(0,this.size*3)),o.set(this.normals.slice(0,this.size*3)),l.set(this.uvs.slice(0,this.size*2)),this.buffer=r,this.positions=a,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},jS=Ym;jS.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var mv={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},GS={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},VS={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},hf=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),HS=class extends He{constructor(e,t,i=0,r=12,s=3,n=wt.ODD){super(),this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,t/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],r),o=this._shape.shapeHoles.map(_=>{let S=_.extractShapePointsToFlatArray([],r),A=[];for(let b=S.length-1;b>=1;b-=2){let M=S[b-1],C=S[b-0];A.push(M,C)}return A}),l;try{l=Rn({windingRule:n,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]})}catch{l=mv}let h;try{h=Rn({windingRule:wt.ODD,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{h=GS}if(!l)throw new Error("error generating geometry");let d=l.elementCount;if(h){l.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let S=h.elements[_],A=_%2===0?l.vertexCount:0;l.elements.push(S+A)}for(let _=0;_<h.vertexIndices.length;_++){let S=h.vertexIndices[_],A=l.vertexCount;l.vertexIndices.push(S+A)}for(let _=0;_<h.vertices.length;_++){let S=h.vertices[_];l.vertices.push(S)}}let c=1/0,u=-1/0,p=1/0,f=-1/0;for(let _=0,S=l.vertexCount;_<S;_++){let A=_*2,b=l.vertices[A+0],M=l.vertices[A+1];b<c&&(c=b),b>u&&(u=b),M<p&&(p=M),M>f&&(f=M)}this._minX=c,this._minY=p,this._width=u-c,this._height=f-p,this._buffer=new jS(this._computeBufferEstimatedSize(l));let m=[],g=[];for(let _=l.elementCount-1;_>=0;_--){let S=_>=d,A=_*2,b=l.elements[A+0],M=l.elements[A+1],C=b+M,T={start:b,count:M,normals:[],continuous:[],concave:[]},P=b,O=C-1,D=b+1,N=this._shape.roundedCurves.length;do{let V=P-b,k=l.vertices[O*2+0],U=l.vertices[O*2+1],B=l.vertices[P*2+0],H=l.vertices[P*2+1],X=l.vertices[D*2+0],Z=l.vertices[D*2+1],F=B-k,ne=H-U,j=Math.sqrt(F*F+ne*ne);F/=j,ne/=j;let $=B-X,Q=H-Z,me=Math.sqrt($*$+Q*Q);$/=me,Q/=me,T.normals[V*2+0]=-Q,T.normals[V*2+1]=$,T.concave[V]=F*Q-ne*$>0;let re=l.vertexIndices[P];if(Array.isArray(re))T.continuous[V]=!1;else{let[oe,de]=this._shape.getCurveIndexFromVertexId(re-1,!0);if(de>0&&de<1)T.continuous[V]=!0;else{let xe=de===1?oe+1:oe-1;xe=(xe+N)%N;let Te=de===1?0:1,we=this._shape.roundedCurves[oe].getTangent(de),be=this._shape.roundedCurves[xe].getTangent(Te);T.continuous[V]=we.dot(be)>.95}}S&&(T.normals[V*2+0]*=-1,T.normals[V*2+1]*=-1),[O,P,D]=[P,D,D+1],D>=C&&(D-=M)}while(D!==b+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(b*2,C*2),vertexCount:M,vertexIndices:new Array(M).fill(!0).map((V,k)=>[k,k]),elements:[0,M],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(b*2,C*2)});for(let V=1;V<=this._bevelSegments;V++){let k=V/this._bevelSegments*Math.PI/2,U=(1-Math.cos(k))*this._bevelSize,B=[],H=[],X=[],Z=[],F=0;for(let j=0;j<M;j++){let $=j*2,Q=(j-1+M)%M*2,me=l.vertices[T.start*2+$+0],re=l.vertices[T.start*2+$+1],oe=-T.normals[Q+0]*U,de=-T.normals[Q+1]*U,xe=-T.normals[$+0]*U,Te=-T.normals[$+1]*U;if(T.concave[j]||!T.concave[j]&&S){let we=Math.atan2(de,oe),be=Math.atan2(Te,xe);be>we&&(be-=Math.PI*2);let Re=be-we;if(T.continuous[j]||S){let We=we+Re/2,ot=Math.cos(We)*U,I=Math.sin(We)*U;B[2*F+0]=me+ot*(S?-1:1),B[2*F+1]=re+I*(S?-1:1),Z[F]=j,F++}else{let We=Math.max(1,Math.floor(r/4*Math.abs(Re)/Math.PI));for(let ot=0;ot<=We;ot++){let I=we+Re*(ot/We),L=Math.cos(I)*U,ie=Math.sin(I)*U;B[2*F+0]=me+L,B[2*F+1]=re+ie,Z[F]=j,F++}}}else B[2*F+0]=me+oe,B[2*F+1]=re+de,Z[F]=j,H[j]=F,F++,B[2*F+0]=me,B[2*F+1]=re,Z[F]=j,F++,B[2*F+0]=me+xe,B[2*F+1]=re+Te,Z[F]=j,X[j]=F,F++}let ne=Rn({windingRule:wt.POSITIVE,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[B],edgeCreateCallback:j=>{let $=j.Org.idx,Q=Z[$],me=Z[($+1)%Z.length];j.idx=[Q,me],j.Sym.idx=[me,Q]},vertexIdCallback:j=>{let $=j.Lprev.idx;return[$?$[1]:0,j.idx?j.idx[0]:0]}});if(!ne)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!ne.vertexCount)break;for(let j=0;j<ne.vertexIndices.length;j++){let[$,Q]=ne.vertexIndices[j];if($===Q)continue;let me=Q;Q<$&&(me+=M);for(let re=$;re<me;re++){let oe=re%M,de=(re+1)%M;if(!T.continuous[oe]||!T.continuous[de]){ne.vertexIndices[j]=[$,oe],ne.vertexIndices.splice(j+1,0,[de,Q]),ne.vertices.splice((j+1)*2,0,ne.vertices[j*2],ne.vertices[j*2+1]);break}}}W.push({bevelI:V,angle:k,size:U,boundary:ne,reverseMap:Z,insetPoints:B})}let q=(V,k,U)=>{let B=0,H=V.boundary.vertexIndices.length;for(;B<H&&U(V.boundary.vertexIndices[k]);)k=(k+1)%H,B++;return B},z=m.length;for(let V=1;V<W.length;V++){let k=W[V-1],U=W[V],B=k.boundary.vertexIndices.length,H=U.boundary.vertexIndices.length;if(!B||!H)break;let X=T.concave.length,Z=0,F=hf(Z,M);for(;!k.boundary.vertexIndices.filter(F).length||!U.boundary.vertexIndices.filter(F).length;)Z++,F=hf(Z,M);let ne=k.boundary.vertexIndices.findIndex(F),j=U.boundary.vertexIndices.findIndex(F);do ne=(ne+1)%B;while(F(k.boundary.vertexIndices[ne]));do j=(j+1)%H;while(F(U.boundary.vertexIndices[j]));Z=(Z+1)%M;let $=Z,Q=this._buildBevelVert(T,k,(ne-1+B)%B),me=this._buildBevelVert(T,U,(j-1+H)%H),re=Q,oe=me,de,xe,Te=!1;do{F=hf(Z,M);let we=q(k,ne,F),be=q(U,j,F),Re=Te;if(Te=!1,we&&!be){for(let We=0;We<we;We++)de=this._buildBevelVert(T,k,(ne+We)%B,We/(we-1)),m.push(re.topN,de.topP,oe.topN),m.push(de.bottomP,re.bottomN,oe.bottomN),re=de;Te=!0}else if(!we&&be)for(let We=0;We<be;We++)xe=this._buildBevelVert(T,U,(j+We)%H,We/(be-1)),m.push(oe.topN,re.topP,xe.topP),m.push(re.bottomP,oe.bottomN,xe.bottomP),oe=xe;else if(we&&be)if(de=this._buildBevelVert(T,k,ne,0),xe=this._buildBevelVert(T,U,j,0),Re?(m.push(re.topN,xe.topP,oe.topN),m.push(re.topN,de.topP,xe.topP),m.push(xe.bottomP,re.bottomN,oe.bottomN),m.push(xe.bottomP,de.bottomP,re.bottomN)):(m.push(oe.topN,re.topN,de.topP),m.push(oe.topN,de.topP,xe.topP),m.push(de.bottomP,re.bottomN,oe.bottomN),m.push(de.bottomP,oe.bottomN,xe.bottomP)),re=de,oe=xe,we===be)for(let We=1;We<we;We++)de=this._buildBevelVert(T,k,(ne+We)%B,We/(we-1)),xe=this._buildBevelVert(T,U,(j+We)%H,We/(be-1)),m.push(re.topN,de.topP,oe.topN),m.push(oe.topN,de.topP,xe.topP),m.push(de.bottomP,re.bottomN,oe.bottomN),m.push(de.bottomP,oe.bottomN,xe.bottomP),re=de,oe=xe;else if(we>be){let We=we/be,ot=0;for(let I=1;I<we;I++)de=this._buildBevelVert(T,k,(ne+I)%B,I/(we-1)),m.push(re.topN,de.topP,oe.topN),m.push(de.bottomP,re.bottomN,oe.bottomN),re=de,I>(ot+1)*We&&(ot++,xe=this._buildBevelVert(T,U,(j+ot)%H,ot/(be-1)),m.push(oe.topN,de.topP,xe.topP),m.push(de.bottomP,oe.bottomN,xe.bottomP),oe=xe)}else{let We=be/we,ot=0;for(let I=1;I<be;I++)xe=this._buildBevelVert(T,U,(j+I)%H,I/(be-1)),m.push(oe.topN,de.topP,xe.topP),m.push(de.bottomP,oe.bottomN,xe.bottomP),oe=xe,I>(ot+1)*We&&(ot++,de=this._buildBevelVert(T,k,(ne+ot)%B,ot/(we-1)),m.push(re.topN,de.topP,oe.topN),m.push(de.bottomP,re.bottomN,oe.bottomN),re=de)}ne=(ne+we)%B,j=(j+be)%H,Z=(Z+1)%X}while(Z!==$)}if(this._buildWall(W,T,m),S){let V=[];for(let k=m.length-1;k>=z+2;k-=3){let U=m[k-2],B=m[k-1],H=m[k-0];V.push(H,B,U)}m.splice(z,m.length-z,...V)}if(S){let V=[];for(let k=W[W.length-1].boundary.vertices.length-1;k>=1;k-=2){let U=W[W.length-1].boundary.vertices[k-1],B=W[W.length-1].boundary.vertices[k-0];V.push(U,B)}g.push(V)}if(!S){let V=W[W.length-1],k;try{k=Rn({windingRule:W.length>1?wt.POSITIVE:wt.ODD,elementType:Kt.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...g]})}catch{k=VS}if(!k)throw new Error("Error generating geometry for surface");o.length===0&&Object.assign(this,{capStartIndex:m.length});for(let U=0;U<k.elementCount*3;U+=3){let B=this._buildSurfaceVert(k,k.elements[U+0]),H=this._buildSurfaceVert(k,k.elements[U+1]),X=this._buildSurfaceVert(k,k.elements[U+2]);m.push(B.top,H.top,X.top),m.push(X.bottom,H.bottom,B.bottom)}}this.vertexCache={}}this._buffer.shrink();let v=new Ye(Uint32Array.from(m),1),y=new Ye(this._buffer.positions,3),x=new Ye(this._buffer.normals,3),w=new Ye(this._buffer.uvs,2);y.needsUpdate=!0,x.needsUpdate=!0,w.needsUpdate=!0,v.needsUpdate=!0,this.setAttribute("position",y),this.setAttribute("normal",x),this.setAttribute("uv",w),this.setIndex(v)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(e,t){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let r=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(r-this._minX)/this._width,a=(s-this._minY)/this._height,o=this._buffer.get(2),l=o*3,h=o*2,d={top:o+0,bottom:o+1};return this._buffer.positions[l+0]=r,this._buffer.positions[l+1]=s,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[h+0]=n,this._buffer.uvs[h+1]=a,this._buffer.positions[l+3]=r,this._buffer.positions[l+4]=s,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[h+2]=n,this._buffer.uvs[h+3]=a,this.vertexCache[i]=d,d}_buildBevelVert(e,t,i,r=1){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[n,a]=t.boundary.vertexIndices[i],o,l,h,d;n!==a?(l=n,o=a,d=!1,h=e.continuous[l]&&e.continuous[o]):(o=n,l=(o-1+e.count)%e.count,d=e.concave[o]&&t.bevelI>0,h=e.continuous[o]||d);let c=Math.cos(t.angle),u=Math.sin(t.angle),p=i*2,f=o*2,m=l*2,g=t.boundary.vertices[p+0],v=t.boundary.vertices[p+1],y=(1-u)*this._bevelSize,x=(g-this._minX)/this._width,w=(v-this._minY)/this._height,_=e.normals[f+0],S=e.normals[f+1],A=e.normals[m+0],b=e.normals[m+1];if(d){let O=A-_,D=b-S;_=_+O*(1-r),S=S+D*(1-r);let N=Math.sqrt(_*_+S*S);_/=N,S/=N}let M=this._buffer.get(h?2:4),C=M*3,T=M*2,P={i,fi:o,topP:M+0,topN:M+0,bottomP:M+1,bottomN:M+1};return this._buffer.positions[C+0]=g,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=_*c,this._buffer.normals[C+1]=S*c,this._buffer.normals[C+2]=u,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=g,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=_*c,this._buffer.normals[C+4]=S*c,this._buffer.normals[C+5]=-u,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x,h||(M+=2,C+=6,T+=4,P.topP=M+0,P.bottomP=M+1,this._buffer.positions[C+0]=g,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=A*c,this._buffer.normals[C+1]=b*c,this._buffer.normals[C+2]=u,this._buffer.uvs[T+0]=x,this._buffer.uvs[T+1]=w,this._buffer.positions[C+3]=g,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=A*c,this._buffer.normals[C+4]=b*c,this._buffer.normals[C+5]=-u,this._buffer.uvs[T+2]=w,this._buffer.uvs[T+3]=x),this.vertexCache[s]=P,P}clone(){let e=new HS(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Du(this.userData),e}},WS=class extends He{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=wt.ODD,this.elementType=Kt.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:wt.ODD,elementType:Kt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),n,a=!0,o=!0,l,h;for(let u=0,p=r.length/2;u<p;u++){let f=u*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(a=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!a&&!o)break}if(!a&&!o)try{n=Rn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=mv}let d=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new Ye(new Float32Array(d*3),3),this._normalAttribute=new Ye(new Float32Array(d*3),3),this._uvAttribute=new Ye(new Float32Array(d*2),2),this._indexAttribute=new Ye(new Uint32Array(c*3),1),n){let u=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,x=d;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1];_<u&&(u=_),_>p&&(p=_),S<f&&(f=S),S>m&&(m=S)}let g=p-u,v=m-f;for(let y=0,x=d;y<x;y++){let w=y*2,_=n.vertices[w+0],S=n.vertices[w+1],A=(_-u)/g,b=(S-f)/v;this._positionAttribute.setXYZ(y,_,S,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,A,b)}for(let y=0,x=c;y<x;y++){let w=y*3,_=n.elements[w+0],S=n.elements[w+1],A=n.elements[w+2];this._indexAttribute.setX(w+0,_),this._indexAttribute.setX(w+1,S),this._indexAttribute.setX(w+2,A)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(n?.elementCount??1)*3)}clone(){let e=new WS(this._shape,this._curveSegments);return e.userData=Du(this.userData),e}},qS=class extends HS{constructor(e,t,i=0,r=12,s=3,n=wt.ODD){super(e,t,i,r,s,n),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let e=new qS(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Du(this.userData),e}},za=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:wt.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=e.shape??t?.shape,o=a?.roundness??i.roundness;a!==void 0&&(a instanceof Ft?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Ft(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Ft(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:n,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:n,windingRule:a}=e.parameters;e.shape.roundness=n;let o;return t<=0?o=new WS(e.shape,s,{windingRule:a}):o=new qS(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},XS=Math.PI*2,gv=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,d=t*.5,c=i*.5,u=N6(h,d,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=za.create({shape:h,parameters:{subdivisions:u,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function N6(e,t,i,r,s,n){if(r>=XS)return s>30||s%4===0?(U6(e,t,i,n),Math.round(s/4)):Gx(e,r,s,t,i,n);r=Math.max(r,.001);let a={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=O6({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?z6(e,a.x,a.y,h,s,t,i,n):Gx(e,r,s,t,i,n)}function z6(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(Fo(t,i));for(let h=0,d=r.length;h<d;h++){let c=r[h],u=e.points[h],p=Fo(c.x,c.y);u.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?YS(e,n,a,o):e.addPoint(Fo(0,0)),l}function Gx(e,t,i,r,s,n){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,d=Math.cos(l)*s;e.addPoint(Fo(h,d))}return t<XS?n>0?YS(e,r,s,n):e.addPoint(Fo(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&ZS(e,r,s,n)),1}function U6(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(qc(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(qc(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(qc(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(qc(s,n-i,s+o,n-i,s-o,n-i)),r>0&&ZS(e,t,i,r)}function Fo(e,t){return new Uo(it.generateUUID(),new G(e,t))}function qc(e,t,i,r,s,n){let a=Fo(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function YS(e,t,i,r){QS(e,t,i,r).forEach(s=>e.addPoint(s))}function ZS(e,t,i,r){let s=QS(e,t,i,r),n=new Ft;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function QS(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new G(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=it.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),d=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(d),l.controls[1].position.copy(h)}),o}var F6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:d,cornerSegments:c}=e.parameters,u=new KS(!1,t,i,r,s,n,a,o,l,h,d,c);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},KS=class extends He{constructor(e=!0,t=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,d=1,c=1){if(super(),n===0)return;let u=e&&n===1;u&&(c=0),d>100&&(d=100),d===0&&(c=0);let p=()=>new E,f=new E,m=p(),g=p(),v=p(),y,x,w,_,S,A,b,M,C=p(),T=p(),P=p(),O=p(),D=p(),N=p(),W=p(),q=p(),z=i-2*o+.001,V=z/n,k=Math.ceil(a*n),U=k+1,B=z/k,H=-z/2,X=h+1,Z=2*Math.PI/h,F=Math.PI/2/c,ne=.01,j=Math.min((1-d/100)*o,o-ne),$=o-j,Q=0,me=2,re=c*me+me,oe=X*re/me,de=oe+X*U,xe=X*(U+re),[Te,we,be]=[3,3,2].map(Me=>Array(xe*Me).fill(0)),Re=[],We=s-o;function ot(Me,De){let Ee=Math.PI/2;A=De*B,M=2*Math.PI*(A%V)/V+Ee,A+=H,b=Math.sin(M)*We,S=Math.cos(M)*We,e?Me.set(S,b,A):Me.set(S,A,b)}ot(f,-1e-10),ot(m,0),C.copy(f),ot(f,1);let I=f.distanceTo(m),L=u?0:$+j,ie=I*k+2*L,pe=j,fe=ie-L;for(let Me=0;Me<=k;Me++){ot(g,Me),q.subVectors(g,C).normalize(),C.copy(g),N.copy(g).setComponent(+e+1,0).normalize(),W.crossVectors(q,N).normalize();let De=Me===0,Ee=Me===k,Ge=De?3*Math.PI/2:F,Ne=De?pe:fe,lt=De?X:de,Ct=De?0:xe-X,qt=q.clone().multiplyScalar(De?-$:$).add(g),Y=q.clone().multiplyScalar(De?-1:1).normalize();for(let se=0;se<X;se++){let ue=se*Z;if(T.addVectors(f.copy(N).multiplyScalar(o*Math.cos(ue)),m.copy(W).multiplyScalar(o*Math.sin(ue))),P.copy(T).normalize(),De||Ee){u||(Q=Ct+se,[0,1,2].forEach(ye=>{Te[Q*3+ye]=qt.getComponent(ye),we[Q*3+ye]=Y.getComponent(ye)}),be[Q*2]=+Ee,be[Q*2+1]=se/h),m.copy(P).multiplyScalar(j),v.addVectors(g,m);for(let ye=0;ye<c;ye++){let Ue=ye*F+Ge;O.addVectors(f.copy(q).multiplyScalar($*Math.sin(Ue)),m.copy(P).multiplyScalar($*Math.cos(Ue))),D.copy(O).normalize(),m.addVectors(v,O),O.normalize(),Q=lt+ye*X+se,[0,1,2].forEach(Rt=>{Te[Q*3+Rt]=m.getComponent(Rt),we[Q*3+Rt]=D.getComponent(Rt)});let dt=+De+Math.sin(Ue);be[Q*2]=(Ne+$*dt)/ie,be[Q*2+1]=se/h}}m.addVectors(g,T),Q=oe+Me*X+se,[0,1,2].forEach(ye=>{Te[Q*3+ye]=m.getComponent(ye),we[Q*3+ye]=P.getComponent(ye)}),be[Q*2]=(L+Me*I)/ie,be[Q*2+1]=se/h}}let _e=U+2*c+me,qe=1,[Se,ce]=[+u,_e-1];u&&(ce-=1);for(let Me=Se;Me<=ce-1;Me++){let De=u&&Me===ce-1;for(let Ee=0;Ee<X-1;Ee++)y=Me*X+Ee,x=y+1,w=(De?Ee:y)+X,_=(De?Ee+1:x)+X,Me===0?Re.push(x,_,w):Me===_e-2?Re.push(y,x,w):Re.push(y,x,w,x,_,w)}this.setIndex(Re),this.setAttribute("position",new Ce(Te,3)),this.setAttribute("normal",new Ce(we,3)),this.setAttribute("uv",new Ce(be,2))}},k6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new JS(t*.5,n,a):new n_(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},JS=class extends uv{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[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,n,a,e,t,i),this.type=a}static fromJSON(e){return new JS(e.radius,e.corner,e.cornerSides)}},j6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new Ld;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new Jb(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ns=new ge,cf=new _t,Xc=new E,lu=class extends Ui{constructor(){super(),this.uuid=it.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 vi().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let n=0,a=s.vertexNormals.length;n<a;n++)s.vertexNormals[n].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ns.makeRotationX(e),this.applyMatrix4(ns),this}rotateY(e){return ns.makeRotationY(e),this.applyMatrix4(ns),this}rotateZ(e){return ns.makeRotationZ(e),this.applyMatrix4(ns),this}translate(e,t,i){return ns.makeTranslation(e,t,i),this.applyMatrix4(ns),this}scale(e,t,i){return ns.makeScale(e,t,i),this.applyMatrix4(ns),this}lookAt(e){return cf.lookAt(e),cf.updateMatrix(),this.applyMatrix4(cf.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,n=r.normal,a=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<s.count;c++)t.vertices.push(new E().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new je().fromBufferAttribute(a,c));function h(c,u,p,f){let m=a===void 0?[]:[t.colors[c].clone(),t.colors[u].clone(),t.colors[p].clone()],g=n===void 0?[]:[new E().fromBufferAttribute(n,c),new E().fromBufferAttribute(n,u),new E().fromBufferAttribute(n,p)],v=new Zm(c,u,p,g,m,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new G().fromBufferAttribute(o,c),new G().fromBufferAttribute(o,u),new G().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new G().fromBufferAttribute(l,c),new G().fromBufferAttribute(l,u),new G().fromBufferAttribute(l,p)])}let d=e.groups;if(d.length>0)for(let c=0;c<d.length;c++){let u=d[c],p=u.start,f=u.count;for(let m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),u.materialIndex):h(m,m+1,m+2,u.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+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(Xc).negate(),this.translate(Xc.x,Xc.y,Xc.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new ge;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new E,t=new E;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=this.vertices[s.a],a=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,a),t.subVectors(n,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new E;if(e){let i=new E,r=new E;for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=this.vertices[a.a],l=this.vertices[a.b],h=this.vertices[a.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[a.a].add(i),t[a.b].add(i),t[a.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=s.vertexNormals;n.length===3?(n[0].copy(t[s.a]),n[1].copy(t[s.b]),n[2].copy(t[s.c])):(n[0]=t[s.a].clone(),n[1]=t[s.b].clone(),n[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 i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,n=r.vertexNormals.length;s<n;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new lu;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let a=0,o=this.faces.length;a<o;a++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),n.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(a.normal),l.a.copy(a.vertexNormals[0]),l.b.copy(a.vertexNormals[1]),l.c.copy(a.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Jt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,n=this.vertices,a=e.vertices,o=this.faces,l=e.faces,h=this.colors,d=e.colors;t!==void 0&&(r=new vi().getNormalMatrix(t));for(let c=0,u=a.length;c<u;c++){let p=a[c].clone();t!==void 0&&p.applyMatrix4(t),n.push(p)}for(let c=0,u=d.length;c<u;c++)h.push(d[c].clone());for(let c=0,u=l.length;c<u;c++){let p=l[c],f,m,g=p.vertexNormals,v=p.vertexColors,y=new Zm(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,w=g.length;x<w;x++)f=g[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,w=v.length;x<w;x++)m=v[x],y.vertexColors.push(m.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++)v.push(g[y].clone());this.faceVertexUvs[c].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],d=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[d]===void 0?(t[d]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[d]]}let n=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let d=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(d[c]===d[(c+1)%3]){n.push(o);break}}for(let o=n.length-1;o>=0;o--){let l=n[o];this.faces.splice(l,1);for(let h=0,d=this.faceVertexUvs.length;h<d;h++)this.faceVertexUvs[h].splice(l,1)}let a=this.vertices.length-i.length;return this.vertices=i,a}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new E(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],n,a;r&&r.length===t&&(n=[]),s&&s.length===t&&(a=[]);for(let o=0;o<t;o++){let l=e[o]._id;n&&n.push(r[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),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 p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],s={},n=[],a={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,w=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,S=0;if(S=h(S,0,0),S=h(S,1,m),S=h(S,2,g),S=h(S,3,v),S=h(S,4,y),S=h(S,5,x),S=h(S,6,w),S=h(S,7,_),i.push(S),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let A=this.faceVertexUvs[0][p];i.push(u(A[0]),u(A[1]),u(A[2]))}if(y&&i.push(d(f.normal)),x){let A=f.vertexNormals;i.push(d(A[0]),d(A[1]),d(A[2]))}if(w&&i.push(c(f.color)),_){let A=f.vertexColors;i.push(c(A[0]),c(A[1]),c(A[2]))}}function h(p,f,m){return m?p|1<<f:p&~(1<<f)}function d(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function c(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return a[f]!==void 0||(a[f]=n.length,n.push(p.getHex())),a[f]}function u(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,n.length>0&&(e.data.colors=n),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new lu().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 c=0,u=t.length;c<u;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,u=i.length;c<u;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,u=r.length;c<u;c++)this.faces.push(r[c].clone());for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++){let w=g[y];v.push(w.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,u=s.length;c<u;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,m=s[c].vertices.length;f<m;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,m=s[c].normals.length;f<m;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let n=e.morphNormals;for(let c=0,u=n.length;c<u;c++){let p={};if(n[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=n[c].vertexNormals.length;f<m;f++){let g=n[c].vertexNormals[f],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=n[c].faceNormals.length;f<m;f++)p.faceNormals.push(n[c].faceNormals[f].clone())}this.morphNormals.push(p)}let a=e.skinWeights;for(let c=0,u=a.length;c<u;c++)this.skinWeights.push(a[c].clone());let o=e.skinIndices;for(let c=0,u=o.length;c<u;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,u=l.length;c<u;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let d=e.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new G6().fromGeometry(this),t=new He,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Yc.call(new Ye(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Yc.call(new Ye(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",Vx.call(new Ye(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",Hx.call(new Ye(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",Hx.call(new Ye(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],n=e.morphTargets[r];for(let a=0,o=n.length;a<o;a++){let l=n[a],h=new Ce(l.data.length*3,3);h.name=l.name,s.push(Yc.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Ce(e.skinIndices.length*4,4);t.setAttribute("skinIndex",Wx.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Ce(e.skinWeights.length*4,4);t.setAttribute("skinWeight",Wx.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new He,i=e.geometry;if(e.isPoints||e.isLine){let r=new Ce(i.vertices.length*3,3),s=new Ce(i.colors.length*3,3);if(t.setAttribute("position",Yc.call(r,i.vertices)),t.setAttribute("color",Vx.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Ce(i.lineDistances.length,1);t.setAttribute("lineDistance",V6.call(n,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};lu.prototype.isGeometry=!0;var G6=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,n=e.faces;for(r=0;r<n.length;r++){let a=n[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,n=r[1]&&r[1].length>0,a=e.morphTargets,o=a.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:a[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,d=h.length,c;if(d>0){c=[];for(let g=0;g<d;g++)c[g]={name:h[g].name,data:[]};this.morphTargets.normal=c}let u=e.skinIndices,p=e.skinWeights,f=u.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let v=t[g];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let w=v.normal;this.normals.push(w,w,w)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][g];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new G,new G,new G))}if(n===!0){let w=r[1][g];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new G,new G,new G))}for(let w=0;w<o;w++){let _=a[w].vertices;l[w].data.push(_[v.a],_[v.b],_[v.c])}for(let w=0;w<d;w++){let _=h[w].vertexNormals[g];c[w].data.push(_.a,_.b,_.c)}f&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),m&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Zm=class{constructor(e,t,i,r,s,n=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new E,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new je,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=n}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function V6(e){return this.array.set(e),this}function Vx(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new je),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function Hx(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new G),t[i++]=n.x,t[i++]=n.y}return this}function Yc(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new E),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function Wx(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new $e),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var H6=["a","b","c"];function W6(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function df(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function uf(e,t,i,r,s,n){let a=Math.min(e,t),o=Math.max(e,t),l=a+"_"+o,h;if(r.has(l))h=r.get(l);else{let d=i[a],c=i[o];h={a:d,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),n[e].edges.push(h),n[t].edges.push(h)}function q6(e,t,i,r){let s,n,a;for(s=0,n=e.length;s<n;s++)i[s]={edges:[]};for(s=0,n=t.length;s<n;s++)a=t[s],uf(a.a,a.b,e,r,a,i),uf(a.b,a.c,e,r,a,i),uf(a.c,a.a,e,r,a,i)}function Zc(e,t,i,r,s){e.push(new Zm(t,i,r,void 0,void 0,s))}function ao(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Qc(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var X6=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof He?e=new lu().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 E,i,r,s,n,a,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],d=h!==void 0&&h.length>0,c=[],u=new Map;q6(o,l,c,u);let p=[],f,m,g,v,y,x,w;for(let ne of Array.from(u.keys())){for(m=u.get(ne),g=new E,y=3/8,x=1/8,w=m.faces.length,w!=2&&(y=.5,x=0,w!=1),g.addVectors(m.a,m.b).multiplyScalar(y),t.set(0,0,0),n=0;n<w;n++){for(v=m.faces[n],a=0;a<3&&(f=o[W6(v,H6[a])],!(f!==m.a&&f!==m.b));a++);f&&t.add(f)}t.multiplyScalar(x),g.add(t),m.newEdge=p.length,p.push(g)}let _,S,A,b,M,C,T,P=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?_=3/16:i>3&&(_=3/(8*i)),S=1-i*Number(_),A=_,i<=2&&(i==2?(S=3/4,A=1/8):i==1||i==0),T=C.clone().multiplyScalar(S),t.set(0,0,0),n=0;n<i;n++)b=M[n],f=b.a!==C?b.a:b.b,t.add(f);t.multiplyScalar(Number(A)),T.add(t),P.push(T)}let O=P.concat(p),D=P.length,N,W,q,z=[],V=[],k,U,B,H,X=new G,Z=new G,F=new G;for(r=0,s=l.length;r<s;r++)v=l[r],N=Number(df(v.a,v.b,u).newEdge)+D,W=Number(df(v.b,v.c,u).newEdge)+D,q=Number(df(v.c,v.a,u).newEdge)+D,Zc(z,N,W,q,v.materialIndex),Zc(z,v.a,N,q,v.materialIndex),Zc(z,v.b,W,N,v.materialIndex),Zc(z,v.c,q,W,v.materialIndex),d&&(k=h[r],U=k[0],B=k[1],H=k[2],X.set(ao(U.x,B.x),ao(U.y,B.y)),Z.set(ao(B.x,H.x),ao(B.y,H.y)),F.set(ao(U.x,H.x),ao(U.y,H.y)),Qc(V,X,Z,F),Qc(V,U,X,F),Qc(V,B,Z,X),Qc(V,H,F,Z));e.vertices=O,e.faces=z,d&&(e.faceVertexUvs[0]=V)}},ei=new E,Y6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new He().copy(new Cs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ei),r={width:ei.x,height:ei.y,depth:ei.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,n=e.geometry??new He().copy(new Cs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ei)):ei.set(a.width,a.height,a.depth),(t!==ei.x||i!==ei.y||r!==ei.z)&&n.scale(ei.x===0?1:t/ei.x,ei.y===0?1:i/ei.y,ei.z===0?1:r/ei.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new X6(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new h_(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ei);let n=100/ei.x;Object.assign(s.parameters,{width:100,height:ei.y*n,depth:ei.z*n}),t(this.build(s))})}},$S=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5,c=0,u=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,v=c+Math.sin(g)*h,y=u+Math.cos(g)*d;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=s;l.roundness=s,l.update();let f=za.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},Z6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new K6(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Ul(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function pf(e,t,i,r,s,n){let a=t.clone().sub(e),o=i.clone().sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(e),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function Q6(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var K6=class extends He{constructor(e=.5,t=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],d=[],c=0,u=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,v=Math.PI-g,y=new E(0,-u,0),x=new E(0,u,0),w=new G(e,-u),_=new G(f,-u),S=new G(0,x.y).sub(_),A=new G(0,x.y).sub(w),b=new G(S.y,-S.x).normalize(),M=new G(A.y,-A.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new E(b.x,b.y,0),V=new E(Math.cos(m)*z.x,z.y,Math.sin(m)*z.x);T=z.angleTo(V)}let P=n/Math.tan((Math.PI-S.angle())/2),O=n/Math.tan((Math.PI-T)/2),D=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),d.push(0,0);let z=c++,V=[],k=w.clone(),U=P/Math.cos(Math.PI/i);k.x-=U;for(let B=0;B<i;B++){let H=B/i*Math.PI*2+p,X=new G(Math.sin(H),Math.cos(H));Ul(k,X,D),l.push(D.x,D.y,D.z),h.push(0,-1,0),d.push(0,0),V.push(c++)}for(let B=0;B<V.length;B++)o.push(V[B],z,V[(B+1)%V.length])}let N=[];{let z=new E,V=new E,k=new E,U=new E,B=new E,H=new E;for(let X=0;X<i;X++){let Z=X/i*Math.PI*2+p,F=(X+.5)/i*Math.PI*2+p,ne=(X+1)/i*Math.PI*2+p,j=new G(Math.sin(Z),Math.cos(Z)),$=new G(Math.sin(F),Math.cos(F)),Q=new G(Math.sin(ne),Math.cos(ne));Ul(w,j,V),Ul(w,Q,k),Ul(b,$,z),pf(x,V,k,O,O,U),l.push(U.x,U.y,U.z),pf(V,x,k,O,P,B),l.push(B.x,B.y,B.z),pf(k,V,x,P,O,H),l.push(H.x,H.y,H.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),d.push(0,0),d.push(0,0),d.push(0,0);let me=c++,re=c++,oe=c++;if(o.push(me,re,oe),n>0){{let Te=V.clone().add(k).multiplyScalar(.5),we=x.clone().sub(Te).normalize(),be=y.clone().sub(Te).normalize().add(we).normalize().multiplyScalar(-1),Re=H.clone().sub(B);W(Te,Re,be,S.angle())}let de,xe;{let Te=new E;Ul(M,Q,Te);let we=H.clone().add(U).multiplyScalar(.5);we=Q6(we,k,x);let be=H.clone().sub(U);[de,xe]=W(we,be,Te,T,U.y)}{let Te=de,we=Te.clone().setY(0).normalize(),be=new E(0,-1,0),Re=we.clone().cross(be);q(Te,we,be,Re)}N.concat(xe);{let Te=S.angle(),we=Math.PI-Te,be=x.clone();be.y-=n/Math.sin(Te-Math.PI/2);let Re=new E,We=[];for(let I=0;I<a;I++){let L=[],ie=Math.PI/2-we*I/a,pe=Math.cos(ie),fe=Math.sin(ie),_e=F;for(let qe=0;qe<=I;qe++){let Se=Math.cos(_e),ce=Math.sin(_e);z.x=pe*ce,z.y=fe,z.z=pe*Se,Re.copy(be).addScaledVector(z,n),l.push(Re.x,Re.y,Re.z),h.push(z.x,z.y,z.z),d.push(0,0),L.push(c++),_e+=Math.PI*2/I/i}We.push(L)}xe.reverse(),We.push(xe);let ot=We.length-1;for(let I=0;I<ot;I++){let L=We[I],ie=We[I+1],pe=L.length-1;o.push(ie[1],L[0],ie[0]);for(let fe=1;fe<=pe;fe++)o.push(L[fe],L[fe-1],ie[fe]),o.push(ie[fe+1],L[fe],ie[fe])}}}}}this.setIndex(o),this.setAttribute("position",new Ce(l,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(d,2));function W(z,V,k,U,B){let H=-U/2,X=(Math.PI-U)/2,Z=V.clone().normalize().cross(k);z.addScaledVector(k,-n/Math.sin(X));let F=new E,ne=new E,j=1,$=c,Q=[];for(let me=0;me<=a;me++){let re=H+me/a*U;ne.set(0,0,0),ne.addScaledVector(Z,Math.sin(re)),ne.addScaledVector(k,Math.cos(re));for(let oe=0;oe<=j;oe++){let de=oe/j-.5;if(F.copy(z),F.addScaledVector(V,de),F.addScaledVector(ne,n),B!=null){let xe=Math.max(0,F.y-B);F.addScaledVector(V,-xe/V.y)}l.push(F.x,F.y,F.z),h.push(ne.x,ne.y,ne.z),d.push(0,0),oe===0&&Q.push(c),c++}}for(let me=0;me<a;me++)for(let re=0;re<j;re++){let oe=$+re+(j+1)*me,de=oe+(j+1),xe=de+1,Te=oe+1;o.push(oe,de,Te),o.push(de,xe,Te)}return[z.clone().addScaledVector(V,.5),Q]}function q(z,V,k,U){let B=Math.PI/2,H=A.angle()-B,X=[],Z=new E,F=new E;for(let j=0;j<=a;j++){let $=[],Q=j/a;for(let me=0;me<=j;me++){let re=((j?me/j:0)-.5)*v,oe=Math.cos(re),de=Math.sin(re),xe=Math.atan(Math.tan(H)*oe),Te=(B+xe)*Q,we=Math.cos(Te),be=Math.sin(Te);Z.set(0,0,0),Z.addScaledVector(V,be*oe),Z.addScaledVector(k,we),Z.addScaledVector(U,be*de),F.copy(z).addScaledVector(Z,n),l.push(F.x,F.y,F.z),h.push(Z.x,Z.y,Z.z),d.push(0,0),$.push(c++)}X.push($)}let ne=X.length-1;for(let j=0;j<ne;j++){let $=X[j],Q=X[j+1],me=$.length-1;o.push($[0],Q[1],Q[0]);for(let re=1;re<=me;re++)o.push($[re-1],$[re],Q[re]),o.push($[re],Q[re+1],Q[re])}}}},eA=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},d={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function u(w,_,S){return _>i&&S>r?Math.min(w*i/_,w*r/S):_>i?w*i/_:S>r?w*r/S:w}let p=[];p[0]=s[0]===0?0:u(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:u(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:u(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:u(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,m=c.x,g=c.y,v=d.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let w=0,_=t.points.length;w<_;w++)t.points[w].roundness=p[w],w>0&&p[w]!==p[w-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=za.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},J6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:n=64,phiStart:a,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,d=new Pg(.5*t,s,n,a,o,l,h);return d.scale(1,i/t,r/t),Object.assign(d,{userData:{...e,type:"SphereGeometry"}})}},$6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,n=new xu(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},ek=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=e.parameters,o=new tk(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},tk=class extends He{constructor(e=1,t=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let d=[],c=Math.PI/2,u=(ne=0,j=0,$=0)=>new E(ne,j,$),p=u(),f=u(),[m,g,v]=[t/2,e/2,i/2],y=-g,x=+g,[w,_,S]=[u(y,-m,+v),u(y,-m,-v),u(y,+m,-v)],A=(ne,j=!1)=>Math.sin(ne-Math.PI/(1+ +j)),b=(ne,j=!1)=>Math.cos(ne-Math.PI/(1+ +j));S.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,C=w.z-h;r<=c?(S.z=Math.min(M,C),S.z==C&&(S.y-=(M-C)/Math.tan(c-r))):_.z=Math.min(_.z-M-v,w.z-h),p.subVectors(w,_),f.subVectors(S,_);let T=Math.min(p.length(),f.length())*s/100,P=T*Math.tan(r/2),O=T/Math.cos(r/2),D=p.clone().normalize().add(f.normalize()).setLength(O).add(_);p.set(0,A(r,!0),b(r,!0)),d.push([S,p.clone()]);let N=(Math.PI-r)/n;for(let ne=0;ne<=n;ne++){let j=c+r+ne*N;p.set(0,Math.sin(j)*P,Math.cos(j)*P),p.add(D),f.set(0,A(j),b(j)),d.push([p.clone(),f.clone()])}d.push([w,u(0,1,0)]);let W=Math.sin(N/2)*P*2,q=d.length-1,z=d[0][0].distanceTo(d[1][0]),V=d[q-1][0].distanceTo(d[q][0]),k=z+W*n+V;d[0].push(1);for(let ne=0;ne<=n;ne++)d[ne+1].push(1-(z+ne*W)/k);d[q].push(0);let[U,B,H]=d[0],X,Z,F;for(let ne=1;ne<d.length;ne++)[X,Z,F]=d[ne],a.push(y,U.y,U.z,y,X.y,X.z,x,U.y,U.z,x,U.y,U.z,y,X.y,X.z,x,X.y,X.z),o.push(0,B.y,B.z,0,Z.y,Z.z,0,B.y,B.z,0,B.y,B.z,0,Z.y,Z.z,0,Z.y,Z.z),l.push(0,H,0,F,1,H,1,H,0,F,1,F),[U,B,H]=[X,Z,F];this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(o,3)),this.setAttribute("uv",new Ce(l,2))}},tA=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,d=e.shape,c=t*.5,u=i*.5,p=0,f=0,m=a*Math.PI/360/s,g=Math.PI/2*3*-1,v=c*r/100,y=u*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let w=0;w<s;w++){let _=m*w,S=p+Math.sin(_)*c,A=f+Math.cos(_)*u;d.addPoint(d.createPoint(S,A))}}else for(let w=0;w<s;w++){let _=p+Math.cos(g)*c,S=f+Math.sin(g)*u;d.addPoint(d.createPoint(_,S)),g+=m,_=p+Math.cos(g)*v,S=f+Math.sin(g)*y,w<=s,d.addPoint(d.createPoint(_,S)),g+=m}d.isClosed=!0;for(let w=0,_=d.points.length;w<_;w++)d.points[w].roundness=n;d.roundness=n,d.update();let x=za.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},ik=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new xu(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},rk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=sk(t,i,r,t*.5,a,n,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function sk(e,t,i,r,s,n,a,o,l,h,d){return[t,i]=[i,t],a=t/2,s/=2*Math.PI,s==1&&(h=0),new KS(!0,e,t,i,r,s,n,a,o,l,h,d)}var nk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new a_(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},ak=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof Ft?e.shape:new Ft,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5;o?(l.addPoint(l.createPoint(-h,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))),l.isClosed=!0;for(let u=0,p=l.points.length;u<p;u++)l.points[u].roundness=r;l.roundness=r,l.update();let c=za.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function ok(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function lk(e,t,i){let r=[new E,new E,new E],s=[new E,new E,new E];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((n,a)=>{let o=s[a],l=it.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new ge().makeBasis(r[0],r[1],r[2])}var hk=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=t?.shapeData??gv.create({parameters:bS}).userData.shape;return{path:e.path??Zd.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{..._S,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new ck(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new He,{userData:{...e,type:"PathGeometry"}})}},ck=class extends He{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!ok(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,n=Math.floor(r*s),a=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,a-n+1),s+2),l=[],h=[];for(let C=0;C<o;C++){let T=this.inputs.path.isClosed?(C+n)%e.length:Math.min(C+n,e.length-1);l.push(e[T].clone()),h.push(t[T].clone())}let d=(C,T,P)=>{l[C]=l[C].clone().lerp(l[T],P),h[C]=lk(h[C],h[T],P)},c=0,u=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(u||r===0)&&(c=u,d(0,1,c));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,d(l.length-1,l.length-2,1-p)),i===0){let C=l.length-1;l[C].copy(l[0]),h[C].copy(h[0])}this._applyPathModifiers(h,c,p);let{regions:m,infos:g,vertices:v}=this._computeShapePoints(5),y=0,x=0;g.sort((C,T)=>C.start-T.start),g.forEach(C=>{C.verticesStart=y,C.verticesCount=C.continuous.reduce((T,P,O)=>T+(O===0||!P?2:1),0),x+=C.verticesCount,y=x});let w=x*o,_,S=0;if(this._isOpenEnded()){try{_=Rn({windingRule:wt.ODD,elementType:Kt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:m})}catch{_=VS}S=_.vertexCount}let A=w+2*S,b={positions:new Float32Array(A*3),normals:new Float32Array(A*3),uvs:new Float32Array(A*2)},M=[];g.forEach(C=>{this._extrudeRegion(C,v,h,l,b,M,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,w,M,b,h[0],l[0],!1),this._closeEnd(_,w+S,M,b,h[h.length-1],l[l.length-1],!0)),this.setAttribute("position",new Ye(b.positions,3)),this.setAttribute("normal",new Ye(b.normals,3)),this.setAttribute("uv",new Ye(b.uvs,2)),this.setIndex(M)}_extractPathPoints(){let e=RS(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new E,n=new E,a=new E,o=new E,l=new E(0,1,0);for(let f=0;f<i;f++){let m=e[f],g;f===0?g=r?e[e.length-2]:m.clone().multiplyScalar(2).sub(e[1]):g=e[f-1];let v;f===i-1?v=r?e[1]:m.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=m.clone().sub(g).normalize(),x=v.clone().sub(m).normalize(),w=y.clone().add(x).normalize();a.copy(w),f===0&&(w.equals(l)||w.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(w).normalize(),S=w.clone().cross(_).normalize();l.copy(S),o.copy(_),f===0&&(s.copy(S),n.copy(w));let A=new ge().makeBasis(_,S,w);t.push(A)}let h=r?n:a,d=r?s:new E(0,1,0),c=h.clone().cross(o).normalize(),u=Math.acos(d.dot(c));if(isNaN(u))return t;let p=d.clone().cross(c);h.dot(p)>0&&(u*=-1);for(let f=1;f<t.length;f++){let m=new ge().makeRotationZ(u*f/t.length);t[f].multiply(m)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new ge,h=new ge;return e.forEach((d,c)=>{let u=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(it.lerp(s,s+n,u));let p=it.lerp(a,o,u);h.makeScale(p,p,p),d.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=wt.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),m=[];for(let g=f.length-1;g>=1;g-=2){let v=f[g-1],y=f[g-0];m.push(v,y)}return m}),n;try{n=Rn({windingRule:t,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=mv}let a;try{a=Rn({windingRule:wt.ODD,elementType:Kt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=GS}if(!n)throw new Error("error generating geometry");let o=n.elementCount;if(a){n.elementCount+=a.elementCount;for(let p=0;p<a.elements.length;p++){let f=a.elements[p],m=p%2===0?n.vertexCount:0;n.elements.push(f+m)}for(let p=0;p<a.vertexIndices.length;p++){let f=a.vertexIndices[p],m=n.vertexCount;n.vertexIndices.push(f+m)}for(let p=0;p<a.vertices.length;p++){let f=a.vertices[p];n.vertices.push(f)}}let l=1/0,h=-1/0,d=1/0,c=-1/0;for(let p=0,f=n.vertexCount;p<f;p++){let m=p*2,g=n.vertices[m+0],v=n.vertices[m+1];g<l&&(l=g),g>h&&(h=g),v<d&&(d=v),v>c&&(c=v)}let u=[];for(let p=n.elementCount-1;p>=0;p--){let f=p>=o,m=p*2,g=n.elements[m+0],v=n.elements[m+1],y=g+v,x={start:g,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};u.push(x);let w=g,_=y-1,S=g+1,A=i.roundedCurves.length;do{let b=w-g,M=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[w*2+0],P=n.vertices[w*2+1],O=n.vertices[S*2+0],D=n.vertices[S*2+1],N=T-M,W=P-C,q=Math.sqrt(N*N+W*W);N/=q,W/=q;let z=T-O,V=P-D,k=Math.sqrt(z*z+V*V);z/=k,V/=k,x.normals[b*2+0]=-V,x.normals[b*2+1]=z;let U=n.vertexIndices[w];if(Array.isArray(U))x.continuous[b]=!1;else{let[B,H]=i.getCurveIndexFromVertexId(U-1,!0);if(H>0&&H<1)x.continuous[b]=!0;else{let X=H===1?B+1:B-1;X=(X+A)%A;let Z=H===1?0:1,F=i.roundedCurves[B].getTangent(H),ne=i.roundedCurves[X].getTangent(Z);x.continuous[b]=F.dot(ne)>.95}}f&&(x.normals[b*2+0]*=-1,x.normals[b*2+1]*=-1),[_,w,S]=[w,S,S+1],S>=y&&(S-=v)}while(S!==g+1)}return{regions:[r,...s],infos:u,vertices:n.vertices}}_insertVertex(e,t,i,r,s){let n=t*2,a=t*3;e.positions[a+0]=i.x,e.positions[a+1]=i.y,e.positions[a+2]=i.z,e.normals[a+0]=r.x,e.normals[a+1]=r.y,e.normals[a+2]=r.z,e.uvs[n+0]=s.x,e.uvs[n+1]=s.y}_extrudeRegion(e,t,i,r,s,n,a){let o=new E,l=new E,h=new E,d=new E,c=new G;i.forEach((p,f)=>{let m=r[f],g=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(m),e.continuous[v])d.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v==0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),d.copy(o).sub(l),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(s,g,h,d,c),g++,!e.continuous[v]||v===0){if(v===0)d.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,f/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),d.copy(l).sub(o),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(p).normalize(),this._insertVertex(s,g,h,d,c),g++}}});let u=i.length-1;for(let p=0;p<u;p++){let f=e.verticesStart*i.length+e.verticesCount*p,m=e.verticesStart*i.length+e.verticesCount*(p+1),g=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&g++;let y=v===e.count-1?0:g+1,x=f+g,w=f+y,_=m+y,S=m+g;e.isHole?n.push(x,_,w,x,S,_):n.push(x,w,_,x,_,S),g++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new E(0,0,a?-1:1).applyMatrix4(s),h=new E,d=new G;for(let u=0;u<o;u++){let p=2*u;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(n),this._insertVertex(r,t+u,h,l,d)}let c=e.elements;for(let u=0;u<e.elementCount;u++){let p=3*u,f=c[p+0]+t,m=c[p+(a?1:2)]+t,g=c[p+(a?2:1)]+t;i.push(f,m,g)}}};function iA(){let e=new He;return e.setAttribute("position",new Ye(new Float32Array([]),3)),e.setIndex(new Ye(new Uint16Array([]),1)),e}var dk=iA().attributes,uk=12,pk=1,rA=class extends He{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,dk),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,text:o,textTransform:l}=e,h=l===2?o.toUpperCase():l===3?o.toLowerCase():o,d=fk(e,t,h),{shapes:c,charWidths:u,charCoords:p}=t.generateShapes(d,e),f=i*.5,m=r*.5,g=c.map(x=>new Ft().fromShape(x));this.vectorShapes=g;let v=g.map(x=>za.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?wt.NONZERO:wt.ODD,subdivisions:this.isLowResolution&&s>0?pk:uk}})),y=v.length?Co(v):iA();y.translate(-f,m,0),this.dispose(),this.wrappedText=d,this.charCoords=p,this.charWidths=u,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,w])=>{this.setAttribute(x,w)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=La(new He,rA.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function fk(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
|
|
3139
3139
|
`?(r[r.length-1]+=s,s="",n===`
|
|
3140
|
-
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var sA,vv=new Promise(e=>{sA=e}),qx=!1;async function mk(){if(qx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.339/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});sA(s),qx=!0}function hu(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Ft.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new h_().parse(e);else{if(e.type==="SubdivGeometry")return new Bi(e,i);if(e.type==="TextGeometry")return new rA(e,t)}let s;try{s=Jx(r)}catch(n){console.error(n)}if(!s){let n=Ft.createFromState(Yd.defaultData(),100,100);r.shape=n,s=Jx(r)}return s}var gk=new ge;function Qm(e,t,i,r){let s=e.position.array,n=e.normal.array,a=gk.makeScale(t,i,r).invert().elements,o,l,h;for(var d=0,c=s.length;d<c;d+=3)s[d]*=t,s[d+1]*=i,s[d+2]*=r,o=n[d],l=n[d+1],h=n[d+2],n[d]=a[0]*o+a[4]*l+a[8]*h,n[d+1]=a[1]*o+a[5]*l+a[9]*h,n[d+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var Kc=new Jt,oo=new E,ze;vv.then(e=>{ze=e});var Xx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Yx=new Uint32Array([0,1,2,3]),Zx=new Uint8Array([4]),Bi=class extends He{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=Aa.div(t,i);this.subdividedGeometry&&Qm(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Qm(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(oo.fromArray(r));let n=oo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Bi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Cs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Bi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Kc.setFromBufferAttribute(t),Kc.getCenter(i),e.boundingSphere.radius=i.distanceTo(Kc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Kc.getSize(oo);let r={width:oo.x,height:oo.y,depth:oo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(ze.free_bvh(t),ze.free_subdivision_surface(t));try{s=Bi.allocate(e,r)}catch(l){console.error(l,e),s=Bi.allocate({positionWASM:Xx,indexWASM:Yx,verticesPerFaceWASM:Zx},r)}if(ze.set_destination_refinement_level(s,0),n=Bi.buildLevel(s,!0,o),e.subdivisions>0)try{ze.set_destination_refinement_level(s,e.subdivisions),a=Bi.buildLevel(s,!1,o)}catch{try{ze.set_destination_refinement_level(s,e.subdivisions-1),a=Bi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0?t.geometry:hu(e,i,!1),s,n,a,o;({positions:s,triIndices:o}=yv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,d=h+e.radialSegments*3;l=[h,d]}return{indices:n,verticesPerFace:a}=nA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Xx,r=Yx,s=Zx);let o=i.length,l=r.length,h=s.length,d=i.length+n.length+a.length,c=r.length+s.length,u=d*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,m=ze._malloc(u),g=new Float32Array(ze.HEAPF32.buffer,m,d),v=new Uint32Array(ze.HEAPU32.buffer,m+p,c);g.set(i,0),g.set(n,i.length),g.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(w=>w!==1)&&(y=new ge().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?ze.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):ze.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return ze._free(m),x}static buildLevel(e,t,i,r,s){let n=s?ze.get_mesh_data2(e,t?ze.Level.CONTROL:ze.Level.REFINED,i,s.elements):ze.get_mesh_data(e,t?ze.Level.CONTROL:ze.Level.REFINED,i),a=8,o=ze.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,d=ze.HEAPU32[o[h]>>2],c=ze.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=ze.HEAPU32[o[h]>>2],p=ze.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=ze.HEAPU32[o[h]>>2],m=ze.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=ze.HEAPU32[o[h]>>2],v=ze.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let y=new He;if(y.setIndex(new ah(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new ah(m,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ye(x,4))}return ze.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,ze.free_mesh_data(n)}static freeSubdivPointer(e){ze.free_bvh(e),ze.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ze.get_wireframe_data_for_base_level(e),s=4,n=ze.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=ze.HEAPU32[n[o]>>2],h=ze.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let d=ze.HEAPU32[n[o]>>2],c=ze.HEAPU32.subarray(d>>2,(d>>2)+a[o]);if(t===void 0){let u=new He;u.setAttribute("position",new Ce(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Ye(p,3)),u.setIndex(new ah(c,1)),ze.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,ze.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ze.set_destination_refinement_level(e,t);let s=i?ze.get_topological_data2(e,r?ze.Level.CONTROL:ze.Level.REFINED,i.elements):ze.get_topological_data(e,r?ze.Level.CONTROL:ze.Level.REFINED),n=6,a=ze.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=ze.HEAPU32[a[l]>>2],d=new Float32Array(ze.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=ze.HEAPU32[a[l]>>2],u=new Uint32Array(ze.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=ze.HEAPU32[a[l]>>2],f=new Uint8Array(ze.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return ze.free_topological_data(s),{positions:d,indices:u,verticesPerFace:f}}},Qx=["getX","getY","getZ"];function yv(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let d=t?t.getX(h):h,c="";for(let u=0;u<3;u++)c+=`${~~(e[Qx[u]](d)*o)},`;if(c in i)n.push(i[c]);else{for(let u=0;u<3;u++)a.push(e[Qx[u]](d));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var Jc=new E,ff=new E,mf=new E,gf=new E;function nA(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let d=a.length/2/o;a=a.filter((c,u)=>Math.floor(u/2)%d===0)}let l=0;for(let d=0;d<a.length;d+=2)l+=(a[d]-a[(d===0?a.length:d)-2])*(a[d+1]+a[(d===0?a.length:d)-1]);e.length=0;let h=0;if(l<0)for(let d=0;d<a.length;d+=2)e.push(a[d],a[d+1],0),s.push(h++);else for(let d=a.length-2;d>=0;d-=2)e.push(a[d],a[d+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Jc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),ff.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),mf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),gf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),ff.sub(Jc).normalize(),mf.sub(Jc).normalize(),gf.sub(Jc).normalize();let l=ff.cross(mf).dot(gf);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:a>=r[d]&&a<r[d+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let d=0,c=0;d<e.length;d+=3,c++)e[d+2]===0&&(a.push(c),l++),e[d+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let d=o[0];o[0]=o[1],o[1]=d}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var Sn={};SM(Sn,{calcBoolean:()=>bk,calcBooleanTopological:()=>wk,freeMeshSet:()=>Ak,getMeshSet:()=>_k,transformMeshSet:()=>Sk});var aA,vk=new Promise(e=>{aA=e}),Kx=!1;async function yk(){if(Kx)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.339/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});aA(s),Kx=!0}var st,ko;vk.then(e=>st=e);function xk(e,t,i){let r,{positions:s,triIndices:n}=yv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=nA(s,n,e);a=l.length,r=[];for(let h=0,d=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[d++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function oA(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=st._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(st.HEAPU32.buffer,n,t):new Float32Array(st.HEAPF32.buffer,n,t)).set(e,0),n}function lA(e){switch(e){case 0:return st.OP.UNION;case 1:return st.OP.INTERSECTION;case 2:return st.OP.A_MINUS_B;case 3:return st.OP.B_MINUS_A;case 4:return st.OP.SYMMETRIC_DIFFERENCE;case 5:return st.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function wk(e,t){ko===void 0&&(ko=st.init_csg());let i=oA(e),r=st.csg_calc_topological(ko,i,e.length,lA(t));st._free(i);let s=6,n=st.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=st.HEAPU32[n[o]>>2],h=new Float32Array(st.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let d=st.HEAPU32[n[o]>>2],c=new Uint32Array(st.HEAPU32.subarray(d>>2,(d>>2)+a[o]));o++;let u=st.HEAPU32[n[o]>>2],p=new Uint8Array(st.HEAPU32.subarray(u>>2,(u>>2)+a[o]));return st.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function bk(e,t,i,r){ko===void 0&&(ko=st.init_csg());let s=oA(e),n=st.csg_calc(ko,s,e.length,r,lA(t));st._free(s);let a=5,o=st.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,d=st.HEAPU32[o[h]>>2],c=st.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=st.HEAPU32[o[h]>>2],p=st.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let m=st.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Tr),i.boundingSphere.center.set(m[0],m[1],m[2]),i.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},st.free_mesh_data(n),f}function _k(e,t,i){if(st===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let g=e.userData;n=g.verticesPerFace.length,r=g.positions,s=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<g.verticesPerFace.length;v++){s[x++]=g.verticesPerFace[v];for(let w=0;w<g.verticesPerFace[v];w++)s[x++]=g.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=xk(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,d=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=st._malloc(d),f=new Float32Array(st.HEAPF32.buffer,p,l),m=new Uint32Array(st.HEAPU32.buffer,p+c,h);return f.set(r,0),m.set(s,0),st.get_csg_mesh(p,a,p+c,o,n)}function Sk(e,t){st.transform_csg_mesh(e,t.elements)}function Ak(e){st.free_csg_mesh(e)}var Mk={ConeGeometry:n6,CubeGeometry:a6,CylinderGeometry:s6,DodecahedronGeometry:l6,EllipseGeometry:gv,HelixGeometry:F6,IcosahedronGeometry:k6,LatheGeometry:j6,NonParametricGeometry:Y6,PolygonGeometry:$S,PyramidGeometry:Z6,RectangleGeometry:eA,SphereGeometry:J6,PlaneGeometry:$6,BackdropGeometry:ek,StarGeometry:tA,TextFrameGeometry:ik,TorusGeometry:rk,TorusKnotGeometry:nk,TriangleGeometry:ak,PathGeometry:hk,VectorGeometry:za},Jx=e=>Mk[e.type].create(e);function Fl(e){return e!==null&&"booleanOp"in e}var hA=class extends BS(nr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ge}updateVisible(){super.updateVisible(),this.visible=!Fl(this.parent)&&this.visible,Fl(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Sn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Fl(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof hA&&(e.freeBooleanPointer(),Fl(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Fl(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},$c=new Jt;function xv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0;for(let c=t;c<i;c++){let u=e.getX(c),p=e.getY(c),f=e.getZ(c);u<n&&(n=u),p<a&&(a=p),f<o&&(o=f),u>l&&(l=u),p>h&&(h=p),f>d&&(d=f)}$c.min.set(n,a,o),$c.max.set(l,h,d),$c.getCenter(r),$c.getSize(s).multiplyScalar(.5)}var Ek=new He,Ck=new jh,Xi=class extends hA{constructor(e,t){super(Ek,Ck),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?xv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},$x=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}},Hn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=it.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,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof Hn&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},Tk=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Gi=new Tk,Et=class extends Hn{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=it.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},cr=class extends Et{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},wr=class extends cr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},vr=class extends cr{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},qi=class extends je{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},pa=class extends cr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof qi?e:new qi(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Pk=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,ew=/[a-z_0-9]+/gi,Le=class extends Et{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=ew.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let d=l[h],c=d[0],u=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&u&&Gi.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=Gi.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||Gi.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[d.index+a-1]!=="."&&(o=o.substring(0,d.index+a)+p+o.substring(d.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&Gi.contains(p)&&e.include(Gi.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=Pk.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(ew);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Dk=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,cA=class extends Et{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||cA.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=Dk.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},yt=cA;yt.PI="PI",yt.PI2="PI2",yt.RECIPROCAL_PI="RECIPROCAL_PI",yt.RECIPROCAL_PI2="RECIPROCAL_PI2",yt.LOG2="LOG2",yt.EPSILON="EPSILON";var Ok=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3140
|
+
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var sA,vv=new Promise(e=>{sA=e}),qx=!1;async function mk(){if(qx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.341/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});sA(s),qx=!0}function hu(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Ft.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new h_().parse(e);else{if(e.type==="SubdivGeometry")return new Bi(e,i);if(e.type==="TextGeometry")return new rA(e,t)}let s;try{s=Jx(r)}catch(n){console.error(n)}if(!s){let n=Ft.createFromState(Yd.defaultData(),100,100);r.shape=n,s=Jx(r)}return s}var gk=new ge;function Qm(e,t,i,r){let s=e.position.array,n=e.normal.array,a=gk.makeScale(t,i,r).invert().elements,o,l,h;for(var d=0,c=s.length;d<c;d+=3)s[d]*=t,s[d+1]*=i,s[d+2]*=r,o=n[d],l=n[d+1],h=n[d+2],n[d]=a[0]*o+a[4]*l+a[8]*h,n[d+1]=a[1]*o+a[5]*l+a[9]*h,n[d+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var Kc=new Jt,oo=new E,ze;vv.then(e=>{ze=e});var Xx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Yx=new Uint32Array([0,1,2,3]),Zx=new Uint8Array([4]),Bi=class extends He{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=Aa.div(t,i);this.subdividedGeometry&&Qm(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Qm(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(oo.fromArray(r));let n=oo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Bi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Cs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Bi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Kc.setFromBufferAttribute(t),Kc.getCenter(i),e.boundingSphere.radius=i.distanceTo(Kc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Kc.getSize(oo);let r={width:oo.x,height:oo.y,depth:oo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(ze.free_bvh(t),ze.free_subdivision_surface(t));try{s=Bi.allocate(e,r)}catch(l){console.error(l,e),s=Bi.allocate({positionWASM:Xx,indexWASM:Yx,verticesPerFaceWASM:Zx},r)}if(ze.set_destination_refinement_level(s,0),n=Bi.buildLevel(s,!0,o),e.subdivisions>0)try{ze.set_destination_refinement_level(s,e.subdivisions),a=Bi.buildLevel(s,!1,o)}catch{try{ze.set_destination_refinement_level(s,e.subdivisions-1),a=Bi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0?t.geometry:hu(e,i,!1),s,n,a,o;({positions:s,triIndices:o}=yv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,d=h+e.radialSegments*3;l=[h,d]}return{indices:n,verticesPerFace:a}=nA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=Xx,r=Yx,s=Zx);let o=i.length,l=r.length,h=s.length,d=i.length+n.length+a.length,c=r.length+s.length,u=d*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,m=ze._malloc(u),g=new Float32Array(ze.HEAPF32.buffer,m,d),v=new Uint32Array(ze.HEAPU32.buffer,m+p,c);g.set(i,0),g.set(n,i.length),g.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(w=>w!==1)&&(y=new ge().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?ze.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):ze.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return ze._free(m),x}static buildLevel(e,t,i,r,s){let n=s?ze.get_mesh_data2(e,t?ze.Level.CONTROL:ze.Level.REFINED,i,s.elements):ze.get_mesh_data(e,t?ze.Level.CONTROL:ze.Level.REFINED,i),a=8,o=ze.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,d=ze.HEAPU32[o[h]>>2],c=ze.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=ze.HEAPU32[o[h]>>2],p=ze.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=ze.HEAPU32[o[h]>>2],m=ze.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=ze.HEAPU32[o[h]>>2],v=ze.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let y=new He;if(y.setIndex(new ah(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new ah(m,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ye(x,4))}return ze.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,ze.free_mesh_data(n)}static freeSubdivPointer(e){ze.free_bvh(e),ze.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ze.get_wireframe_data_for_base_level(e),s=4,n=ze.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=ze.HEAPU32[n[o]>>2],h=ze.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let d=ze.HEAPU32[n[o]>>2],c=ze.HEAPU32.subarray(d>>2,(d>>2)+a[o]);if(t===void 0){let u=new He;u.setAttribute("position",new Ce(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Ye(p,3)),u.setIndex(new ah(c,1)),ze.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,ze.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ze.set_destination_refinement_level(e,t);let s=i?ze.get_topological_data2(e,r?ze.Level.CONTROL:ze.Level.REFINED,i.elements):ze.get_topological_data(e,r?ze.Level.CONTROL:ze.Level.REFINED),n=6,a=ze.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=ze.HEAPU32[a[l]>>2],d=new Float32Array(ze.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=ze.HEAPU32[a[l]>>2],u=new Uint32Array(ze.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=ze.HEAPU32[a[l]>>2],f=new Uint8Array(ze.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return ze.free_topological_data(s),{positions:d,indices:u,verticesPerFace:f}}},Qx=["getX","getY","getZ"];function yv(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let d=t?t.getX(h):h,c="";for(let u=0;u<3;u++)c+=`${~~(e[Qx[u]](d)*o)},`;if(c in i)n.push(i[c]);else{for(let u=0;u<3;u++)a.push(e[Qx[u]](d));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var Jc=new E,ff=new E,mf=new E,gf=new E;function nA(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let d=a.length/2/o;a=a.filter((c,u)=>Math.floor(u/2)%d===0)}let l=0;for(let d=0;d<a.length;d+=2)l+=(a[d]-a[(d===0?a.length:d)-2])*(a[d+1]+a[(d===0?a.length:d)-1]);e.length=0;let h=0;if(l<0)for(let d=0;d<a.length;d+=2)e.push(a[d],a[d+1],0),s.push(h++);else for(let d=a.length-2;d>=0;d-=2)e.push(a[d],a[d+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Jc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),ff.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),mf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),gf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),ff.sub(Jc).normalize(),mf.sub(Jc).normalize(),gf.sub(Jc).normalize();let l=ff.cross(mf).dot(gf);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:a>=r[d]&&a<r[d+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let d=0,c=0;d<e.length;d+=3,c++)e[d+2]===0&&(a.push(c),l++),e[d+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let d=o[0];o[0]=o[1],o[1]=d}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var Sn={};SM(Sn,{calcBoolean:()=>bk,calcBooleanTopological:()=>wk,freeMeshSet:()=>Ak,getMeshSet:()=>_k,transformMeshSet:()=>Sk});var aA,vk=new Promise(e=>{aA=e}),Kx=!1;async function yk(){if(Kx)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.341/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});aA(s),Kx=!0}var st,ko;vk.then(e=>st=e);function xk(e,t,i){let r,{positions:s,triIndices:n}=yv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=nA(s,n,e);a=l.length,r=[];for(let h=0,d=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[d++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function oA(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=st._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(st.HEAPU32.buffer,n,t):new Float32Array(st.HEAPF32.buffer,n,t)).set(e,0),n}function lA(e){switch(e){case 0:return st.OP.UNION;case 1:return st.OP.INTERSECTION;case 2:return st.OP.A_MINUS_B;case 3:return st.OP.B_MINUS_A;case 4:return st.OP.SYMMETRIC_DIFFERENCE;case 5:return st.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function wk(e,t){ko===void 0&&(ko=st.init_csg());let i=oA(e),r=st.csg_calc_topological(ko,i,e.length,lA(t));st._free(i);let s=6,n=st.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=st.HEAPU32[n[o]>>2],h=new Float32Array(st.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let d=st.HEAPU32[n[o]>>2],c=new Uint32Array(st.HEAPU32.subarray(d>>2,(d>>2)+a[o]));o++;let u=st.HEAPU32[n[o]>>2],p=new Uint8Array(st.HEAPU32.subarray(u>>2,(u>>2)+a[o]));return st.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function bk(e,t,i,r){ko===void 0&&(ko=st.init_csg());let s=oA(e),n=st.csg_calc(ko,s,e.length,r,lA(t));st._free(s);let a=5,o=st.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,d=st.HEAPU32[o[h]>>2],c=st.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=st.HEAPU32[o[h]>>2],p=st.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let m=st.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Tr),i.boundingSphere.center.set(m[0],m[1],m[2]),i.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},st.free_mesh_data(n),f}function _k(e,t,i){if(st===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let g=e.userData;n=g.verticesPerFace.length,r=g.positions,s=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<g.verticesPerFace.length;v++){s[x++]=g.verticesPerFace[v];for(let w=0;w<g.verticesPerFace[v];w++)s[x++]=g.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=xk(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,d=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=st._malloc(d),f=new Float32Array(st.HEAPF32.buffer,p,l),m=new Uint32Array(st.HEAPU32.buffer,p+c,h);return f.set(r,0),m.set(s,0),st.get_csg_mesh(p,a,p+c,o,n)}function Sk(e,t){st.transform_csg_mesh(e,t.elements)}function Ak(e){st.free_csg_mesh(e)}var Mk={ConeGeometry:n6,CubeGeometry:a6,CylinderGeometry:s6,DodecahedronGeometry:l6,EllipseGeometry:gv,HelixGeometry:F6,IcosahedronGeometry:k6,LatheGeometry:j6,NonParametricGeometry:Y6,PolygonGeometry:$S,PyramidGeometry:Z6,RectangleGeometry:eA,SphereGeometry:J6,PlaneGeometry:$6,BackdropGeometry:ek,StarGeometry:tA,TextFrameGeometry:ik,TorusGeometry:rk,TorusKnotGeometry:nk,TriangleGeometry:ak,PathGeometry:hk,VectorGeometry:za},Jx=e=>Mk[e.type].create(e);function Fl(e){return e!==null&&"booleanOp"in e}var hA=class extends BS(nr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ge}updateVisible(){super.updateVisible(),this.visible=!Fl(this.parent)&&this.visible,Fl(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Sn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Fl(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof hA&&(e.freeBooleanPointer(),Fl(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Fl(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},$c=new Jt;function xv(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0;for(let c=t;c<i;c++){let u=e.getX(c),p=e.getY(c),f=e.getZ(c);u<n&&(n=u),p<a&&(a=p),f<o&&(o=f),u>l&&(l=u),p>h&&(h=p),f>d&&(d=f)}$c.min.set(n,a,o),$c.max.set(l,h,d),$c.getCenter(r),$c.getSize(s).multiplyScalar(.5)}var Ek=new He,Ck=new jh,Xi=class extends hA{constructor(e,t){super(Ek,Ck),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?xv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},$x=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}},Hn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=it.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,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof Hn&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},Tk=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Gi=new Tk,Et=class extends Hn{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=it.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},cr=class extends Et{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},wr=class extends cr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},vr=class extends cr{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},qi=class extends je{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},pa=class extends cr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof qi?e:new qi(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Pk=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,ew=/[a-z_0-9]+/gi,Le=class extends Et{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=ew.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let d=l[h],c=d[0],u=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&u&&Gi.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=Gi.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||Gi.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[d.index+a-1]!=="."&&(o=o.substring(0,d.index+a)+p+o.substring(d.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&Gi.contains(p)&&e.include(Gi.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=Pk.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(ew);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Dk=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,cA=class extends Et{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||cA.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=Dk.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},yt=cA;yt.PI="PI",yt.PI2="PI2",yt.RECIPROCAL_PI="RECIPROCAL_PI",yt.RECIPROCAL_PI2="RECIPROCAL_PI2",yt.LOG2="LOG2",yt.EPSILON="EPSILON";var Ok=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3141
3141
|
)*?)}`,"gim"),Lk=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),dA=class extends Et{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=Ok.exec(e);if(t){let i=t[2],r;for(;r=Lk.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},wv=class extends Et{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};Gi.addKeyword("uv",function(){return new wv});Gi.addKeyword("uv2",function(){return new wv(1)});var wo=class extends Et{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??wo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Es:return["Linear"];case Ke:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=wo.Nodes[this.method],n=e.include(s);if(n===wo.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let a=this.factor.build(e,"f");return e.format(n+"( "+i+", "+a+" )",r,t)}else return e.format(n+"( "+i+" )",r,t)}fromEncoding(e){let t=wo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=wo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},ws=wo;ws.Nodes={LinearToLinear:new Le(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3142
3142
|
`)),sRGBToLinear:new Le(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
3143
3143
|
`)),LinearTosRGB:new Le(["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(`
|
|
@@ -5209,7 +5209,7 @@ outputColor=vec4(color,inputColor.a);}`,hd={DEFAULT:0,ESKIL:1},M9=class extends
|
|
|
5209
5209
|
void main() {
|
|
5210
5210
|
gl_FragColor = vec4(0.0);
|
|
5211
5211
|
}
|
|
5212
|
-
`}),Yf=class extends Lr{constructor(e,t){super("OpaquePass",e??Ab,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??Ab}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof Xi&&(this.originalMaterials.set(r.id,r.material),r.material=N9)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function Mb(e,t){return t&&t.enabled&&e.push(t.effect),e}var z9=e=>Object.values(at).includes(e)?e:at.NORMAL,U9=class extends Ui{constructor(e){super(),this.postprocessingState=Lh.defaultData,this._scene=new _a,this._camera=new Ni,this.effects=new Map,this._renderToScreen=!0,this.clock=new EO,this.renderer=e,this.debug=!1,this.effects.set("bloom",new E9),this.effects.set("chromaticAberration",new T9),this.effects.set("vignette",new L9),this.effects.set("noise",new O9),this.effects.set("colorAverage",new P9),this.effects.set("hueSaturation",new D9),this.effects.set("brightnessContrast",new C9),this.effects.set("depthOfField",new I9),this.effects.set("pixelation",new R9),this.effectComposer=new r9(this.renderer),this.opaquePass=new Yf(this.scene,this.camera),this.transmissionPass=new B9(this.scene,this.camera,this.renderer),this.helperPass=new Yf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Hu(!1,!0,!1),this.helperPassOnTop=new Yf(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new S9({preset:_o.ULTRA,edgeDetectionMode:Vv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=k2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Wf(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(Mb,[]);e.length>0&&(this.uvEffectPass=new Wf(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Mb,[]);t.length>0&&(this.effectPass=new Wf(this.camera,...t),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new G;this.renderer.getDrawingBufferSize(e),this._rt=new si(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:xh,wrapT:xh}),this._rt.samples=0,this._savePass=new vu(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=z9(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Eb=new ui,F9=class extends Yb{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new U9(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new si(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ho,magFilter:gt,wrapS:ir,wrapT:ir,depthBuffer:!1}),this.transmissionDepthTarget=new si(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Bt,magFilter:Bt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new si(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Bt,magFilter:Bt,type:Pn,depthTexture:new Ag(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Ni?Ef.uniforms.depthContrast.value=(t.far-t.near)/1e4:Ef.uniforms.depthContrast.value=1,e.overrideMaterial=Ef,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?sg:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{It.penumbraSize.value[o]=a}),It.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?It.resolution.value.set(this.resolution.x,this.resolution.y):It.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(It.normalRenderTarget.value=this.overrideNormal,It.normalRenderTargetDepth.value=Eb):e.needsNormal()&&(this.createNormalRenderTarget(),It.normalRenderTarget.value=this.normalRenderTarget.texture,It.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)It.transmissionRenderTarget.value=this.overrideTransmission,It.transmissionRenderTargetDepth.value=Eb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),It.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,It.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?sg:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},k9=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Uu(e.shared,t),this.scene=new Er(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Dr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},j9=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function G9(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function yh(e){return e instanceof Nh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function V9(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Xi)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Xi&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!hr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!hr.isMergable(l.material))return;n=hr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][yh(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][yh(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][yh(r)].push(l)}),i}function H9(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function W9(e,t){let i=V9(t,e),r=H9(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,d=new Array(r),c=0;for(let[u,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof Xi&&(a[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),a[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&G9(a[g]);let m=Co(a.slice(0,o),!1);if(m){let g;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new nr(m,l[0].material);break}default:{g=new nr(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof Xi&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][yh(x)]&&i[x.material.uuid][yh(x)].length>1||(d[c++]=x));for(let x=0;x<c;x++)t.attach(d[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let u=0;u<n;u++)s[u].removeFromParent()}var q9=Uh(CM(),1),X9=new G;function Y9(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Wv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))},this._resize=Jg(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=X9.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new j9({x:10,y:10})),FU(e)}async load(e,t){Y9(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await sH(e);this._data=i,i.version&&(0,q9.default)(i.version,"0.9.339")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([xw(i)&&yk(),D8(i)&&mk(),i.scene.environment.usePhysics&&tU(),fw(i)&&v8()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new k9(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();W9(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}xw(i)&&this._scene.traverse(n=>{Qs(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(n=>{n instanceof va&&n.pendingMediaLoad&&n.update()})});let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this.requestRender()}),fw(i)&&IV(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),D2(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new F9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?yg:Tb,mj(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new aH(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}t&&(this._scene.updateMatrixWorld(!0),this._controls=new RV(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new nH(this._renderer,this._scene,this._camera,i.scene.publish,this._sharedAssetsManager,this.requestRender,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)),this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof U2&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new qi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0),this._proxyObjectCache.forEach(e=>{Qy.unsubscribe(e)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),kU(this.canvas)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=Qy(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Wu=window,qu=Wu.ShadowRoot&&(Wu.ShadyCSS===void 0||Wu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qv=Symbol(),V2=new WeakMap,Jh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==qv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(qu&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=V2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&V2.set(i,t))}return t}toString(){return this.cssText}},H2=e=>new Jh(typeof e=="string"?e:e+"",void 0,qv),Xv=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new Jh(i,e,qv)},Yv=(e,t)=>{qu?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Wu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Xu=qu?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return H2(i)})(e):e;var Zv,Yu=window,W2=Yu.trustedTypes,Z9=W2?W2.emptyScript:"",q2=Yu.reactiveElementPolyfillSupport,Kv={toAttribute(e,t){switch(t){case Boolean:e=e?Z9:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},X2=(e,t)=>t!==e&&(t==t||e==e),Qv={attribute:!0,type:String,converter:Kv,reflect:!1,hasChanged:X2},on=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=Qv){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Qv}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Xu(s))}else t!==void 0&&i.push(Xu(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Yv(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=Qv){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Kv).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:Kv;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||X2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};on.finalized=!0,on.elementProperties=new Map,on.elementStyles=[],on.shadowRootOptions={mode:"open"},q2?.({ReactiveElement:on}),((Zv=Yu.reactiveElementVersions)!==null&&Zv!==void 0?Zv:Yu.reactiveElementVersions=[]).push("1.6.0");var Jv,Zu=window,fl=Zu.trustedTypes,Y2=fl?fl.createPolicy("lit-html",{createHTML:e=>e}):void 0,qn=`lit$${(Math.random()+"").slice(9)}$`,tM="?"+qn,Q9=`<${tM}>`,ml=document,ec=(e="")=>ml.createComment(e),tc=e=>e===null||typeof e!="object"&&typeof e!="function",iM=Array.isArray,K9=e=>iM(e)||typeof e?.[Symbol.iterator]=="function",$h=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Z2=/-->/g,Q2=/>/g,Fa=RegExp(`>|[
|
|
5212
|
+
`}),Yf=class extends Lr{constructor(e,t){super("OpaquePass",e??Ab,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??Ab}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof Xi&&(this.originalMaterials.set(r.id,r.material),r.material=N9)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function Mb(e,t){return t&&t.enabled&&e.push(t.effect),e}var z9=e=>Object.values(at).includes(e)?e:at.NORMAL,U9=class extends Ui{constructor(e){super(),this.postprocessingState=Lh.defaultData,this._scene=new _a,this._camera=new Ni,this.effects=new Map,this._renderToScreen=!0,this.clock=new EO,this.renderer=e,this.debug=!1,this.effects.set("bloom",new E9),this.effects.set("chromaticAberration",new T9),this.effects.set("vignette",new L9),this.effects.set("noise",new O9),this.effects.set("colorAverage",new P9),this.effects.set("hueSaturation",new D9),this.effects.set("brightnessContrast",new C9),this.effects.set("depthOfField",new I9),this.effects.set("pixelation",new R9),this.effectComposer=new r9(this.renderer),this.opaquePass=new Yf(this.scene,this.camera),this.transmissionPass=new B9(this.scene,this.camera,this.renderer),this.helperPass=new Yf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Hu(!1,!0,!1),this.helperPassOnTop=new Yf(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new S9({preset:_o.ULTRA,edgeDetectionMode:Vv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=k2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Wf(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(Mb,[]);e.length>0&&(this.uvEffectPass=new Wf(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Mb,[]);t.length>0&&(this.effectPass=new Wf(this.camera,...t),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new G;this.renderer.getDrawingBufferSize(e),this._rt=new si(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:xh,wrapT:xh}),this._rt.samples=0,this._savePass=new vu(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=z9(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Eb=new ui,F9=class extends Yb{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new U9(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio=s,t(s)},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new si(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ho,magFilter:gt,wrapS:ir,wrapT:ir,depthBuffer:!1}),this.transmissionDepthTarget=new si(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Bt,magFilter:Bt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new si(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Bt,magFilter:Bt,type:Pn,depthTexture:new Ag(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof Ni?Ef.uniforms.depthContrast.value=(t.far-t.near)/1e4:Ef.uniforms.depthContrast.value=1,e.overrideMaterial=Ef,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?sg:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{It.penumbraSize.value[o]=a}),It.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?It.resolution.value.set(this.resolution.x,this.resolution.y):It.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(It.normalRenderTarget.value=this.overrideNormal,It.normalRenderTargetDepth.value=Eb):e.needsNormal()&&(this.createNormalRenderTarget(),It.normalRenderTarget.value=this.normalRenderTarget.texture,It.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)It.transmissionRenderTarget.value=this.overrideTransmission,It.transmissionRenderTargetDepth.value=Eb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),It.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,It.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?sg:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},k9=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Uu(e.shared,t),this.scene=new Er(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Dr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},j9=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function G9(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function yh(e){return e instanceof Nh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function V9(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Xi)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Xi&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!hr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!hr.isMergable(l.material))return;n=hr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][yh(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][yh(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][yh(r)].push(l)}),i}function H9(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function W9(e,t){let i=V9(t,e),r=H9(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,d=new Array(r),c=0;for(let[u,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof Xi&&(a[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),a[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&G9(a[g]);let m=Co(a.slice(0,o),!1);if(m){let g;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new nr(m,l[0].material);break}default:{g=new nr(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof Xi&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][yh(x)]&&i[x.material.uuid][yh(x)].length>1||(d[c++]=x));for(let x=0;x<c;x++)t.attach(d[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let u=0;u<n;u++)s[u].removeFromParent()}var q9=Uh(CM(),1),X9=new G;function Y9(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Wv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),this._eventManager.handlers.DragDrop.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))},this._resize=Jg(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=X9.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new j9({x:10,y:10})),FU(e)}async load(e,t){Y9(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await sH(e);this._data=i,i.version&&(0,q9.default)(i.version,"0.9.341")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([xw(i)&&yk(),D8(i)&&mk(),i.scene.environment.usePhysics&&tU(),fw(i)&&v8()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new k9(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();W9(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}xw(i)&&this._scene.traverse(n=>{Qs(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(n=>{n instanceof va&&n.pendingMediaLoad&&n.update()})});let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n).loadingPromise);if(Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this.requestRender()}),fw(i)&&IV(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),D2(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new F9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?yg:Tb,mj(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new aH(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}t&&(this._scene.updateMatrixWorld(!0),this._controls=new RV(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new nH(this._renderer,this._scene,this._camera,i.scene.publish,this._sharedAssetsManager,this.requestRender,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),this._rafId===void 0?this.render(performance.now()):this.requestRender(),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof U2&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new qi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0),this._proxyObjectCache.forEach(e=>{Qy.unsubscribe(e)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),kU(this.canvas)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=Qy(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Wu=window,qu=Wu.ShadowRoot&&(Wu.ShadyCSS===void 0||Wu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qv=Symbol(),V2=new WeakMap,Jh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==qv)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(qu&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=V2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&V2.set(i,t))}return t}toString(){return this.cssText}},H2=e=>new Jh(typeof e=="string"?e:e+"",void 0,qv),Xv=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new Jh(i,e,qv)},Yv=(e,t)=>{qu?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Wu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Xu=qu?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return H2(i)})(e):e;var Zv,Yu=window,W2=Yu.trustedTypes,Z9=W2?W2.emptyScript:"",q2=Yu.reactiveElementPolyfillSupport,Kv={toAttribute(e,t){switch(t){case Boolean:e=e?Z9:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},X2=(e,t)=>t!==e&&(t==t||e==e),Qv={attribute:!0,type:String,converter:Kv,reflect:!1,hasChanged:X2},on=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=Qv){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Qv}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Xu(s))}else t!==void 0&&i.push(Xu(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Yv(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=Qv){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Kv).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:Kv;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||X2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};on.finalized=!0,on.elementProperties=new Map,on.elementStyles=[],on.shadowRootOptions={mode:"open"},q2?.({ReactiveElement:on}),((Zv=Yu.reactiveElementVersions)!==null&&Zv!==void 0?Zv:Yu.reactiveElementVersions=[]).push("1.6.0");var Jv,Zu=window,fl=Zu.trustedTypes,Y2=fl?fl.createPolicy("lit-html",{createHTML:e=>e}):void 0,qn=`lit$${(Math.random()+"").slice(9)}$`,tM="?"+qn,Q9=`<${tM}>`,ml=document,ec=(e="")=>ml.createComment(e),tc=e=>e===null||typeof e!="object"&&typeof e!="function",iM=Array.isArray,K9=e=>iM(e)||typeof e?.[Symbol.iterator]=="function",$h=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Z2=/-->/g,Q2=/>/g,Fa=RegExp(`>|[
|
|
5213
5213
|
\f\r](?:([^\\s"'>=/]+)([
|
|
5214
5214
|
\f\r]*=[
|
|
5215
5215
|
\f\r]*(?:[^
|