@splinetool/viewer 0.9.423 → 0.9.424
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 +247 -247
- package/build/spline-viewer.js +5 -5
- package/package.json +2 -2
package/build/spline-viewer.js
CHANGED
|
@@ -3135,9 +3135,9 @@ void main() {
|
|
|
3135
3135
|
squared_mean = squared_mean / samples;
|
|
3136
3136
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3137
3137
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3138
|
-
}`;function LI(e,t,i){let r=new Ev,s=new F,n=new F,a=new $e,o=new iS({depthPacking:G_}),l=new PI,h={},d=i.maxTextureSize,c={[ns]:xi,[xi]:ns,[yr]:yr},u=new Lt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:DI,fragmentShader:II}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new qe;f.setAttribute("position",new Ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new ir(f,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bv,this.render=function(b,_,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;let S=e.getRenderTarget(),w=e.getActiveCubeFace(),E=e.getActiveMipmapLevel(),C=e.state;C.setBlending(si),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=b.length;T<D;T++){let P=b[T],L=P.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;s.copy(L.mapSize);let R=L.getFrameExtents();if(s.multiply(R),n.copy(L.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(n.x=Math.floor(d/R.x),s.x=n.x*R.x,L.mapSize.x=n.x),s.y>d&&(n.y=Math.floor(d/R.y),s.y=n.y*R.y,L.mapSize.y=n.y)),L.map===null){let k=this.type!==Ph?{minFilter:It,magFilter:It}:{};L.map=new At(s.x,s.y,k),L.map.texture.name=P.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let V=L.getViewportCount();for(let k=0;k<V;k++){let z=L.getViewport(k);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),L.updateMatrices(P,k),r=L.getFrustum(),x(_,A,L.camera,P,this.type)}L.isPointLightShadow!==!0&&this.type===Ph&&v(L,A),L.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(S,w,E)};function v(b,_){let A=t.update(g);u.defines.VSM_SAMPLES!==b.blurSamples&&(u.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new At(s.x,s.y)),u.uniforms.shadow_pass.value=b.map.texture,u.uniforms.resolution.value=b.mapSize,u.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(_,null,A,u,g,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(_,null,A,p,g,null)}function y(b,_,A,S,w,E){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let D=C.uuid,P=_.uuid,L=h[D];L===void 0&&(L={},h[D]=L);let R=L[P];R===void 0&&(R=C.clone(),L[P]=R),C=R}return C.visible=_.visible,C.wireframe=_.wireframe,E===Ph?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,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=S,C.farDistance=w),C}function x(b,_,A,S,w){if(b.visible===!1)return;if(b.layers.test(_.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&w===Ph)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,L=D.length;P<L;P++){let R=D[P],V=T[R.materialIndex];if(V&&V.visible){let k=y(b,V,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,k,b,R)}}}else if(T.visible){let D=y(b,T,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,D,b,null)}}let E=b.children;for(let C=0,T=E.length;C<T;C++)x(E[C],_,A,S,w)}}function OI(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,ne=new $e,ge=null,we=new $e(0,0,0,0);return{setMask:function(Ge){ge!==Ge&&!Y&&(e.colorMask(Ge,Ge,Ge,Ge),ge=Ge)},setLocked:function(Ge){Y=Ge},setClear:function(Ge,gt,Ut,Pi,ua){ua===!0&&(Ge*=Pi,gt*=Pi,Ut*=Pi),ne.set(Ge,gt,Ut,Pi),we.equals(ne)===!1&&(e.clearColor(Ge,gt,Ut,Pi),we.copy(ne))},reset:function(){Y=!1,ge=null,we.set(-1,0,0,0)}}}function n(){let Y=!1,ne=null,ge=null,we=null;return{setTest:function(Ge){Ge?ie(2929):Q(2929)},setMask:function(Ge){ne!==Ge&&!Y&&(e.depthMask(Ge),ne=Ge)},setFunc:function(Ge){if(ge!==Ge){switch(Ge){case $E:e.depthFunc(512);break;case eC:e.depthFunc(519);break;case tC:e.depthFunc(513);break;case Bm:e.depthFunc(515);break;case iC:e.depthFunc(514);break;case rC:e.depthFunc(518);break;case sC:e.depthFunc(516);break;case nC:e.depthFunc(517);break;default:e.depthFunc(515)}ge=Ge}},setLocked:function(Ge){Y=Ge},setClear:function(Ge){we!==Ge&&(e.clearDepth(Ge),we=Ge)},reset:function(){Y=!1,ne=null,ge=null,we=null}}}function a(){let Y=!1,ne=null,ge=null,we=null,Ge=null,gt=null,Ut=null,Pi=null,ua=null;return{setTest:function(Nt){Y||(Nt?ie(2960):Q(2960))},setMask:function(Nt){ne!==Nt&&!Y&&(e.stencilMask(Nt),ne=Nt)},setFunc:function(Nt,Vs,Ar){(ge!==Nt||we!==Vs||Ge!==Ar)&&(e.stencilFunc(Nt,Vs,Ar),ge=Nt,we=Vs,Ge=Ar)},setOp:function(Nt,Vs,Ar){(gt!==Nt||Ut!==Vs||Pi!==Ar)&&(e.stencilOp(Nt,Vs,Ar),gt=Nt,Ut=Vs,Pi=Ar)},setLocked:function(Nt){Y=Nt},setClear:function(Nt){ua!==Nt&&(e.clearStencil(Nt),ua=Nt)},reset:function(){Y=!1,ne=null,ge=null,we=null,Ge=null,gt=null,Ut=null,Pi=null,ua=null}}}let o=new s,l=new n,h=new a,d=new WeakMap,c=new WeakMap,u={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,E=!1,C=null,T=null,D=null,P=null,L=null,R=e.getParameter(35661),V=!1,k=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(z)[1]),V=k>=1):z.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),V=k>=2);let X=null,H={},G=e.getParameter(3088),N=e.getParameter(2978),q=new $e().fromArray(G),j=new $e().fromArray(N);function W(Y,ne,ge){let we=new Uint8Array(4),Ge=e.createTexture();e.bindTexture(Y,Ge),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let gt=0;gt<ge;gt++)e.texImage2D(ne+gt,0,6408,1,1,0,6408,5121,we);return Ge}let U={};U[3553]=W(3553,3553,1),U[34067]=W(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(Bm),Me(!1),Pe(xy),ie(2884),Ae(si);function ie(Y){u[Y]!==!0&&(e.enable(Y),u[Y]=!0)}function Q(Y){u[Y]!==!1&&(e.disable(Y),u[Y]=!1)}function re(Y,ne){return p[Y]!==ne?(e.bindFramebuffer(Y,ne),p[Y]=ne,r&&(Y===36009&&(p[36160]=ne),Y===36160&&(p[36009]=ne)),!0):!1}function Z(Y,ne){let ge=g,we=!1;if(Y)if(ge=f.get(ne),ge===void 0&&(ge=[],f.set(ne,ge)),Y.isWebGLMultipleRenderTargets){let Ge=Y.texture;if(ge.length!==Ge.length||ge[0]!==36064){for(let gt=0,Ut=Ge.length;gt<Ut;gt++)ge[gt]=36064+gt;ge.length=Ge.length,we=!0}}else ge[0]!==36064&&(ge[0]=36064,we=!0);else ge[0]!==1029&&(ge[0]=1029,we=!0);we&&(i.isWebGL2?e.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function ue(Y){return m!==Y?(e.useProgram(Y),m=Y,!0):!1}let ae={[Fo]:32774,[GE]:32778,[VE]:32779};if(r)ae[Sy]=32775,ae[Ay]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(ae[Sy]=Y.MIN_EXT,ae[Ay]=Y.MAX_EXT)}let se={[HE]:0,[WE]:1,[qE]:768,[B_]:770,[JE]:776,[ZE]:774,[YE]:772,[XE]:769,[R_]:771,[KE]:775,[QE]:773};function Ae(Y,ne,ge,we,Ge,gt,Ut,Pi){if(Y===si){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),Y!==jE){if(Y!==y||Pi!==E){if((x!==Fo||A!==Fo)&&(e.blendEquation(32774),x=Fo,A=Fo),Pi)switch(Y){case Jo:e.blendFuncSeparate(1,771,1,771);break;case by:e.blendFunc(1,1);break;case wy:e.blendFuncSeparate(0,769,0,1);break;case _y:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Jo:e.blendFuncSeparate(770,771,1,771);break;case by:e.blendFunc(770,1);break;case wy:e.blendFuncSeparate(0,769,0,1);break;case _y:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,_=null,S=null,w=null,y=Y,E=Pi}return}Ge=Ge||ne,gt=gt||ge,Ut=Ut||we,(ne!==x||Ge!==A)&&(e.blendEquationSeparate(ae[ne],ae[Ge]),x=ne,A=Ge),(ge!==b||we!==_||gt!==S||Ut!==w)&&(e.blendFuncSeparate(se[ge],se[we],se[gt],se[Ut]),b=ge,_=we,S=gt,w=Ut),y=Y,E=!1}function Se(Y,ne){Y.side===yr?Q(2884):ie(2884);let ge=Y.side===xi;ne&&(ge=!ge),Me(ge),Y.blending===Jo&&Y.transparent===!1?Ae(si):Ae(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 we=Y.stencilWrite;h.setTest(we),we&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),ve(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ie(32926):Q(32926)}function Me(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function Pe(Y){Y!==UE?(ie(2884),Y!==T&&(Y===xy?e.cullFace(1029):Y===FE?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=Y}function xe(Y){Y!==D&&(V&&e.lineWidth(Y),D=Y)}function ve(Y,ne,ge){Y?(ie(32823),(P!==ne||L!==ge)&&(e.polygonOffset(ne,ge),P=ne,L=ge)):Q(32823)}function Re(Y){Y?ie(3089):Q(3089)}function Qe(Y){Y===void 0&&(Y=33984+R-1),X!==Y&&(e.activeTexture(Y),X=Y)}function B(Y,ne,ge){ge===void 0&&(X===null?ge=33984+R-1:ge=X);let we=H[ge];we===void 0&&(we={type:void 0,texture:void 0},H[ge]=we),(we.type!==Y||we.texture!==ne)&&(X!==ge&&(e.activeTexture(ge),X=ge),e.bindTexture(Y,ne||U[Y]),we.type=Y,we.texture=ne)}function I(){let Y=H[X];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ce(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ye(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Oe(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Be(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Xe(Y){q.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),q.copy(Y))}function Ue(Y){j.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function pt(Y,ne){let ge=c.get(ne);ge===void 0&&(ge=new WeakMap,c.set(ne,ge));let we=ge.get(Y);we===void 0&&(we=e.getUniformBlockIndex(ne,Y.name),ge.set(Y,we))}function Ot(Y,ne){let ge=c.get(ne).get(Y);d.get(ne)!==ge&&(e.uniformBlockBinding(ne,ge,Y.__bindingPointIndex),d.set(ne,ge))}function Jt(){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={},X=null,H={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,E=!1,C=null,T=null,D=null,P=null,L=null,q.set(0,0,e.canvas.width,e.canvas.height),j.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:ue,setBlending:Ae,setMaterial:Se,setFlipSided:Me,setCullFace:Pe,setLineWidth:xe,setPolygonOffset:ve,setScissorTest:Re,activeTexture:Qe,bindTexture:B,unbindTexture:I,compressedTexImage2D:$,compressedTexImage3D:me,texImage2D:Be,texImage3D:Ie,updateUBOMapping:pt,uniformBlockBinding:Ot,texStorage2D:de,texStorage3D:De,texSubImage2D:ce,texSubImage3D:ye,compressedTexSubImage2D:Oe,compressedTexSubImage3D:Ee,scissor:Xe,viewport:Ue,reset:Jt}}function BI(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,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(B,I){return v?new OffscreenCanvas(B,I):uu("canvas")}function x(B,I,$,me){let ce=1;if((B.width>me||B.height>me)&&(ce=me/Math.max(B.width,B.height)),ce<1||I===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){let ye=I?du:Math.floor,Oe=ye(ce*B.width),Ee=ye(ce*B.height);g===void 0&&(g=y(Oe,Ee));let de=$?y(Oe,Ee):g;return de.width=Oe,de.height=Ee,de.getContext("2d").drawImage(B,0,0,Oe,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+Oe+"x"+Ee+")."),de}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function b(B){return km(B.width)&&km(B.height)}function _(B){return o?!1:B.wrapS!==Yt||B.wrapT!==Yt||B.minFilter!==It&&B.minFilter!==st}function A(B,I){return B.generateMipmaps&&I&&B.minFilter!==It&&B.minFilter!==st}function S(B){e.generateMipmap(B)}function w(B,I,$,me,ce=!1){if(o===!1)return I;if(B!==null){if(e[B]!==void 0)return e[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ye=I;return I===6403&&($===5126&&(ye=33326),$===5131&&(ye=33325),$===5121&&(ye=33321)),I===33319&&($===5126&&(ye=33328),$===5131&&(ye=33327),$===5121&&(ye=33323)),I===6408&&($===5126&&(ye=34836),$===5131&&(ye=34842),$===5121&&(ye=me===Je&&ce===!1?35907:32856),$===32819&&(ye=32854),$===32820&&(ye=32855)),(ye===33325||ye===33326||ye===33327||ye===33328||ye===34842||ye===34836)&&t.get("EXT_color_buffer_float"),ye}function E(B,I,$){return A(B,$)===!0||B.isFramebufferTexture&&B.minFilter!==It&&B.minFilter!==st?Math.log2(Math.max(I.width,I.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?I.mipmaps.length:1}function C(B){return B===It||B===My||B===kp?9728:9729}function T(B){let I=B.target;I.removeEventListener("dispose",T),P(I),I.isVideoTexture&&f.delete(I)}function D(B){let I=B.target;I.removeEventListener("dispose",D),R(I)}function P(B){let I=r.get(B);if(I.__webglInit===void 0)return;let $=B.source,me=m.get($);if(me){let ce=me[I.__cacheKey];ce.usedTimes--,ce.usedTimes===0&&L(B),Object.keys(me).length===0&&m.delete($)}r.remove(B)}function L(B){let I=r.get(B);e.deleteTexture(I.__webglTexture);let $=B.source,me=m.get($);delete me[I.__cacheKey],a.memory.textures--}function R(B){let I=B.texture,$=r.get(B),me=r.get(I);if(me.__webglTexture!==void 0&&(e.deleteTexture(me.__webglTexture),a.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let ce=0;ce<6;ce++)e.deleteFramebuffer($.__webglFramebuffer[ce]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[ce]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let ce=0;ce<$.__webglColorRenderbuffer.length;ce++)$.__webglColorRenderbuffer[ce]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[ce]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let ce=0,ye=I.length;ce<ye;ce++){let Oe=r.get(I[ce]);Oe.__webglTexture&&(e.deleteTexture(Oe.__webglTexture),a.memory.textures--),r.remove(I[ce])}r.remove(I),r.remove(B)}let V=0;function k(){V=0}function z(){let B=V;return B>=l&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l),V+=1,B}function X(B){let I=[];return I.push(B.wrapS),I.push(B.wrapT),I.push(B.wrapR||0),I.push(B.magFilter),I.push(B.minFilter),I.push(B.anisotropy),I.push(B.internalFormat),I.push(B.format),I.push(B.type),I.push(B.generateMipmaps),I.push(B.premultiplyAlpha),I.push(B.flipY),I.push(B.unpackAlignment),I.push(B.encoding),I.join()}function H(B,I){let $=r.get(B);if(B.isVideoTexture&&Re(B),B.isRenderTargetTexture===!1&&B.version>0&&$.__version!==B.version){let me=B.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,B,I);return}}i.bindTexture(3553,$.__webglTexture,33984+I)}function G(B,I){let $=r.get(B);if(B.version>0&&$.__version!==B.version){Q($,B,I);return}i.bindTexture(35866,$.__webglTexture,33984+I)}function N(B,I){let $=r.get(B);if(B.version>0&&$.__version!==B.version){Q($,B,I);return}i.bindTexture(32879,$.__webglTexture,33984+I)}function q(B,I){let $=r.get(B);if(B.version>0&&$.__version!==B.version){re($,B,I);return}i.bindTexture(34067,$.__webglTexture,33984+I)}let j={[pn]:10497,[Yt]:33071,[Nm]:33648},W={[It]:9728,[My]:9984,[kp]:9986,[st]:9729,[pC]:9985,[pl]:9987};function U(B,I,$){if($?(e.texParameteri(B,10242,j[I.wrapS]),e.texParameteri(B,10243,j[I.wrapT]),(B===32879||B===35866)&&e.texParameteri(B,32882,j[I.wrapR]),e.texParameteri(B,10240,W[I.magFilter]),e.texParameteri(B,10241,W[I.minFilter])):(e.texParameteri(B,10242,33071),e.texParameteri(B,10243,33071),(B===32879||B===35866)&&e.texParameteri(B,32882,33071),(I.wrapS!==Yt||I.wrapT!==Yt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(B,10240,C(I.magFilter)),e.texParameteri(B,10241,C(I.minFilter)),I.minFilter!==It&&I.minFilter!==st&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let me=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===It||I.minFilter!==kp&&I.minFilter!==pl||I.type===xr&&t.has("OES_texture_float_linear")===!1||o===!1&&I.type===fl&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(e.texParameterf(B,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function ie(B,I){let $=!1;B.__webglInit===void 0&&(B.__webglInit=!0,I.addEventListener("dispose",T));let me=I.source,ce=m.get(me);ce===void 0&&(ce={},m.set(me,ce));let ye=X(I);if(ye!==B.__cacheKey){ce[ye]===void 0&&(ce[ye]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,$=!0),ce[ye].usedTimes++;let Oe=ce[B.__cacheKey];Oe!==void 0&&(ce[B.__cacheKey].usedTimes--,Oe.usedTimes===0&&L(I)),B.__cacheKey=ye,B.__webglTexture=ce[ye].texture}return $}function Q(B,I,$){let me=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(me=35866),I.isData3DTexture&&(me=32879);let ce=ie(B,I),ye=I.source;i.bindTexture(me,B.__webglTexture,33984+$);let Oe=r.get(ye);if(ye.version!==Oe.__version||ce===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Ee=_(I)&&b(I.image)===!1,de=x(I.image,Ee,!1,d);de=Qe(I,de);let De=b(de)||o,Be=n.convert(I.format,I.encoding),Ie=n.convert(I.type),Xe=w(I.internalFormat,Be,Ie,I.encoding,I.isVideoTexture);U(me,I,De);let Ue,pt=I.mipmaps,Ot=o&&I.isVideoTexture!==!0,Jt=Oe.__version===void 0||ce===!0,Y=E(I,de,De);if(I.isDepthTexture)Xe=6402,o?I.type===xr?Xe=36012:I.type===Hn?Xe=33190:I.type===Ua?Xe=35056:Xe=33189:I.type===xr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Fa&&Xe===6402&&I.type!==U_&&I.type!==Hn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Hn,Ie=n.convert(I.type)),I.format===Xa&&Xe===6402&&(Xe=34041,I.type!==Ua&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Ua,Ie=n.convert(I.type))),Jt&&(Ot?i.texStorage2D(3553,1,Xe,de.width,de.height):i.texImage2D(3553,0,Xe,de.width,de.height,0,Be,Ie,null));else if(I.isDataTexture)if(pt.length>0&&De){Ot&&Jt&&i.texStorage2D(3553,Y,Xe,pt[0].width,pt[0].height);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],Ot?i.texSubImage2D(3553,ne,0,0,Ue.width,Ue.height,Be,Ie,Ue.data):i.texImage2D(3553,ne,Xe,Ue.width,Ue.height,0,Be,Ie,Ue.data);I.generateMipmaps=!1}else Ot?(Jt&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,de.width,de.height,Be,Ie,de.data)):i.texImage2D(3553,0,Xe,de.width,de.height,0,Be,Ie,de.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){Ot&&Jt&&i.texStorage3D(35866,Y,Xe,pt[0].width,pt[0].height,de.depth);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],I.format!==Rr?Be!==null?Ot?i.compressedTexSubImage3D(35866,ne,0,0,0,Ue.width,Ue.height,de.depth,Be,Ue.data,0,0):i.compressedTexImage3D(35866,ne,Xe,Ue.width,Ue.height,de.depth,0,Ue.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage3D(35866,ne,0,0,0,Ue.width,Ue.height,de.depth,Be,Ie,Ue.data):i.texImage3D(35866,ne,Xe,Ue.width,Ue.height,de.depth,0,Be,Ie,Ue.data)}else{Ot&&Jt&&i.texStorage2D(3553,Y,Xe,pt[0].width,pt[0].height);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],I.format!==Rr?Be!==null?Ot?i.compressedTexSubImage2D(3553,ne,0,0,Ue.width,Ue.height,Be,Ue.data):i.compressedTexImage2D(3553,ne,Xe,Ue.width,Ue.height,0,Ue.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage2D(3553,ne,0,0,Ue.width,Ue.height,Be,Ie,Ue.data):i.texImage2D(3553,ne,Xe,Ue.width,Ue.height,0,Be,Ie,Ue.data)}else if(I.isDataArrayTexture)Ot?(Jt&&i.texStorage3D(35866,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Be,Ie,de.data)):i.texImage3D(35866,0,Xe,de.width,de.height,de.depth,0,Be,Ie,de.data);else if(I.isData3DTexture)Ot?(Jt&&i.texStorage3D(32879,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Be,Ie,de.data)):i.texImage3D(32879,0,Xe,de.width,de.height,de.depth,0,Be,Ie,de.data);else if(I.isFramebufferTexture){if(Jt)if(Ot)i.texStorage2D(3553,Y,Xe,de.width,de.height);else{let ne=de.width,ge=de.height;for(let we=0;we<Y;we++)i.texImage2D(3553,we,Xe,ne,ge,0,Be,Ie,null),ne>>=1,ge>>=1}}else if(pt.length>0&&De){Ot&&Jt&&i.texStorage2D(3553,Y,Xe,pt[0].width,pt[0].height);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],Ot?i.texSubImage2D(3553,ne,0,0,Be,Ie,Ue):i.texImage2D(3553,ne,Xe,Be,Ie,Ue);I.generateMipmaps=!1}else Ot?(Jt&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,Be,Ie,de)):i.texImage2D(3553,0,Xe,Be,Ie,de);A(I,De)&&S(me),Oe.__version=ye.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function re(B,I,$){if(I.image.length!==6)return;let me=ie(B,I),ce=I.source;i.bindTexture(34067,B.__webglTexture,33984+$);let ye=r.get(ce);if(ce.version!==ye.__version||me===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Oe=I.isCompressedTexture||I.image[0].isCompressedTexture,Ee=I.image[0]&&I.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++)!Oe&&!Ee?de[ne]=x(I.image[ne],!1,!0,h):de[ne]=Ee?I.image[ne].image:I.image[ne],de[ne]=Qe(I,de[ne]);let De=de[0],Be=b(De)||o,Ie=n.convert(I.format,I.encoding),Xe=n.convert(I.type),Ue=w(I.internalFormat,Ie,Xe,I.encoding),pt=o&&I.isVideoTexture!==!0,Ot=ye.__version===void 0||me===!0,Jt=E(I,De,Be);U(34067,I,Be);let Y;if(Oe){pt&&Ot&&i.texStorage2D(34067,Jt,Ue,De.width,De.height);for(let ne=0;ne<6;ne++){Y=de[ne].mipmaps;for(let ge=0;ge<Y.length;ge++){let we=Y[ge];I.format!==Rr?Ie!==null?pt?i.compressedTexSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,we.data):i.compressedTexImage2D(34069+ne,ge,Ue,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):pt?i.texSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge,Ue,we.width,we.height,0,Ie,Xe,we.data)}}}else{Y=I.mipmaps,pt&&Ot&&(Y.length>0&&Jt++,i.texStorage2D(34067,Jt,Ue,de[0].width,de[0].height));for(let ne=0;ne<6;ne++)if(Ee){pt?i.texSubImage2D(34069+ne,0,0,0,de[ne].width,de[ne].height,Ie,Xe,de[ne].data):i.texImage2D(34069+ne,0,Ue,de[ne].width,de[ne].height,0,Ie,Xe,de[ne].data);for(let ge=0;ge<Y.length;ge++){let we=Y[ge].image[ne].image;pt?i.texSubImage2D(34069+ne,ge+1,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge+1,Ue,we.width,we.height,0,Ie,Xe,we.data)}}else{pt?i.texSubImage2D(34069+ne,0,0,0,Ie,Xe,de[ne]):i.texImage2D(34069+ne,0,Ue,Ie,Xe,de[ne]);for(let ge=0;ge<Y.length;ge++){let we=Y[ge];pt?i.texSubImage2D(34069+ne,ge+1,0,0,Ie,Xe,we.image[ne]):i.texImage2D(34069+ne,ge+1,Ue,Ie,Xe,we.image[ne])}}}A(I,Be)&&S(34067),ye.__version=ce.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function Z(B,I,$,me,ce){let ye=n.convert($.format,$.encoding),Oe=n.convert($.type),Ee=w($.internalFormat,ye,Oe,$.encoding);r.get(I).__hasExternalTextures||(ce===32879||ce===35866?i.texImage3D(ce,0,Ee,I.width,I.height,I.depth,0,ye,Oe,null):i.texImage2D(ce,0,Ee,I.width,I.height,0,ye,Oe,null)),i.bindFramebuffer(36160,B),ve(I)?u.framebufferTexture2DMultisampleEXT(36160,me,ce,r.get($).__webglTexture,0,xe(I)):(ce===3553||ce>=34069&&ce<=34074)&&e.framebufferTexture2D(36160,me,ce,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function ue(B,I,$){if(e.bindRenderbuffer(36161,B),I.depthBuffer&&!I.stencilBuffer){let me=33189;if($||ve(I)){let ce=I.depthTexture;ce&&ce.isDepthTexture&&(ce.type===xr?me=36012:ce.type===Hn&&(me=33190));let ye=xe(I);ve(I)?u.renderbufferStorageMultisampleEXT(36161,ye,me,I.width,I.height):e.renderbufferStorageMultisample(36161,ye,me,I.width,I.height)}else e.renderbufferStorage(36161,me,I.width,I.height);e.framebufferRenderbuffer(36160,36096,36161,B)}else if(I.depthBuffer&&I.stencilBuffer){let me=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,me,35056,I.width,I.height):ve(I)?u.renderbufferStorageMultisampleEXT(36161,me,35056,I.width,I.height):e.renderbufferStorage(36161,34041,I.width,I.height),e.framebufferRenderbuffer(36160,33306,36161,B)}else{let me=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let ce=0;ce<me.length;ce++){let ye=me[ce],Oe=n.convert(ye.format,ye.encoding),Ee=n.convert(ye.type),de=w(ye.internalFormat,Oe,Ee,ye.encoding),De=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,De,de,I.width,I.height):ve(I)?u.renderbufferStorageMultisampleEXT(36161,De,de,I.width,I.height):e.renderbufferStorage(36161,de,I.width,I.height)}}e.bindRenderbuffer(36161,null)}function ae(B,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,B),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),H(I.depthTexture,0);let $=r.get(I.depthTexture).__webglTexture,me=xe(I);if(I.depthTexture.format===Fa)ve(I)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,me):e.framebufferTexture2D(36160,36096,3553,$,0);else if(I.depthTexture.format===Xa)ve(I)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,me):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function se(B){let I=r.get(B),$=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!I.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");ae(I.__webglFramebuffer,B)}else if($){I.__webglDepthbuffer=[];for(let me=0;me<6;me++)i.bindFramebuffer(36160,I.__webglFramebuffer[me]),I.__webglDepthbuffer[me]=e.createRenderbuffer(),ue(I.__webglDepthbuffer[me],B,!1)}else i.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=e.createRenderbuffer(),ue(I.__webglDepthbuffer,B,!1);i.bindFramebuffer(36160,null)}function Ae(B,I,$){let me=r.get(B);I!==void 0&&Z(me.__webglFramebuffer,B,B.texture,36064,3553),$!==void 0&&se(B)}function Se(B){let I=B.texture,$=r.get(B),me=r.get(I);B.addEventListener("dispose",D),B.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=e.createTexture()),me.__version=I.version,a.memory.textures++);let ce=B.isWebGLCubeRenderTarget===!0,ye=B.isWebGLMultipleRenderTargets===!0,Oe=b(B)||o;if(ce){$.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)$.__webglFramebuffer[Ee]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),ye)if(s.drawBuffers){let Ee=B.texture;for(let de=0,De=Ee.length;de<De;de++){let Be=r.get(Ee[de]);Be.__webglTexture===void 0&&(Be.__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&&B.samples>0&&ve(B)===!1){let Ee=ye?I:[I];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let de=0;de<Ee.length;de++){let De=Ee[de];$.__webglColorRenderbuffer[de]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[de]);let Be=n.convert(De.format,De.encoding),Ie=n.convert(De.type),Xe=w(De.internalFormat,Be,Ie,De.encoding,B.isXRRenderTarget===!0),Ue=xe(B);e.renderbufferStorageMultisample(36161,Ue,Xe,B.width,B.height),e.framebufferRenderbuffer(36160,36064+de,36161,$.__webglColorRenderbuffer[de])}e.bindRenderbuffer(36161,null),B.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),ue($.__webglDepthRenderbuffer,B,!0)),i.bindFramebuffer(36160,null)}}if(ce){i.bindTexture(34067,me.__webglTexture),U(34067,I,Oe);for(let Ee=0;Ee<6;Ee++)Z($.__webglFramebuffer[Ee],B,I,36064,34069+Ee);A(I,Oe)&&S(34067),i.unbindTexture()}else if(ye){let Ee=B.texture;for(let de=0,De=Ee.length;de<De;de++){let Be=Ee[de],Ie=r.get(Be);i.bindTexture(3553,Ie.__webglTexture),U(3553,Be,Oe),Z($.__webglFramebuffer,B,Be,36064+de,3553),A(Be,Oe)&&S(3553)}i.unbindTexture()}else{let Ee=3553;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(o?Ee=B.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ee,me.__webglTexture),U(Ee,I,Oe),Z($.__webglFramebuffer,B,I,36064,Ee),A(I,Oe)&&S(Ee),i.unbindTexture()}B.depthBuffer&&se(B)}function Me(B){let I=b(B)||o,$=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let me=0,ce=$.length;me<ce;me++){let ye=$[me];if(A(ye,I)){let Oe=B.isWebGLCubeRenderTarget?34067:3553,Ee=r.get(ye).__webglTexture;i.bindTexture(Oe,Ee),S(Oe),i.unbindTexture()}}}function Pe(B){if(o&&B.samples>0&&ve(B)===!1){let I=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],$=B.width,me=B.height,ce=16384,ye=[],Oe=B.stencilBuffer?33306:36096,Ee=r.get(B),de=B.isWebGLMultipleRenderTargets===!0;if(de)for(let De=0;De<I.length;De++)i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,null),i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,null,0);i.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let De=0;De<I.length;De++){ye.push(36064+De),B.depthBuffer&&ye.push(Oe);let Be=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(Be===!1&&(B.depthBuffer&&(ce|=256),B.stencilBuffer&&(ce|=1024)),de&&e.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[De]),Be===!0&&(e.invalidateFramebuffer(36008,[Oe]),e.invalidateFramebuffer(36009,[Oe])),de){let Ie=r.get(I[De]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Ie,0)}e.blitFramebuffer(0,0,$,me,0,0,$,me,ce,9728),p&&e.invalidateFramebuffer(36008,ye)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),de)for(let De=0;De<I.length;De++){i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,Ee.__webglColorRenderbuffer[De]);let Be=r.get(I[De]).__webglTexture;i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,Be,0)}i.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function xe(B){return Math.min(c,B.samples)}function ve(B){let I=r.get(B);return o&&B.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Re(B){let I=a.render.frame;f.get(B)!==I&&(f.set(B,I),B.update())}function Qe(B,I){let $=B.encoding,me=B.format,ce=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===Fm||$!==Bs&&($===Je?o===!1?t.has("EXT_sRGB")===!0&&me===Rr?(B.format=Fm,B.minFilter=st,B.generateMipmaps=!1):I=q_.sRGBToLinear(I):(me!==Rr||ce!==Ni)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),I}this.allocateTextureUnit=z,this.resetTextureUnits=k,this.setTexture2D=H,this.setTexture2DArray=G,this.setTexture3D=N,this.setTextureCube=q,this.rebindTextures=Ae,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=Pe,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ve}function RI(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Ni)return 5121;if(n===vC)return 32819;if(n===yC)return 32820;if(n===fC)return 5120;if(n===mC)return 5122;if(n===U_)return 5123;if(n===gC)return 5124;if(n===Hn)return 5125;if(n===xr)return 5126;if(n===fl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===xC)return 6406;if(n===Rr)return 6408;if(n===bC)return 6409;if(n===wC)return 6410;if(n===Fa)return 6402;if(n===Xa)return 34041;if(n===Fm)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===_C)return 6403;if(n===SC)return 36244;if(n===F_)return 33319;if(n===AC)return 33320;if(n===MC)return 36249;if(n===jp||n===Gp||n===Vp||n===Hp)if(a===Je)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===jp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Gp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Vp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Hp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===jp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Gp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Vp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Hp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ey||n===Cy||n===Ty||n===Py)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===Ey)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Cy)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ty)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Py)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===EC)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Dy||n===Iy)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===Dy)return a===Je?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Iy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Ly||n===Oy||n===By||n===Ry||n===zy||n===Ny||n===Uy||n===Fy||n===ky||n===jy||n===Gy||n===Vy||n===Hy||n===Wy)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Ly)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Oy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===By)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ry)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===zy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ny)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Uy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Fy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ky)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===jy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Gy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Vy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Hy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Wy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Wp)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===Wp)return a===Je?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===CC||n===qy||n===Xy||n===Yy)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===Wp)return o.COMPRESSED_RED_RGTC1_EXT;if(n===qy)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Xy)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Yy)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ua?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 zI=class extends Oi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Xo=class extends Mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},NI={type:"move"},yf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xo,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 Xo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),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 g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==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(NI)))}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 Xo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},gl=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:Fa,h!==Fa&&h!==Xa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===Fa&&(i=Hn),i===void 0&&h===Xa&&(i=Ua),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:It,this.minFilter=o!==void 0?o:It,this.flipY=!1,this.generateMipmaps=!1}},UI=class extends Ti{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(),g=null,m=null,v=[],y=[],x=new Set,b=new Map,_=new Oi;_.layers.enable(1),_.viewport=new $e;let A=new Oi;A.layers.enable(2),A.viewport=new $e;let S=[_,A],w=new zI;w.layers.enable(1),w.layers.enable(2);let E=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let N=v[G];return N===void 0&&(N=new yf,v[G]=N),N.getTargetRaySpace()},this.getControllerGrip=function(G){let N=v[G];return N===void 0&&(N=new yf,v[G]=N),N.getGripSpace()},this.getHand=function(G){let N=v[G];return N===void 0&&(N=new yf,v[G]=N),N.getHandSpace()};function T(G){let N=y.indexOf(G.inputSource);if(N===-1)return;let q=v[N];q!==void 0&&q.dispatchEvent({type:G.type,data:G.inputSource})}function D(){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",D),r.removeEventListener("inputsourceschange",P);for(let G=0;G<v.length;G++){let N=y[G];N!==null&&(y[G]=null,v[G].disconnect(N))}E=null,C=null,e.setRenderTarget(g),u=null,c=null,d=null,r=null,m=null,H.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){s=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(G){l=G},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(G){if(r=G,r!==null){if(g=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",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let N={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,N),r.updateRenderState({baseLayer:u}),m=new At(u.framebufferWidth,u.framebufferHeight,{format:Rr,type:Ni,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let N=null,q=null,j=null;f.depth&&(j=f.stencil?35056:33190,N=f.stencil?Xa:Fa,q=f.stencil?Ua:Hn);let W={colorFormat:32856,depthFormat:j,scaleFactor:s};d=new XRWebGLBinding(r,t),c=d.createProjectionLayer(W),r.updateRenderState({layers:[c]}),m=new At(c.textureWidth,c.textureHeight,{format:Rr,type:Ni,depthTexture:new gl(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,N),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let U=e.properties.get(m);U.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),H.setContext(r),H.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(G){for(let N=0;N<G.removed.length;N++){let q=G.removed[N],j=y.indexOf(q);j>=0&&(y[j]=null,v[j].disconnect(q))}for(let N=0;N<G.added.length;N++){let q=G.added[N],j=y.indexOf(q);if(j===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(q),j=U;break}else if(y[U]===null){y[U]=q,j=U;break}if(j===-1)break}let W=v[j];W&&W.connect(q)}}let L=new M,R=new M;function V(G,N,q){L.setFromMatrixPosition(N.matrixWorld),R.setFromMatrixPosition(q.matrixWorld);let j=L.distanceTo(R),W=N.projectionMatrix.elements,U=q.projectionMatrix.elements,ie=W[14]/(W[10]-1),Q=W[14]/(W[10]+1),re=(W[9]+1)/W[5],Z=(W[9]-1)/W[5],ue=(W[8]-1)/W[0],ae=(U[8]+1)/U[0],se=ie*ue,Ae=ie*ae,Se=j/(-ue+ae),Me=Se*-ue;N.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Me),G.translateZ(Se),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Pe=ie+Se,xe=Q+Se,ve=se-Me,Re=Ae+(j-Me),Qe=re*Q/xe*Pe,B=Z*Q/xe*Pe;G.projectionMatrix.makePerspective(ve,Re,Qe,B,Pe,xe)}function k(G,N){N===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(N.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(r===null)return;w.near=A.near=_.near=G.near,w.far=A.far=_.far=G.far,(E!==w.near||C!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),E=w.near,C=w.far);let N=G.parent,q=w.cameras;k(w,N);for(let W=0;W<q.length;W++)k(q[W],N);w.matrixWorld.decompose(w.position,w.quaternion,w.scale),G.matrix.copy(w.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let j=G.children;for(let W=0,U=j.length;W<U;W++)j[W].updateMatrixWorld(!0);q.length===2?V(w,_,A):w.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return w},this.getFoveation=function(){if(!(c===null&&u===null))return o},this.setFoveation=function(G){o=G,c!==null&&(c.fixedFoveation=G),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=G)},this.getPlanes=function(){return x};let z=null;function X(G,N){if(h=N.getViewerPose(l||n),p=N,h!==null){let q=h.views;u!==null&&(e.setRenderTargetFramebuffer(m,u.framebuffer),e.setRenderTarget(m));let j=!1;q.length!==w.cameras.length&&(w.cameras.length=0,j=!0);for(let W=0;W<q.length;W++){let U=q[W],ie=null;if(u!==null)ie=u.getViewport(U);else{let re=d.getViewSubImage(c,U);ie=re.viewport,W===0&&(e.setRenderTargetTextures(m,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(m))}let Q=S[W];Q===void 0&&(Q=new Oi,Q.layers.enable(W),Q.viewport=new $e,S[W]=Q),Q.matrix.fromArray(U.transform.matrix),Q.projectionMatrix.fromArray(U.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&w.matrix.copy(Q.matrix),j===!0&&w.cameras.push(Q)}}for(let q=0;q<v.length;q++){let j=y[q],W=v[q];j!==null&&W!==void 0&&W.update(j,N,l||n)}if(z&&z(G,N),N.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:N.detectedPlanes});let q=null;for(let j of x)N.detectedPlanes.has(j)||(q===null&&(q=[]),q.push(j));if(q!==null)for(let j of q)x.delete(j),b.delete(j),i.dispatchEvent({type:"planeremoved",data:j});for(let j of N.detectedPlanes)if(!x.has(j))x.add(j),b.set(j,N.lastChangedTime),i.dispatchEvent({type:"planeadded",data:j});else{let W=b.get(j);j.lastChangedTime>W&&(b.set(j,j.lastChangedTime),i.dispatchEvent({type:"planechanged",data:j}))}}p=null}let H=new K_;H.setAnimationLoop(X),this.setAnimationLoop=function(G){z=G},this.dispose=function(){}}};function FI(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,Z_(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),d(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),c(g,m),m.isMeshPhysicalMaterial&&u(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(n(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===xi&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===xi&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*b}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uv2Transform.value.copy(x.matrix))}function n(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function c(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function u(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===xi&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function kI(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=d(y),s[y.id]=b,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let A=t.render.frame;n[y.id]!==A&&(u(y),n[y.id]=A)}function d(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),_=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,_,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}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],b=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let A=0,S=b.length;A<S;A++){let w=b[A];if(p(w,A,_)===!0){let E=w.__offset,C=Array.isArray(w.value)?w.value:[w.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],L=g(P);typeof P=="number"?(w.__data[0]=P,e.bufferSubData(35345,E+T,w.__data)):P.isMatrix3?(w.__data[0]=P.elements[0],w.__data[1]=P.elements[1],w.__data[2]=P.elements[2],w.__data[3]=P.elements[0],w.__data[4]=P.elements[3],w.__data[5]=P.elements[4],w.__data[6]=P.elements[5],w.__data[7]=P.elements[0],w.__data[8]=P.elements[6],w.__data[9]=P.elements[7],w.__data[10]=P.elements[8],w.__data[11]=P.elements[0]):(P.toArray(w.__data,T),T+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,E,w.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let _=y.value;if(b[x]===void 0){if(typeof _=="number")b[x]=_;else{let A=Array.isArray(_)?_:[_],S=[];for(let w=0;w<A.length;w++)S.push(A[w].clone());b[x]=S}return!0}else if(typeof _=="number"){if(b[x]!==_)return b[x]=_,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],S=Array.isArray(_)?_:[_];for(let w=0;w<A.length;w++){let E=A[w];if(E.equals(S[w])===!1)return E.copy(S[w]),!0}}return!1}function f(y){let x=y.uniforms,b=0,_=16,A=0;for(let S=0,w=x.length;S<w;S++){let E=x[S],C={boundary:0,storage:0},T=Array.isArray(E.value)?E.value:[E.value];for(let D=0,P=T.length;D<P;D++){let L=T[D],R=g(L);C.boundary+=R.boundary,C.storage+=R.storage}if(E.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=b,S>0){A=b%_;let D=_-A;A!==0&&D-C.boundary<0&&(b+=_-A,E.__offset=b)}b+=C.storage}return A=b%_,A>0&&(b+=_-A),y.__size=b,y.__cache={},this}function g(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 m(y){let x=y.target;x.removeEventListener("dispose",m);let b=a.indexOf(x.__bindingPointIndex);a.splice(b,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 jI(){let e=uu("canvas");return e.style.display="block",e}function rS(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:jI(),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=Bs,this.physicallyCorrectLights=!1,this.toneMapping=gn,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,x=null,b=-1,_=null,A=new $e,S=new $e,w=null,E=t.width,C=t.height,T=1,D=null,P=null,L=new $e(0,0,E,C),R=new $e(0,0,E,C),V=!1,k=new Ev,z=!1,X=!1,H=null,G=new fe,N=new F,q=new M,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return x===null?T:1}let U=i;function ie(O,ee){for(let oe=0;oe<O.length;oe++){let J=O[oe],le=t.getContext(J,ee);if(le!==null)return le}return null}try{let O={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${Dl}`),t.addEventListener("webglcontextlost",Xe,!1),t.addEventListener("webglcontextrestored",Ue,!1),t.addEventListener("webglcontextcreationerror",pt,!1),U===null){let ee=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&ee.shift(),U=ie(ee,O),U===null)throw ie(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}U.getShaderPrecisionFormat===void 0&&(U.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(O){throw console.error("THREE.WebGLRenderer: "+O.message),O}let Q,re,Z,ue,ae,se,Ae,Se,Me,Pe,xe,ve,Re,Qe,B,I,$,me,ce,ye,Oe,Ee,de,De;function Be(){Q=new eD(U),re=new YP(U,Q,e),Q.init(re),Ee=new RI(U,Q,re),Z=new OI(U,Q,re),ue=new rD,ae=new bI,se=new BI(U,Q,Z,ae,re,Ee,ue),Ae=new ZP(g),Se=new $P(g),Me=new uT(U,re),de=new qP(U,Q,Me,re),Pe=new tD(U,Me,ue,de),xe=new oD(U,Pe,Me,ue),ce=new aD(U,re,se),I=new QP(ae),ve=new xI(g,Ae,Se,Q,re,de,I),Re=new FI(g,ae),Qe=new _I,B=new TI(Q,re),me=new WP(g,Ae,Se,Z,xe,d,a),$=new LI(g,xe,re),De=new kI(U,ue,re,Z),ye=new XP(U,Q,ue,re),Oe=new iD(U,Q,ue,re),ue.programs=ve.programs,g.capabilities=re,g.extensions=Q,g.properties=ae,g.renderLists=Qe,g.shadowMap=$,g.state=Z,g.info=ue}Be();let Ie=new UI(g,U);this.xr=Ie,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let O=Q.get("WEBGL_lose_context");O&&O.loseContext()},this.forceContextRestore=function(){let O=Q.get("WEBGL_lose_context");O&&O.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(O){O!==void 0&&(T=O,this.setSize(E,C,!1))},this.getSize=function(O){return O.set(E,C)},this.setSize=function(O,ee,oe){if(Ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=O,C=ee,t.width=Math.floor(O*T),t.height=Math.floor(ee*T),oe!==!1&&(t.style.width=O+"px",t.style.height=ee+"px"),this.setViewport(0,0,O,ee)},this.getDrawingBufferSize=function(O){return O.set(E*T,C*T).floor()},this.setDrawingBufferSize=function(O,ee,oe){E=O,C=ee,T=oe,t.width=Math.floor(O*oe),t.height=Math.floor(ee*oe),this.setViewport(0,0,O,ee)},this.getCurrentViewport=function(O){return O.copy(A)},this.getViewport=function(O){return O.copy(L)},this.setViewport=function(O,ee,oe,J){O.isVector4?L.set(O.x,O.y,O.z,O.w):L.set(O,ee,oe,J),Z.viewport(A.copy(L).multiplyScalar(T).floor())},this.getScissor=function(O){return O.copy(R)},this.setScissor=function(O,ee,oe,J){O.isVector4?R.set(O.x,O.y,O.z,O.w):R.set(O,ee,oe,J),Z.scissor(S.copy(R).multiplyScalar(T).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(O){Z.setScissorTest(V=O)},this.setOpaqueSort=function(O){D=O},this.setTransparentSort=function(O){P=O},this.getClearColor=function(O){return O.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(O=!0,ee=!0,oe=!0){let J=0;O&&(J|=16384),ee&&(J|=256),oe&&(J|=1024),U.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",Xe,!1),t.removeEventListener("webglcontextrestored",Ue,!1),t.removeEventListener("webglcontextcreationerror",pt,!1),Qe.dispose(),B.dispose(),ae.dispose(),Ae.dispose(),Se.dispose(),xe.dispose(),de.dispose(),De.dispose(),ve.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",we),Ie.removeEventListener("sessionend",Ge),H&&(H.dispose(),H=null),gt.stop()};function Xe(O){O.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Ue(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let O=ue.autoReset,ee=$.enabled,oe=$.autoUpdate,J=$.needsUpdate,le=$.type;Be(),ue.autoReset=O,$.enabled=ee,$.autoUpdate=oe,$.needsUpdate=J,$.type=le}function pt(O){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",O.statusMessage)}function Ot(O){let ee=O.target;ee.removeEventListener("dispose",Ot),Jt(ee)}function Jt(O){Y(O),ae.remove(O)}function Y(O){let ee=ae.get(O).programs;ee!==void 0&&(ee.forEach(function(oe){ve.releaseProgram(oe)}),O.isShaderMaterial&&ve.releaseShaderCache(O))}this.renderBufferDirect=function(O,ee,oe,J,le,ze){ee===null&&(ee=j);let rt=le.isMesh&&le.matrixWorld.determinant()<0,ot=bE(O,ee,oe,J,le);Z.setMaterial(J,rt);let ht=oe.index,Pt=1;J.wireframe===!0&&(ht=Pe.getWireframeAttribute(oe),Pt=2);let vt=oe.drawRange,ft=oe.attributes.position,Di=vt.start*Pt,dr=(vt.start+vt.count)*Pt;ze!==null&&(Di=Math.max(Di,ze.start*Pt),dr=Math.min(dr,(ze.start+ze.count)*Pt)),ht!==null?(Di=Math.max(Di,0),dr=Math.min(dr,ht.count)):ft!=null&&(Di=Math.max(Di,0),dr=Math.min(dr,ft.count));let Hs=dr-Di;if(Hs<0||Hs===1/0)return;de.setup(le,J,ot,oe,ht);let pa,$t=ye;if(ht!==null&&(pa=Me.get(ht),$t=Oe,$t.setIndex(pa)),le.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*W()),$t.setMode(1)):$t.setMode(4);else if(le.isLine){let mt=J.linewidth;mt===void 0&&(mt=1),Z.setLineWidth(mt*W()),le.isLineSegments?$t.setMode(1):le.isLineLoop?$t.setMode(2):$t.setMode(3)}else le.isPoints?$t.setMode(0):le.isSprite&&$t.setMode(4);if(le.isInstancedMesh)$t.renderInstances(Di,Hs,le.count);else if(oe.isInstancedBufferGeometry){let mt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Rp=Math.min(oe.instanceCount,mt);$t.renderInstances(Di,Hs,Rp)}else $t.render(Di,Hs)},this.compile=function(O,ee){function oe(J,le,ze){J.transparent===!0&&J.side===yr&&J.forceSinglePass===!1?(J.side=xi,J.needsUpdate=!0,Ar(J,le,ze),J.side=ns,J.needsUpdate=!0,Ar(J,le,ze),J.side=yr):Ar(J,le,ze)}u=B.get(O),u.init(),f.push(u),O.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(u.pushLight(J),J.castShadow&&u.pushShadow(J))}),u.setupLights(g.physicallyCorrectLights),O.traverse(function(J){let le=J.material;if(le)if(Array.isArray(le))for(let ze=0;ze<le.length;ze++){let rt=le[ze];oe(rt,O,J)}else oe(le,O,J)}),f.pop(),u=null};let ne=null;function ge(O){ne&&ne(O)}function we(){gt.stop()}function Ge(){gt.start()}let gt=new K_;gt.setAnimationLoop(ge),typeof self<"u"&>.setContext(self),this.setAnimationLoop=function(O){ne=O,Ie.setAnimationLoop(O),O===null?gt.stop():gt.start()},Ie.addEventListener("sessionstart",we),Ie.addEventListener("sessionend",Ge),this.render=function(O,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(ee),ee=Ie.getCamera()),O.isScene===!0&&O.onBeforeRender(g,O,ee,x),u=B.get(O,f.length),u.init(),f.push(u),G.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),k.setFromProjectionMatrix(G),X=this.localClippingEnabled,z=I.init(this.clippingPlanes,X),c=Qe.get(O,p.length),c.init(),p.push(c),Ut(O,ee,0,g.sortObjects),c.finish(),g.sortObjects===!0&&c.sort(D,P),z===!0&&I.beginShadows();let oe=u.state.shadowsArray;if($.render(oe,O,ee),z===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(c,O),u.setupLights(g.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let le=0,ze=J.length;le<ze;le++){let rt=J[le];Pi(c,O,rt,rt.viewport)}}else Pi(c,O,ee);x!==null&&(se.updateMultisampleRenderTarget(x),se.updateRenderTargetMipmap(x)),O.isScene===!0&&O.onAfterRender(g,O,ee),de.resetDefaultState(),b=-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 Ut(O,ee,oe,J){if(O.visible===!1)return;if(O.layers.test(ee.layers)){if(O.isGroup)oe=O.renderOrder;else if(O.isLOD)O.autoUpdate===!0&&O.update(ee);else if(O.isLight)u.pushLight(O),O.castShadow&&u.pushShadow(O);else if(O.isSprite){if(!O.frustumCulled||k.intersectsSprite(O)){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}else if((O.isMesh||O.isLine||O.isPoints)&&(O.isSkinnedMesh&&O.skeleton.frame!==ue.render.frame&&(O.skeleton.update(),O.skeleton.frame=ue.render.frame),!O.frustumCulled||k.intersectsObject(O))){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;if(Array.isArray(rt)){let ot=ze.groups;for(let ht=0,Pt=ot.length;ht<Pt;ht++){let vt=ot[ht],ft=rt[vt.materialIndex];ft&&ft.visible&&c.push(O,ze,ft,oe,q.z,vt)}}else rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}let le=O.children;for(let ze=0,rt=le.length;ze<rt;ze++)Ut(le[ze],ee,oe,J)}function Pi(O,ee,oe,J){let le=O.opaque,ze=O.transmissive,rt=O.transparent;u.setupLightsView(oe),z===!0&&I.setGlobalState(g.clippingPlanes,oe),ze.length>0&&ua(le,ee,oe),J&&Z.viewport(A.copy(J)),le.length>0&&Nt(le,ee,oe),ze.length>0&&Nt(ze,ee,oe),rt.length>0&&Nt(rt,ee,oe),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function ua(O,ee,oe){let J=re.isWebGL2;H===null&&(H=new At(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?fl:Ni,minFilter:pl,samples:J&&n===!0?4:0})),g.getDrawingBufferSize(N),J?H.setSize(N.x,N.y):H.setSize(du(N.x),du(N.y));let le=g.getRenderTarget();g.setRenderTarget(H),g.clear();let ze=g.toneMapping;g.toneMapping=gn,Nt(O,ee,oe),g.toneMapping=ze,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),g.setRenderTarget(le)}function Nt(O,ee,oe){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let le=0,ze=O.length;le<ze;le++){let rt=O[le],ot=rt.object,ht=rt.geometry,Pt=J===null?rt.material:J,vt=rt.group;ot.layers.test(oe.layers)&&Vs(ot,ee,oe,ht,Pt,vt)}}function Vs(O,ee,oe,J,le,ze){O.onBeforeRender(g,ee,oe,J,le,ze),O.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,O.matrixWorld),O.normalMatrix.getNormalMatrix(O.modelViewMatrix),le.onBeforeRender(g,ee,oe,J,O,ze),le.transparent===!0&&le.side===yr&&le.forceSinglePass===!1?(le.side=xi,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=ns,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=yr):g.renderBufferDirect(oe,ee,J,le,O,ze),O.onAfterRender(g,ee,oe,J,le,ze)}function Ar(O,ee,oe){ee.isScene!==!0&&(ee=j);let J=ae.get(O),le=u.state.lights,ze=u.state.shadowsArray,rt=le.state.version,ot=ve.getParameters(O,le.state,ze,ee,oe),ht=ve.getProgramCacheKey(ot),Pt=J.programs;J.environment=O.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(O.isMeshStandardMaterial?Se:Ae).get(O.envMap||J.environment),Pt===void 0&&(O.addEventListener("dispose",Ot),Pt=new Map,J.programs=Pt);let vt=Pt.get(ht);if(vt!==void 0){if(J.currentProgram===vt&&J.lightsStateVersion===rt)return gy(O,ot),vt}else ot.uniforms=ve.getUniforms(O),O.onBuild(oe,ot,g),O.onBeforeCompile(ot,g),vt=ve.acquireProgram(ot,ht),Pt.set(ht,vt),J.uniforms=ot.uniforms;let ft=J.uniforms;(!O.isShaderMaterial&&!O.isRawShaderMaterial||O.clipping===!0)&&(ft.clippingPlanes=I.uniform),gy(O,ot),J.needsLights=_E(O),J.lightsStateVersion=rt,J.needsLights&&(ft.ambientLightColor.value=le.state.ambient,ft.lightProbe.value=le.state.probe,ft.directionalLights.value=le.state.directional,ft.directionalLightShadows.value=le.state.directionalShadow,ft.spotLights.value=le.state.spot,ft.spotLightShadows.value=le.state.spotShadow,ft.rectAreaLights.value=le.state.rectArea,ft.ltc_1.value=le.state.rectAreaLTC1,ft.ltc_2.value=le.state.rectAreaLTC2,ft.pointLights.value=le.state.point,ft.pointLightShadows.value=le.state.pointShadow,ft.hemisphereLights.value=le.state.hemi,ft.directionalShadowMap.value=le.state.directionalShadowMap,ft.directionalShadowMatrix.value=le.state.directionalShadowMatrix,ft.spotShadowMap.value=le.state.spotShadowMap,ft.spotLightMatrix.value=le.state.spotLightMatrix,ft.spotLightMap.value=le.state.spotLightMap,ft.pointShadowMap.value=le.state.pointShadowMap,ft.pointShadowMatrix.value=le.state.pointShadowMatrix);let Di=vt.getUniforms(),dr=Kd.seqWithValue(Di.seq,ft);return J.currentProgram=vt,J.uniformsList=dr,vt}function gy(O,ee){let oe=ae.get(O);oe.outputEncoding=ee.outputEncoding,oe.instancing=ee.instancing,oe.skinning=ee.skinning,oe.morphTargets=ee.morphTargets,oe.morphNormals=ee.morphNormals,oe.morphColors=ee.morphColors,oe.morphTargetsCount=ee.morphTargetsCount,oe.numClippingPlanes=ee.numClippingPlanes,oe.numIntersection=ee.numClipIntersection,oe.vertexAlphas=ee.vertexAlphas,oe.vertexTangents=ee.vertexTangents,oe.toneMapping=ee.toneMapping}function bE(O,ee,oe,J,le){ee.isScene!==!0&&(ee=j),se.resetTextureUnits();let ze=ee.fog,rt=J.isMeshStandardMaterial?ee.environment:null,ot=x===null?g.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Bs,ht=(J.isMeshStandardMaterial?Se:Ae).get(J.envMap||rt),Pt=J.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,vt=!!J.normalMap&&!!oe.attributes.tangent,ft=!!oe.morphAttributes.position,Di=!!oe.morphAttributes.normal,dr=!!oe.morphAttributes.color,Hs=J.toneMapped?g.toneMapping:gn,pa=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,$t=pa!==void 0?pa.length:0,mt=ae.get(J),Rp=u.state.lights;if(z===!0&&(X===!0||O!==_)){let ur=O===_&&J.id===b;I.setState(J,O,ur)}let zp=!1;J.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Rp.state.version||mt.outputEncoding!==ot||le.isInstancedMesh&&mt.instancing===!1||!le.isInstancedMesh&&mt.instancing===!0||le.isSkinnedMesh&&mt.skinning===!1||!le.isSkinnedMesh&&mt.skinning===!0||mt.envMap!==ht||J.fog===!0&&mt.fog!==ze||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==I.numPlanes||mt.numIntersection!==I.numIntersection)||mt.vertexAlphas!==Pt||mt.vertexTangents!==vt||mt.morphTargets!==ft||mt.morphNormals!==Di||mt.morphColors!==dr||mt.toneMapping!==Hs||re.isWebGL2===!0&&mt.morphTargetsCount!==$t)&&(zp=!0):(zp=!0,mt.__version=J.version);let fa=mt.currentProgram;zp===!0&&(fa=Ar(J,ee,le));let vy=!1,Jl=!1,Np=!1,Ai=fa.getUniforms(),ma=mt.uniforms;if(Z.useProgram(fa.program)&&(vy=!0,Jl=!0,Np=!0),J.id!==b&&(b=J.id,Jl=!0),vy||_!==O){if(Ai.setValue(U,"projectionMatrix",O.projectionMatrix),re.logarithmicDepthBuffer&&Ai.setValue(U,"logDepthBufFC",2/(Math.log(O.far+1)/Math.LN2)),_!==O&&(_=O,Jl=!0,Np=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let ur=Ai.map.cameraPosition;ur!==void 0&&ur.setValue(U,q.setFromMatrixPosition(O.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Ai.setValue(U,"isOrthographic",O.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||le.isSkinnedMesh)&&Ai.setValue(U,"viewMatrix",O.matrixWorldInverse)}if(le.isSkinnedMesh){Ai.setOptional(U,le,"bindMatrix"),Ai.setOptional(U,le,"bindMatrixInverse");let ur=le.skeleton;ur&&(re.floatVertexTextures?(ur.boneTexture===null&&ur.computeBoneTexture(),Ai.setValue(U,"boneTexture",ur.boneTexture,se),Ai.setValue(U,"boneTextureSize",ur.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 Up=oe.morphAttributes;if((Up.position!==void 0||Up.normal!==void 0||Up.color!==void 0&&re.isWebGL2===!0)&&ce.update(le,oe,J,fa),(Jl||mt.receiveShadow!==le.receiveShadow)&&(mt.receiveShadow=le.receiveShadow,Ai.setValue(U,"receiveShadow",le.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(ma.envMap.value=ht,ma.flipEnvMap.value=ht.isCubeTexture&&ht.isRenderTargetTexture===!1?-1:1),Jl&&(Ai.setValue(U,"toneMappingExposure",g.toneMappingExposure),mt.needsLights&&wE(ma,Np),ze&&J.fog===!0&&Re.refreshFogUniforms(ma,ze),Re.refreshMaterialUniforms(ma,J,T,C,H),Kd.upload(U,mt.uniformsList,ma,se)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Kd.upload(U,mt.uniformsList,ma,se),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Ai.setValue(U,"center",le.center),Ai.setValue(U,"modelViewMatrix",le.modelViewMatrix),Ai.setValue(U,"normalMatrix",le.normalMatrix),Ai.setValue(U,"modelMatrix",le.matrixWorld),le.previousModelViewMatrix&&Ai.setValue(U,"previousModelViewMatrix",le.previousModelViewMatrix),O.previousProjectionMatrix&&Ai.setValue(U,"previousProjectionMatrix",O.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let ur=J.uniformsGroups;for(let Fp=0,SE=ur.length;Fp<SE;Fp++)if(re.isWebGL2){let yy=ur[Fp];De.update(yy,fa),De.bind(yy,fa)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fa}function wE(O,ee){O.ambientLightColor.needsUpdate=ee,O.lightProbe.needsUpdate=ee,O.directionalLights.needsUpdate=ee,O.directionalLightShadows.needsUpdate=ee,O.pointLights.needsUpdate=ee,O.pointLightShadows.needsUpdate=ee,O.spotLights.needsUpdate=ee,O.spotLightShadows.needsUpdate=ee,O.rectAreaLights.needsUpdate=ee,O.hemisphereLights.needsUpdate=ee}function _E(O){return O.isMeshLambertMaterial||O.isMeshToonMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isShadowMaterial||O.isShaderMaterial&&O.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(O,ee,oe){ae.get(O.texture).__webglTexture=ee,ae.get(O.depthTexture).__webglTexture=oe;let J=ae.get(O);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=oe===void 0,J.__autoAllocateDepthBuffer||Q.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(O,ee){let oe=ae.get(O);oe.__webglFramebuffer=ee,oe.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(O,ee=0,oe=0){x=O,v=ee,y=oe;let J=!0,le=null,ze=!1,rt=!1;if(O){let ot=ae.get(O);ot.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):ot.__webglFramebuffer===void 0?se.setupRenderTarget(O):ot.__hasExternalTextures&&se.rebindTextures(O,ae.get(O.texture).__webglTexture,ae.get(O.depthTexture).__webglTexture);let ht=O.texture;(ht.isData3DTexture||ht.isDataArrayTexture||ht.isCompressedArrayTexture)&&(rt=!0);let Pt=ae.get(O).__webglFramebuffer;O.isWebGLCubeRenderTarget?(le=Pt[ee],ze=!0):re.isWebGL2&&O.samples>0&&se.useMultisampledRTT(O)===!1?le=ae.get(O).__webglMultisampledFramebuffer:le=Pt,A.copy(O.viewport),S.copy(O.scissor),w=O.scissorTest}else A.copy(L).multiplyScalar(T).floor(),S.copy(R).multiplyScalar(T).floor(),w=V;if(Z.bindFramebuffer(36160,le)&&re.drawBuffers&&J&&Z.drawBuffers(O,le),Z.viewport(A),Z.scissor(S),Z.setScissorTest(w),ze){let ot=ae.get(O.texture);U.framebufferTexture2D(36160,36064,34069+ee,ot.__webglTexture,oe)}else if(rt){let ot=ae.get(O.texture),ht=ee||0;U.framebufferTextureLayer(36160,36064,ot.__webglTexture,oe||0,ht)}b=-1},this.readRenderTargetPixels=function(O,ee,oe,J,le,ze,rt){if(!(O&&O.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=ae.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&rt!==void 0&&(ot=ot[rt]),ot){Z.bindFramebuffer(36160,ot);try{let ht=O.texture,Pt=ht.format,vt=ht.type;if(Pt!==Rr&&Ee.convert(Pt)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ft=vt===fl&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(vt!==Ni&&Ee.convert(vt)!==U.getParameter(35738)&&!(vt===xr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!ft){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=O.width-J&&oe>=0&&oe<=O.height-le&&U.readPixels(ee,oe,J,le,Ee.convert(Pt),Ee.convert(vt),ze)}finally{let ht=x!==null?ae.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,ht)}}},this.copyFramebufferToTexture=function(O,ee,oe=0){let J=Math.pow(2,-oe),le=Math.floor(ee.image.width*J),ze=Math.floor(ee.image.height*J);se.setTexture2D(ee,0),U.copyTexSubImage2D(3553,oe,0,0,O.x,O.y,le,ze),Z.unbindTexture()},this.copyTextureToTexture=function(O,ee,oe,J=0){let le=ee.image.width,ze=ee.image.height,rt=Ee.convert(oe.format),ot=Ee.convert(oe.type);se.setTexture2D(oe,0),U.pixelStorei(37440,oe.flipY),U.pixelStorei(37441,oe.premultiplyAlpha),U.pixelStorei(3317,oe.unpackAlignment),ee.isDataTexture?U.texSubImage2D(3553,J,O.x,O.y,le,ze,rt,ot,ee.image.data):ee.isCompressedTexture?U.compressedTexSubImage2D(3553,J,O.x,O.y,ee.mipmaps[0].width,ee.mipmaps[0].height,rt,ee.mipmaps[0].data):U.texSubImage2D(3553,J,O.x,O.y,rt,ot,ee.image),J===0&&oe.generateMipmaps&&U.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(O,ee,oe,J,le=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ze=O.max.x-O.min.x+1,rt=O.max.y-O.min.y+1,ot=O.max.z-O.min.z+1,ht=Ee.convert(J.format),Pt=Ee.convert(J.type),vt;if(J.isData3DTexture)se.setTexture3D(J,0),vt=32879;else if(J.isDataArrayTexture)se.setTexture2DArray(J,0),vt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,J.flipY),U.pixelStorei(37441,J.premultiplyAlpha),U.pixelStorei(3317,J.unpackAlignment);let ft=U.getParameter(3314),Di=U.getParameter(32878),dr=U.getParameter(3316),Hs=U.getParameter(3315),pa=U.getParameter(32877),$t=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;U.pixelStorei(3314,$t.width),U.pixelStorei(32878,$t.height),U.pixelStorei(3316,O.min.x),U.pixelStorei(3315,O.min.y),U.pixelStorei(32877,O.min.z),oe.isDataTexture||oe.isData3DTexture?U.texSubImage3D(vt,le,ee.x,ee.y,ee.z,ze,rt,ot,ht,Pt,$t.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(vt,le,ee.x,ee.y,ee.z,ze,rt,ot,ht,$t.data)):U.texSubImage3D(vt,le,ee.x,ee.y,ee.z,ze,rt,ot,ht,Pt,$t),U.pixelStorei(3314,ft),U.pixelStorei(32878,Di),U.pixelStorei(3316,dr),U.pixelStorei(3315,Hs),U.pixelStorei(32877,pa),le===0&&J.generateMipmaps&&U.generateMipmap(vt),Z.unbindTexture()},this.initTexture=function(O){O.isCubeTexture?se.setTextureCube(O,0):O.isData3DTexture?se.setTexture3D(O,0):O.isDataArrayTexture||O.isCompressedArrayTexture?se.setTexture2DArray(O,0):se.setTexture2D(O,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var GI=class extends rS{};GI.prototype.isWebGL1Renderer=!0;var sS=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 sS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Jn=class extends Mt{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}},VI=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Um,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Nr()}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=Nr()),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=Nr()),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}}},Fi=new M,Gm=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++)Fi.fromBufferAttribute(this,t),Fi.applyMatrix4(e),this.setXYZ(t,Fi.x,Fi.y,Fi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Fi.fromBufferAttribute(this,t),Fi.applyNormalMatrix(e),this.setXYZ(t,Fi.x,Fi.y,Fi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Fi.fromBufferAttribute(this,t),Fi.transformDirection(e),this.setXYZ(t,Fi.x,Fi.y,Fi.z);return this}setX(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Dt(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=fn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=fn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=fn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=fn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),i=Dt(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=Dt(t,this.array),i=Dt(i,this.array),r=Dt(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=Dt(t,this.array),i=Dt(i,this.array),r=Dt(r,this.array),s=Dt(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 Gm(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}}},nS=class extends Mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},pu=class extends ci{constructor(e=null,t=1,i=1,r,s,n,a,o,l=It,h=It,d,c){super(null,n,a,o,l,h,r,s,d,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},P1=new fe,HI=new fe,Pv=class{constructor(e=[],t=[]){this.uuid=Nr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new fe;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,n=e.length;s<n;s++){let a=e[s]?e[s].matrixWorld:HI;P1.multiplyMatrices(a,t[s]),P1.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Pv(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=V_(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new pu(t,e,e,Rr,xr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],n=t[s];n===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),n=new nS),this.bones.push(n),this.boneInverses.push(new fe().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let n=t[r];e.bones.push(n.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},WI=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}},oa=class extends yc{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}},D1=new M,I1=new M,L1=new fe,xf=new Il,ed=new _r,fu=class extends Mt{constructor(e=new qe,t=new oa){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++)D1.fromBufferAttribute(t,r-1),I1.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=D1.distanceTo(I1);e.setAttribute("lineDistance",new Le(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(),ed.copy(i.boundingSphere),ed.applyMatrix4(r),ed.radius+=s,e.ray.intersectsSphere(ed)===!1)return;L1.copy(r).invert(),xf.copy(e.ray).applyMatrix4(L1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new M,h=new M,d=new M,c=new M,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=u){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),xf.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 g=Math.max(0,n.start),m=Math.min(f.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=u){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),xf.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}}}}},O1=new M,B1=new M,bc=class extends fu{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)O1.fromBufferAttribute(t,r),B1.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+O1.distanceTo(B1);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},qI=class extends ci{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:st,this.magFilter=s!==void 0?s:st,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)}},ks=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 F:new M);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 M,r=[],s=[],n=[],a=new M,o=new fe;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new M)}s[0]=new M,n[0]=new M;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(hi(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(hi(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}},np=class extends ks{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 F,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}},XI=class extends np{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function Dv(){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 td=new M,bf=new Dv,wf=new Dv,_f=new Dv,YI=class extends ks{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 M){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]:(td.subVectors(r[0],r[1]).add(r[0]),l=td);let d=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(td.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=td),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),g=Math.pow(c.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),bf.initNonuniformCatmullRom(l.x,d.x,c.x,h.x,p,f,g),wf.initNonuniformCatmullRom(l.y,d.y,c.y,h.y,p,f,g),_f.initNonuniformCatmullRom(l.z,d.z,c.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(bf.initCatmullRom(l.x,d.x,c.x,h.x,this.tension),wf.initCatmullRom(l.y,d.y,c.y,h.y,this.tension),_f.initCatmullRom(l.z,d.z,c.z,h.z,this.tension));return i.set(bf.calc(o),wf.calc(o),_f.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 M().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function R1(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 QI(e,t){let i=1-e;return i*i*t}function ZI(e,t){return 2*(1-e)*e*t}function KI(e,t){return e*e*t}function kh(e,t,i,r){return QI(e,t)+ZI(e,i)+KI(e,r)}function JI(e,t){let i=1-e;return i*i*i*t}function $I(e,t){let i=1-e;return 3*i*i*e*t}function eL(e,t){return 3*(1-e)*e*e*t}function tL(e,t){return e*e*e*t}function jh(e,t,i,r,s){return JI(e,t)+$I(e,i)+eL(e,r)+tL(e,s)}var $r=class extends ks{constructor(e=new F,t=new F,i=new F,r=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(jh(e,r.x,s.x,n.x,a.x),jh(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}},Jd=class extends ks{constructor(e=new M,t=new M,i=new M,r=new M){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(jh(e,r.x,s.x,n.x,a.x),jh(e,r.y,s.y,n.y,a.y),jh(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}},ss=class extends ks{constructor(e=new F,t=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new F){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 F;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}},aS=class extends ks{constructor(e=new M,t=new M){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new M){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}},sa=class extends ks{constructor(e=new F,t=new F,i=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(kh(e,r.x,s.x,n.x),kh(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}},iL=class extends ks{constructor(e=new M,t=new M,i=new M){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(kh(e,r.x,s.x,n.x),kh(e,r.y,s.y,n.y),kh(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}},Iv=class extends ks{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new F){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(R1(a,o.x,l.x,h.x,d.x),R1(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 F().fromArray(r))}return this}},rL=Object.freeze({__proto__:null,ArcCurve:XI,CatmullRomCurve3:YI,CubicBezierCurve:$r,CubicBezierCurve3:Jd,EllipseCurve:np,LineCurve:ss,LineCurve3:aS,QuadraticBezierCurve:sa,QuadraticBezierCurve3:iL,SplineCurve:Iv}),oS=class extends ks{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 ss(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 rL[r.type]().fromJSON(r))}return this}},mu=class extends oS{constructor(e){super(),this.type="Path",this.currentPoint=new F,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 ss(this.currentPoint.clone(),new F(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new sa(this.currentPoint.clone(),new F(e,t),new F(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new $r(this.currentPoint.clone(),new F(e,t),new F(i,r),new F(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Iv(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 np(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}},lS=class extends qe{constructor(e=[new F(0,-.5),new F(.5,0),new F(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=hi(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,d=new M,c=new F,u=new M,p=new M,f=new M,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*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:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*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),b=Math.cos(y);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*x,d.y=e[_].y,d.z=e[_].x*b,n.push(d.x,d.y,d.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let A=o[3*_+0]*x,S=o[3*_+1],w=o[3*_+0]*b;l.push(A,S,w)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,_=x+e.length,A=x+e.length+1,S=x+1;s.push(b,_,S),s.push(A,S,_)}this.setIndex(s),this.setAttribute("position",new Le(n,3)),this.setAttribute("uv",new Le(a,2)),this.setAttribute("normal",new Le(l,3))}static fromJSON(e){return new lS(e.points,e.segments,e.phiStart,e.phiLength)}},Lv=class extends qe{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=[],g=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Le(d,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(u,2));function v(){let x=new M,b=new M,_=0,A=(t-e)/i;for(let S=0;S<=s;S++){let w=[],E=S/s,C=E*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,P=D*o+a,L=Math.sin(P),R=Math.cos(P);b.x=C*L,b.y=-E*i+g,b.z=C*R,d.push(b.x,b.y,b.z),x.set(L,A,R).normalize(),c.push(x.x,x.y,x.z),u.push(D,1-E),w.push(p++)}f.push(w)}for(let S=0;S<r;S++)for(let w=0;w<s;w++){let E=f[w][S],C=f[w+1][S],T=f[w+1][S+1],D=f[w][S+1];h.push(E,C,D),h.push(C,T,D),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let b=p,_=new F,A=new M,S=0,w=x===!0?e:t,E=x===!0?1:-1;for(let T=1;T<=r;T++)d.push(0,g*E,0),c.push(0,E,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+a,P=Math.cos(D),L=Math.sin(D);A.x=w*L,A.y=g*E,A.z=w*P,d.push(A.x,A.y,A.z),c.push(0,E,0),_.x=P*.5+.5,_.y=L*.5*E+.5,u.push(_.x,_.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),S+=3}l.addGroup(m,S,x===!0?1:2),m+=S}}static fromJSON(e){return new Lv(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},hS=class extends Lv{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 hS(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ov=class extends qe{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 Le(s,3)),this.setAttribute("normal",new Le(s.slice(),3)),this.setAttribute("uv",new Le(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new M,x=new M,b=new M;for(let _=0;_<t.length;_+=3)u(t[_+0],y),u(t[_+1],x),u(t[_+2],b),o(y,x,b,v)}function o(v,y,x,b){let _=b+1,A=[];for(let S=0;S<=_;S++){A[S]=[];let w=v.clone().lerp(x,S/_),E=y.clone().lerp(x,S/_),C=_-S;for(let T=0;T<=C;T++)T===0&&S===_?A[S][T]=w:A[S][T]=w.clone().lerp(E,T/C)}for(let S=0;S<_;S++)for(let w=0;w<2*(_-S)-1;w++){let E=Math.floor(w/2);w%2===0?(c(A[S][E+1]),c(A[S+1][E]),c(A[S][E])):(c(A[S][E+1]),c(A[S+1][E+1]),c(A[S+1][E]))}}function l(v){let y=new M;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 M;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=g(v)/2/Math.PI+.5,b=m(v)/Math.PI+.5;n.push(x,1-b)}p(),d()}function d(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],b=n[v+4],_=Math.max(y,x,b),A=Math.min(y,x,b);_>.9&&A<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),b<.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 M,y=new M,x=new M,b=new M,_=new F,A=new F,S=new F;for(let w=0,E=0;w<s.length;w+=9,E+=6){v.set(s[w+0],s[w+1],s[w+2]),y.set(s[w+3],s[w+4],s[w+5]),x.set(s[w+6],s[w+7],s[w+8]),_.set(n[E+0],n[E+1]),A.set(n[E+2],n[E+3]),S.set(n[E+4],n[E+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=g(b);f(_,E+0,v,C),f(A,E+2,y,C),f(S,E+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=b/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Ov(e.vertices,e.indices,e.radius,e.details)}},cS=class extends Ov{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 cS(e.radius,e.detail)}},gu=class extends mu{constructor(e){super(e),this.uuid=Nr(),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 mu().fromJSON(r))}return this}},sL={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=dS(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=hL(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 tc(n,a,i,o,l,p,0),a}};function dS(e,t,i,r,s){let n,a;if(s===bL(e,t,i,r)>0)for(n=t;n<i;n+=r)a=z1(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=z1(n,e[n],e[n+1],a);return a&&ap(a,a.next)&&(rc(a),a=a.next),a}function Ya(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(ap(i,i.next)||Ft(i.prev,i,i.next)===0)){if(rc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function tc(e,t,i,r,s,n,a){if(!e)return;!a&&n&&fL(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?aL(e,r,s,n):nL(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),rc(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=oL(Ya(e),t,i),tc(e,t,i,r,s,n,2)):a===2&&lL(e,t,i,r,s,n):tc(Ya(e),t,i,r,s,n,1);break}}}function nL(e){let t=e.prev,i=e,r=e.next;if(Ft(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&&Yo(s,o,n,l,a,h,f.x,f.y)&&Ft(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function aL(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Ft(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,g=o>l?o>h?o:h:l>h?l:h,m=d>c?d>u?d:u:c>u?c:u,v=Vm(p,f,t,i,r),y=Vm(g,m,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Yo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Yo(o,d,l,c,h,u,b.x,b.y)&&Ft(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Yo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Yo(o,d,l,c,h,u,b.x,b.y)&&Ft(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function oL(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!ap(s,n)&&uS(s,r,r.next,n)&&ic(s,n)&&ic(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),rc(r),rc(r.next),r=e=n),r=r.next}while(r!==e);return Ya(r)}function lL(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&vL(a,o)){let l=pS(a,o);a=Ya(a,a.next),l=Ya(l,l.next),tc(a,t,i,r,s,n,0),tc(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function hL(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=dS(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(gL(h));for(s.sort(cL),n=0;n<s.length;n++)i=dL(s[n],i);return i}function cL(e,t){return e.x-t.x}function dL(e,t){let i=uL(e,t);if(!i)return t;let r=pS(i,e);return Ya(r,r.next),Ya(i,i.next)}function uL(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&&Yo(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),ic(i,e)&&(c<d||c===d&&(i.x>s.x||i.x===s.x&&pL(s,i)))&&(s=i,d=c)),i=i.next;while(i!==o);return s}function pL(e,t){return Ft(e.prev,e,t.prev)<0&&Ft(t.next,e,e.next)<0}function fL(e,t,i,r){let s=e;do s.z===0&&(s.z=Vm(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,mL(s)}function mL(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 Vm(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 gL(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 Yo(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 vL(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!yL(e,t)&&(ic(e,t)&&ic(t,e)&&xL(e,t)&&(Ft(e.prev,e,t.prev)||Ft(e,t.prev,t))||ap(e,t)&&Ft(e.prev,e,e.next)>0&&Ft(t.prev,t,t.next)>0)}function Ft(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ap(e,t){return e.x===t.x&&e.y===t.y}function uS(e,t,i,r){let s=rd(Ft(e,t,i)),n=rd(Ft(e,t,r)),a=rd(Ft(i,r,e)),o=rd(Ft(i,r,t));return!!(s!==n&&a!==o||s===0&&id(e,i,t)||n===0&&id(e,r,t)||a===0&&id(i,e,r)||o===0&&id(i,t,r))}function id(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 rd(e){return e>0?1:e<0?-1:0}function yL(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&&uS(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function ic(e,t){return Ft(e.prev,e,e.next)<0?Ft(e,t,e.next)>=0&&Ft(e,e.prev,t)>=0:Ft(e,t,e.prev)<0||Ft(e,e.next,t)<0}function xL(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 pS(e,t){let i=new Hm(e.i,e.x,e.y),r=new Hm(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 z1(e,t,i,r){let s=new Hm(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 rc(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 Hm(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 bL(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 fS=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 fS.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];N1(e),U1(i,e);let n=e.length;t.forEach(N1);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,U1(i,t[o]);let a=sL.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function N1(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function U1(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var mS=class extends Ov{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 mS(e.radius,e.detail)}},Bv=class extends qe{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 M,c=new M,u=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&n==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let _=b/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),g.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],b=h[m+1][v],_=h[m+1][v+1];(m!==0||n>0)&&u.push(y,x,_),(m!==i-1||o<Math.PI)&&u.push(x,b,_)}this.setIndex(u),this.setAttribute("position",new Le(p,3)),this.setAttribute("normal",new Le(f,3)),this.setAttribute("uv",new Le(g,2))}static fromJSON(e){return new Bv(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},gS=class extends qe{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 M,c=new M,u=new M,p=new M,f=new M,g=new M,m=new M;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),g.subVectors(p,u),m.addVectors(p,u),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let b=0;b<=r;++b){let _=b/r*Math.PI*2,A=-t*Math.cos(_),S=t*Math.sin(_);d.x=u.x+(A*m.x+S*f.x),d.y=u.y+(A*m.y+S*f.y),d.z=u.z+(A*m.z+S*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(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),A=(r+1)*y+x,S=(r+1)*(y-1)+x;a.push(b,_,S),a.push(_,A,S)}this.setIndex(a),this.setAttribute("position",new Le(o,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(h,2));function v(y,x,b,_,A){let S=Math.cos(y),w=Math.sin(y),E=b/x*y,C=Math.cos(E);A.x=_*(2+C)*.5*S,A.y=_*(2+C)*w*.5,A.z=_*Math.sin(E)*.5}}static fromJSON(e){return new gS(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Dn(e,t,i){return vS(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function sd(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 vS(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function wL(e){function t(s,n){return e[s]-e[n]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function F1(e,t,i){let r=e.length,s=new e.constructor(r);for(let n=0,a=0;a!==r;++n){let o=i[n]*t;for(let l=0;l!==t;++l)s[a++]=e[o+l]}return s}function yS(e,t,i,r){let s=1,n=e[0];for(;n!==void 0&&n[r]===void 0;)n=e[s++];if(n===void 0)return;let a=n[r];if(a!==void 0)if(Array.isArray(a))do a=n[r],a!==void 0&&(t.push(n.time),i.push.apply(i,a)),n=e[s++];while(n!==void 0);else if(a.toArray!==void 0)do a=n[r],a!==void 0&&(t.push(n.time),a.toArray(i,i.length)),n=e[s++];while(n!==void 0);else do a=n[r],a!==void 0&&(t.push(n.time),i.push(a)),n=e[s++];while(n!==void 0)}var op=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];e:{t:{let n;i:{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 t}n=t.length;break i}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 t}n=i,i=0;break i}break e}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_(){}},_L=class extends op{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:Ho,endingEnd:Ho}}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 Wo:s=e,a=2*t-i;break;case hu: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 Wo:n=e,o=2*i-t;break;case hu: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,g=f*p,m=-c*g+2*c*f-c*p,v=(1+c)*g+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-u)*g+(1.5+u)*f+.5*p,x=u*g-u*f;for(let b=0;b!==a;++b)s[b]=m*n[h+b]+v*n[l+b]+y*n[o+b]+x*n[d+b];return s}},xS=class extends op{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}},SL=class extends op{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},js=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=sd(t,this.TimeBufferType),this.values=sd(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:sd(e.times,Array),values:sd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new SL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new _L(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ou:t=this.InterpolantFactoryMethodDiscrete;break;case lu:t=this.InterpolantFactoryMethodLinear;break;case qp: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 ou;case this.InterpolantFactoryMethodLinear:return lu;case this.InterpolantFactoryMethodSmooth:return qp}}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=Dn(i,s,n),this.values=Dn(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&&vS(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=Dn(this.times),t=Dn(this.values),i=this.getValueSize(),r=this.getInterpolation()===qp,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=Dn(e,0,n),this.values=Dn(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=Dn(this.times,0),t=Dn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};js.prototype.TimeBufferType=Float32Array;js.prototype.ValueBufferType=Float32Array;js.prototype.DefaultInterpolation=lu;var Rl=class extends js{};Rl.prototype.ValueTypeName="bool";Rl.prototype.ValueBufferType=Array;Rl.prototype.DefaultInterpolation=ou;Rl.prototype.InterpolantFactoryMethodLinear=void 0;Rl.prototype.InterpolantFactoryMethodSmooth=void 0;var bS=class extends js{};bS.prototype.ValueTypeName="color";var vu=class extends js{};vu.prototype.ValueTypeName="number";var AL=class extends op{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)it.slerpFlat(s,0,n,l-a,n,l,o);return s}},wc=class extends js{InterpolantFactoryMethodLinear(e){return new AL(this.times,this.values,this.getValueSize(),e)}};wc.prototype.ValueTypeName="quaternion";wc.prototype.DefaultInterpolation=lu;wc.prototype.InterpolantFactoryMethodSmooth=void 0;var zl=class extends js{};zl.prototype.ValueTypeName="string";zl.prototype.ValueBufferType=Array;zl.prototype.DefaultInterpolation=ou;zl.prototype.InterpolantFactoryMethodLinear=void 0;zl.prototype.InterpolantFactoryMethodSmooth=void 0;var yu=class extends js{};yu.prototype.ValueTypeName="vector";var Wm=class{constructor(e,t=-1,i,r=_v){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Nr(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let n=0,a=i.length;n!==a;++n)t.push(EL(i[n]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,n=i.length;s!==n;++s)t.push(js.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,n=[];for(let a=0;a<s;a++){let o=[],l=[];o.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let h=wL(o);o=F1(o,1,h),l=F1(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),n.push(new vu(".morphTargetInfluences["+t[a].name+"]",o,l).scale(1/i))}return new this(e,-1,n)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){let l=e[a],h=l.name.match(s);if(h&&h.length>1){let d=h[1],c=r[d];c||(r[d]=c=[]),c.push(l)}}let n=[];for(let a in r)n.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return n}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,d,c,u,p){if(c.length!==0){let f=[],g=[];yS(c,f,g,u),f.length!==0&&p.push(new h(d,f,g))}},r=[],s=e.name||"default",n=e.fps||30,a=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let c={},u;for(u=0;u<d.length;u++)if(d[u].morphTargets)for(let p=0;p<d[u].morphTargets.length;p++)c[d[u].morphTargets[p]]=-1;for(let p in c){let f=[],g=[];for(let m=0;m!==d[u].morphTargets.length;++m){let v=d[u];f.push(v.time),g.push(v.morphTarget===p?1:0)}r.push(new vu(".morphTargetInfluence["+p+"]",f,g))}o=c.length*n}else{let c=".bones["+t[h].name+"]";i(yu,c+".position",d,"pos",r),i(wc,c+".quaternion",d,"rot",r),i(yu,c+".scale",d,"scl",r)}}return r.length===0?null:new this(s,o,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function ML(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return vu;case"vector":case"vector2":case"vector3":case"vector4":return yu;case"color":return bS;case"quaternion":return wc;case"bool":case"boolean":return Rl;case"string":return zl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function EL(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ML(e.type);if(e.times===void 0){let i=[],r=[];yS(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var k1={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={}}},wS=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}}},CL=new wS,Rv=class{constructor(e){this.manager=e!==void 0?e:CL,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}},Zs={},TL=class extends Error{constructor(e,t){super(e),this.response=t}},qm=class extends Rv{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=k1.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Zs[e]!==void 0){Zs[e].push({onLoad:t,onProgress:i,onError:r});return}Zs[e]=[],Zs[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=Zs[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,g=new ReadableStream({start(m){v();function v(){d.read().then(({done:y,value:x})=>{if(y)m.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let _=0,A=h.length;_<A;_++){let S=h[_];S.onProgress&&S.onProgress(b)}m.enqueue(x),v()}})}}});return new Response(g)}else throw new TL(`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=>{k1.add(e,l);let h=Zs[e];delete Zs[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=Zs[e];if(h===void 0)throw this.manager.itemError(e),l;delete Zs[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}},_c=class extends Mt{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}},PL=class extends _c{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Sf=new fe,j1=new M,G1=new M,zv=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ev,this._frameExtents=new F(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;j1.setFromMatrixPosition(e.matrixWorld),t.position.copy(j1),G1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(G1),t.updateMatrixWorld(),Sf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sf),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Sf)}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}},DL=class extends zv{constructor(){super(new Oi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ec*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}},IL=class extends _c{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(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new DL}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}},V1=new fe,ah=new M,Af=new M,LL=class extends zv{constructor(){super(new Oi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(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 M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(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()),ah.setFromMatrixPosition(e.matrixWorld),i.position.copy(ah),Af.copy(i.position),Af.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Af),i.updateMatrixWorld(),r.makeTranslation(-ah.x,-ah.y,-ah.z),V1.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(V1)}},OL=class extends _c{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 LL}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}},BL=class extends zv{constructor(){super(new Cv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},RL=class extends _c{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.shadow=new BL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},zL=class extends qe{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}},_S=class extends Rv{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new qm(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),g=Rc(p.type,f),m=new VI(g,p.stride);return m.uuid=p.uuid,t[u]=m,m}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 zL:new qe,a=e.data.index;if(a!==void 0){let c=Rc(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 Gm(f,u.itemSize,u.offset,u.normalized)}else{let f=Rc(u.type,u.array),g=u.isInstancedBufferAttribute?WI:Ye;p=new g(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,g=u.length;f<g;f++){let m=u[f],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new Gm(y,m.itemSize,m.offset,m.normalized)}else{let y=Rc(m.type,m.array);v=new Ye(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.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 M;d.center!==void 0&&c.fromArray(d.center),n.boundingSphere=new _r(c,d.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},NL=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=H1(),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=H1();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function H1(){return(typeof performance>"u"?Date:performance).now()}var UL=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,n;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,n=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,n=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,n=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=n,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,n=this.cumulativeWeight;if(n===0){for(let a=0;a!==r;++a)i[s+a]=i[a];n=t}else{n+=t;let a=t/n;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=n}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,n=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}n>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,n=r;s!==n;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let n=0;n!==s;++n)e[t+n]=e[i+n]}_slerp(e,t,i,r){it.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let n=this._workIndex*s;it.multiplyQuaternionsFlat(e,n,e,t,e,i),it.slerpFlat(e,t,e,t,e,n,r)}_lerp(e,t,i,r,s){let n=1-r;for(let a=0;a!==s;++a){let o=t+a;e[o]=e[o]*n+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let n=0;n!==s;++n){let a=t+n;e[a]=e[a]+e[i+n]*r}}},Nv="\\[\\]\\.:\\/",FL=new RegExp("["+Nv+"]","g"),Uv="[^"+Nv+"]",kL="[^"+Nv.replace("\\.","")+"]",jL=/((?:WC+[\/:])*)/.source.replace("WC",Uv),GL=/(WCOD+)?/.source.replace("WCOD",kL),VL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Uv),HL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Uv),WL=new RegExp("^"+jL+GL+VL+HL+"$"),qL=["material","materials","bones","map"],XL=class{constructor(e,t,i){let r=i||Ct.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()}},Ct=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Ct.parseTrackName(t),this.node=Ct.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 Ct.Composite(e,t,i):new Ct(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(FL,"")}static parseTrackName(e){let t=WL.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);qL.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=Ct.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}};Ct.Composite=XL;Ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ct.prototype.GetterByBindingType=[Ct.prototype._getValue_direct,Ct.prototype._getValue_array,Ct.prototype._getValue_arrayElement,Ct.prototype._getValue_toArray];Ct.prototype.SetterByBindingTypeAndVersioning=[[Ct.prototype._setValue_direct,Ct.prototype._setValue_direct_setNeedsUpdate,Ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_array,Ct.prototype._setValue_array_setNeedsUpdate,Ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_arrayElement,Ct.prototype._setValue_arrayElement_setNeedsUpdate,Ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_fromArray,Ct.prototype._setValue_fromArray_setNeedsUpdate,Ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var YL=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,n=s.length,a=new Array(n),o={endingStart:Ho,endingEnd:Ho};for(let l=0;l!==n;++l){let h=s[l].createInterpolant(null);a[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=j_,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,n=s/r,a=r/s;e.warp(1,n,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,n=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let o=a.parameterPositions,l=a.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/n,l[1]=t/n,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let n=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case TC:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(n),l[h].accumulateAdditive(a);break;case _v:default:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(n),l[h].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,n=i===wv;if(e===0)return s===-1?r:n&&(s&1)===1?t-r:r;if(i===k_){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,n)}else this._setEndings(!1,!1,n);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(n&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Wo,r.endingEnd=Wo):(e?r.endingStart=this.zeroSlopeAtStart?Wo:Ho:r.endingStart=hu,t?r.endingEnd=this.zeroSlopeAtEnd?Wo:Ho:r.endingEnd=hu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,n=this._weightInterpolant;n===null&&(n=r._lendControlInterpolant(),this._weightInterpolant=n);let a=n.parameterPositions,o=n.sampleValues;return a[0]=s,o[0]=t,a[1]=s+e,o[1]=i,this}},QL=new Float32Array(1),ZL=class extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,n=e._propertyBindings,a=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let d=0;d!==s;++d){let c=r[d],u=c.name,p=h[u];if(p!==void 0)++p.referenceCount,n[d]=p;else{if(p=n[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[d].binding.parsedPath;p=new UL(Ct.create(i,u,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),n[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,n=s[t];if(n===void 0)n={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=n;else{let a=n.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),n.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,n=this._actionsByClip,a=n[s],o=a.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let d=a.actionByRoot,c=(e._localRoot||this._root).uuid;delete d[c],o.length===0&&delete n[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,n=r[t];n===void 0&&(n={},r[t]=n),n[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,n=this._bindingsByRootAndName,a=n[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete a[s],Object.keys(a).length===0&&delete n[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new xS(new Float32Array(2),new Float32Array(2),1,QL),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,n=typeof e=="string"?Wm.findByName(r,e):e,a=n!==null?n.uuid:e,o=this._actionsByClip[a],l=null;if(i===void 0&&(n!==null?i=n.blendMode:i=_v),o!==void 0){let d=o.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=o.knownActions[0],n===null&&(n=l._clip)}if(n===null)return null;let h=new YL(this,n,t,i);return this._bindAction(h,l),this._addInactiveAction(h,a,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Wm.findByName(i,e):e,n=s?s.uuid:e,a=this._actionsByClip[n];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),n=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,n);let a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(n);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let n=s.knownActions;for(let a=0,o=n.length;a!==o;++a){let l=n[a];this._deactivateAction(l);let h=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=h,t[h]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let n in i){let a=i[n].actionByRoot,o=a[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let n in s){let a=s[n];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},pe=class{constructor(e){this.value=e}clone(){return new pe(this.value.clone===void 0?this.value:this.value.clone())}},SS=class{constructor(e,t,i=0,r=1/0){this.ray=new Il(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Av,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 Xm(e,this,i,t),i.sort(W1),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Xm(e[r],this,i,t);return i.sort(W1),i}};function W1(e,t){return e.distance-t.distance}function Xm(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++)Xm(s[n],t,i,!0)}}var q1=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(hi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},X1=new F,KL=class{constructor(e=new F(1/0,1/0),t=new F(-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=X1.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 X1.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)}},Y1=new M,nd=new M,Ur=class{constructor(e=new M,t=new M){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){Y1.subVectors(e,this.start),nd.subVectors(this.end,this.start);let i=nd.dot(nd),r=nd.dot(Y1)/i;return t&&(r=hi(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)}},Q1=new M,JL=class extends Mt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new qe,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 Le(r,3));let s=new oa({fog:!1,toneMapped:!1});this.cone=new bc(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),Q1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Q1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},$L=class extends ir{constructor(e,t,i){let r=new Bv(t,4,2),s=new xc({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)}},Z1=new M,ad=new M,K1=new M,eO=class extends Mt{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 qe;r.setAttribute("position",new Le([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new oa({fog:!1,toneMapped:!1});this.lightPlane=new fu(r,s),this.add(this.lightPlane),r=new qe,r.setAttribute("position",new Le([0,0,0,0,0,1],3)),this.targetLine=new fu(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),Z1.setFromMatrixPosition(this.light.matrixWorld),ad.setFromMatrixPosition(this.light.target.matrixWorld),K1.subVectors(ad,Z1),this.lightPlane.lookAt(ad),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(ad),this.targetLine.scale.z=K1.length()}},od=new M,kt=new Ol,xu=class extends bc{constructor(e){let t=new qe,i=new oa({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 Le(r,3)),t.setAttribute("color",new Le(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;kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Wt("c",t,e,kt,0,0,-1),Wt("t",t,e,kt,0,0,1),Wt("n1",t,e,kt,-i,-r,-1),Wt("n2",t,e,kt,i,-r,-1),Wt("n3",t,e,kt,-i,r,-1),Wt("n4",t,e,kt,i,r,-1),Wt("f1",t,e,kt,-i,-r,1),Wt("f2",t,e,kt,i,-r,1),Wt("f3",t,e,kt,-i,r,1),Wt("f4",t,e,kt,i,r,1),Wt("u1",t,e,kt,i*.7,r*1.1,-1),Wt("u2",t,e,kt,-i*.7,r*1.1,-1),Wt("u3",t,e,kt,0,r*2,-1),Wt("cf1",t,e,kt,-i,0,1),Wt("cf2",t,e,kt,i,0,1),Wt("cf3",t,e,kt,0,-r,1),Wt("cf4",t,e,kt,0,r,1),Wt("cn1",t,e,kt,-i,0,-1),Wt("cn2",t,e,kt,i,0,-1),Wt("cn3",t,e,kt,0,-r,-1),Wt("cn4",t,e,kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Wt(e,t,i,r,s,n,a){od.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],od.x,od.y,od.z)}}var bu=class extends bc{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 qe;s.setIndex(new Ye(i,1)),s.setAttribute("position",new Le(r,3)),super(s,new oa({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()}},tO=class extends bc{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 qe;r.setAttribute("position",new Le(t,3)),r.setAttribute("color",new Le(i,3));let s=new oa({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:Dl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dl);var oh=".",Fv=Symbol("target"),AS=Symbol("unsubscribe");function Ym(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function iO(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Cs=Array.isArray;function kv(e){return typeof e=="symbol"}var rO={after:(e,t)=>Cs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Cs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=oh),kv(t)?e+t.toString():e+t):e,initial:e=>{if(Cs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(oh);return t===-1?"":e.slice(0,t)},last:e=>{if(Cs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(oh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Cs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(oh);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(oh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Lr=rO;function sO(e){return typeof e=="object"&&typeof e.next=="function"}function nO(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[Fv].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 J1(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&kv(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var aO=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,Lr.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 Qm(e){return toString.call(e)==="[object Object]"}function ld(){return!0}function _o(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var MS=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),oO=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),ES={push:ld,pop:ld,shift:ld,unshift:ld,copyWithin:_o,reverse:_o,sort:_o,splice:_o,flat:_o,fill:_o},lO=new Set([...MS,...oO,...Object.keys(ES)]);function hd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var CS=["keys","values","entries"],TS=new Set(["has","toString"]),PS={add:hd,clear:hd,delete:hd,forEach:hd},hO=new Set([...TS,...Object.keys(PS),...CS]);function cd(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 cO=new Set([...TS,"get"]),DS={set:cd,clear:cd,delete:cd,forEach:cd},dO=new Set([...cO,...Object.keys(DS),...CS]),na=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 MS.has(e)}_shallowClone(e){let t=e;if(Qm(e))t={...e};else if(Cs(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?(Cs(r)?this._onIsChanged=ES[t]:r instanceof Set?this._onIsChanged=PS[t]:r instanceof Map&&(this._onIsChanged=DS[t]),r):i}update(e,t,i){let r=Lr.after(e,this._path);if(t!=="length"){let s=this.clone;Lr.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],Lr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},$1=class extends na{static isHandledMethod(e){return lO.has(e)}},uO=class extends na{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},ex=class extends na{static isHandledMethod(e){return hO.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)}},tx=class extends na{static isHandledMethod(e){return dO.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)}},pO=class extends na{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)}},fO=class extends na{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)}},ko=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Qm(e)||Cs(e)||Ym(e)}static isHandledMethod(e,t){return Qm(e)?na.isHandledMethod(t):Cs(e)?$1.isHandledMethod(t):e instanceof Set?ex.isHandledMethod(t):e instanceof Map?tx.isHandledMethod(t):Ym(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=na;Cs(e)?r=$1:e instanceof Date?r=uO:e instanceof Set?r=ex:e instanceof Map?r=tx:e instanceof WeakSet?r=pO:e instanceof WeakMap&&(r=fO),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=ko.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}},mO={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},jv=(e,t,i={})=>{i={...mO,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new aO(s),h=typeof i.onValidate=="function",d=new ko(h),c=(y,x,b,_,A)=>!h||d.isCloning||i.onValidate(Lr.concat(l.getPath(y),x),b,_,A)===!0,u=(y,x,b,_)=>{!J1(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,b,_)},p=(y,x,b,_,A)=>{d.isCloning?d.update(y,x,_):t(Lr.concat(y,x),b,_,A)},f=y=>y&&(y[r]||y),g=(y,x,b,_)=>iO(y)||b==="constructor"||n&&!ko.isHandledMethod(x,b)||J1(l,i,b)||l.isGetInvariant(x,b)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,Lr.concat(_,b),m,r)),m={get(y,x,b){if(kv(x)){if(x===r||x===Fv)return y;if(x===AS&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=Ym(y)?Reflect.get(y,x):Reflect.get(y,x,b);return g(_,y,x)},set(y,x,b,_){b=f(b);let A=y[r]||y,S=A[x];if(s(S,b)&&x in y)return!0;let w=c(y,x,b,S);return w&&l.setProperty(A,x,b,_,S)?(u(y,x,y[x],S),!0):!w},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let _=y[x];c(y,x,b.value,_)&&l.defineProperty(y,x,b,_)&&u(y,x,b.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),_=c(y,x,void 0,b);return _&&l.deleteProperty(y,x,b)?(u(y,x,void 0,b),!0):!_},apply(y,x,b){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,b);if((o===!1||o!==!0&&!o.includes(y.name))&&ko.isHandledType(_)){let A=Lr.initial(l.getPath(y)),S=ko.isHandledMethod(_,y.name);d.start(_,A,b);let w=Reflect.apply(y,d.preferredThisArg(y,x,_),S?b.map(T=>f(T)):b),E=d.isChanged(_,s),C=d.stop();if(ko.isHandledType(w)&&S&&(x instanceof Map&&y.name==="get"&&(A=Lr.concat(A,b[0])),w=l.getProxy(w,A,m)),E){let T={name:y.name,args:b,result:w},D=d.isCloning?Lr.initial(A):A,P=d.isCloning?Lr.last(A):"";c(Lr.get(e,D),P,_,C,T)?p(D,P,_,C,T):d.undo(_)}return(x instanceof Map||x instanceof Set)&&sO(w)?nO(w,y,x,A,g):w}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};jv.target=e=>e&&e[Fv]||e;jv.unsubscribe=e=>e[AS]||e;var ix=jv,gO=typeof global=="object"&&global&&global.Object===Object&&global,IS=gO,vO=typeof self=="object"&&self&&self.Object===Object&&self,yO=IS||vO||Function("return this")(),os=yO,xO=os.Symbol,kr=xO,LS=Object.prototype,bO=LS.hasOwnProperty,wO=LS.toString,lh=kr?kr.toStringTag:void 0;function _O(e){var t=bO.call(e,lh),i=e[lh];try{e[lh]=void 0;var r=!0}catch{}var s=wO.call(e);return r&&(t?e[lh]=i:delete e[lh]),s}var SO=_O,AO=Object.prototype,MO=AO.toString;function EO(e){return MO.call(e)}var CO=EO,TO="[object Null]",PO="[object Undefined]",rx=kr?kr.toStringTag:void 0;function DO(e){return e==null?e===void 0?PO:TO:rx&&rx in Object(e)?SO(e):CO(e)}var Ja=DO;function IO(e){return e!=null&&typeof e=="object"}var bn=IO,LO="[object Symbol]";function OO(e){return typeof e=="symbol"||bn(e)&&Ja(e)==LO}var lp=OO;function BO(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 OS=BO,RO=Array.isArray,zs=RO,zO=1/0,sx=kr?kr.prototype:void 0,nx=sx?sx.toString:void 0;function BS(e){if(typeof e=="string")return e;if(zs(e))return OS(e,BS)+"";if(lp(e))return nx?nx.call(e):"";var t=e+"";return t=="0"&&1/e==-zO?"-0":t}var NO=BS,UO=/\s/;function FO(e){for(var t=e.length;t--&&UO.test(e.charAt(t)););return t}var kO=FO,jO=/^\s+/;function GO(e){return e&&e.slice(0,kO(e)+1).replace(jO,"")}var VO=GO;function HO(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var as=HO,ax=0/0,WO=/^[-+]0x[0-9a-f]+$/i,qO=/^0b[01]+$/i,XO=/^0o[0-7]+$/i,YO=parseInt;function QO(e){if(typeof e=="number")return e;if(lp(e))return ax;if(as(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=as(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=VO(e);var i=qO.test(e);return i||XO.test(e)?YO(e.slice(2),i?2:8):WO.test(e)?ax:+e}var ox=QO;function ZO(e){return e}var KO=ZO,JO="[object AsyncFunction]",$O="[object Function]",e4="[object GeneratorFunction]",t4="[object Proxy]";function i4(e){if(!as(e))return!1;var t=Ja(e);return t==$O||t==e4||t==JO||t==t4}var RS=i4,r4=os["__core-js_shared__"],Mf=r4,lx=function(){var e=/[^.]+$/.exec(Mf&&Mf.keys&&Mf.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function s4(e){return!!lx&&lx in e}var n4=s4,a4=Function.prototype,o4=a4.toString;function l4(e){if(e!=null){try{return o4.call(e)}catch{}try{return e+""}catch{}}return""}var $a=l4,h4=/[\\^$.*+?()[\]{}|]/g,c4=/^\[object .+?Constructor\]$/,d4=Function.prototype,u4=Object.prototype,p4=d4.toString,f4=u4.hasOwnProperty,m4=RegExp("^"+p4.call(f4).replace(h4,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g4(e){if(!as(e)||n4(e))return!1;var t=RS(e)?m4:c4;return t.test($a(e))}var v4=g4;function y4(e,t){return e?.[t]}var x4=y4;function b4(e,t){var i=x4(e,t);return v4(i)?i:void 0}var eo=b4,w4=eo(os,"WeakMap"),Zm=w4,hx=Object.create,_4=function(){function e(){}return function(t){if(!as(t))return{};if(hx)return hx(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),S4=_4;function A4(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 M4=A4;function E4(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var C4=E4,T4=800,P4=16,D4=Date.now;function I4(e){var t=0,i=0;return function(){var r=D4(),s=P4-(r-i);if(i=r,s>0){if(++t>=T4)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var L4=I4;function O4(e){return function(){return e}}var B4=O4,R4=function(){try{var e=eo(Object,"defineProperty");return e({},"",{}),e}catch{}}(),wu=R4,z4=wu?function(e,t){return wu(e,"toString",{configurable:!0,enumerable:!1,value:B4(t),writable:!0})}:KO,N4=z4,U4=L4(N4),F4=U4;function k4(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var j4=k4,G4=9007199254740991,V4=/^(?:0|[1-9]\d*)$/;function H4(e,t){var i=typeof e;return t=t??G4,!!t&&(i=="number"||i!="symbol"&&V4.test(e))&&e>-1&&e%1==0&&e<t}var Gv=H4;function W4(e,t,i){t=="__proto__"&&wu?wu(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var zS=W4;function q4(e,t){return e===t||e!==e&&t!==t}var Vv=q4,X4=Object.prototype,Y4=X4.hasOwnProperty;function Q4(e,t,i){var r=e[t];(!(Y4.call(e,t)&&Vv(r,i))||i===void 0&&!(t in e))&&zS(e,t,i)}var Hv=Q4;function Z4(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?zS(i,o,l):Hv(i,o,l)}return i}var Sc=Z4,cx=Math.max;function K4(e,t,i){return t=cx(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=cx(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),M4(e,this,o)}}var J4=K4,$4=9007199254740991;function eB(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=$4}var Wv=eB;function tB(e){return e!=null&&Wv(e.length)&&!RS(e)}var NS=tB,iB=Object.prototype;function rB(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||iB;return e===i}var qv=rB;function sB(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var nB=sB,aB="[object Arguments]";function oB(e){return bn(e)&&Ja(e)==aB}var dx=oB,US=Object.prototype,lB=US.hasOwnProperty,hB=US.propertyIsEnumerable,cB=dx(function(){return arguments}())?dx:function(e){return bn(e)&&lB.call(e,"callee")&&!hB.call(e,"callee")},Xv=cB;function dB(){return!1}var uB=dB,FS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ux=FS&&typeof module=="object"&&module&&!module.nodeType&&module,pB=ux&&ux.exports===FS,px=pB?os.Buffer:void 0,fB=px?px.isBuffer:void 0,mB=fB||uB,_u=mB,gB="[object Arguments]",vB="[object Array]",yB="[object Boolean]",xB="[object Date]",bB="[object Error]",wB="[object Function]",_B="[object Map]",SB="[object Number]",AB="[object Object]",MB="[object RegExp]",EB="[object Set]",CB="[object String]",TB="[object WeakMap]",PB="[object ArrayBuffer]",DB="[object DataView]",IB="[object Float32Array]",LB="[object Float64Array]",OB="[object Int8Array]",BB="[object Int16Array]",RB="[object Int32Array]",zB="[object Uint8Array]",NB="[object Uint8ClampedArray]",UB="[object Uint16Array]",FB="[object Uint32Array]",zt={};zt[IB]=zt[LB]=zt[OB]=zt[BB]=zt[RB]=zt[zB]=zt[NB]=zt[UB]=zt[FB]=!0;zt[gB]=zt[vB]=zt[PB]=zt[yB]=zt[DB]=zt[xB]=zt[bB]=zt[wB]=zt[_B]=zt[SB]=zt[AB]=zt[MB]=zt[EB]=zt[CB]=zt[TB]=!1;function kB(e){return bn(e)&&Wv(e.length)&&!!zt[Ja(e)]}var jB=kB;function GB(e){return function(t){return e(t)}}var Yv=GB,kS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gh=kS&&typeof module=="object"&&module&&!module.nodeType&&module,VB=Gh&&Gh.exports===kS,Ef=VB&&IS.process,HB=function(){try{var e=Gh&&Gh.require&&Gh.require("util").types;return e||Ef&&Ef.binding&&Ef.binding("util")}catch{}}(),vl=HB,fx=vl&&vl.isTypedArray,WB=fx?Yv(fx):jB,jS=WB,qB=Object.prototype,XB=qB.hasOwnProperty;function YB(e,t){var i=zs(e),r=!i&&Xv(e),s=!i&&!r&&_u(e),n=!i&&!r&&!s&&jS(e),a=i||r||s||n,o=a?nB(e.length,String):[],l=o.length;for(var h in e)(t||XB.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Gv(h,l)))&&o.push(h);return o}var GS=YB;function QB(e,t){return function(i){return e(t(i))}}var VS=QB,ZB=VS(Object.keys,Object),KB=ZB,JB=Object.prototype,$B=JB.hasOwnProperty;function eR(e){if(!qv(e))return KB(e);var t=[];for(var i in Object(e))$B.call(e,i)&&i!="constructor"&&t.push(i);return t}var tR=eR;function iR(e){return NS(e)?GS(e):tR(e)}var Qv=iR;function rR(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var sR=rR,nR=Object.prototype,aR=nR.hasOwnProperty;function oR(e){if(!as(e))return sR(e);var t=qv(e),i=[];for(var r in e)r=="constructor"&&(t||!aR.call(e,r))||i.push(r);return i}var lR=oR;function hR(e){return NS(e)?GS(e,!0):lR(e)}var Zv=hR,cR=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dR=/^\w*$/;function uR(e,t){if(zs(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||lp(e)?!0:dR.test(e)||!cR.test(e)||t!=null&&e in Object(t)}var pR=uR,fR=eo(Object,"create"),sc=fR;function mR(){this.__data__=sc?sc(null):{},this.size=0}var gR=mR;function vR(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var yR=vR,xR="__lodash_hash_undefined__",bR=Object.prototype,wR=bR.hasOwnProperty;function _R(e){var t=this.__data__;if(sc){var i=t[e];return i===xR?void 0:i}return wR.call(t,e)?t[e]:void 0}var SR=_R,AR=Object.prototype,MR=AR.hasOwnProperty;function ER(e){var t=this.__data__;return sc?t[e]!==void 0:MR.call(t,e)}var CR=ER,TR="__lodash_hash_undefined__";function PR(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=sc&&t===void 0?TR:t,this}var DR=PR;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=gR;Nl.prototype.delete=yR;Nl.prototype.get=SR;Nl.prototype.has=CR;Nl.prototype.set=DR;var mx=Nl;function IR(){this.__data__=[],this.size=0}var LR=IR;function OR(e,t){for(var i=e.length;i--;)if(Vv(e[i][0],t))return i;return-1}var hp=OR,BR=Array.prototype,RR=BR.splice;function zR(e){var t=this.__data__,i=hp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():RR.call(t,i,1),--this.size,!0}var NR=zR;function UR(e){var t=this.__data__,i=hp(t,e);return i<0?void 0:t[i][1]}var FR=UR;function kR(e){return hp(this.__data__,e)>-1}var jR=kR;function GR(e,t){var i=this.__data__,r=hp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var VR=GR;function Ul(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])}}Ul.prototype.clear=LR;Ul.prototype.delete=NR;Ul.prototype.get=FR;Ul.prototype.has=jR;Ul.prototype.set=VR;var cp=Ul,HR=eo(os,"Map"),nc=HR;function WR(){this.size=0,this.__data__={hash:new mx,map:new(nc||cp),string:new mx}}var qR=WR;function XR(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var YR=XR;function QR(e,t){var i=e.__data__;return YR(t)?i[typeof t=="string"?"string":"hash"]:i.map}var dp=QR;function ZR(e){var t=dp(this,e).delete(e);return this.size-=t?1:0,t}var KR=ZR;function JR(e){return dp(this,e).get(e)}var $R=JR;function ez(e){return dp(this,e).has(e)}var tz=ez;function iz(e,t){var i=dp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var rz=iz;function Fl(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])}}Fl.prototype.clear=qR;Fl.prototype.delete=KR;Fl.prototype.get=$R;Fl.prototype.has=tz;Fl.prototype.set=rz;var up=Fl,sz="Expected a function";function Kv(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(sz);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(Kv.Cache||up),i}Kv.Cache=up;var nz=Kv,az=500;function oz(e){var t=nz(e,function(r){return i.size===az&&i.clear(),r}),i=t.cache;return t}var lz=oz,hz=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cz=/\\(\\)?/g,dz=lz(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(hz,function(i,r,s,n){t.push(s?n.replace(cz,"$1"):r||i)}),t}),uz=dz;function pz(e){return e==null?"":NO(e)}var fz=pz;function mz(e,t){return zs(e)?e:pR(e,t)?[e]:uz(fz(e))}var kl=mz,gz=1/0;function vz(e){if(typeof e=="string"||lp(e))return e;var t=e+"";return t=="0"&&1/e==-gz?"-0":t}var pp=vz;function yz(e,t){t=kl(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[pp(t[i++])];return i&&i==r?e:void 0}var HS=yz;function xz(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Jv=xz,gx=kr?kr.isConcatSpreadable:void 0;function bz(e){return zs(e)||Xv(e)||!!(gx&&e&&e[gx])}var wz=bz;function WS(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=wz),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?WS(o,t-1,i,r,s):Jv(s,o):r||(s[s.length]=o)}return s}var _z=WS;function Sz(e){var t=e==null?0:e.length;return t?_z(e,1):[]}var Az=Sz;function Mz(e){return F4(J4(e,void 0,Az),e+"")}var qS=Mz,Ez=VS(Object.getPrototypeOf,Object),$v=Ez,Cz="[object Object]",Tz=Function.prototype,Pz=Object.prototype,XS=Tz.toString,Dz=Pz.hasOwnProperty,Iz=XS.call(Object);function Lz(e){if(!bn(e)||Ja(e)!=Cz)return!1;var t=$v(e);if(t===null)return!0;var i=Dz.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&XS.call(i)==Iz}var Oz=Lz;function Bz(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 Rz=Bz;function zz(){this.__data__=new cp,this.size=0}var Nz=zz;function Uz(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Fz=Uz;function kz(e){return this.__data__.get(e)}var jz=kz;function Gz(e){return this.__data__.has(e)}var Vz=Gz,Hz=200;function Wz(e,t){var i=this.__data__;if(i instanceof cp){var r=i.__data__;if(!nc||r.length<Hz-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new up(r)}return i.set(e,t),this.size=i.size,this}var qz=Wz;function jl(e){var t=this.__data__=new cp(e);this.size=t.size}jl.prototype.clear=Nz;jl.prototype.delete=Fz;jl.prototype.get=jz;jl.prototype.has=Vz;jl.prototype.set=qz;var $d=jl;function Xz(e,t){return e&&Sc(t,Qv(t),e)}var Yz=Xz;function Qz(e,t){return e&&Sc(t,Zv(t),e)}var Zz=Qz,YS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vx=YS&&typeof module=="object"&&module&&!module.nodeType&&module,Kz=vx&&vx.exports===YS,yx=Kz?os.Buffer:void 0,xx=yx?yx.allocUnsafe:void 0;function Jz(e,t){if(t)return e.slice();var i=e.length,r=xx?xx(i):new e.constructor(i);return e.copy(r),r}var $z=Jz;function e5(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 t5=e5;function i5(){return[]}var QS=i5,r5=Object.prototype,s5=r5.propertyIsEnumerable,bx=Object.getOwnPropertySymbols,n5=bx?function(e){return e==null?[]:(e=Object(e),t5(bx(e),function(t){return s5.call(e,t)}))}:QS,e0=n5;function a5(e,t){return Sc(e,e0(e),t)}var o5=a5,l5=Object.getOwnPropertySymbols,h5=l5?function(e){for(var t=[];e;)Jv(t,e0(e)),e=$v(e);return t}:QS,ZS=h5;function c5(e,t){return Sc(e,ZS(e),t)}var d5=c5;function u5(e,t,i){var r=t(e);return zs(e)?r:Jv(r,i(e))}var KS=u5;function p5(e){return KS(e,Qv,e0)}var Km=p5;function f5(e){return KS(e,Zv,ZS)}var JS=f5,m5=eo(os,"DataView"),Jm=m5,g5=eo(os,"Promise"),$m=g5,v5=eo(os,"Set"),eg=v5,wx="[object Map]",y5="[object Object]",_x="[object Promise]",Sx="[object Set]",Ax="[object WeakMap]",Mx="[object DataView]",x5=$a(Jm),b5=$a(nc),w5=$a($m),_5=$a(eg),S5=$a(Zm),Ma=Ja;(Jm&&Ma(new Jm(new ArrayBuffer(1)))!=Mx||nc&&Ma(new nc)!=wx||$m&&Ma($m.resolve())!=_x||eg&&Ma(new eg)!=Sx||Zm&&Ma(new Zm)!=Ax)&&(Ma=function(e){var t=Ja(e),i=t==y5?e.constructor:void 0,r=i?$a(i):"";if(r)switch(r){case x5:return Mx;case b5:return wx;case w5:return _x;case _5:return Sx;case S5:return Ax}return t});var ac=Ma,A5=Object.prototype,M5=A5.hasOwnProperty;function E5(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&M5.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var C5=E5,T5=os.Uint8Array,Su=T5;function P5(e){var t=new e.constructor(e.byteLength);return new Su(t).set(new Su(e)),t}var t0=P5;function D5(e,t){var i=t?t0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var I5=D5,L5=/\w*$/;function O5(e){var t=new e.constructor(e.source,L5.exec(e));return t.lastIndex=e.lastIndex,t}var B5=O5,Ex=kr?kr.prototype:void 0,Cx=Ex?Ex.valueOf:void 0;function R5(e){return Cx?Object(Cx.call(e)):{}}var z5=R5;function N5(e,t){var i=t?t0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var U5=N5,F5="[object Boolean]",k5="[object Date]",j5="[object Map]",G5="[object Number]",V5="[object RegExp]",H5="[object Set]",W5="[object String]",q5="[object Symbol]",X5="[object ArrayBuffer]",Y5="[object DataView]",Q5="[object Float32Array]",Z5="[object Float64Array]",K5="[object Int8Array]",J5="[object Int16Array]",$5="[object Int32Array]",eN="[object Uint8Array]",tN="[object Uint8ClampedArray]",iN="[object Uint16Array]",rN="[object Uint32Array]";function sN(e,t,i){var r=e.constructor;switch(t){case X5:return t0(e);case F5:case k5:return new r(+e);case Y5:return I5(e,i);case Q5:case Z5:case K5:case J5:case $5:case eN:case tN:case iN:case rN:return U5(e,i);case j5:return new r;case G5:case W5:return new r(e);case V5:return B5(e);case H5:return new r;case q5:return z5(e)}}var nN=sN;function aN(e){return typeof e.constructor=="function"&&!qv(e)?S4($v(e)):{}}var oN=aN,lN="[object Map]";function hN(e){return bn(e)&&ac(e)==lN}var cN=hN,Tx=vl&&vl.isMap,dN=Tx?Yv(Tx):cN,uN=dN,pN="[object Set]";function fN(e){return bn(e)&&ac(e)==pN}var mN=fN,Px=vl&&vl.isSet,gN=Px?Yv(Px):mN,vN=gN,yN=1,xN=2,bN=4,$S="[object Arguments]",wN="[object Array]",_N="[object Boolean]",SN="[object Date]",AN="[object Error]",eA="[object Function]",MN="[object GeneratorFunction]",EN="[object Map]",CN="[object Number]",tA="[object Object]",TN="[object RegExp]",PN="[object Set]",DN="[object String]",IN="[object Symbol]",LN="[object WeakMap]",ON="[object ArrayBuffer]",BN="[object DataView]",RN="[object Float32Array]",zN="[object Float64Array]",NN="[object Int8Array]",UN="[object Int16Array]",FN="[object Int32Array]",kN="[object Uint8Array]",jN="[object Uint8ClampedArray]",GN="[object Uint16Array]",VN="[object Uint32Array]",Bt={};Bt[$S]=Bt[wN]=Bt[ON]=Bt[BN]=Bt[_N]=Bt[SN]=Bt[RN]=Bt[zN]=Bt[NN]=Bt[UN]=Bt[FN]=Bt[EN]=Bt[CN]=Bt[tA]=Bt[TN]=Bt[PN]=Bt[DN]=Bt[IN]=Bt[kN]=Bt[jN]=Bt[GN]=Bt[VN]=!0;Bt[AN]=Bt[eA]=Bt[LN]=!1;function eu(e,t,i,r,s,n){var a,o=t&yN,l=t&xN,h=t&bN;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!as(e))return e;var d=zs(e);if(d){if(a=C5(e),!o)return C4(e,a)}else{var c=ac(e),u=c==eA||c==MN;if(_u(e))return $z(e,o);if(c==tA||c==$S||u&&!s){if(a=l||u?{}:oN(e),!o)return l?d5(e,Zz(a,e)):o5(e,Yz(a,e))}else{if(!Bt[c])return s?e:{};a=nN(e,c,o)}}n||(n=new $d);var p=n.get(e);if(p)return p;n.set(e,a),vN(e)?e.forEach(function(m){a.add(eu(m,t,i,m,e,n))}):uN(e)&&e.forEach(function(m,v){a.set(v,eu(m,t,i,v,e,n))});var f=h?l?JS:Km:l?Zv:Qv,g=d?void 0:f(e);return j4(g||e,function(m,v){g&&(v=m,m=e[v]),Hv(a,v,eu(m,t,i,v,e,n))}),a}var iA=eu,HN=1,WN=4;function qN(e){return iA(e,HN|WN)}var fp=qN,XN="__lodash_hash_undefined__";function YN(e){return this.__data__.set(e,XN),this}var QN=YN;function ZN(e){return this.__data__.has(e)}var KN=ZN;function Au(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new up;++t<i;)this.add(e[t])}Au.prototype.add=Au.prototype.push=QN;Au.prototype.has=KN;var JN=Au;function $N(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 eU=$N;function tU(e,t){return e.has(t)}var iU=tU,rU=1,sU=2;function nU(e,t,i,r,s,n){var a=i&rU,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&sU?new JN:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var f=e[c],g=t[c];if(r)var m=a?r(g,f,c,t,e,n):r(f,g,c,e,t,n);if(m!==void 0){if(m)continue;u=!1;break}if(p){if(!eU(t,function(v,y){if(!iU(p,y)&&(f===v||s(f,v,i,r,n)))return p.push(y)})){u=!1;break}}else if(!(f===g||s(f,g,i,r,n))){u=!1;break}}return n.delete(e),n.delete(t),u}var rA=nU;function aU(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var oU=aU;function lU(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var hU=lU,cU=1,dU=2,uU="[object Boolean]",pU="[object Date]",fU="[object Error]",mU="[object Map]",gU="[object Number]",vU="[object RegExp]",yU="[object Set]",xU="[object String]",bU="[object Symbol]",wU="[object ArrayBuffer]",_U="[object DataView]",Dx=kr?kr.prototype:void 0,Cf=Dx?Dx.valueOf:void 0;function SU(e,t,i,r,s,n,a){switch(i){case _U:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case wU:return!(e.byteLength!=t.byteLength||!n(new Su(e),new Su(t)));case uU:case pU:case gU:return Vv(+e,+t);case fU:return e.name==t.name&&e.message==t.message;case vU:case xU:return e==t+"";case mU:var o=oU;case yU:var l=r&cU;if(o||(o=hU),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=dU,a.set(e,t);var d=rA(o(e),o(t),r,s,n,a);return a.delete(e),d;case bU:if(Cf)return Cf.call(e)==Cf.call(t)}return!1}var AU=SU,MU=1,EU=Object.prototype,CU=EU.hasOwnProperty;function TU(e,t,i,r,s,n){var a=i&MU,o=Km(e),l=o.length,h=Km(t),d=h.length;if(l!=d&&!a)return!1;for(var c=l;c--;){var u=o[c];if(!(a?u in t:CU.call(t,u)))return!1}var p=n.get(e),f=n.get(t);if(p&&f)return p==t&&f==e;var g=!0;n.set(e,t),n.set(t,e);for(var m=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)){g=!1;break}m||(m=u=="constructor")}if(g&&!m){var b=e.constructor,_=t.constructor;b!=_&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof _=="function"&&_ instanceof _)&&(g=!1)}return n.delete(e),n.delete(t),g}var PU=TU,DU=1,Ix="[object Arguments]",Lx="[object Array]",dd="[object Object]",IU=Object.prototype,Ox=IU.hasOwnProperty;function LU(e,t,i,r,s,n){var a=zs(e),o=zs(t),l=a?Lx:ac(e),h=o?Lx:ac(t);l=l==Ix?dd:l,h=h==Ix?dd:h;var d=l==dd,c=h==dd,u=l==h;if(u&&_u(e)){if(!_u(t))return!1;a=!0,d=!1}if(u&&!d)return n||(n=new $d),a||jS(e)?rA(e,t,i,r,s,n):AU(e,t,l,i,r,s,n);if(!(i&DU)){var p=d&&Ox.call(e,"__wrapped__"),f=c&&Ox.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return n||(n=new $d),s(g,m,i,r,n)}}return u?(n||(n=new $d),PU(e,t,i,r,s,n)):!1}var OU=LU;function sA(e,t,i,r,s){return e===t?!0:e==null||t==null||!bn(e)&&!bn(t)?e!==e&&t!==t:OU(e,t,i,r,sA,s)}var BU=sA;function RU(e,t){return e!=null&&t in Object(e)}var zU=RU;function NU(e,t,i){t=kl(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=pp(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&&Wv(s)&&Gv(a,s)&&(zs(e)||Xv(e)))}var UU=NU;function FU(e,t){return e!=null&&UU(e,t,zU)}var kU=FU,jU=function(){return os.Date.now()},Tf=jU,GU="Expected a function",VU=Math.max,HU=Math.min;function WU(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(GU);t=ox(t)||0,as(i)&&(d=!!i.leading,c="maxWait"in i,n=c?VU(ox(i.maxWait)||0,t):n,u="trailing"in i?!!i.trailing:u);function p(A){var S=r,w=s;return r=s=void 0,h=A,a=e.apply(w,S),a}function f(A){return h=A,o=setTimeout(v,t),d?p(A):a}function g(A){var S=A-l,w=A-h,E=t-S;return c?HU(E,n-w):E}function m(A){var S=A-l,w=A-h;return l===void 0||S>=t||S<0||c&&w>=n}function v(){var A=Tf();if(m(A))return y(A);o=setTimeout(v,g(A))}function y(A){return o=void 0,u&&r?p(A):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?a:y(Tf())}function _(){var A=Tf(),S=m(A);if(r=arguments,s=this,l=A,S){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=b,_}var i0=WU;function qU(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var XU=qU;function YU(e,t){return t.length<2?e:HS(e,Rz(t,0,-1))}var QU=YU;function ZU(e,t){return BU(e,t)}var r0=ZU;function KU(e,t){return t=kl(t,e),e=QU(e,t),e==null||delete e[pp(XU(t))]}var JU=KU;function $U(e){return Oz(e)?void 0:e}var eF=$U,tF=1,iF=2,rF=4,sF=qS(function(e,t){var i={};if(e==null)return i;var r=!1;t=OS(t,function(n){return n=kl(n,e),r||(r=n.length>1),n}),Sc(e,JS(e),i),r&&(i=iA(i,tF|iF|rF,eF));for(var s=t.length;s--;)JU(i,t[s]);return i}),tg=sF;function nF(e,t,i,r){if(!as(e))return e;t=kl(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=pp(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=as(d)?d:Gv(t[s+1])?[]:{})}Hv(o,l,h),o=o[l]}return e}var aF=nF;function oF(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=HS(e,a);i(o,a)&&aF(n,kl(a,e),o)}return n}var lF=oF;function hF(e,t){return lF(e,t,function(i,r){return kU(e,r)})}var cF=hF,dF=qS(function(e,t){return e==null?{}:cF(e,t)}),vn=dF,uF="Expected a function";function pF(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(uF);return as(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),i0(e,t,{leading:r,maxWait:t,trailing:s})}var fF=pF;function mF(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Qa(e,t){return Object.setPrototypeOf(e,t),e}var gF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),vF=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),yF=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||mp&&"ontouchend"in document,xF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,bF=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,wF=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},_F=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},SF=()=>typeof window>"u"?void 0:new URLSearchParams(window.location.search).get("desktop-app-version")??"0.0.6",AF=gF(),Mq=AF?SF():void 0,mp=vF(),nA=yF(),MF=xF(),br=bF(),Bx=wF(),Rx=Number(_F());function aA(e){return Array.isArray(e)?e:[e]}function EF(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 ud(e){return mp?e.metaKey:e.ctrlKey}var Ve=[],Mu={},Ih={},tu={};function oA(e){Ve.includes(e)||Ve.push(e)}function el(e){delete Mu[e.pointerId];for(let t=0;t<Ve.length;t++)if(Ve[t].pointerId===e.pointerId){Ve.splice(t,1);break}}function CF(){Ve.splice(0,Ve.length)}function Eu(e){if(e.pointerType!=="touch")return;let t=Mu[e.pointerId];t===void 0&&(t={x:0,y:0},Mu[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Pf(e){let t=e.pointerId===Ve[0].pointerId?Ve[1]:Ve[0];return Mu[t.pointerId]}function lA(e){Ih[e.key]=!0,tu[e.key]=tu[e.key]===void 0?1:tu[e.key]+1}function hA(e){if(mp&&Ih.Meta)for(let t in Ih)Ih[t]=!1;else Ih[e.key]=!1;tu={}}function TF(e){e.addEventListener("pointerdown",oA,!0),e.addEventListener("pointerdown",Eu,!0),e.addEventListener("pointermove",Eu,!0),e.addEventListener("pointerup",el,!0),e.addEventListener("pointercancel",el,!0),e.addEventListener("pointerleave",el,!0),window.addEventListener("keydown",lA,!0),window.addEventListener("keyup",hA,!0)}function PF(e){e.removeEventListener("pointerdown",oA,!0),e.removeEventListener("pointerdown",Eu,!0),e.removeEventListener("pointermove",Eu,!0),e.removeEventListener("pointerup",el,!0),e.removeEventListener("pointercancel",el,!0),e.removeEventListener("pointerleave",el,!0),window.removeEventListener("keydown",lA,!0),window.removeEventListener("keyup",hA,!0)}var cA,DF=new Promise(e=>{cA=e}),pd;function IF(){if(pd)return pd;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.423/build",[i,r]=await Promise.all([import("./navmesh.js".toString()),fetch(`${t}/navmesh.wasm`).then(a=>a.arrayBuffer())]),s=i.default,n=await s({wasmBinary:r});cA(n)}return pd=e(),pd}var dA,LF=new Promise(e=>{dA=e}),fd;function OF(){if(fd)return fd;async function e(){let t=await import("./physics.js".toString());await t.init(),dA(t)}return fd=e(),fd}var ii=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,ii.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,ii.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,ii.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function s0(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"&&s0(r)}return Object.freeze(e)}function BF(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 uA=class extends Error{};function Df(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Wn(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 n0(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 RF(){return typeof process<"u"}function pA(e,t){for(let i of e)t(i.id,i.data)!==!0&&pA(i.children,t)}function fA(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)fA(i,t)}var nr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,nr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)s0(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&fA(i,t)}}traverse(e){pA(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,nr.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 uA("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)=>BF(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 Wn(0,i,i);{let s=r[0].fi;return Wn(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 Wn(a,a+i,i)}else return Wn(s.fi,n.fi,i)}}},Cu;(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})(Cu||(Cu={}));var et=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,et.prototype)}deepFreeze(){let e=0;for(;e<this.length;)s0(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 RF()||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 Wn(0,t,t);{let r=i[0].fi;return Wn(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 Wn(n,n+t,t)}else return Wn(r.fi,s.fi,t)}}};function yl(e){return e&&typeof e=="object"&&e instanceof di}var di=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&&!yl(i))return null;r+=1}i=i?Df(i):new di;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=Df(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Df(o);l[e.path[r-1]]=i,i=l}else{let l=new di;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,di.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},$n;(e=>{function t(s,n){return oc(s,n)??s}e.apply=t;function i(s,n){return o0(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=Ls.zoomOnce(l,o[a]),l===void 0)return n;if(!yl(l))return;a+=1}if(l===void 0)return n;if(yl(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=a0([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})($n||($n={}));function a0(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=oc(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=a0(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 zF(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=oc(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 oc(e,t){if(!yl(t))return t;if(e instanceof nr){let i=a0(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof et)return zF(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=oc(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 di)return o0(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=oc(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 o0(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!yl(t))return t;if(!yl(e))return $n.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 di;for(let s of i){let n=o0(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function NF(e,t){let i={cur:[],result:[],len:0};return e=lc(e,t,i)??e,[e,i.result]}function Tu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Pu(e){e&&(e.len-=1)}function UF(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function mA(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=lc(n.data,t,Tu(i,a));Pu(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=mA(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 FF(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=lc(n.data,t,Tu(i,a));return Pu(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 lc(e,t,i){if(e instanceof nr){let r=mA(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof et)return FF(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=lc(n,t,Tu(i,a));return Pu(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"&&!n0(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=lc(a,t,Tu(i,n));Pu(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");UF(i)}return r}else return}}var ig;(e=>{function t(i,r){let s=Ls.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})(ig||(ig={}));var wr;(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 di&&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 nr||l instanceof et||l instanceof ii?u=l.runOp(h):u=Cu.runOp(l,h)),u!==void 0)if(u!==null){let g=u.data;for(let m=c.length-1;m>=0;m--){let v=d[m],y=c[m];if(y instanceof nr){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof et){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof ii){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof di){let x={...y,[v]:g};g=Object.setPrototypeOf(x,di.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=g;g=[...y],g[v]=x}else g={...y,[v]:g};else return null}return{data:g,actual:{...u.actual,path:d},reverse:{...u.reverse,path:d}}}else return null;let p=d[c.length],f;if(l instanceof nr){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})(wr||(wr={}));var zx;(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=>wr.subsumed(c,u))),...d]}e.compress=n;function a(h,d){return h.every(c=>d.every(u=>wr.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 g=Ls.zoom(c,[...f.path,f.id]),m=wr.apply(c,{...f,type:2});if(m!==null){c=m.data;let[v,y]=NF(c,{[f.id]:g});c=v;for(let x of y){let b=x[x.length-1];x.splice(x.length-1,1),u.push({type:0,path:x,props:{[b]:g}}),p.push({type:0,path:x,props:{[b]:f.id}})}p.push(m.reverse),u.push(m.actual)}}else{let g=wr.apply(c,f);g!==null&&(u.push(g.actual),c=g.data,p.push(g.reverse))}}catch(g){if(g instanceof uA)return null;throw g}return{data:c,actual:u,reverse:p.reverse()}}e.apply=l})(zx||(zx={}));var gA=Symbol(),kF=Symbol(),gp=Symbol(),Ac=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof yA);){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[gp];i&&i(),delete this._children[e]}}}},jF=class extends Ac{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,Cu.runOp(this._current,e),e.path)}},GF=class extends Ac{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,ii.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},vA={get(e,t){if(t===gp)return()=>{e._parent=null};if(t===gA)return e._current;if(t===kF)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=vp(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]}}},VF={...vA,set(e,t,i){let r={type:0,props:{[t]:wi(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}},HF={...vA,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}},l0=class extends Ac{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[gp]=()=>{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=vp(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)}},h0=class extends Ac{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[gp]=()=>{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=vp(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 If(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Ls.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var yA=class extends Ac{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){If(this.ts,t,e),If(this.actual,i,e),If(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function vp(e,t,i){return i instanceof nr?new l0(e,t,i):i instanceof et?new h0(e,t,i):i instanceof ii?new Proxy(new GF(e,t,i),HF):i!==null&&typeof i=="object"?n0(i)?i:new Proxy(new jF(e,t,i),VF):i}function xA(e){let t=new yA(e);return[vp(t,"",e),t]}function Du(e,t){let[i,r]=xA(e);return t(i),r.result()}function wi(e){return e instanceof l0||e instanceof h0?e._current:e!==null&&typeof e=="object"?e[gA]:e}var Ls;(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 nr||n instanceof l0)&&typeof a=="string"||(n instanceof et||n instanceof h0)&&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})(Ls||(Ls={}));function WF(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 zr(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 bA=class{},Nx=class extends bA{constructor(e){super(),this.id=e}},Ux=class extends bA{constructor(e){super(),this.data=e}},rg;try{rg=new TextDecoder}catch{}var Te,ea,K=0,wA=[],sg=wA,ng=0,er={},yt,qn,Or=0,Ts=0,gr,yn,Qi=[],bt,Fx={useRecords:!1,mapsAsObjects:!0},_A=class{},SA=new _A;SA.name="MessagePack 0xC1";var xl=!1,Iu=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(Te)return PA(()=>(og(),this?this.unpack(e,t):Iu.prototype.unpack.call(Fx,e,t)));ea=t>-1?t:e.length,K=0,ng=0,Ts=0,qn=null,sg=wA,gr=null,Te=e;try{bt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Te=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 Iu){if(er=this,this.structures)return yt=this.structures,md();(!yt||yt.length>0)&&(yt=[])}else er=Fx,(!yt||yt.length>0)&&(yt=[]);return md()}unpackMultiple(e,t){let i,r=0;try{xl=!0;let s=e.length,n=this?this.unpack(e,s):xp.unpack(e,s);if(t){for(t(n);K<s;)if(r=K,t(md())===!1)return}else{for(i=[n];K<s;)r=K,i.push(md());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{xl=!1,og()}}_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 md(){try{if(!er.trusted&&!xl){let t=yt.sharedLength||0;t<yt.length&&(yt.length=t)}let e=Gt();if(K==ea)yt.restoreStructures&&kx(),yt=null,Te=null,yn&&(yn=null);else if(K>ea){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!xl)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw yt.restoreStructures&&kx(),og(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function kx(){for(let e in yt.restoreStructures)yt[e]=yt.restoreStructures[e];yt.restoreStructures=null}function Gt(){let e=Te[K++];if(e<160)if(e<128){if(e<64)return e;{let t=yt[e&63]||er.getStructures&&AA()[e&63];return t?(t.read||(t.read=c0(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,er.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[EA()]=Gt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gt(),Gt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gt();return t}else if(e<192){let t=e-160;if(Ts>=K)return qn.slice(K-Or,(K+=t)-Or);if(Ts==0&&ea<140){let i=t<16?d0(t):MA(t);if(i!=null)return i}return ag(t)}else{let t;switch(e){case 192:return null;case 193:return gr?(t=Gt(),t>0?gr[1].slice(gr.position1,gr.position1+=t):gr[0].slice(gr.position0,gr.position0-=t)):SA;case 194:return!1;case 195:return!0;case 196:return Lf(Te[K++]);case 197:return t=bt.getUint16(K),K+=2,Lf(t);case 198:return t=bt.getUint32(K),K+=4,Lf(t);case 199:return xa(Te[K++]);case 200:return t=bt.getUint16(K),K+=2,xa(t);case 201:return t=bt.getUint32(K),K+=4,xa(t);case 202:if(t=bt.getFloat32(K),er.useFloat32>2){let i=u0[(Te[K]&127)<<1|Te[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=bt.getFloat64(K),K+=8,t;case 204:return Te[K++];case 205:return t=bt.getUint16(K),K+=2,t;case 206:return t=bt.getUint32(K),K+=4,t;case 207:return er.int64AsNumber?(t=bt.getUint32(K)*4294967296,t+=bt.getUint32(K+4)):t=bt.getBigUint64(K),K+=8,t;case 208:return bt.getInt8(K++);case 209:return t=bt.getInt16(K),K+=2,t;case 210:return t=bt.getInt32(K),K+=4,t;case 211:return er.int64AsNumber?(t=bt.getInt32(K)*4294967296,t+=bt.getUint32(K+4)):t=bt.getBigInt64(K),K+=8,t;case 212:if(t=Te[K++],t==114)return Wx(Te[K++]&63);{let i=Qi[t];if(i)return i.read?(K++,i.read(Gt())):i.noBuffer?(K++,i()):i(Te.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Te[K],t==114?(K++,Wx(Te[K++]&63,Te[K++])):xa(2);case 214:return xa(4);case 215:return xa(8);case 216:return xa(16);case 217:return t=Te[K++],Ts>=K?qn.slice(K-Or,(K+=t)-Or):XF(t);case 218:return t=bt.getUint16(K),K+=2,Ts>=K?qn.slice(K-Or,(K+=t)-Or):YF(t);case 219:return t=bt.getUint32(K),K+=4,Ts>=K?qn.slice(K-Or,(K+=t)-Or):QF(t);case 220:return t=bt.getUint16(K),K+=2,Gx(t);case 221:return t=bt.getUint32(K),K+=4,Gx(t);case 222:return t=bt.getUint16(K),K+=2,Vx(t);case 223:return t=bt.getUint32(K),K+=4,Vx(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 qF=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function c0(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>qF.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Gt);return e.highByte===0&&(e.read=jx(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=Gt()}return r}return i.count=0,e.highByte===0?jx(t,i):i}var jx=(e,t)=>function(){let i=Te[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=yt[r]||AA()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=c0(s,e)),s.read()};function AA(){let e=PA(()=>(Te=null,er.getStructures()));return yt=er._mergeStructures(e,yt)}var ag=yp,XF=yp,YF=yp,QF=yp;function yp(e){let t;if(e<16&&(t=d0(e)))return t;if(e>64&&rg)return rg.decode(Te.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Te[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Te[K++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Te[K++]&63,a=Te[K++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Te[K++]&63,a=Te[K++]&63,o=Te[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+=vi.apply(String,r),r.length=0)}return r.length>0&&(t+=vi.apply(String,r)),t}function Gx(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gt();return t}function Vx(e){if(er.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[EA()]=Gt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gt(),Gt());return t}}var vi=String.fromCharCode;function MA(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Te[K++];if((s&128)>0){K=t;return}i[r]=s}return vi.apply(String,i)}function d0(e){if(e<4)if(e<2){if(e===0)return"";{let t=Te[K++];if((t&128)>1){K-=1;return}return vi(t)}}else{let t=Te[K++],i=Te[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return vi(t,i);let r=Te[K++];if((r&128)>0){K-=3;return}return vi(t,i,r)}else{let t=Te[K++],i=Te[K++],r=Te[K++],s=Te[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return vi(t,i,r,s);{let n=Te[K++];if((n&128)>0){K-=5;return}return vi(t,i,r,s,n)}}else if(e<8){let n=Te[K++],a=Te[K++];if((n&128)>0||(a&128)>0){K-=6;return}if(e<7)return vi(t,i,r,s,n,a);let o=Te[K++];if((o&128)>0){K-=7;return}return vi(t,i,r,s,n,a,o)}else{let n=Te[K++],a=Te[K++],o=Te[K++],l=Te[K++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return vi(t,i,r,s,n,a,o,l);{let h=Te[K++];if((h&128)>0){K-=9;return}return vi(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Te[K++],d=Te[K++];if((h&128)>0||(d&128)>0){K-=10;return}if(e<11)return vi(t,i,r,s,n,a,o,l,h,d);let c=Te[K++];if((c&128)>0){K-=11;return}return vi(t,i,r,s,n,a,o,l,h,d,c)}else{let h=Te[K++],d=Te[K++],c=Te[K++],u=Te[K++];if((h&128)>0||(d&128)>0||(c&128)>0||(u&128)>0){K-=12;return}if(e<14){if(e===12)return vi(t,i,r,s,n,a,o,l,h,d,c,u);{let p=Te[K++];if((p&128)>0){K-=13;return}return vi(t,i,r,s,n,a,o,l,h,d,c,u,p)}}else{let p=Te[K++],f=Te[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return vi(t,i,r,s,n,a,o,l,h,d,c,u,p,f);let g=Te[K++];if((g&128)>0){K-=15;return}return vi(t,i,r,s,n,a,o,l,h,d,c,u,p,f,g)}}}}}function Lf(e){return er.copyBuffers?Uint8Array.prototype.slice.call(Te,K,K+=e):Te.subarray(K,K+=e)}function xa(e){let t=Te[K++];if(Qi[t])return Qi[t](Te.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var Hx=new Array(4096);function EA(){let e=Te[K++];if(e>=160&&e<192){if(e=e-160,Ts>=K)return qn.slice(K-Or,(K+=e)-Or);if(!(Ts==0&&ea<180))return ag(e)}else return K--,Gt();let t=(e<<5^(e>1?bt.getUint16(K):e>0?Te[K]:0))&4095,i=Hx[t],r=K,s=K+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=bt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Te[r++],n!=i[a++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],Hx[t]=i,i.bytes=e;r<s;)n=bt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Te[r++],i.push(n);let o=e<16?d0(e):MA(e);return o!=null?i.string=o:i.string=ag(e)}var Wx=(e,t)=>{var i=Gt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=yt[e];return s&&s.isShared&&((yt.restoreStructures||(yt.restoreStructures=[]))[e]=s),yt[e]=i,i.read=c0(i,r),i.read()},CA=typeof self=="object"?self:global;Qi[0]=()=>{};Qi[0].noBuffer=!0;Qi[101]=()=>{let e=Gt();return(CA[e[0]]||Error)(e[1])};Qi[105]=e=>{let t=bt.getUint32(K-4);yn||(yn=new Map);let i=Te[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};yn.set(t,s);let n=Gt();return s.used?Object.assign(r,n):(s.target=n,n)};Qi[112]=e=>{let t=bt.getUint32(K-4),i=yn.get(t);return i.used=!0,i.target};Qi[115]=()=>new Set(Gt());var TA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Qi[116]=e=>{let t=e[0],i=TA[t];if(!i)throw new Error("Could not find typed array for code "+t);return new CA[i](Uint8Array.prototype.slice.call(e,1).buffer)};Qi[120]=()=>{let e=Gt();return new RegExp(e[0],e[1])};Qi[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,gr=[Gt(),Gt()],gr.position0=0,gr.position1=0;let r=K;K=i;try{return Gt()}finally{K=r}};Qi[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 PA(e){let t=ea,i=K,r=ng,s=Or,n=Ts,a=qn,o=sg,l=yn,h=gr,d=new Uint8Array(Te.slice(0,ea)),c=yt,u=yt.slice(0,yt.length),p=er,f=xl,g=e();return ea=t,K=i,ng=r,Or=s,Ts=n,qn=a,sg=o,yn=l,gr=h,Te=d,xl=f,yt=c,yt.splice(0,yt.length,...u),er=p,bt=new DataView(Te.buffer,Te.byteOffset,Te.byteLength),g}function og(){Te=null,yn=null,yt=null}function ZF(e){e.unpack?Qi[e.type]=e.unpack:Qi[e.type]=e}var u0=new Array(147);for(let e=0;e<256;e++)u0[e]=+("1e"+Math.floor(45.15-e*.30103));var xp=new Iu({useRecords:!1}),Eq=xp.unpack,Cq=xp.unpackMultiple,Tq=xp.unpack,KF={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},JF=new Float32Array(1),Pq=new Uint8Array(JF.buffer,0,4),iu;try{iu=new TextEncoder}catch{}var Lu,p0,bp=typeof Buffer<"u",Of=bp?Buffer.allocUnsafeSlow:Uint8Array,DA=bp?Buffer:Uint8Array,qx=bp?4294967296:2144337920,he,qt,te=0,cs,ds=null,$F=/[\u0080-\uFFFF]/,hh=Symbol("record-id"),IA=class extends Iu{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=DA.prototype.utf8Write?function(S,w,E){return he.utf8Write(S,w,E)}:iu&&iu.encodeInto?function(S,w){return iu.encodeInto(S,he.subarray(w)).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,g=u+64,m=u+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(S,w){if(he||(he=new Of(8192),qt=new DataView(he.buffer,0,8192),te=0),cs=he.length-10,cs-te<2048?(he=new Of(he.length),qt=new DataView(he.buffer,0,he.length),cs=he.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(ds=["",""],he[te++]=214,he[te++]=98,ds.position=te-i,te+=4):ds=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let E=r.sharedLength||0;if(E>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<E;C++){let T=r[C];if(!T)continue;let D,P=r.transitions;for(let L=0,R=T.length;L<R;L++){let V=T[L];D=P[V],D||(D=P[V]=Object.create(null)),P=D}P[hh]=C+64}o=E}d||(r.nextId=E+64)}s&&(s=!1),n=r||[];try{if(b(S),ds){qt.setUint32(ds.position+i,te-ds.position-i);let E=ds;ds=null,b(E[0]),b(E[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>cs&&A(te),h.offset=te;let E=tk(he.subarray(i,te),a.idsToInsert);return a=null,E}return w&ik?(he.start=i,he.end=te,he):he.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 E=0,C=v.length;E<C;E++)v[E][hh]=0;v=[]}if(s&&h.saveStructures){let E=r.sharedLength||u;r.length>E&&(r=r.slice(0,E));let C=he.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=E,C)}}w&rk&&(te=i)}};let b=S=>{te>cs&&(he=A(te));var w=typeof S,E;if(w==="string"){let C=S.length;if(ds&&C>=8&&C<4096){let P=$F.test(S);ds[P?0:1]+=S,he[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>cs&&(he=A(te+D)),C<64||!l){let P,L,R,V=te+T;for(P=0;P<C;P++)L=S.charCodeAt(P),L<128?he[V++]=L:L<2048?(he[V++]=L>>6|192,he[V++]=L&63|128):(L&64512)===55296&&((R=S.charCodeAt(P+1))&64512)===56320?(L=65536+((L&1023)<<10)+(R&1023),P++,he[V++]=L>>18|240,he[V++]=L>>12&63|128,he[V++]=L>>6&63|128,he[V++]=L&63|128):(he[V++]=L>>12|224,he[V++]=L>>6&63|128,he[V++]=L&63|128);E=V-te-T}else E=l(S,te+T,D);E<32?he[te++]=160|E:E<256?(T<2&&he.copyWithin(te+2,te+1,te+1+E),he[te++]=217,he[te++]=E):E<65536?(T<3&&he.copyWithin(te+3,te+2,te+2+E),he[te++]=218,he[te++]=E>>8,he[te++]=E&255):(T<5&&he.copyWithin(te+5,te+3,te+3+E),he[te++]=219,qt.setUint32(te,E),te+=4),te+=E}else if(w==="number")if(S>>>0===S)S<64?he[te++]=S:S<256?(he[te++]=204,he[te++]=S):S<65536?(he[te++]=205,he[te++]=S>>8,he[te++]=S&255):(he[te++]=206,qt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?he[te++]=256+S:S>=-128?(he[te++]=208,he[te++]=S+256):S>=-32768?(he[te++]=209,qt.setInt16(te,S),te+=2):(he[te++]=210,qt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){he[te++]=202,qt.setFloat32(te,S);let T;if(C<4||(T=S*u0[(he[te]&127)<<1|he[te+1]>>7])>>0===T){te+=4;return}else te--}he[te++]=203,qt.setFloat64(te,S),te+=8}else if(w==="object")if(!S)he[te++]=192;else{if(a){let T=a.get(S);if(T){if(!T.id){let D=a.idsToInsert||(a.idsToInsert=[]);T.id=D.push(T)}he[te++]=214,he[te++]=112,qt.setUint32(te,T.id),te+=4;return}else a.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)_(S,!0);else if(C===Array){E=S.length,E<16?he[te++]=144|E:E<65536?(he[te++]=220,he[te++]=E>>8,he[te++]=E&255):(he[te++]=221,qt.setUint32(te,E),te+=4);for(let T=0;T<E;T++)b(S[T])}else if(C===Map){E=S.size,E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,qt.setUint32(te,E),te+=4);for(let[T,D]of S)b(T),b(D)}else{for(let T=0,D=Lu.length;T<D;T++){let P=p0[T];if(S instanceof P){let L=Lu[T];if(L.write){L.type&&(he[te++]=212,he[te++]=L.type,he[te++]=0),b(L.write.call(this,S));return}let R=he,V=qt,k=te;he=null;let z;try{z=L.pack.call(this,S,X=>(he=R,R=null,te+=X,te>cs&&A(te),{target:he,targetView:qt,position:te-X}),b)}finally{R&&(he=R,qt=V,te=k,cs=he.length-10)}z&&(z.length+te>cs&&A(z.length+te),te=ek(z,he,te,L.type));return}}_(S,!S.hasOwnProperty)}}else if(w==="boolean")he[te++]=S?195:194;else if(w==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))he[te++]=211,qt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)he[te++]=207,qt.setBigUint64(te,S);else if(this.largeBigIntToFloat)he[te++]=203,qt.setFloat64(te,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(w==="undefined")this.encodeUndefinedAsNil?he[te++]=192:(he[te++]=212,he[te++]=0,he[te++]=0);else if(w==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+w)},_=this.useRecords===!1?this.variableMapSize?S=>{let w=Object.keys(S),E=w.length;E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,qt.setUint32(te,E),te+=4);let C;for(let T=0;T<E;T++)b(C=w[T]),b(S[C])}:(S,w)=>{he[te++]=222;let E=te-i;te+=2;let C=0;for(let T in S)(w||S.hasOwnProperty(T))&&(b(T),b(S[T]),C++);he[E+++i]=C>>8,he[E+i]=C&255}:S=>{let w=Object.keys(S),E,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let P=0,L=w.length;P<L;P++){let R=w[P];E=C[R],E||(E=C[R]=Object.create(null),T++),C=E}let D=C[hh];if(D)D>=96&&f?(he[te++]=((D-=96)&31)+96,he[te++]=D>>5):he[te++]=D;else{D=n.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(w)?(D=n.nextOwnId,D<m||(D=g),n.nextOwnId=D+1):(D>=m&&(D=g),n.nextId=D+1);let P=w.highByte=D>=96&&f?D-96>>5:-1;C[hh]=D,n[D-64]=w,D<g?(w.isShared=!0,n.sharedLength=D-63,s=!0,P>=0?(he[te++]=(D&31)+96,he[te++]=P):he[te++]=D):(P>=0?(he[te++]=213,he[te++]=114,he[te++]=(D&31)+96,he[te++]=P):(he[te++]=212,he[te++]=114,he[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[hh]=0),v.push(C),b(w))}for(let P=0,L=w.length;P<L;P++)b(S[w[P]])},A=S=>{let w;if(S>16777216){if(S-i>qx)throw new Error("Packed buffer would be larger than maximum buffer size");w=Math.min(qx,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else w=(Math.max(S-i<<2,he.length-1)>>12)+1<<12;let E=new Of(w);return qt=new DataView(E.buffer,0,w),he.copy?he.copy(E,0,i,S):E.set(he.slice(i,S)),te-=i,i=0,cs=E.length-10,he=E}}useBuffer(e){he=e,qt=new DataView(he.buffer,he.byteOffset,he.byteLength),te=0}};p0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,_A];Lu=[{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?Xx(e,16,t):Yx(bp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==DA&&this.structuredClone?Xx(e,TA.indexOf(i.name),t):Yx(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function Xx(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 Yx(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 ek(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 tk(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 Gl(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)");p0.unshift(e.Class),Lu.unshift(e)}ZF(e)}var LA=new IA({useRecords:!1}),Dq=LA.pack,Iq=LA.pack,{NEVER:Lq,ALWAYS:Oq,DECIMAL_ROUND:Bq,DECIMAL_FIT:Rq}=KF,ik=512,rk=1024,Qx=new IA({structuredClone:!0});Gl({Class:ii.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ii.prototype),e}});Gl({Class:et.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,et.prototype),e}});Gl({Class:nr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,nr.prototype),e}});Gl({Class:Nx.prototype.constructor,type:4,write(e){return e.id},read(e){return new Nx(e)}});Gl({Class:Ux.prototype.constructor,type:5,write(e){return e.data},read(e){return new Ux(e)}});Gl({Class:di.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,di.prototype),e}});function sk(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 lg(e){if(n0(e))return e;if(Array.isArray(e))return e.map(lg);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=lg(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var hg;(e=>{function t(s){return Qx.pack(s)}e.serialize=t;function i(s){return Qx.unpack(s)}e.deserialize=i;function r(s){return sk(t(lg(s))).toString()}e.checksum=r})(hg||(hg={}));var us={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition"],Scroll:["Transition","Animation","Create"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset"],GameControl:["Transition","Animation","Audio","Video","Create"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"]},Zx;(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})(Zx||(Zx={}));var Ou;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Ou||(Ou={}));var cg;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Ou.propertyDefaultData(s),rOperand:{...Ou.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})(cg||(cg={}));var Kx;(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:cg.distanceDefaultData(r)}}e.defaultData=i})(Kx||(Kx={}));var Jx;(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}})(Jx||(Jx={}));var dg;(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})(dg||(dg={}));var ug;(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})(ug||(ug={}));var $x;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new et}}e.defaultData=i})($x||($x={}));var eb;(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})(eb||(eb={}));var tb;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new et}}e.defaultData=i})(tb||(tb={}));var ib;(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})(ib||(ib={}));var rb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,toggle:!1,target:"all",triggeringObjects:[],actions:new et,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(rb||(rb={}));var Vl="personal camera",Vh="a218fcc3-276b-49b9-b485-49037fd14f5f",nk=2960946,jr=5526619,Qo;(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})(Qo||(Qo={}));var ja;(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})(ja||(ja={}));var Bu;(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})(Bu||(Bu={}));var bl;(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})(bl||(bl={}));var Vi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.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(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function n(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=n;function a(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=a;function o(l,h,d){return{r:l.r+(h.r-l.r)*d,g:l.g+(h.g-l.g)*d,b:l.b+(h.b-l.b)*d}}e.lerp=o})(Vi||(Vi={}));var es;(e=>{e.white={...Vi.white,a:1},e.transparent={...Vi.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{...Vi.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 Vi.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})(es||(es={}));var pg;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(pg||(pg={}));var sb;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(sb||(sb={}));var nb;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(nb||(nb={}));var kn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(kn||(kn={}));var Za;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Za||(Za={}));var wl;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(wl||(wl={}));var Xn;(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(OA.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;BA.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;RA.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;zA.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;NA.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;UA.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(Xn||(Xn={}));var fg;(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})(fg||(fg={}));var OA=["count"],BA=["radius","start","end","position","scale","rotation"],RA=["position","scale","rotation"],zA=["count","size"],NA=["count","position","scale","rotation"],UA=["strength","scale","rotation","position","movement","seed","freqScale"],mg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(mg||(mg={}));var gg;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:es.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(gg||(gg={}));var _l;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(_l||(_l={}));var vg;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(vg||(vg={}));var yg;(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})(yg||(yg={}));var xg;(e=>e.defaultData={...yg.defaultData,...vg.defaultData})(xg||(xg={}));var Ru;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Ru||(Ru={}));var ab;(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==="pattern"||i==="light"}e.is=t})(ab||(ab={}));function ak(e){return e.type!=="displace"}var ob;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(ob||(ob={}));var FA=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],ok=["wrapping","image","video","name"],Ji;(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){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Ru.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:Vi.fromHex(jr)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Vi.fromHex(6710886),a:1},colorB:{...Vi.fromHex(6710886),a:1},colorC:{...Vi.fromHex(16777215),a:1},colorD:{...Vi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:es.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:es.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:es.fromHexAndA(0,1),contourColor:es.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{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Vi.fromHex(0),a:1},colorB:{...Vi.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Ji||(Ji={}));var zi;(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:Ji.defaultData("light",h),id:d}),u.push({fi:1,data:Ji.defaultData("color"),id:c}),{layers:u}}e.defaultTwoLayerData=a;function o(h,d="phong",c="layer1",u="layer2"){let p=Ji.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:Ji.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,d="phong",c="layer1",u="layer2"){let p=Ji.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:Ji.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(zi||(zi={}));var zu;(e=>{function t(){return{points:new et,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(zu||(zu={}));var Nu;(e=>{function t(){return{points:new et,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Nu||(Nu={}));var kA={type:"Ellipse",width:100,height:100,spikes:16,angle:360,innerRadius:0},bg;(e=>{function t(i,r){let s={...i};return GA.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(bg||(bg={}));var jA={shape:kA,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},GA=["depth","offset","angle","twist","startScale","endScale"],Uu;(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})(Uu||(Uu={}));var wg;(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,bg.merge(s.extrusion,r.extrusion))),s}e.merge=t})(wg||(wg={}));var tl;(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:Nu.defaultData(),extrusion:jA};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:zu.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};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}e.defaultData=t})(tl||(tl={}));var lb=["width","height","depth"],_g;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Vi.white,near:.1,far:2e3})(_g||(_g={}));var Fu;(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}}})(Fu||(Fu={}));var Sg;(e=>e.defaultData={softShadowQuality:"low"})(Sg||(Sg={}));var Ag;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Ag||(Ag={}));var Mg;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Mg||(Mg={}));var Sl;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Sl||(Sl={}));var Eg;(e=>e.defaultData={playCamera:Vl,gameControlObject:null})(Eg||(Eg={}));var Cg;(e=>e.defaultData={backgroundColor:es.fromHexAndA(nk,1),postprocessing:Fu.defaultData,fog:_g.defaultData,globalPhysics:Sl.defaultData,ambient:Ag.defaultData,ao:Mg.defaultData,shadow:Sg.defaultData,publish:Eg.defaultData})(Cg||(Cg={}));var hb;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(hb||(hb={}));var Al;(e=>{e.identity={...pg.identity,hiddenMatrix:bl.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 mF({position:ja.isEqual(s.position,n.position)?void 0:n.position,rotation:ja.isEqual(s.rotation,n.rotation)?void 0:n.rotation,scale:ja.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:bl.isEqual(s.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})}e.diff=r})(Al||(Al={}));var Xi;(e=>e.defaultData={states:new et,events:new et,visible:!0,raycastLock:!1,physics:_l.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Al.identity,cloner:null})(Xi||(Xi={}));var cb;(e=>e.defaultData={type:"Empty",...Xi.defaultData})(cb||(cb={}));var db;(e=>e.defaultData={type:"Component",...Xi.defaultData})(db||(db={}));var il;(e=>e.defaultData={type:"Mesh",...Xi.defaultData,...xg.defaultData})(il||(il={}));var hc;(e=>e.defaultData={...Xi.defaultData,...Al.identity,position:[0,0,wl.DefaultTargetOffset],...wl.defaultData})(hc||(hc={}));var Tg;(e=>{function t(i){return{...Xi.defaultData,...gg.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Tg||(Tg={}));var ku;(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})(ku||(ku={}));var Yn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Xi.defaultData,...s,component:r,overrides:new di,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Al.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Yn||(Yn={}));var Ml;(e=>e.defaultData={type:"Page",...Xi.defaultData,physics:{..._l.defaultData,fusedBody:!1},...Cg.defaultData,camera:hc.defaultData})(Ml||(Ml={}));var Pg;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:bl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:_l.defaultData,states:new et,events:new et,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...wl.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",...Xi.defaultData,...il.defaultData,geometry:tl.defaultData("RectangleGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Xi.defaultData,...il.defaultData,geometry:tl.defaultData("BooleanGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Xi.defaultData,...il.defaultData,geometry:tl.defaultData("TextGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")}))(Pg||(Pg={}));var Oa;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new di}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new di})))):Za.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=Du(o.material,l=>{if(typeof l!="string")for(let[h,d]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&Ji.patch(c,d)}}).data),o.materials&&a.materials&&(o.materials=Du(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&&Ji.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:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let v={path:[...c,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,u]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...fg.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,Al.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})}),Za.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:wg.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Xn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Xn.merge(o.cloner,a.cloner)});else if(mg.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=Vi.clone(l.color))}return o}e.patch=s})(Oa||(Oa={}));var ju;(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})(ju||(ju={}));var Ga;(e=>e.defaultData={orbitControls:ju.defaultData,playPage:Vh,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",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"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Ga||(Ga={}));var Dg;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Dg||(Dg={}));var Ig;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Ig||(Ig={}));var rl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Dg.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Ig.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(rl||(rl={}));var cc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,n){r.traverseFrom(s,(a,o)=>{if(o.type==="Instance"){let l=r.data(o.component);l&&n(a,o,l.events)}else n(a,o,o.events)})}e.traverseModuleInstances=i})(cc||(cc={}));var Lg;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=[],a=Pg.defaultMeshObject;s.withLight===!0&&n.push({fi:-1,data:Tg.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]});let o=new nr;return o.push({fi:1,id:Vh,data:{...Ml.defaultData,name:"Scene 1"},children:n}),o}e.defaultData={objects:t(),publish:Ga.defaultData,styles:rl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new nr,publish:Ga.defaultData,styles:rl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Ga.defaultData,styles:rl.defaultData()}};function i(s){return{...e.defaultData,objects:Qa(s,nr.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(Lg||(Lg={}));var Gu;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Gu||(Gu={}));var Og;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Qa(s,ii.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Gu.emptyImage,name:"AI generated image"}),Qa(n,ii.prototype)}e.defaultImages=i;function r(){return{materials:new ii,images:new ii,videos:new ii,colors:new ii,audios:new ii,fonts:new ii}}e.emptyData=r})(Og||(Og={}));var Bg;(e=>e.list=["idle","move","jump","run"])(Bg||(Bg={}));var Vu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new et,move:new et,jump:new et,run:new et},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:es.fromHexAndA(3728051,1)}}))(Vu||(Vu={}));function ub(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={...vn(wi(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={...wi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function jn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Gn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=zi.defaultData(),s=r.materials[n]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function lk(e){Object.assign(e.scene.publish,{orbitControls:{...ju.defaultData,...wi(e.scene.publish.orbitControls)}})}function hk(e){Object.assign(e.scene.publish.settings,{video:{...Ga.defaultData.settings.video,...wi(e.scene.publish.settings.video)}})}function ck(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((FA.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(ok.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 dk(e){e.scene.publish.withBackground=!0}function uk(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function pk(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 fk(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 mk(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=wi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=wi(i).booleanExclude!==!0)}})}function gk(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 vk(e){function t(r){Object.setPrototypeOf(r,di.prototype),r.texture&&Object.setPrototypeOf(r.texture,di.prototype)}function i(r){Object.setPrototypeOf(r,di.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=wi(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=wi(l).layers;i(h),l.layers=h}})})}function pb(e){e.layers===void 0&&Object.assign(e,zi.defaultTwoLayerData("lambert"))}function Bf(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={...wi(t),colors:i,steps:r};Object.assign(t,s)}})}function yk(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function fb(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Bf(r)}):"material"in i&&typeof i.material!="string"&&Bf(i.material)}),Object.values(e.shared.materials).forEach(t=>Bf(t))}function xk(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 bk(e){e.shared.audios=Qa({},ii.prototype)}function wk(e){e.shared.videos=Qa({},ii.prototype)}function _k(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 Sk(e){Object.entries(wi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(wi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function Ak(e){e.scene.publish.settings.web.preload=!1}function mb(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 gb(e){e.layers&&e.layers.forEach(t=>{ak(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function Mk(e){e.shared.fonts=Qa({},ii.prototype)}function Ek(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 Ck(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=zi.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=Ek(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Xi.defaultData,...il.defaultData,flatShading:!1,wireframe:!1,geometry:{...tl.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:wi(s.states),events:wi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=wi(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 Tk(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:nt.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,vn(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:nt.generateUUID(),data:h},{fi:1,id:nt.generateUUID(),data:u})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function Pk(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={...vn(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...vn(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:nt.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function vb(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Ji.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function yb(e){jn(e,vb),Gn(e,vb)}function Dk(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function Ik(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 Lk(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=zi.defaultTwoLayerData("phong"))})}function Ok(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 Bk(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 Rk(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 zk(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function Nk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function Uk(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function Fk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Vu.defaultDataThirdPerson.navmesh)})})}function kk(e){e.scene.styles||(e.scene.styles=rl.defaultData())}function xb(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function jk(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Gn(e,xb),jn(e,xb)}function Gk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new et})})})}function Vk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function bb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function Hk(e,t){if(t<1&&(Gn(e,ub),jn(e,ub),e.schema=1),t<2&&(lk(e),e.schema=2),t<3&&(ck(e),e.schema=3),t<4&&(dk(e),e.schema=4),t<5&&(uk(e),e.schema=5),t<6&&(pk(e),e.schema=6),t<7&&(fk(e),e.schema=7),t<8&&(e.schema=8),t<9&&(fb(e),e.schema=9),t<10&&(yk(e),e.schema=10),t<11&&(xk(e),e.schema=11),t<12&&(fb(e),e.schema=12),t<13&&(bk(e),e.schema=13),t<14&&(_k(e),e.schema=14),t<15&&(Sk(e),e.schema=15),t<16&&(Ak(e),e.schema=16),t<17&&(Gn(e,mb),jn(e,mb),e.schema=17),t<18&&(Gn(e,pb),jn(e,pb),e.schema=18),t<19&&(hk(e),e.schema=19),t<20&&(Mk(e),Ck(e),e.schema=20),t<21&&(Tk(e),Pk(e),e.schema=21),t<22&&(yb(e),e.schema=22),t<23&&(Dk(e),e.schema=23),t<24&&(Ik(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(wk(e),t<25&&(e.schema=25)),t<26&&(mk(e),e.schema=26),t<27&&(gk(e),e.schema=27),t<28&&(yb(e),e.schema=28),t<29&&(vk(e),e.schema=29),t<30&&(Lk(e),e.schema=30),t<31&&(Ok(e),e.schema=31),t<33&&(Bk(e),e.schema=33),t<34&&(Rk(e),e.schema=34),t<35&&(zk(e),e.schema=35),t<36&&(Nk(e),e.schema=36),t<37&&(Uk(e),e.schema=37),t<38&&(Gn(e,gb),jn(e,gb),e.schema=38),t<39&&(Fk(e),e.schema=39),t<40&&(kk(e),e.schema=40),t<41&&(jk(e),e.schema=41),t<42&&(Gk(e),e.schema=42),t<43&&(Vk(e),e.schema=43),t<99){Gn(e,bb),jn(e,bb),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Vl);let i=wi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Vh,r.insertBefore(null,null,[{id:Vh,data:{...Ml.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:vn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:vn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Sl.defaultData,...vn(e.scene.environment,"usePhysics","gravity")},camera:wi(e.scene.ownerCamera)??Ml.defaultData.camera,name:"Scene"},children:[]}]);for(let a of i)a.id!==Lg.TRASH_CAN_ID&&r.move(Vh,a.fi,a.id);let s=0,n=0;e.shared.penumbraSize&&e.scene.objects.traverse((a,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(n,1)],n+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,_l.defaultData)),o.physics!==void 0&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function wb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function Wk(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var _b=102;function qk(e){let t=e.schema??0;t!==_b&&(console.warn("updating from ",t,"to ",_b),Hk(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Ga.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Gn(e,wb),jn(e,wb),e.schema=101),t<102&&(Wk(e),e.schema=102))}function Ba(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 qe,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=Sb(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 g=0;g<a[d].length;++g)p.push(a[d][g][u]);let f=Sb(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 Sb(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 Xk=Math.pow(2,-24),gd=class{constructor(){}};function Ps(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 Ab(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 Mb(e,t){t.set(e)}function Eb(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 vd(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 ch(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 Yk(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 Qk(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 Rf(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,g=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],_=e[y+1],A=b-_,S=b+_;A<n&&(n=A),S>l&&(l=S),v&&b<c&&(c=b),v&&b>f&&(f=b);let w=e[y+2],E=e[y+3],C=w-E,T=w+E;C<a&&(a=C),T>h&&(h=T),v&&w<u&&(u=w),v&&w>g&&(g=w);let D=e[y+4],P=e[y+5],L=D-P,R=D+P;L<o&&(o=L),R>d&&(d=R),v&&D<p&&(p=D),v&&D>m&&(m=D)}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]=g,s[5]=m)}function Zk(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 Kk(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 sn=32,Jk=(e,t)=>e.candidate-t.candidate,In=new Array(sn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),yd=new Float32Array(6);function $k(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=Ab(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=Ab(e),a!==-1&&(o=e6(i,r,s,a));else if(n===2){let l=ch(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)/sn;if(s<sn/4){let g=[...In];g.length=s;let m=0;for(let y=d;y<c;y+=6,m++){let x=g[m];x.candidate=i[y+2*u],x.count=0;let{bounds:b,leftCacheBounds:_,rightCacheBounds:A}=x;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,_[S]=1/0,_[S+3]=-1/0,b[S]=1/0,b[S+3]=-1/0;vd(y,i,b)}g.sort(Jk);let v=s;for(let y=0;y<v;y++){let x=g[y];for(;y+1<v&&g[y+1].candidate===x.candidate;)g.splice(y+1,1),v--}for(let y=d;y<c;y+=6){let x=i[y+2*u];for(let b=0;b<v;b++){let _=g[b];x>=_.candidate?vd(y,i,_.rightCacheBounds):(vd(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=g[y],b=x.count,_=s-x.count,A=x.leftCacheBounds,S=x.rightCacheBounds,w=0;b!==0&&(w=ch(A)/l);let E=0;_!==0&&(E=ch(S)/l);let C=1+1.25*(w*b+E*_);C<h&&(a=u,h=C,o=x.candidate)}}else{for(let v=0;v<sn;v++){let y=In[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=d;v<c;v+=6){let y=~~((i[v+2*u]-p)/f);y>=sn&&(y=sn-1);let x=In[y];x.count++,vd(v,i,x.bounds)}let g=In[sn-1];Mb(g.bounds,g.rightCacheBounds);for(let v=sn-2;v>=0;v--){let y=In[v],x=In[v+1];Eb(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<sn-1;v++){let y=In[v],x=y.count,b=y.bounds,_=In[v+1].rightCacheBounds;x!==0&&(m===0?Mb(b,yd):Eb(b,yd,yd)),m+=x;let A=0,S=0;m!==0&&(A=ch(yd)/l);let w=s-m;w!==0&&(S=ch(_)/l);let E=1+1.25*(A*m+S*w);E<h&&(a=u,h=E,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function e6(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 t6(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,n=new Float32Array(s*6),a=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let d=["getX","getY","getZ"];for(let c=0;c<s;c++){let u=c*3,p=c*6,f,g,m;a?(f=r[u+0],g=r[u+1],m=r[u+2]):(f=r[u+0]*h+l,g=r[u+1]*h+l,m=r[u+2]*h+l);for(let v=0;v<3;v++){let y,x,b;a?(y=i[d[v]](f),x=i[d[v]](g),b=i[d[v]](m)):(y=o[f+v],x=o[g+v],b=o[m+v]);let _=y;x<_&&(_=x),b<_&&(_=b);let A=y;x>A&&(A=x),b>A&&(A=b);let S=(A-_)/2,w=v*2;n[p+w+0]=_+S,n[p+w+1]=S+(Math.abs(_)+S)*Xk,_<t[v]&&(t[v]=_),A>t[v+3]&&(t[v+3]=A)}}return n}function i6(e,t){function i(v){u&&u(v/p)}function r(v,y,x,b=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 A=$k(v.boundingData,b,a,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let S=Kk(o,a,y,x,A);if(S===y||S===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let w=new gd,E=y,C=S-y;v.left=w,w.boundingData=new Float32Array(6),Rf(a,E,C,w.boundingData,n),r(w,E,C,n,_+1);let T=new gd,D=S,P=x-C;v.right=T,T.boundingData=new Float32Array(6),Rf(a,D,P,T.boundingData,n),r(T,D,P,n,_+1)}return v}Yk(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=t6(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,g=[],m=Qk(e);if(m.length===1){let v=m[0],y=new gd;y.boundingData=s,Zk(a,v.offset,v.count,n),r(y,v.offset,v.count,n),g.push(y)}else for(let v of m){let y=new gd;y.boundingData=new Float32Array(6),Rf(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),g.push(y)}return g}function r6(e,t){let i=i6(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,g=c.boundingData;for(let m=0;m<6;m++)r[u+m]=g[m];if(f){let m=c.offset,v=c.count;return s[u+6]=m,n[p+14]=v,n[p+15]=65535,d+32}else{let m=c.left,v=c.right,y=c.splitAxis,x;if(x=h(d+32,m),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 Ns=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}};Ns.prototype.setFromBox=function(){let e=new M;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 zq=function(){let e=new Ns;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}}}(),s6=function(){let e=new M,t=new M,i=new M;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,r.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,g,m;f!==0?g=(d*c-p*u)/f:g=0,m=(d+g*c)/u,n.x=g,n.y=m}}(),f0=function(){let e=new F,t=new M,i=new M;return function(r,s,n,a){s6(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}}}}(),n6=function(){let e=new M,t=new M,i=new vr,r=new Ur;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}}(),a6=1e-15;function So(e){return Math.abs(e)<a6}var wn=class extends Bi{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M),this.satBounds=new Array(4).fill().map(()=>new Ns),this.points=[this.a,this.b,this.c],this.sphere=new _r,this.plane=new vr,this.needsUpdate=!0}intersectsSphere(e){return n6(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}};wn.prototype.closestPointToSegment=function(){let e=new M,t=new M,i=new Ur;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]),f0(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)}}();wn.prototype.intersectsTriangle=function(){let e=new wn,t=new Array(3),i=new Array(3),r=new Ns,s=new Ns,n=new M,a=new M,o=new M,l=new M,h=new Ur,d=new Ur,c=new Ur;return function(u,p=null,f=!1){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let g=this.plane,m=u.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let _=0;_<4;_++){let A=v[_],S=y[_];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let x=u.satBounds,b=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let A=x[_],S=b[_];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let _=0;_<4;_++){let A=y[_];for(let S=0;S<4;S++){let w=b[S];if(n.crossVectors(A,w),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let L=v[P],R=v[(P+1)%3];h.start.copy(L),h.end.copy(R),h.delta(a);let V=y?d.start:d.end,k=So(m.distanceToPoint(L));if(So(m.normal.dot(a))&&k){d.copy(h),x=2;break}if((m.intersectLine(h,V)||k)&&!So(V.distanceTo(R))){if(x++,y)break;y=!0}}if(x===1&&u.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(x!==2)return!1;let b=u.points,_=!1,A=0;for(let P=0;P<3;P++){let L=b[P],R=b[(P+1)%3];h.start.copy(L),h.end.copy(R),h.delta(o);let V=_?c.start:c.end,k=So(g.distanceToPoint(L));if(So(g.normal.dot(o))&&k){c.copy(h),A=2;break}if((g.intersectLine(h,V)||k)&&!So(V.distanceTo(R))){if(A++,_)break;_=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==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),w=d.end.dot(a),E=c.start.dot(a),C=c.end.dot(a),T=w<E,D=S<C;return S!==C&&E!==w&&T===D?!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)}}}();wn.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();wn.prototype.distanceToTriangle=function(){let e=new M,t=new M,i=["a","b","c"],r=new Ur,s=new Ur;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],g=i[(p+1)%3];s.set(n[f],n[g]),f0(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Us=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new M,this.max=new M,this.matrix=new fe,this.invMatrix=new fe,this.points=new Array(8).fill().map(()=>new M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new Ns),this.alignedSatBounds=new Array(3).fill().map(()=>new Ns),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Us.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}}();Us.prototype.intersectsBox=function(){let e=new Ns;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}}();Us.prototype.intersectsTriangle=function(){let e=new wn,t=new Array(3),i=new Ns,r=new Ns,s=new M;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}}();Us.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}}();Us.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Us.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Ur),i=new Array(12).fill().map(()=>new Ur),r=new M,s=new M;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 g=0;g<8;g++){let m=u[g];s.copy(m).clamp(d,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(g+1)%3,x=(g+2)%3,b=m<<y|v<<x,_=1<<g|m<<y|v<<x,A=u[b],S=u[_];t[f].set(A,S);let w=e[g],E=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[w]=d[w],D[E]=m?d[E]:c[E],D[C]=v?d[C]:c[E],P[w]=c[w],P[E]=m?d[E]:c[E],P[C]=v?d[C]:c[E],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=g?c.x:d.x,s.y=m?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 g=0;g<12;g++){let m=t[g];for(let v=0;v<12;v++){let y=i[v];f0(m,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 Ao=new M,Mo=new M,Eo=new M,xd=new F,bd=new F,wd=new F,Cb=new M,Tb=new M,Pb=new M,_d=new M;function o6(e,t,i,r,s,n){let a;return n===xi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==yr,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function l6(e,t,i,r,s,n,a,o,l){Ao.fromBufferAttribute(t,n),Mo.fromBufferAttribute(t,a),Eo.fromBufferAttribute(t,o);let h=o6(e,Ao,Mo,Eo,_d,l);if(h){r&&(xd.fromBufferAttribute(r,n),bd.fromBufferAttribute(r,a),wd.fromBufferAttribute(r,o),h.uv=Bi.getInterpolation(_d,Ao,Mo,Eo,xd,bd,wd,new F)),s&&(xd.fromBufferAttribute(s,n),bd.fromBufferAttribute(s,a),wd.fromBufferAttribute(s,o),h.uv1=Bi.getInterpolation(_d,Ao,Mo,Eo,xd,bd,wd,new F)),i&&(Cb.fromBufferAttribute(i,n),Tb.fromBufferAttribute(i,a),Pb.fromBufferAttribute(i,o),h.normal=Bi.getInterpolation(_d,Ao,Mo,Eo,Cb,Tb,Pb,new M),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let d={a:n,b:a,c:o,normal:new M,materialIndex:0};Bi.getNormal(Ao,Mo,Eo,d.normal),h.face=d,h.faceIndex=n}return h}function VA(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),{position:h,normal:d,uv:c,uv1:u}=e.attributes,p=l6(i,h,d,c,u,a,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function h6(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)VA(e,t,i,a,n)}function c6(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=VA(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}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 Db(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 HA=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 Vn(e,t){return t[e+15]===65535}function sl(e,t){return t[e+6]}function dc(e,t){return t[e+14]}function uc(e){return e+8}function pc(e,t){return t[e+6]}function d6(e,t){return t[e+7]}var Zo=new Kt,Hu=new M,u6=["x","y","z"];function Rg(e,t,i,r,s){let n=e*2,a=Hl,o=ta,l=ia;if(Vn(n,o)){let h=sl(e,l),d=dc(n,o);h6(t,i,r,h,d,s)}else{let h=uc(e);Wu(h,a,r,Hu)&&Rg(h,t,i,r,s);let d=pc(e,l);Wu(d,a,r,Hu)&&Rg(d,t,i,r,s)}}function zg(e,t,i,r){let s=e*2,n=Hl,a=ta,o=ia;if(Vn(s,a)){let l=sl(e,o),h=dc(s,a);return c6(t,i,r,l,h)}else{let l=d6(e,o),h=u6[l],d=r.direction[h]>=0,c,u;d?(c=uc(e),u=pc(e,o)):(c=pc(e,o),u=uc(e));let p=Wu(c,n,r,Hu)?zg(c,t,i,r):null;if(p){let g=p.point[h];if(d?g<=n[u+l]:g>=n[u+l+3])return p}let f=Wu(u,n,r,Hu)?zg(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var p6=function(){let e,t,i=[],r=new HA(()=>new Kt);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,b=ta,_=ia;for(;!Vn(x,b);)y=uc(y),x=y*2;return sl(y,_)}function p(y){let x=y*2,b=ta,_=ia;for(;!Vn(x,b);)y=pc(y,_),x=y*2;return sl(y,_)+dc(x,b)}let f=n*2,g=Hl,m=ta,v=ia;if(Vn(f,m)){let y=sl(n,v),x=dc(f,m);return Ps(n,g,e),l(y,x,!1,c,d+n,e)}else{let y=uc(n),x=pc(n,v),b=y,_=x,A,S,w,E;if(h&&(w=e,E=t,Ps(b,g,w),Ps(_,g,E),A=h(w),S=h(E),S<A)){b=x,_=y;let V=A;A=S,S=V,w=E}w||(w=e,Ps(b,g,w));let C=Vn(b*2,m),T=o(w,C,A,c+1,d+b),D;if(T===2){let V=u(b),k=p(b)-V;D=l(V,k,!0,c+1,d+b,w)}else D=T&&s(b,a,o,l,h,d,c+1);if(D)return!0;E=t,Ps(_,g,E);let P=Vn(_*2,m),L=o(E,P,S,c+1,d+_),R;if(L===2){let V=u(_),k=p(_)-V;R=l(V,k,!0,c+1,d+_,E)}else R=L&&s(_,a,o,l,h,d,c+1);return!!R}}}(),f6=function(){let e=new wn,t=new wn,i=new fe,r=new Us,s=new Us;return function n(a,o,l,h,d=null){let c=a*2,u=Hl,p=ta,f=ia;if(d===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),d=r),Vn(c,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,x=l.attributes.position,b=sl(a,f),_=dc(c,p);if(i.copy(h).invert(),l.boundsTree)return Ps(a,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>s.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=b*3,w=(_+b)*3;S<w;S+=3)if(Ms(t,S,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,S=_+b*3;A<S;A+=3){Ms(e,A,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let w=0,E=y.count;w<E;w+=3)if(Ms(t,w,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=a+8,m=f[a+6];return Ps(g,u,Zo),!!(d.intersectsBox(Zo)&&n(g,o,l,h,d)||(Ps(m,u,Zo),d.intersectsBox(Zo)&&n(m,o,l,h,d)))}}}();function Wu(e,t,i,r){return Ps(e,t,Zo),i.intersectBox(Zo,r)}var Ng=[],ru,Hl,ta,ia;function Lh(e){ru&&Ng.push(ru),ru=e,Hl=new Float32Array(e),ta=new Uint16Array(e),ia=new Uint32Array(e)}function Sd(){ru=null,Hl=null,ta=null,ia=null,Ng.length&&Lh(Ng.pop())}var zf=Symbol("skip tree generation"),Nf=new Kt,Uf=new Kt,Co=new fe,ba=new Us,dh=new Us,uh=new M,Ad=new M,m6=new M,g6=new M,v6=new M,Ib=new Kt,ps=new HA(()=>new wn),Hh=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."),Hh.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."),Hh.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 Hh(t,{...i,[zf]:!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,[zf]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[zf]||(this._roots=r6(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Kt))),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,n,a,o,l=0,h=this._roots;for(let c=0,u=h.length;c<u;c++)s=h[c],n=new Uint32Array(s),a=new Uint16Array(s),o=new Float32Array(s),d(0,l),l+=s.byteLength;function d(c,u,p=!1){let f=c*2;if(a[f+15]===65535){let g=n[c+6],m=a[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,_=-1/0,A=-1/0;for(let S=3*g,w=3*(g+m);S<w;S++){let E=i[S],C=r.getX(E),T=r.getY(E),D=r.getZ(E);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>_&&(_=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==_||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=_,o[c+5]=A,!0):!1}else{let g=c+8,m=n[c+6],v=g+u,y=m+u,x=p,b=!1,_=!1;e?x||(b=e.has(v),_=e.has(y),x=!b&&!_):(b=!0,_=!0);let A=x||b,S=x||_,w=!1;A&&(w=d(g,u,x));let E=!1;S&&(E=d(m,u,x));let C=w||E;if(C)for(let T=0;T<3;T++){let D=g+T,P=m+T,L=o[D],R=o[D+3],V=o[P],k=o[P+3];o[c+T]=L<V?L:V,o[c+T+3]=R>k?R:k}return C}}}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=ns){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(Lh(i[h]),Rg(0,r,c,e,s),Sd(),a){let p=o[h].materialIndex;for(let f=u,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=ns){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;Lh(i[h]);let u=zg(0,r,c,e);Sd(),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(Lh(s),r=f6(0,i,e,t),Sd(),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,g)=>{let m=p*3;return c(u,m,m+1,m+2,f,g)}}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=ps.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(u,p,f,g,m)=>c(u,p,f,g,m)?!0:Db(u,p,r,l,f,g,s)}else o||(l?o=(c,u,p,f)=>Db(c,u,r,l,p,f,s):o=(c,u,p)=>p);let h=!1,d=0;for(let c of this._roots){if(Lh(c),h=p6(0,r,a,o,n,d),Sd(),h)break;d+=c.byteLength}return ps.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;Co.copy(t).invert();let h=ps.getPrimitive(),d=ps.getPrimitive();if(s){let u=function(p,f,g,m,v,y,x,b){for(let _=g,A=g+m;_<A;_++){Ms(d,_*3,o,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=p,w=p+f;S<w;S++)if(Ms(h,S*3,n,a),h.needsUpdate=!0,s(h,d,S,_,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,x,b,_){return p(f,g,m,v,y,x,b,_)?!0:u(f,g,m,v,y,x,b,_)}}else r=u}e.getBoundingBox(Uf),Uf.applyMatrix4(t);let c=this.shapecast({intersectsBounds:u=>Uf.intersectsBox(u),intersectsRange:(u,p,f,g,m,v)=>(Nf.copy(v),Nf.applyMatrix4(Co),e.shapecast({intersectsBounds:y=>Nf.intersectsBox(y),intersectsRange:(y,x,b,_,A)=>r(u,p,y,x,g,m,_,A)}))});return ps.releasePrimitive(h),ps.releasePrimitive(d),c}intersectsBox(e,t){return ba.set(e.min,e.max,t),ba.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ba.intersectsBox(i),intersectsTriangle:i=>ba.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(),ba.set(e.boundingBox.min,e.boundingBox.max,t),ba.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,d=e.index,c=ps.getPrimitive(),u=ps.getPrimitive(),p=Ad,f=m6,g=null,m=null;r&&(g=g6,m=v6);let v=1/0,y=null,x=null;return Co.copy(t).invert(),dh.matrix.copy(Co),this.shapecast({boundsTraverseOrder:b=>ba.distanceToBox(b),intersectsBounds:(b,_,A)=>A<v&&A<n?(_&&(dh.min.copy(b.min),dh.max.copy(b.max),dh.needsUpdate=!0),!0):!1,intersectsRange:(b,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>dh.distanceToBox(A),intersectsBounds:(A,S,w)=>w<v&&w<n,intersectsRange:(A,S)=>{for(let w=A*3,E=(A+S)*3;w<E;w+=3){Ms(u,w,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=b*3,T=(b+_)*3;C<T;C+=3){Ms(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(u,p,g);if(D<v&&(f.copy(p),m&&m.copy(g),v=D,y=C/3,x=w/3),D<s)return!0}}}});{let A=d?d.count:h.count;for(let S=0,w=A;S<w;S+=3){Ms(u,S,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let E=b*3,C=(b+_)*3;E<C;E+=3){Ms(c,E,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(u,p,g);if(T<v&&(f.copy(p),m&&m.copy(g),v=T,y=E/3,x=S/3),T<s)return!0}}}}}),ps.releasePrimitive(c),ps.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(m):r.point=m.clone(),r.point.applyMatrix4(Co),f.applyMatrix4(Co),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=>(uh.copy(e).clamp(h.min,h.max),uh.distanceToSquared(e)),intersectsBounds:(h,d,c)=>c<a&&c<n,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,uh);let c=e.distanceToSquared(uh);return c<a&&(Ad.copy(uh),a=c,o=d),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Ad):t.point=Ad.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Ps(0,new Float32Array(t),Ib),e.union(Ib)}),e}},ph=Pl(OE()),y6=.5*(Math.sqrt(3)-1),fh=(3-Math.sqrt(3))/6,x6=1/3,fs=1/6,Nq=(Math.sqrt(5)-1)/4,Uq=(5-Math.sqrt(5))/20,Wh=e=>Math.floor(e)|0,Lb=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]),Ff=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 kf(e=Math.random){let t=WA(e),i=new Float64Array(t).map(s=>Lb[s%12*2]),r=new Float64Array(t).map(s=>Lb[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*y6,d=Wh(s+h),c=Wh(n+h),u=(d+c)*fh,p=d-u,f=c-u,g=s-p,m=n-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let x=g-v+fh,b=m-y+fh,_=g-1+2*fh,A=m-1+2*fh,S=d&255,w=c&255,E=.5-g*g-m*m;if(E>=0){let D=S+t[w],P=i[D],L=r[D];E*=E,a=E*E*(P*g+L*m)}let C=.5-x*x-b*b;if(C>=0){let D=S+v+t[w+y],P=i[D],L=r[D];C*=C,o=C*C*(P*x+L*b)}let T=.5-_*_-A*A;if(T>=0){let D=S+1+t[w+1],P=i[D],L=r[D];T*=T,l=T*T*(P*_+L*A)}return 70*(a+o+l)}}function b6(e=Math.random){let t=WA(e),i=new Float64Array(t).map(n=>Ff[n%12*3]),r=new Float64Array(t).map(n=>Ff[n%12*3+1]),s=new Float64Array(t).map(n=>Ff[n%12*3+2]);return function(n,a,o){let l,h,d,c,u=(n+a+o)*x6,p=Wh(n+u),f=Wh(a+u),g=Wh(o+u),m=(p+f+g)*fs,v=p-m,y=f-m,x=g-m,b=n-v,_=a-y,A=o-x,S,w,E,C,T,D;b>=_?_>=A?(S=1,w=0,E=0,C=1,T=1,D=0):b>=A?(S=1,w=0,E=0,C=1,T=0,D=1):(S=0,w=0,E=1,C=1,T=0,D=1):_<A?(S=0,w=0,E=1,C=0,T=1,D=1):b<A?(S=0,w=1,E=0,C=0,T=1,D=1):(S=0,w=1,E=0,C=1,T=1,D=0);let P=b-S+fs,L=_-w+fs,R=A-E+fs,V=b-C+2*fs,k=_-T+2*fs,z=A-D+2*fs,X=b-1+3*fs,H=_-1+3*fs,G=A-1+3*fs,N=p&255,q=f&255,j=g&255,W=.6-b*b-_*_-A*A;if(W<0)l=0;else{let re=N+t[q+t[j]];W*=W,l=W*W*(i[re]*b+r[re]*_+s[re]*A)}let U=.6-P*P-L*L-R*R;if(U<0)h=0;else{let re=N+S+t[q+w+t[j+E]];U*=U,h=U*U*(i[re]*P+r[re]*L+s[re]*R)}let ie=.6-V*V-k*k-z*z;if(ie<0)d=0;else{let re=N+C+t[q+T+t[j+D]];ie*=ie,d=ie*ie*(i[re]*V+r[re]*k+s[re]*z)}let Q=.6-X*X-H*H-G*G;if(Q<0)c=0;else{let re=N+1+t[q+1+t[j+1]];Q*=Q,c=Q*Q*(i[re]*X+r[re]*H+s[re]*G)}return 32*(l+h+d+c)}}function WA(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 Xr=new Bi,w6=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;Xr.a.fromBufferAttribute(e,r),Xr.b.fromBufferAttribute(e,r+1),Xr.c.fromBufferAttribute(e,r+2),s*=Xr.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),Xr.a.fromBufferAttribute(this.positionAttribute,e*3),Xr.b.fromBufferAttribute(this.positionAttribute,e*3+1),Xr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Xr.a,r).addScaledVector(Xr.b,s).addScaledVector(Xr.c,1-(r+s)),Xr.getNormal(i),this}},_6=Pl(O_()),S6=new fe,A6=new fe,M6=new fe,fc;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(fc||(fc={}));var m0=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new fe,this.copyPreviousMatrix=!0,this.hiddenMatrix=new fe,this.matrixWorldRigid=new fe,this.shearScale=new fe,this.shearScaleInv=new fe}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Mt&&(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)}traverseChildren(t,i=0){for(let r of this.children)fc.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)fc.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,_6.SVD)(i),a=S6.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=A6.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=M6.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 fe().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof fe?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},E6=class extends m0(Mt){},C6=e=>e.type==="Mesh",Ri=class extends E6{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 Ri(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 C6(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}},Pa=new M,Da=new M,nl=new fe,qA=[new M(-1,1,1),new M(-1,-1,1),new M(1,-1,1),new M(1,1,1),new M(-1,1,-1),new M(-1,-1,-1),new M(1,-1,-1),new M(1,1,-1)],T6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],P6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Ob=(e,t,i)=>{e.updateEntityBoxSize(Pa,Da),nl.copy(t).multiply(e.matrixWorld),Da.x===0&&Da.y===0&&Da.z===0?i.push(new M(Pa.x,Pa.y,Pa.z).applyMatrix4(nl)):qA.forEach(r=>{i.push(r.clone().multiply(Da).add(Pa).applyMatrix4(nl))})},Bb=class extends Kt{constructor(){super(...arguments),this.matrix=new fe,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 fe().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 M);return}Ob(s,t,r)}}):Ob(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(nl.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Da).multiplyScalar(.5),this.getCenter(Pa),nl.copy(this.matrix).setPosition(Pa),this.vertices=qA.map(e=>e.clone().multiply(Da).applyMatrix4(nl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=T6.map(([e,t])=>new Ur(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new M))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=P6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},Qn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},D6=class extends oS{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}},Ug=.001;function Fg(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Ug}function jf(e,t){let i=new M(...e.position),r=new M(...e.controlNext.position),s=new M(...t.controlPrevious.position),n=new M(...t.position);return Fg(i,r,n)&&Fg(i,s,n)}function XA(e){let t=e.points.map(d=>new M(...d.data.position)),i=[e.points[0]],r=new M(...i[0].data.position);for(let d=0;d<e.points.length-1;d++)Fg(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 M(...c.position),p=new M(...c.controlPrevious.position),f=new M(...c.controlNext.position),g={position:u,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(d===0||d===a-1)){o[d]={...g,removedLength:0};continue}let m=s&&d==0?a-1:d-1,v=s&&d==a-1?0:d+1,y=i[m].data,x=i[v].data,b=new M(...y.position),_=new M(...x.position),A=b.clone().sub(u).normalize(),S=_.clone().sub(u).normalize();Object.assign(g,{prevDir:A,nextDir:S});let w=jf(y,c),E=jf(c,x);if(!w||!E)o[d]={...g,removedLength:0};else{let C=A.clone().add(S).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[d]={...g,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 g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/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],g=null;if(!jf(i[c].data,i[u].data))p.position.distanceTo(f.position)>Ug&&(g=new Jd(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>Ug&&(g=new Jd(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*d+1]=g}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),g=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),b=m.clone().multiplyScalar(-g).add(x),_=u.distanceTo(b)/u.distanceTo(v),A=c.prevDir.clone().multiplyScalar(_*u.distanceTo(p)).add(u),S=A.clone().lerp(b,2),w=p.clone().lerp(A,4/3),E=f.clone().lerp(S,4/3);l[2*d]=new Jd(p,w,E,f)}let h=new D6;return l.forEach(d=>{d&&h.add(d)}),h}var ut;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ut||(ut={}));var cn=e=>ut.is(e),I6={type:"completeState",isfromEntity:!0},g0=e=>class extends m0(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 Bb,this._recursiveBBox=new Bb,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(ut.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ut.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ut.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)Oa.toOps(this.data,s.data).forEach(n=>{let a=ig.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=Oa.patch(this.data,s),Oa.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(ut.is(i[r]))return i[r];if(ut.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ut.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=>{ut.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)cn(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}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 tg(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??bl.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)ut.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ut.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return tg(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=zr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let c=Ls.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=Ls.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Oa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),zr(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($n.apply(c.component.data,c.overrideData),r))}}else{let d=r.scene.findInstance([this.uuid,...l]);if(d){let c=Ls.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=ku.resolve(i.overrides,l),d.updateByOp(t,wr.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 Yn.rootOverrideProps)d in t.props&&(h===void 0&&(h={}),h[d]=t.props[d]);h&&(l={...t,props:h})}else for(let h of Yn.rootOverrideProps)if(zr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=$n.filterOp(h.overrideData,l);d&&h.updateByOp(d,wr.applySimple(h.data,d),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=$n.filterOp(h.overrideData,t);if(d){let c;n===h.data&&t===d?c=i:c=wr.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&&!Za.is(t.props.type)&&Qn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Qn.changeEntityProptotype(this,i,r);for(let s of this.children)ut.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),zr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),zr(t.path,["cloner"])!==null){let s=wr.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;if(o.geometry.path.points.length<=1)return;let l=XA(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 fe;a.updateMatrixWorld();let u=new fe().multiplyMatrices(c.clone().invert(),a.matrixWorld);d.applyMatrix4(u);let p={position:d.toArray(),rotation:o.rotation};if(n==="tangential"){let f=new fe().extractRotation(a.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(d),m=new fe().lookAt(d,g,new M(0,1,0)),v=new yi().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(I6)})}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()),i&&"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 Qn.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 Qn.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)}},YA=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 QA(h,d,r,s,n,a,o,l*Math.PI/180,c,c,u,p):f=new Lv(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 Ln(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Rb(e){return new F(e.y,-e.x)}var QA=class extends qe{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=[],g=[],m=[],v=0,y=i/2,x=new M,b=new M;u&&e==0&&(e=l),u&&t==0&&(t=h);let _=new F(e,y),A=new F(t,-y),S=null,w=null,E=null,C=null,T=_.clone().sub(A),D=0,P=0,L=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,L=t-D);let R=_.clone();R.x-=D;let V=Math.PI-T.angle(),k=T.angle(),z=Math.tan(k/2),X=Math.tan(V/2),H=z+X,G=c?H:X,N=c?H:z;if(l=Math.min(l,(e-P)/G,T.length()/H),h=Math.min(h,(t-L)/N,T.length()/H),l>0){let Q=l/z;S=_.clone().sub(new F(Q,l)),c&&(E=S.clone(),E.x-=D-H*l),_.sub(T.clone().setLength(Q))}if(h>0){let Q=h/X;w=A.clone().sub(new F(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=w.clone(),C.x-=D-H*h,R.sub(T.clone().setLength(Q)))}T=_.clone().sub(A);let q=T.length()<.5,j=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,ue=Z*o+a,ae=new F(Math.sin(ue),Math.cos(ue));C&&w?(W(re,Z,ae,V,h,C,-1,!0),W(re,Z,ae,k,h,w,-1,!1)):w?(U(re,ae,w.x,0,-1),W(re,Z,ae,k,h,w,-1,!1)):n||U(re,ae,t,L,-1);let se=Rb(T).normalize();if(Ln(se,ae,x),!q)for(let Ae=0;Ae<=s;Ae++){let Se=Ae/s,Me=T.clone().multiplyScalar(Se).add(A);Ln(Me,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}if(E&&S?(W(re,Z,ae,V,l,S,1,!1),W(re,Z,ae,k,l,E,1,!0)):S?(W(re,Z,ae,V,l,S,1,!1),U(re,ae,S.x,0,1)):n||U(re,ae,e,P,1),c&&!q){let Ae=Rb(T).multiplyScalar(-1).normalize();Ln(Ae,ae,x);for(let Se=0;Se<=s;Se++){let Me=Se/s,Pe=T.clone().multiplyScalar(-Me).add(R);Ln(Pe,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}}c&&!n&&re.push(re[0]),j.push(re)}for(let Q=0;Q<j.length-1;Q++)for(let re=0;re<j[0].length-1;re++){if(n&&c&&re==s)continue;let Z=j[Q][re],ue=j[Q+1][re],ae=j[Q+1][re+1],se=j[Q][re+1],Ae=f[ae*3+0],Se=f[ae*3+2];p.push(Z,ue,se),(Ae!=0||Se!=0)&&p.push(ue,ae,se)}o<Math.PI*2&&(ie(-1,j[0],a),ie(1,j[j.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Le(f,3)),this.setAttribute("normal",new Le(g,3)),this.setAttribute("uv",new Le(m,2));function W(Q,re,Z,ue,ae,se,Ae,Se){for(let Me=0;Me<d+1;Me++){let Pe=Me/d,xe=Ae<0?Pe:1-Pe;Se&&(xe-=1),xe*=ue;let ve=new F(Math.sin(xe),Math.cos(xe)*Ae),Re=ve.clone().multiplyScalar(ae).add(se);Ln(Re,Z,b),f.push(b.x,b.y,b.z),Ln(ve,Z,x),g.push(x.x,x.y,x.z),m.push(re,.5+b.y/i),Q.push(v++)}}function U(Q,re,Z,ue,ae){let se=new M,Ae=new F,Se=[Z,ue];ae<0&&Se.reverse();for(let Me of Se)Ae.set(Me,y*ae),Ln(Ae,re,se),f.push(se.x,se.y,se.z),g.push(0,ae,0),m.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let ue=new F(Math.sin(Z),Math.cos(Z)),ae=new F(-Math.cos(Z),Math.sin(Z)),se=new M,Ae=Q<0?(Pe,xe,ve)=>p.push(Pe,xe,ve):(Pe,xe,ve)=>p.push(Pe,ve,xe),Se=new F((e+t+P+L)/4,0);Ln(Se,ue,se),f.push(se.x,se.y,se.z),g.push(ae.x,0,ae.y),m.push(.5,.5);let Me=v++;for(let Pe of re){let xe=f.slice(Pe*3,Pe*3+3);f.push(...xe),g.push(ae.x,0,ae.y);let ve=m.slice(Pe*2,Pe*2+2);m.push(...ve),v++}for(let Pe=Me+1;Pe<v-1;Pe++)Ae(Me,Pe,Pe+1);Ae(Me,v-1,Me+1)}}},L6=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 QA(0,t/2,r,s,n,a,o,l*Math.PI/180,h,d,c,0,!0):u=new hS(t/2,r,s,n,a),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},O6=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 Rs(t,i,r,s,n,a):h=new B6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Gf=Math.PI/2,B6=class extends qe{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;g("z","y","x",-1,-1,i,t,e,n,s,0),g("z","y","x",1,-1,i,t,-e,n,s,1),g("x","z","y",1,1,e,i,t,r,n,2),g("x","z","y",1,-1,e,i,-t,r,n,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("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 Le(d,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(u,2));function g(y,x,b,_,A,S,w,E,C,T,D){let P=(S-2*a)/C,L=(w-2*a)/T,R=S/2-a,V=w/2-a,k=E/2,z=C+1,X=T+1,H=0,G=0,N=new M;for(let q=0;q<X;q++){let j=q*L-V;for(let W=0;W<z;W++){let U=W*P-R;N[y]=U*_,N[x]=j*A,N[b]=k,d.push(N.x,N.y,N.z),N[y]=0,N[x]=0,N[b]=E>0?1:-1,c.push(N.x,N.y,N.z),u.push(W/C),u.push(1-q/T),H+=1}}for(let q=0;q<T;q++)for(let j=0;j<C;j++){let W=p+j+z*q,U=p+j+z*(q+1),ie=p+(j+1)+z*(q+1),Q=p+(j+1)+z*q;h.push(W,U,Q),h.push(U,ie,Q),G+=6}l.addGroup(f,G,D),f+=G,p+=H}function m(y,x,b,_,A,S,w,E,C,T,D){let P=(w-2*a)/T,L=w/2-a,R=E/2-a,V=C/2,k=T+1,z=0,X=0,H=new M,G=new M;for(let N=0;N<o+1;N++){let q=N/o*Gf,j=Math.sin(q)*a,W=(1-Math.cos(q))*a,U=Math.sin(q),ie=Math.cos(q);H[x]=(R+j)*A,H[b]=(V-W)*S,G[y]=0,G[x]=U*Math.sign(H[x]),G[b]=ie*Math.sign(H[b]);for(let Q=0;Q<k;Q++){let re=Q*P-L;H[y]=re*_,d.push(H.x,H.y,H.z),c.push(G.x,G.y,G.z),u.push(Q/T),u.push(0),z+=1}}for(let N=0;N<o;N++)for(let q=0;q<T;q++){let j=p+q+k*N,W=p+q+k*(N+1),U=p+(q+1)+k*(N+1),ie=p+(q+1)+k*N;h.push(j,W,ie),h.push(W,U,ie),X+=6}l.addGroup(f,X,D),f+=X,p+=z}function v(y,x,b){let _=new M,A=new M(e/2,t/2,i/2);A.subScalar(a);let S=[],w=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=Gf*(1-C/o),P=Math.cos(D),L=Math.sin(D),R=0;for(let V=0;V<=C;V++){let k=Math.cos(R),z=Math.sin(R);_.x=P*k,_.y=L,_.z=P*z;let X=A.clone().addScaledVector(_,a);d.push(y*X.x,x*X.y,b*X.z),c.push(y*_.x,x*_.y,b*_.z),u.push(0,0),T.push(p++),R+=Gf/C}S.push(T)}let E=S.length-1;for(let C=0;C<E;C++){let T=S[C],D=S[C+1],P=T.length-1;w(T[0],D[1],D[0]);for(let L=1;L<=P;L++)w(T[L-1],T[L],D[L]),w(T[L],D[L+1],D[L])}}}},v0=class extends qe{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),d(),this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(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 M,p=u.clone(),f=new Bi,g=s*r,m=r-g,v=n+1,y=new M,x=(k,z)=>y.subVectors(k,z).normalize(),b=(k,z)=>Array(k).fill(void 0).map(z),_=b(e.length/3,(k,z)=>new M().fromArray(e,z*3).setLength(r)),A=[],S=1e6;for(let k=0;k<_.length;k++){let z=_[k],X=[],H,G,N,q=1e10,j=-1;for(;(j=t.indexOf(k,j+1))!=-1;){let Q=j-j%3;H=t[Q+(j+1)%3],G=t[Q+(j+2)%3],N=z.distanceToSquared(_[H]),q=Math.min(q,N),X.push([H,G,N])}q+=1e-6;let W=[],U=0,ie=X.length;for(let Q=0;Q<ie;Q++){[H,G,N]=X[U];let re=A[H]?.includes(k)==!0;N<=q&&W.push(H+ +re*S),U=X.findIndex(Z=>Z[0]==G)}A.push(W)}let w=[];{let k=0,z=0,X,H,G=c==3;for(let N=0;N<=n;N++){X=N*(N+1)/2,H=(N+1)*(N+2)/2;for(let q=0;q<n-N;q++)[k,z]=[X+q+N+2,H+q+N+3],w.push(X,H,...G?[z,X]:[k,H],z,k),[X,H]=[k,z];w.push(X,H,X+n+2)}}let E=u.clone(),C=u.clone(),T=u.clone(),D=u.clone(),P=u.clone(),L=[],R=b(_.length,()=>b(c,()=>u.clone()));for(let k=0;k<_.length;k++){u.copy(_[k]).normalize(),E.copy(u).multiplyScalar(m);let z=A[k];for(let W=0;W<z.length;W++){let U=z[W],ie=z[(W+1)%c];f.setFromPointsAndIndices(_,k,U%S,ie%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(E,R[k][W])}let X=[],H=[],G=[],N=new M;n==0&&[...R[k]].reduce((W,U)=>W.add(U),N).multiplyScalar(1/c);for(let W=0;W<c;W++){let U=[],ie=(W-1+c)%c,Q=R[k][ie],re=R[k][W];u.copy(Q).sub(E),p.copy(re).sub(E);let Z=E.angleTo(u),ue=u.angleTo(p),ae=Math.cos(Z)*g;n==0?C.copy(N):C.copy(E).setLength(m+ae),H.push(ae);let se=[C,Q,re];for(let Ae=0;Ae<2;Ae++){let Se=se[Ae],Me=se[Ae+1];D.subVectors(Se,E),P.subVectors(Me,E),T.crossVectors(D,P).normalize();for(let Pe=0;Pe<v;Pe++){let xe=[Z,ue][Ae]*Pe/v;u.copy(D).applyAxisAngle(T,xe).add(E),X.push(u.clone()),Ae&&(x(u,E),U.push([Pe==0?Se:u.clone(),y.clone()]))}Ae&&(x(Me,E),U.push([Me,y.clone()]))}G.push(U)}L.push(G);let q=2*v,j=2;for(let W=0;W<c;W++){let U=q*W,ie=q*((W+1)%c),Q=[X[U]];for(let Z=1;Z<v;Z++){D=X[U+Z],P=X[ie+Z],Q.push(D);for(let ue=1,ae=Z-j+1;ue<=ae;ue++)u.lerpVectors(D,P,ue/(ae+1)),u.sub(E).setLength(H[W]).add(E),Q.push(u.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(X[Z+v+U]);Q.push(X[ie+v]);let re=w.map(Z=>Q[Z]);a.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,E),[y.x,y.y,y.z])).flat())}}let V=[];for(let k=0;k<A.length;k++)for(let z=0;z<c;z++){let X=A[k][z];if(X<S){let H=A[X].findIndex(q=>q%S==k),G=L[k][z],N=L[X][H];for(let q=0;q<v;q++){let j=G[q],W=N[v-q],U=G[q+1],ie=N[v-(q+1)];[j,W,U,U,W,ie].forEach(Q=>{a.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}V.push(G[0][0],N[v][0],G[v][0],N[0][0])}}for(;V.length;){let k,z,X,H;[k,z]=V.splice(0,2);let G=[k];for(;k!=z;)G.push(z),X=V.indexOf(z),H=X%2,z=V.splice(X-H,2)[1-H];y.subVectors(G[0],G[1]).cross(u.subVectors(G[0],G[2])).normalize();let N=y.dot(G[0])<0;N&&y.negate();for(let q=1;q<=G.length-2;q++)[G[q+ +N],G[q+1-+N],G[0]].forEach(j=>{a.push(j.x,j.y,j.z),l.push(y.x,y.y,y.z)})}}function d(){let c=new M;for(let A=0;A<a.length;A+=3){c.x=a[A+0],c.y=a[A+1],c.z=a[A+2];let S=b(c)/2/Math.PI+.5,w=_(c)/Math.PI+.5;o.push(S,1-w)}let u=new M,p=new M,f=new M,g=new M,m=new F,v=new F,y=new F,x=(A,S,w,E)=>{E<0&&A.x===1&&(o[S]=A.x-1),w.x===0&&w.z===0&&(o[S]=E/2/Math.PI+.5)};for(let A=0,S=0;A<a.length;A+=9,S+=6){u.set(a[A+0],a[A+1],a[A+2]),p.set(a[A+3],a[A+4],a[A+5]),f.set(a[A+6],a[A+7],a[A+8]),m.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),y.set(o[S+4],o[S+5]),g.copy(u).add(p).add(f).divideScalar(3);let w=b(g);x(m,S+0,u,w),x(v,S+2,p,w),x(y,S+4,f,w)}for(let A=0;A<o.length;A+=6){let S=o[A+0],w=o[A+2],E=o[A+4],C=Math.max(S,w,E),T=Math.min(S,w,E);C>.9&&T<.1&&(S<.2&&(o[A+0]+=1),w<.2&&(o[A+2]+=1),E<.2&&(o[A+4]+=1))}function b(A){return Math.atan2(A.z,-A.x)}function _(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new v0(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},R6=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 ZA(t*.5,n,a):new cS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},ZA=class extends v0{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 ZA(e.radius,e.corner,e.cornerSides)}},mh=1e-12,y0=class{constructor(e){this.position=new F,this.startPosition=new F,this.uuid=nt.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 y0(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},kg=class extends y0{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new kg(this.parent).copy(this)}},al=class extends y0{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new kg(this),new kg(this))}static create(e,t){let i=new al(e,new F(...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 al(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 F,t=new F){let[i,r]=this.computeTangents();return i&&r&&(zb(i,e),zb(r,t)),[e,t]}computeTangent(e=new F){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new F){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function zb(e,t=new F){let i=e.length();return t.set(-e.y/i,e.x/i)}var x0=e=>e,Wl=new F,wp=new F,z6=new F,N6=new F,U6=new F,F6=new F,KA=new M,JA=new M;function k6(e){let t=new F;t.addVectors(e.v0,Wl.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new F;return i.addVectors(e.v2,wp.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new $r(e.v0,t,i,e.v2)}function Oh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function j6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function G6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function $A(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 V6(e,t,i){return Ub(e,t)&&Ub(t,i)&&jg(e.position,t.position,i.position)}function jg(e,t,i){return Wl.copy(t).sub(e).cross(wp.copy(i).sub(e))===0}function H6(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 W6(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function q6(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 $A(t,e,i)>Math.PI&&(d*=-1),Oh(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 Nb(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Ub(e,t){return jg(e.position,e.controls[1].position,t.position)&&jg(e.position,t.controls[0].position,t.position)}function X6(e,t,i,r,s=.5){let n=Wl.subVectors(t,e).multiplyScalar(s).add(e),a=wp.subVectors(i,t).multiplyScalar(s).add(t),o=z6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=N6.subVectors(a,n).multiplyScalar(s).add(n),d=U6.subVectors(o,a).multiplyScalar(s).add(a),c=o,u=F6.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 Y6(e,t,i=12,r=!0){let s=JA.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=x0(t[l]),d=Wl,c=Va(h,i);o.push(c);for(let u=0;u<=c;u++)if(h instanceof $r||h instanceof sa||h instanceof ss){if(h.getPoint(u/c,d),s.set(d.x,d.y,0),n!==void 0&&G6(n,s))continue;n===void 0&&(n=KA),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 Q6(e,t,i,r=12,s=!0){let n=JA.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,d=x0(t[l]),c=Wl,u=Va(d,r);o.push(u);for(let p=0;p<=u;p++)if(d instanceof $r||d instanceof sa||d instanceof ss){if(d.getPoint(p/u,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=KA:(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 Fb(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=Va(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Va(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Va(e[0].roundedCurveCorner,t)*.5),r}function Va(e,t=12){return e&&e instanceof np?t*2:e&&(e instanceof ss||e instanceof aS)?1:e&&e instanceof Iv?t*e.points.length:t}function Z6(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=x0(t[a]),l=Va(o,i),h=Wl;for(let d=0;d<=l;d++)if(o instanceof $r||o instanceof sa||o instanceof ss){if(o.getPoint(d/l,h),s!==void 0&&j6(s,h,mh))continue;s===void 0&&(s=wp),s.copy(h),e.push(h.x,h.y),n++}}return Oh(e[0],e[e.length-2],mh)&&Oh(e[1],e[e.length-1],mh)&&(e.pop(),e.pop()),r&&n>1&&!(Oh(e[n-1],e[1],mh)&&Oh(e[n-2],e[0],mh))&&(e.push(e[0],e[1]),n++),e}var Vf=new F,K6=new F,J6=new F,$6=new F,e8=new F,t8=new F,Vt=class extends gu{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new vr(new M(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=nt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Vt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>al.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Vt.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=Vf.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=nt.generateUUID()){let r;e instanceof F?r=e:r=new F(e,t);let s=new al(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 Y6(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Fb(this.points,e,!1),this.roundedCurveDivisions=Fb(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return Q6(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),Z6(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=Va(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(Nb(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Vf.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){Nb(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&&V6(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(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,x=v/f,b=h.getPointAt(y,Vf),_=d.getPointAt(x,K6);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(d,u,x,void 0,_);let A;if(this.useCubicForRoundedCorners){let S=$A(b,s.position,_)/2,w=Math.tan(S)*b.distanceTo(s.position),[E,C]=H6(b,_,w,J6,$6),T=W6(E,C,s.position),[D,P]=q6(T,b,_,w,e8,t8);A=new $r(b.clone(),D.clone(),P.clone(),_.clone())}else A=new sa(b.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof ss)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=X6(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 Vt(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 al(nt.generateUUID(),new F(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 Vt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof $r&&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 sa&&(r[n]=k6(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 $r?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof ss&&(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 $r?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof ss&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof gu&&(this.shapeHoles=e.holes.map(r=>{let s=new Vt;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)}},Gg=Math.PI*2;function Hf({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function i8(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 kb(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 r8(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 g=f*s/n*o,m=f*-n/s*a,v=g+(e+i)/2,y=m+(t+r)/2,x=(a-g)/s,b=(o-m)/n,_=(-a-g)/s,A=(-o-m)/n,S=kb(1,0,x,b),w=kb(x,b,_,A);return!h&&w>0&&(w-=Gg),h&&w<0&&(w+=Gg),{centerx:v,centery:y,ang1:S,ang2:w}}function s8({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=r8(e,t,i,r,s,n,h,d,a,o),{ang1:p,ang2:f}=u,{centerx:g,centery:m}=u,v=Math.abs(f)/(Gg/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(i8(p,f)),p+=f;return l.map(x=>{let{x:b,y:_}=Hf(x[0],s,n,g,m),{x:A,y:S}=Hf(x[1],s,n,g,m),{x:w,y:E}=Hf(x[2],s,n,g,m);return{x1:b,y1:_,x2:A,y2:S,x:w,y:E}})}var St;(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"})(St||(St={}));var ri;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ri||(ri={}));function He(e,t){if(!e)throw t||"Assertion Failed!"}var Ne=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){He(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){He(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){He(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){He(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}(),gh=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}(),Md=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}(),jo=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}(),jb=function(){function e(){var t=new jo,i=new gh,r=new Md(0),s=new Md(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 Md(0),r=new Md(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;He(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;He(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 jo,i=new jo,r=new gh,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 jo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new gh;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 gh;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 jo;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 gh;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&&Ne.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Ne.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){He(s.prev===n),l=s.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(He(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){He(a.prev===o),l=a.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(He(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)He(l.Sym.next===h.Sym),He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Org!==null),He(l.Dst!==null),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l);He(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}(),Gb=function(){function e(){this.handle=null}return e}(),Vb=function(){function e(){this.key=null,this.node=0}return e}(),n8=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 Gb,this.handles[r]=new Vb;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,He(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 Gb;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new Vb}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;He(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}(),Wf=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}(),Hb=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),a8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new Hb,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 Hb;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}(),o8=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?Ne.vertLeq(n.Org,a.Org)?Ne.edgeSign(a.Dst,n.Org,a.Org)<=0:Ne.edgeSign(n.Dst,a.Org,n.Org)>=0:Ne.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Ne.edgeSign(n.Dst,s,n.Org)>=0;var o=Ne.edgeEval(n.Dst,s,n.Org),l=Ne.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&He(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){He(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 Wf;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 St.ODD:return(i&1)!==0;case St.NONZERO:return i!==0;case St.POSITIVE:return i>0;case St.NEGATIVE:return i<0;case St.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 He(Ne.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,He(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=Ne.vertL1dist(i,t),n=Ne.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(Ne.vertLeq(s.Org,n.Org)){if(Ne.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Ne.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(Ne.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(He(!Ne.vertEq(s.Dst,n.Dst)),Ne.vertLeq(s.Dst,n.Dst)){if(Ne.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(Ne.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 jo,p,f;if(He(!Ne.vertEq(h,l)),He(Ne.edgeSign(l,t.event,a)<=0),He(Ne.edgeSign(h,t.event,o)>=0),He(a!==t.event&&o!==t.event),He(!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(Ne.vertLeq(a,o)){if(Ne.edgeSign(h,a,o)>0)return!1}else if(Ne.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Ne.intersect(l,a,h,o,u),He(Math.min(a.t,l.t)<=u.t),He(u.t<=Math.max(o.t,h.t)),He(Math.min(h.s,l.s)<=u.s),He(u.s<=Math.max(o.s,a.s)),Ne.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Ne.vertLeq(a,o)?a:o,Ne.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Ne.vertEq(u,a)||Ne.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Ne.vertEq(l,t.event)&&Ne.edgeSign(l,t.event,u)>=0||!Ne.vertEq(h,t.event)&&Ne.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):(Ne.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),Ne.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),Ne.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),Ne.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}Ne.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,Ne.vertEq(s.Org,r)){He(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Ne.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}He(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(He(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Ne.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 Wf;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Ne.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Ne.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);He(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 Wf,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 a8(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||(He(i.fixUpperEdge),He(++r===1)),He(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,Ne.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 n8(n,Ne.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,He(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||!Ne.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}(),l8=function(){function e(){this.mesh=new jb,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=St.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],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,f[m]=i,l[m]=n,p[m]=i;for(i=g.next;i!==g;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=g.next;i!==g;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(;Ne.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ne.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Ne.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Ne.edgeGoesLeft(s.Lnext)||Ne.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&&(Ne.edgeGoesRight(r.Lprev)||Ne.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===ri.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===ri.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 jb),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=St.ODD),i===void 0&&(i=ri.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_(),o8.computeInterior(this,a);var o=this.mesh;return i===ri.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===ri.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Zn(e){var t=e.windingRule,i=t===void 0?St.ODD:t,r=e.elementType,s=r===void 0?ri.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,g=e.debug,m=g===void 0?!1:g;if(!u&&f)throw new Error("Contours can't be empty");if(u){var v=new l8;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:m?v.mesh:void 0}}}var Fq=St.ODD,kq=St.NONZERO,jq=St.POSITIVE,Gq=St.NEGATIVE,Vq=St.ABS_GEQ_TWO,Hq=ri.POLYGONS,Wq=ri.CONNECTED_POLYGONS,qq=ri.BOUNDARY_CONTOURS,Vg=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*Vg.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*Vg.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);t?(a.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),o.set(this.normals),l.set(this.uvs)),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)}},e2=Vg;e2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var h8=Pl(RE()),b0={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},t2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},i2={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},qf=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),w0=class extends qe{constructor(e,t,i=0,r=12,s=3,n=St.ODD,a=!1){super(),this.forPathBevel=a,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(E=>{let C=E.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],L=C[D-0];T.push(P,L)}return T}),h=[],d=[];for(let E=0;E<o.length;E+=2)d.push([o[E],o[E+1]]);h.push(d);for(let E=0;E<l.length;E++){let C=l[E],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c=h[0].length?(0,h8.default)(h).distance:i;i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let u;try{u=Zn({windingRule:n,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{u=b0}let p;try{p=Zn({windingRule:St.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=t2}if(!u)throw new Error("error generating geometry");let f=u.elementCount;if(p){u.elementCount+=p.elementCount;for(let E=0;E<p.elements.length;E++){let C=p.elements[E],T=E%2===0?u.vertexCount:0;u.elements.push(C+T)}for(let E=0;E<p.vertexIndices.length;E++){let C=p.vertexIndices[E],T=u.vertexCount;u.vertexIndices.push(C+T)}for(let E=0;E<p.vertices.length;E++){let C=p.vertices[E];u.vertices.push(C)}}let g=1/0,m=-1/0,v=1/0,y=-1/0;for(let E=0,C=u.vertexCount;E<C;E++){let T=E*2,D=u.vertices[T+0],P=u.vertices[T+1];D<g&&(g=D),D>m&&(m=D),P<v&&(v=P),P>y&&(y=P)}this._minX=g,this._minY=v,this._width=m-g,this._height=y-v,this._buffer=new e2(this._computeBufferEstimatedSize(u));let x=[],b=[];for(let E=u.elementCount-1;E>=0;E--){let C=E>=f,T=E*2,D=u.elements[T+0],P=u.elements[T+1],L=D+P,R={start:D,count:P,normals:[],continuous:[],concave:[]},V=D,k=L-1,z=D+1,X=this._shape.roundedCurves.length;do{let j=V-D,W=u.vertices[k*2+0],U=u.vertices[k*2+1],ie=u.vertices[V*2+0],Q=u.vertices[V*2+1],re=u.vertices[z*2+0],Z=u.vertices[z*2+1],ue=ie-W,ae=Q-U,se=Math.sqrt(ue*ue+ae*ae);ue/=se,ae/=se;let Ae=ie-re,Se=Q-Z,Me=Math.sqrt(Ae*Ae+Se*Se);Ae/=Me,Se/=Me,R.normals[j*2+0]=-Se,R.normals[j*2+1]=Ae,R.concave[j]=ue*Se-ae*Ae>0;let Pe=u.vertexIndices[V];if(Array.isArray(Pe))R.continuous[j]=!1;else{let[xe,ve]=this._shape.getCurveIndexFromVertexId(Pe-1,!0);if(ve>0&&ve<1)R.continuous[j]=!0;else{let Re=ve===1?xe+1:xe-1;Re=(Re+X)%X;let Qe=ve===1?0:1,B=this._shape.roundedCurves[xe].getTangent(ve),I=this._shape.roundedCurves[Re].getTangent(Qe);R.continuous[j]=B.dot(I)>.95}}C&&(R.normals[j*2+0]*=-1,R.normals[j*2+1]*=-1),[k,V,z]=[V,z,z+1],z>=L&&(z-=P)}while(z!==D+1);let H=[];H.push({bevelI:0,angle:0,size:0,boundary:{vertices:u.vertices.slice(D*2,L*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((j,W)=>[W,W]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:u.vertices.slice(D*2,L*2)});let G=0;for(let j=1;j<=this._bevelSegments;j++){let W=j/this._bevelSegments*Math.PI/2,U=(1-Math.cos(W))*this._bevel,ie=[],Q=[],re=[],Z=[],ue=0;for(let se=0;se<P;se++){let Ae=se*2,Se=(se-1+P)%P*2,Me=u.vertices[R.start*2+Ae+0],Pe=u.vertices[R.start*2+Ae+1],xe=-R.normals[Se+0]*U,ve=-R.normals[Se+1]*U,Re=-R.normals[Ae+0]*U,Qe=-R.normals[Ae+1]*U;if(R.concave[se]||!R.concave[se]&&C){let B=Math.atan2(ve,xe),I=Math.atan2(Qe,Re);I>B&&(I-=Math.PI*2);let $=I-B;if(R.continuous[se]||C){let me=B+$/2,ce=Math.cos(me)*U,ye=Math.sin(me)*U;ie[2*ue+0]=Me+ce*(C?-1:1),ie[2*ue+1]=Pe+ye*(C?-1:1),Z[ue]=se,ue++}else{let me=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let ce=0;ce<=me;ce++){let ye=B+$*(ce/me),Oe=Math.cos(ye)*U,Ee=Math.sin(ye)*U;ie[2*ue+0]=Me+Oe,ie[2*ue+1]=Pe+Ee,Z[ue]=se,ue++}}}else ie[2*ue+0]=Me+xe,ie[2*ue+1]=Pe+ve,Z[ue]=se,Q[se]=ue,ue++,ie[2*ue+0]=Me,ie[2*ue+1]=Pe,Z[ue]=se,ue++,ie[2*ue+0]=Me+Re,ie[2*ue+1]=Pe+Qe,Z[ue]=se,re[se]=ue,ue++}let ae=Zn({windingRule:St.POSITIVE,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:se=>{let Ae=se.Org.idx,Se=Z[Ae],Me=Z[(Ae+1)%Z.length];se.idx=[Se,Me],se.Sym.idx=[Me,Se]},vertexIdCallback:se=>{let Ae=se.Lprev.idx;return[Ae?Ae[1]:0,se.idx?se.idx[0]:0]}});if(!ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!ae.vertexCount){let se=(j-1)/this._bevelSegments*Math.PI/2;G=(1-Math.sin(se))*this._bevel;break}for(let se=0;se<ae.vertexIndices.length;se++){let[Ae,Se]=ae.vertexIndices[se];if(Ae===Se)continue;let Me=Se;Se<Ae&&(Me+=P);for(let Pe=Ae;Pe<Me;Pe++){let xe=Pe%P,ve=(Pe+1)%P;if(!R.continuous[xe]||!R.continuous[ve]){ae.vertexIndices[se]=[Ae,xe],ae.vertexIndices.splice(se+1,0,[ve,Se]),ae.vertices.splice((se+1)*2,0,ae.vertices[se*2],ae.vertices[se*2+1]);break}}}H.push({bevelI:j,angle:W,size:U,boundary:ae,reverseMap:Z,insetPoints:ie})}let N=(j,W,U)=>{let ie=0,Q=j.boundary.vertexIndices.length;for(;ie<Q&&U(j.boundary.vertexIndices[W]);)W=(W+1)%Q,ie++;return ie},q=x.length;for(let j=1;j<H.length;j++){let W=H[j-1],U=H[j],ie=W.boundary.vertexIndices.length,Q=U.boundary.vertexIndices.length;if(!ie||!Q)break;let re=R.concave.length,Z=0,ue=qf(Z,P);for(;!W.boundary.vertexIndices.filter(ue).length||!U.boundary.vertexIndices.filter(ue).length;)Z++,ue=qf(Z,P);let ae=W.boundary.vertexIndices.findIndex(ue),se=U.boundary.vertexIndices.findIndex(ue);do ae=(ae+1)%ie;while(ue(W.boundary.vertexIndices[ae]));do se=(se+1)%Q;while(ue(U.boundary.vertexIndices[se]));Z=(Z+1)%P;let Ae=Z,Se=0,Me=this._buildBevelVert(R,W,(ae-1+ie)%ie,void 0,Se),Pe=this._buildBevelVert(R,U,(se-1+Q)%Q,void 0,Se),xe=Me,ve=Pe,Re,Qe,B=!1;do{Se=(Z||re)/re,ue=qf(Z,P);let I=N(W,ae,ue),$=N(U,se,ue),me=B;if(B=!1,I&&!$){for(let ce=0;ce<I;ce++)Re=this._buildBevelVert(R,W,(ae+ce)%ie,ce/(I-1),Se),x.push(xe.topN,Re.topP,ve.topN),a===!1&&x.push(Re.bottomP,xe.bottomN,ve.bottomN),xe=Re;B=!0}else if(!I&&$)for(let ce=0;ce<$;ce++)Qe=this._buildBevelVert(R,U,(se+ce)%Q,ce/($-1),Se),x.push(ve.topN,xe.topP,Qe.topP),a===!1&&x.push(xe.bottomP,ve.bottomN,Qe.bottomP),ve=Qe;else if(I&&$)if(Re=this._buildBevelVert(R,W,ae,0,Se),Qe=this._buildBevelVert(R,U,se,0,Se),me?(x.push(xe.topN,Qe.topP,ve.topN),x.push(xe.topN,Re.topP,Qe.topP),a===!1&&(x.push(Qe.bottomP,xe.bottomN,ve.bottomN),x.push(Qe.bottomP,Re.bottomP,xe.bottomN))):(x.push(ve.topN,xe.topN,Re.topP),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&(x.push(Re.bottomP,xe.bottomN,ve.bottomN),x.push(Re.bottomP,ve.bottomN,Qe.bottomP))),xe=Re,ve=Qe,I===$)for(let ce=1;ce<I;ce++)Re=this._buildBevelVert(R,W,(ae+ce)%ie,ce/(I-1),Se),Qe=this._buildBevelVert(R,U,(se+ce)%Q,ce/($-1),Se),x.push(xe.topN,Re.topP,ve.topN),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&(x.push(Re.bottomP,xe.bottomN,ve.bottomN),x.push(Re.bottomP,ve.bottomN,Qe.bottomP)),xe=Re,ve=Qe;else if(I>$){let ce=I/$,ye=0;for(let Oe=1;Oe<I;Oe++)Re=this._buildBevelVert(R,W,(ae+Oe)%ie,Oe/(I-1),Se),x.push(xe.topN,Re.topP,ve.topN),a===!1&&x.push(Re.bottomP,xe.bottomN,ve.bottomN),xe=Re,Oe>(ye+1)*ce&&(ye++,Qe=this._buildBevelVert(R,U,(se+ye)%Q,ye/($-1),Se),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&x.push(Re.bottomP,ve.bottomN,Qe.bottomP),ve=Qe)}else{let ce=$/I,ye=0;for(let Oe=1;Oe<$;Oe++)Qe=this._buildBevelVert(R,U,(se+Oe)%Q,Oe/($-1),Se),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&x.push(Re.bottomP,ve.bottomN,Qe.bottomP),ve=Qe,Oe>(ye+1)*ce&&(ye++,Re=this._buildBevelVert(R,W,(ae+ye)%ie,ye/(I-1),Se),x.push(xe.topN,Re.topP,ve.topN),a===!1&&x.push(Re.bottomP,xe.bottomN,ve.bottomN),xe=Re)}ae=(ae+I)%ie,se=(se+$)%Q,Z=(Z+1)%re}while(Z!==Ae)}if(a===!1&&this._depth>this._bevel*2&&this._buildWall(H,R,x),C){let j=[];for(let W=x.length-1;W>=q+2;W-=3){let U=x[W-2],ie=x[W-1],Q=x[W-0];j.push(Q,ie,U)}x.splice(q,x.length-q,...j)}if(C){let j=[];for(let W=H[H.length-1].boundary.vertices.length-1;W>=1;W-=2){let U=H[H.length-1].boundary.vertices[W-1],ie=H[H.length-1].boundary.vertices[W-0];j.push(U,ie)}b.push(j)}if(!C){let j=H[H.length-1],W;try{W=Zn({windingRule:H.length>1?St.POSITIVE:St.ODD,elementType:ri.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...b]})}catch{W=i2}if(!W)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let U=0;U<W.elementCount*3;U+=3){let ie=this._buildSurfaceVert(W,W.elements[U+0],G),Q=this._buildSurfaceVert(W,W.elements[U+1],G),re=this._buildSurfaceVert(W,W.elements[U+2],G);x.push(ie.top,Q.top,re.top),a===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ye(Uint32Array.from(x),1),A=new Ye(this._buffer.positions,3),S=new Ye(this._buffer.normals,3),w=new Ye(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,w.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",w),this.setIndex(_)}_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,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],n=e.vertices[t*2+1],a=(s-this._minX)/this._width,o=(n-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,d=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=n,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=n,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let n=`${t.bevelI}:${i}`;if(n in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[n].pathBevelUCoord))return this.vertexCache[n];let[a,o]=t.boundary.vertexIndices[i],l,h,d,c;a!==o?(h=a,l=o,c=!1,d=e.continuous[h]&&e.continuous[l]):(l=a,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||c);let u=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,g=l*2,m=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,_=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),_=1);let A=e.normals[g+0],S=e.normals[g+1],w=e.normals[m+0],E=e.normals[m+1];if(c){let L=w-A,R=E-S;A=A+L*(1-r),S=S+R*(1-r);let V=Math.sqrt(A*A+S*S);A/=V,S/=V}let C=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*u,this._buffer.normals[T+1]=S*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*u,this._buffer.normals[T+4]=S*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b),d||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=w*u,this._buffer.normals[T+1]=E*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=w*u,this._buffer.normals[T+4]=E*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b)),this.vertexCache[n]=P,P}clone(){let e=new w0(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fp(this.userData),e}},r2=class extends qe{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=St.ODD,this.elementType=ri.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:St.ODD,elementType:ri.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,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!a&&!o)break}if(!a&&!o)try{n=Zn({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=b0}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,g=-1/0;for(let y=0,x=d;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1];_<u&&(u=_),_>p&&(p=_),A<f&&(f=A),A>g&&(g=A)}let m=p-u,v=g-f;for(let y=0,x=d;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1],S=(_-u)/m,w=(A-f)/v;this._positionAttribute.setXYZ(y,_,A,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,w)}for(let y=0,x=c;y<x;y++){let b=y*3,_=n.elements[b+0],A=n.elements[b+1],S=n.elements[b+2];this._indexAttribute.setX(b+0,_),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,S)}}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 r2(this._shape,this._curveSegments);return e.userData=fp(this.userData),e}},s2=class extends w0{constructor(e,t,i=0,r=12,s=3,n=St.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 s2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fp(this.userData),e}},to=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:St.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 Vt?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Vt(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Vt(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 r2(e.shape,s,{windingRule:a}):o=new s2(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},n2=Math.PI*2,_0=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 Vt?e.shape:new Vt,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=c8(h,d,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=to.create({shape:h,parameters:{subdivisions:u,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function c8(e,t,i,r,s,n){if(r>=n2)return s>30||s%4===0?(u8(e,t,i,n),Math.round(s/4)):Wb(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=s8({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?d8(e,a.x,a.y,h,s,t,i,n):Wb(e,r,s,t,i,n)}function d8(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(ol(t,i));for(let h=0,d=r.length;h<d;h++){let c=r[h],u=e.points[h],p=ol(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?a2(e,n,a,o):e.addPoint(ol(0,0)),l}function Wb(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(ol(h,d))}return t<n2?n>0?a2(e,r,s,n):e.addPoint(ol(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&o2(e,r,s,n)),1}function u8(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(Ed(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(Ed(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(Ed(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(Ed(s,n-i,s+o,n-i,s-o,n-i)),r>0&&o2(e,t,i,r)}function ol(e,t){return new al(nt.generateUUID(),new F(e,t))}function Ed(e,t,i,r,s,n){let a=ol(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function a2(e,t,i,r){l2(e,t,i,r).forEach(s=>e.addPoint(s))}function o2(e,t,i,r){let s=l2(e,t,i,r),n=new Vt;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function l2(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new F(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=nt.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 p8=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 h2(!1,t,i,r,s,n,a,o,l,h,d,c);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},Xf=new $o([0,0,0],1),h2=class extends qe{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 M,f=new M,g=p(),m=p(),v=p(),y,x,b,_,A,S,w,E,C=p(),T=p(),D=p(),P=p(),L=p(),R=p(),V=p(),k=p(),z=i-2*o+.001,X=z/n,H=Math.ceil(a*n),G=H+1,N=z/H,q=-z/2,j=h+1,W=2*Math.PI/h,U=Math.PI/2/c,ie=.01,Q=Math.min((1-d/100)*o,o-ie),re=o-Q,Z=0,ue=2,ae=c*ue+ue,se=j*ae/ue,Ae=se+j*G,Se=j*(G+ae),[Me,Pe,xe]=[3,3,2].map(De=>Array(Se*De).fill(0)),ve=[],Re=s-o;function Qe(De,Be){let Ie=Math.PI/2;S=Be*N,E=2*Math.PI*(S%X)/X+Ie,S+=q,w=Math.sin(E)*Re,A=Math.cos(E)*Re,e?De.set(A,w,S):De.set(A,S,w)}Qe(f,-1e-10),Qe(g,0),C.copy(f),Qe(f,1);let B=f.distanceTo(g),I=u?0:re+Q,$=B*H+2*I,me=Q,ce=$-I;for(let De=0;De<=H;De++){Qe(m,De),k.subVectors(m,C).normalize(),C.copy(m),R.copy(m).setComponent(+e+1,0).normalize(),V.crossVectors(k,R).normalize();let Be=De===0,Ie=De===H,Xe=Be?3*Math.PI/2:U,Ue=Be?me:ce,pt=Be?j:Ae,Ot=Be?0:Se-j,Jt=k.clone().multiplyScalar(Be?-re:re).add(m),Y=k.clone().multiplyScalar(Be?-1:1).normalize();for(let ne=0;ne<j;ne++){let ge=ne*W;if(T.addVectors(f.copy(R).multiplyScalar(o*Math.cos(ge)),g.copy(V).multiplyScalar(o*Math.sin(ge))),D.copy(T).normalize(),Be||Ie){u||(Z=Ot+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=Jt.getComponent(we),Pe[Z*3+we]=Y.getComponent(we)}),xe[Z*2]=+Ie,xe[Z*2+1]=ne/h),g.copy(D).multiplyScalar(Q),v.addVectors(m,g);for(let we=0;we<c;we++){let Ge=we*U+Xe;P.addVectors(f.copy(k).multiplyScalar(re*Math.sin(Ge)),g.copy(D).multiplyScalar(re*Math.cos(Ge))),L.copy(P).normalize(),g.addVectors(v,P),P.normalize(),Z=pt+we*j+ne,[0,1,2].forEach(Ut=>{Me[Z*3+Ut]=g.getComponent(Ut),Pe[Z*3+Ut]=L.getComponent(Ut)});let gt=+Be+Math.sin(Ge);xe[Z*2]=(Ue+re*gt)/$,xe[Z*2+1]=ne/h}}g.addVectors(m,T),Z=se+De*j+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=g.getComponent(we),Pe[Z*3+we]=D.getComponent(we)}),xe[Z*2]=(I+De*B)/$,xe[Z*2+1]=ne/h}}let ye=G+2*c+ue,Oe=1,[Ee,de]=[+u,ye-1];for(let De=Ee;De<=de-1;De++){let Be=u&&De===de-1;for(let Ie=0;Ie<j-1;Ie++)y=De*j+Ie,x=y+1,b=(Be?Ie:y)+j,_=(Be?Ie+1:x)+j,De===0?ve.push(x,_,b):De===ye-2?ve.push(y,x,b):ve.push(y,x,b,x,_,b)}this.setIndex(ve),this.setAttribute("position",new Le(Me,3)),this.setAttribute("normal",new Le(Pe,3)),this.setAttribute("uv",new Le(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,n,a,o,l=6*(t-1)*e.radialSegments,h=t,d=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,n=s+1,a=(d?c:s)+i,o=(d?c+1:n)+i,r[l++]=s,r[l++]=n,r[l++]=a,r[l++]=n,r[l++]=o,r[l++]=a;return r.length=l,Xf.array=r,Xf.count=r.length,Xf}},f8=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 c2(t*.5,n,a):new mS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},c2=class extends v0{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 c2(e.radius,e.corner,e.cornerSides)}},m8=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 gu;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 lS(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ms=new fe,Yf=new Mt,Cd=new M,qu=class extends Ti{constructor(){super(),this.uuid=nt.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 bi().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 ms.makeRotationX(e),this.applyMatrix4(ms),this}rotateY(e){return ms.makeRotationY(e),this.applyMatrix4(ms),this}rotateZ(e){return ms.makeRotationZ(e),this.applyMatrix4(ms),this}translate(e,t,i){return ms.makeTranslation(e,t,i),this.applyMatrix4(ms),this}scale(e,t,i){return ms.makeScale(e,t,i),this.applyMatrix4(ms),this}lookAt(e){return Yf.lookAt(e),Yf.updateMatrix(),this.applyMatrix4(Yf.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 M().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new je().fromBufferAttribute(a,c));function h(c,u,p,f){let g=a===void 0?[]:[t.colors[c].clone(),t.colors[u].clone(),t.colors[p].clone()],m=n===void 0?[]:[new M().fromBufferAttribute(n,c),new M().fromBufferAttribute(n,u),new M().fromBufferAttribute(n,p)],v=new Hg(c,u,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new F().fromBufferAttribute(o,c),new F().fromBufferAttribute(o,u),new F().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new F().fromBufferAttribute(l,c),new F().fromBufferAttribute(l,u),new F().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 g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),u.materialIndex):h(g,g+1,g+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(Cd).negate(),this.translate(Cd.x,Cd.y,Cd.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new fe;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 M,t=new M;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 M;if(e){let i=new M,r=new M;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 qu;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 M,h={a:new M,b:new M,c:new M};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 Kt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _r),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 bi().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,g,m=p.vertexNormals,v=p.vertexColors,y=new Hg(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,b=m.length;x<b;x++)f=m[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)g=v[x],y.vertexColors.push(g.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,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[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 M(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],g=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,g),A=h(A,2,m),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),A=h(A,7,_),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let S=this.faceVertexUvs[0][p];i.push(u(S[0]),u(S[1]),u(S[2]))}if(y&&i.push(d(f.normal)),x){let S=f.vertexNormals;i.push(d(S[0]),d(S[1]),d(S[2]))}if(b&&i.push(c(f.color)),_){let S=f.vertexColors;i.push(c(S[0]),c(S[1]),c(S[2]))}}function h(p,f,g){return g?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 qu().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,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++){let b=m[y];v.push(b.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,g=s[c].vertices.length;f<g;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,g=s[c].normals.length;f<g;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,g=n[c].vertexNormals.length;f<g;f++){let m=n[c].vertexNormals[f],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=n[c].faceNormals.length;f<g;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 g8().fromGeometry(this),t=new qe,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Td.call(new Ye(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Td.call(new Ye(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",qb.call(new Ye(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",Xb.call(new Ye(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",Xb.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 Le(l.data.length*3,3);h.name=l.name,s.push(Td.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Le(e.skinIndices.length*4,4);t.setAttribute("skinIndex",Yb.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Le(e.skinWeights.length*4,4);t.setAttribute("skinWeight",Yb.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 qe,i=e.geometry;if(e.isPoints||e.isLine){let r=new Le(i.vertices.length*3,3),s=new Le(i.colors.length*3,3);if(t.setAttribute("position",Td.call(r,i.vertices)),t.setAttribute("color",qb.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Le(i.lineDistances.length,1);t.setAttribute("lineDistance",v8.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}};qu.prototype.isGeometry=!0;var g8=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 m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,d=h.length,c;if(d>0){c=[];for(let m=0;m<d;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let u=e.skinIndices,p=e.skinWeights,f=u.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];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 b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][m];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new F,new F,new F))}if(n===!0){let b=r[1][m];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new F,new F,new F))}for(let b=0;b<o;b++){let _=a[b].vertices;l[b].data.push(_[v.a],_[v.b],_[v.c])}for(let b=0;b<d;b++){let _=h[b].vertexNormals[m];c[b].data.push(_.a,_.b,_.c)}f&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),g&&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}},Hg=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 M,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 v8(e){return this.array.set(e),this}function qb(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 Xb(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 F),t[i++]=n.x,t[i++]=n.y}return this}function Td(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 M),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function Yb(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 y8=["a","b","c"];function x8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Qf(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function Zf(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 b8(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],Zf(a.a,a.b,e,r,a,i),Zf(a.b,a.c,e,r,a,i),Zf(a.c,a.a,e,r,a,i)}function Pd(e,t,i,r,s){e.push(new Hg(t,i,r,void 0,void 0,s))}function To(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Dd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var w8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof qe?e=new qu().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 M,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;b8(o,l,c,u);let p=[],f,g,m,v,y,x,b;for(let ie of Array.from(u.keys())){for(g=u.get(ie),m=new M,y=3/8,x=1/8,b=g.faces.length,b!=2&&(y=.5,x=0,b!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),n=0;n<b;n++){for(v=g.faces[n],a=0;a<3&&(f=o[x8(v,y8[a])],!(f!==g.a&&f!==g.b));a++);f&&t.add(f)}t.multiplyScalar(x),m.add(t),g.newEdge=p.length,p.push(m)}let _,A,S,w,E,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],E=c[r].edges,i=E.length,i==3?_=3/16:i>3&&(_=3/(8*i)),A=1-i*Number(_),S=_,i<=2&&(i==2?(A=3/4,S=1/8):i==1||i==0),T=C.clone().multiplyScalar(A),t.set(0,0,0),n=0;n<i;n++)w=E[n],f=w.a!==C?w.a:w.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),D.push(T)}let P=D.concat(p),L=D.length,R,V,k,z=[],X=[],H,G,N,q,j=new F,W=new F,U=new F;for(r=0,s=l.length;r<s;r++)v=l[r],R=Number(Qf(v.a,v.b,u).newEdge)+L,V=Number(Qf(v.b,v.c,u).newEdge)+L,k=Number(Qf(v.c,v.a,u).newEdge)+L,Pd(z,R,V,k,v.materialIndex),Pd(z,v.a,R,k,v.materialIndex),Pd(z,v.b,V,R,v.materialIndex),Pd(z,v.c,k,V,v.materialIndex),d&&(H=h[r],G=H[0],N=H[1],q=H[2],j.set(To(G.x,N.x),To(G.y,N.y)),W.set(To(N.x,q.x),To(N.y,q.y)),U.set(To(G.x,q.x),To(G.y,q.y)),Dd(X,j,W,U),Dd(X,G,j,U),Dd(X,N,W,j),Dd(X,q,U,W));e.vertices=P,e.faces=z,d&&(e.faceVertexUvs[0]=X)}},ai=new M,_8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new qe().copy(new Rs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ai),r={width:ai.x,height:ai.y,depth:ai.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 qe().copy(new Rs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ai)):ai.set(a.width,a.height,a.depth),(t!==ai.x||i!==ai.y||r!==ai.z)&&n.scale(ai.x===0?1:t/ai.x,ai.y===0?1:i/ai.y,ai.z===0?1:r/ai.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new w8(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 _S(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ai);let n=100/ai.x;Object.assign(s.parameters,{width:100,height:ai.y*n,depth:ai.z*n}),t(this.build(s))})}},d2=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 Vt?e.shape:new Vt,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 g=0;g<r;g++){let m=p*g,v=c+Math.sin(m)*h,y=u+Math.cos(m)*d;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=to.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},S8=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 M8(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function vh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Kf(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 A8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var M8=class extends qe{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),g=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new M(0,-u,0),x=new M(0,u,0),b=new F(e,-u),_=new F(f,-u),A=new F(0,x.y).sub(_),S=new F(0,x.y).sub(b),w=new F(A.y,-A.x).normalize(),E=new F(S.y,-S.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new M(w.x,w.y,0),X=new M(Math.cos(g)*z.x,z.y,Math.sin(g)*z.x);T=z.angleTo(X)}let D=n/Math.tan((Math.PI-A.angle())/2),P=n/Math.tan((Math.PI-T)/2),L=new M;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),d.push(0,0);let z=c++,X=[],H=b.clone(),G=D/Math.cos(Math.PI/i);H.x-=G;for(let N=0;N<i;N++){let q=N/i*Math.PI*2+p,j=new F(Math.sin(q),Math.cos(q));vh(H,j,L),l.push(L.x,L.y,L.z),h.push(0,-1,0),d.push(0,0),X.push(c++)}for(let N=0;N<X.length;N++)o.push(X[N],z,X[(N+1)%X.length])}let R=[];{let z=new M,X=new M,H=new M,G=new M,N=new M,q=new M;for(let j=0;j<i;j++){let W=j/i*Math.PI*2+p,U=(j+.5)/i*Math.PI*2+p,ie=(j+1)/i*Math.PI*2+p,Q=new F(Math.sin(W),Math.cos(W)),re=new F(Math.sin(U),Math.cos(U)),Z=new F(Math.sin(ie),Math.cos(ie));vh(b,Q,X),vh(b,Z,H),vh(w,re,z),Kf(x,X,H,P,P,G),l.push(G.x,G.y,G.z),Kf(X,x,H,P,D,N),l.push(N.x,N.y,N.z),Kf(H,X,x,D,P,q),l.push(q.x,q.y,q.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 ue=c++,ae=c++,se=c++;if(o.push(ue,ae,se),n>0){{let Me=X.clone().add(H).multiplyScalar(.5),Pe=x.clone().sub(Me).normalize(),xe=y.clone().sub(Me).normalize().add(Pe).normalize().multiplyScalar(-1),ve=q.clone().sub(N);V(Me,ve,xe,A.angle())}let Ae,Se;{let Me=new M;vh(E,Z,Me);let Pe=q.clone().add(G).multiplyScalar(.5);Pe=A8(Pe,H,x);let xe=q.clone().sub(G);[Ae,Se]=V(Pe,xe,Me,T,G.y)}{let Me=Ae,Pe=Me.clone().setY(0).normalize(),xe=new M(0,-1,0),ve=Pe.clone().cross(xe);k(Me,Pe,xe,ve)}R.concat(Se);{let Me=A.angle(),Pe=Math.PI-Me,xe=x.clone();xe.y-=n/Math.sin(Me-Math.PI/2);let ve=new M,Re=[];for(let B=0;B<a;B++){let I=[],$=Math.PI/2-Pe*B/a,me=Math.cos($),ce=Math.sin($),ye=U;for(let Oe=0;Oe<=B;Oe++){let Ee=Math.cos(ye),de=Math.sin(ye);z.x=me*de,z.y=ce,z.z=me*Ee,ve.copy(xe).addScaledVector(z,n),l.push(ve.x,ve.y,ve.z),h.push(z.x,z.y,z.z),d.push(0,0),I.push(c++),ye+=Math.PI*2/B/i}Re.push(I)}Se.reverse(),Re.push(Se);let Qe=Re.length-1;for(let B=0;B<Qe;B++){let I=Re[B],$=Re[B+1],me=I.length-1;o.push($[1],I[0],$[0]);for(let ce=1;ce<=me;ce++)o.push(I[ce],I[ce-1],$[ce]),o.push($[ce+1],I[ce],$[ce])}}}}}this.setIndex(o),this.setAttribute("position",new Le(l,3)),this.setAttribute("normal",new Le(h,3)),this.setAttribute("uv",new Le(d,2));function V(z,X,H,G,N){let q=-G/2,j=(Math.PI-G)/2,W=X.clone().normalize().cross(H);z.addScaledVector(H,-n/Math.sin(j));let U=new M,ie=new M,Q=1,re=c,Z=[];for(let ue=0;ue<=a;ue++){let ae=q+ue/a*G;ie.set(0,0,0),ie.addScaledVector(W,Math.sin(ae)),ie.addScaledVector(H,Math.cos(ae));for(let se=0;se<=Q;se++){let Ae=se/Q-.5;if(U.copy(z),U.addScaledVector(X,Ae),U.addScaledVector(ie,n),N!=null){let Se=Math.max(0,U.y-N);U.addScaledVector(X,-Se/X.y)}l.push(U.x,U.y,U.z),h.push(ie.x,ie.y,ie.z),d.push(0,0),se===0&&Z.push(c),c++}}for(let ue=0;ue<a;ue++)for(let ae=0;ae<Q;ae++){let se=re+ae+(Q+1)*ue,Ae=se+(Q+1),Se=Ae+1,Me=se+1;o.push(se,Ae,Me),o.push(Ae,Se,Me)}return[z.clone().addScaledVector(X,.5),Z]}function k(z,X,H,G){let N=Math.PI/2,q=S.angle()-N,j=[],W=new M,U=new M;for(let Q=0;Q<=a;Q++){let re=[],Z=Q/a;for(let ue=0;ue<=Q;ue++){let ae=((Q?ue/Q:0)-.5)*v,se=Math.cos(ae),Ae=Math.sin(ae),Se=Math.atan(Math.tan(q)*se),Me=(N+Se)*Z,Pe=Math.cos(Me),xe=Math.sin(Me);W.set(0,0,0),W.addScaledVector(X,xe*se),W.addScaledVector(H,Pe),W.addScaledVector(G,xe*Ae),U.copy(z).addScaledVector(W,n),l.push(U.x,U.y,U.z),h.push(W.x,W.y,W.z),d.push(0,0),re.push(c++)}j.push(re)}let ie=j.length-1;for(let Q=0;Q<ie;Q++){let re=j[Q],Z=j[Q+1],ue=re.length-1;o.push(re[0],Z[1],Z[0]);for(let ae=1;ae<=ue;ae++)o.push(re[ae-1],re[ae],Z[ae]),o.push(re[ae],Z[ae+1],Z[ae])}}}},u2=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 Vt?e.shape:new Vt,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(b,_,A){return _>i&&A>r?Math.min(b*i/_,b*r/A):_>i?b*i/_:A>r?b*r/A:b}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,g=c.x,m=c.y,v=d.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,_=t.points.length;b<_;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=to.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},E8=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 Bv(.5*t,s,n,a,o,l,h);return d.scale(1,i/t,r/t),Object.assign(d,{userData:{...e,type:"SphereGeometry"}})}},C8=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 rp(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},T8=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 P8(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},P8=class extends qe{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=(ie=0,Q=0,re=0)=>new M(ie,Q,re),p=u(),f=u(),[g,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[b,_,A]=[u(y,-g,+v),u(y,-g,-v),u(y,+g,-v)],S=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),w=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-g;let E=Math.cos(r)*t-v,C=b.z-h;r<=c?(A.z=Math.min(E,C),A.z==C&&(A.y-=(E-C)/Math.tan(c-r))):_.z=Math.min(_.z-E-v,b.z-h),p.subVectors(b,_),f.subVectors(A,_);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),L=p.clone().normalize().add(f.normalize()).setLength(P).add(_);p.set(0,S(r,!0),w(r,!0)),d.push([A,p.clone()]);let R=(Math.PI-r)/n;for(let ie=0;ie<=n;ie++){let Q=c+r+ie*R;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(L),f.set(0,S(Q),w(Q)),d.push([p.clone(),f.clone()])}d.push([b,u(0,1,0)]);let V=Math.sin(R/2)*D*2,k=d.length-1,z=d[0][0].distanceTo(d[1][0]),X=d[k-1][0].distanceTo(d[k][0]),H=z+V*n+X;d[0].push(1);for(let ie=0;ie<=n;ie++)d[ie+1].push(1-(z+ie*V)/H);d[k].push(0);let[G,N,q]=d[0],j,W,U;for(let ie=1;ie<d.length;ie++)[j,W,U]=d[ie],a.push(y,G.y,G.z,y,j.y,j.z,x,G.y,G.z,x,G.y,G.z,y,j.y,j.z,x,j.y,j.z),o.push(0,N.y,N.z,0,W.y,W.z,0,N.y,N.z,0,N.y,N.z,0,W.y,W.z,0,W.y,W.z),l.push(0,q,0,U,1,q,1,q,0,U,1,U),[G,N,q]=[j,W,U];this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(o,3)),this.setAttribute("uv",new Le(l,2))}},p2=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 Vt?e.shape:new Vt,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,g=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=u*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let b=0;b<s;b++){let _=g*b,A=p+Math.sin(_)*c,S=f+Math.cos(_)*u;d.addPoint(d.createPoint(A,S))}}else for(let b=0;b<s;b++){let _=p+Math.cos(m)*c,A=f+Math.sin(m)*u;d.addPoint(d.createPoint(_,A)),m+=g,_=p+Math.cos(m)*v,A=f+Math.sin(m)*y,b<=s,d.addPoint(d.createPoint(_,A)),m+=g}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let x=to.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},D8=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 rp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},I8=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=L8(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 L8(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 h2(!0,e,t,i,r,s,n,a,o,l,h,d)}var O8=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 gS(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},B8=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 Vt?e.shape:new Vt,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=to.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function R8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var z8=new fe,N8=new fe;function U8(e,t,i){let r=[new M,new M,new M],s=[new M,new M,new M];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=nt.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new fe().makeBasis(r[0],r[1],r[2])}var F8=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??_0.create({parameters:kA}).userData.shape;return{path:e.path??Nu.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...jA,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new k8(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new qe,{userData:{...e,type:"PathGeometry"}})}},k8=class extends qe{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)||!R8(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 k=0;k<o;k++){let z=this.inputs.path.isClosed?(k+n)%e.length:Math.min(k+n,e.length-1);l.push(e[z].clone()),h.push(t[z].clone())}let d=(k,z,X)=>{l[k]=l[k].clone().lerp(l[z],X),h[k]=U8(h[k],h[z],X)},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 k=l.length-1;l[k].copy(l[0]),h[k].copy(h[0])}this._applyPathModifiers(h,c,p);let{bevel:g,bevelSides:m}=this.inputs.parameters.extrusion,v=g>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:b,vertices:_}=this._computeShapePoints(y),A=0,S;v==="round"&&(S=new w0(this.inputs.shapeData,2*g,g,y,m,void 0,!0),A=S.getAttribute("position").count);let w=0,E=0;b.sort((k,z)=>k.start-z.start),b.forEach(k=>{k.verticesStart=w,k.verticesCount=k.continuous.reduce((z,X,H)=>z+(H===0||!X?2:1),0),E+=k.verticesCount,w=E});let C=E*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=Zn({windingRule:St.ODD,elementType:ri.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=i2}D=T.vertexCount}let P=C+2*D+A*2,L=C+2*D,R={positions:new Float32Array(P*3),normals:new Float32Array(P*3),uvs:new Float32Array(P*2)},V=[];if(b.forEach(k=>{this._extrudeRegion(k,_,h,l,R,V,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,V,R,h[0],l[0],!1),this._closeEnd(T,C+D,V,R,h[h.length-1],l[l.length-1],!0)),S){R.positions.set(S.getAttribute("position").array,L*3),R.normals.set(S.getAttribute("normal").array,L*3),R.uvs.set(S.getAttribute("uv").array,L*2);let k=V.length;V.push(...S.getIndex().array.map(H=>H+L)),L+=A,R.positions.set(S.getAttribute("position").array,L*3),R.normals.set(S.getAttribute("normal").array,L*3),R.uvs.set(S.getAttribute("uv").array,L*2);let z=V.length;V.push(...S.getIndex().array.map(H=>H+L)),this.setAttribute("position",new Ye(R.positions,3)),this.setAttribute("normal",new Ye(R.normals,3)),this.setAttribute("uv",new Ye(R.uvs,2)),this.setIndex(V);let X=z8;X.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(X,L,P),X.copy(h[0]).setPosition(l[0]).multiply(N8.makeScale(1,1,-1)),this.applyMatrix4OnRange(X,L-A,L),this.reverseIndicesOnRange(k,z)}else this.setAttribute("position",new Ye(R.positions,3)),this.setAttribute("normal",new Ye(R.normals,3)),this.setAttribute("uv",new Ye(R.uvs,2)),this.setIndex(V)}_extractPathPoints(){let e=XA(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 M,n=new M,a=new M,o=new M,l=new M(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),x=v.clone().sub(g).normalize(),b=y.clone().add(x).normalize();a.copy(b),f===0&&(b.equals(l)||b.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(b).normalize(),A=b.clone().cross(_).normalize();l.copy(A),o.copy(_),f===0&&(s.copy(A),n.copy(b));let S=new fe().makeBasis(_,A,b);t.push(S)}let h=r?n:a,d=r?s:new M(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 g=new fe().makeRotationZ(u*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new fe,h=new fe;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(nt.lerp(s,s+n,u));let p=nt.lerp(a,o,u);h.makeScale(p,p,p),d.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=St.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),g=[];for(let m=f.length-1;m>=1;m-=2){let v=f[m-1],y=f[m-0];g.push(v,y)}return g}),n;try{n=Zn({windingRule:t,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=b0}let a;try{a=Zn({windingRule:St.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=t2}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],g=p%2===0?n.vertexCount:0;n.elements.push(f+g)}for(let p=0;p<a.vertexIndices.length;p++){let f=a.vertexIndices[p],g=n.vertexCount;n.vertexIndices.push(f+g)}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 g=p*2,m=n.vertices[g+0],v=n.vertices[g+1];m<l&&(l=m),m>h&&(h=m),v<d&&(d=v),v>c&&(c=v)}let u=[];for(let p=n.elementCount-1;p>=0;p--){let f=p>=o,g=p*2,m=n.elements[g+0],v=n.elements[g+1],y=m+v,x={start:m,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};u.push(x);let b=m,_=y-1,A=m+1,S=i.roundedCurves.length;do{let w=b-m,E=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[b*2+0],D=n.vertices[b*2+1],P=n.vertices[A*2+0],L=n.vertices[A*2+1],R=T-E,V=D-C,k=Math.sqrt(R*R+V*V);R/=k,V/=k;let z=T-P,X=D-L,H=Math.sqrt(z*z+X*X);z/=H,X/=H,x.normals[w*2+0]=-X,x.normals[w*2+1]=z;let G=n.vertexIndices[b];if(Array.isArray(G))x.continuous[w]=!1;else{let[N,q]=i.getCurveIndexFromVertexId(G-1,!0);if(q>0&&q<1)x.continuous[w]=!0;else{let j=q===1?N+1:N-1;j=(j+S)%S;let W=q===1?0:1,U=i.roundedCurves[N].getTangent(q),ie=i.roundedCurves[j].getTangent(W);x.continuous[w]=U.dot(ie)>.95}}f&&(x.normals[w*2+0]*=-1,x.normals[w*2+1]*=-1),[_,b,A]=[b,A,A+1],A>=y&&(A-=v)}while(A!==m+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 M,l=new M,h=new M,d=new M,c=new F;i.forEach((p,f)=>{let g=r[f],m=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(g),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,m,h,d,c),m++,!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,m,h,d,c),m++}}});let u=i.length-1;for(let p=0;p<u;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=f+m,b=f+y,_=g+y,A=g+m;e.isHole?n.push(x,_,b,x,A,_):n.push(x,b,_,x,_,A),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new M(0,0,a?-1:1).applyMatrix4(s),h=new M,d=new F;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,g=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(f,g,m)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new bi().getNormalMatrix(e).elements,n,a,o,l,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let c=h.array,u=d.array,p=h.itemSize;for(let f=t*p,g=i*p;f<g;f+=p){if(f===t)debugger;n=c[f+0],a=c[f+1],o=c[f+2],l=1/(r[3]*n+r[7]*a+r[11]*o+r[15]),c[f+0]=(r[0]*n+r[4]*a+r[8]*o+r[12])*l,c[f+1]=(r[1]*n+r[5]*a+r[9]*o+r[13])*l,c[f+2]=(r[2]*n+r[6]*a+r[10]*o+r[14])*l,n=u[f+0],a=u[f+1],o=u[f+2],u[f+0]=s[0]*n+s[3]*a+s[6]*o,u[f+1]=s[1]*n+s[4]*a+s[7]*o,u[f+2]=s[2]*n+s[5]*a+s[8]*o}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),n=i.getX(r+1),a=i.getX(r+2);i.setXYZ(r,a,n,s)}i.needsUpdate=!0}}};function f2(){let e=new qe;return e.setAttribute("position",new Ye(new Float32Array([]),3)),e.setIndex(new Ye(new Uint16Array([]),1)),e}var j8=f2().attributes,G8=12,V8=1,m2=class extends qe{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,j8),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=H8(e,t,h),{shapes:c,charWidths:u,charCoords:p}=t.generateShapes(d,e),f=i*.5,g=r*.5,m=c.map(x=>new Vt().fromShape(x));this.vectorShapes=m;let v=m.map(x=>to.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?St.NONZERO:St.ODD,subdivisions:this.isLowResolution&&s>0?V8:G8}})),y=v.length?Ba(v):f2();y.translate(-f,g,0),this.dispose(),this.wrappedText=d,this.charCoords=p,this.charWidths=u,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,b])=>{this.setAttribute(x,b)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Qa(new qe,m2.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 H8(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
|
|
3138
|
+
}`;function LI(e,t,i){let r=new Ev,s=new F,n=new F,a=new $e,o=new iS({depthPacking:G_}),l=new PI,h={},d=i.maxTextureSize,c={[ns]:xi,[xi]:ns,[yr]:yr},u=new Lt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:DI,fragmentShader:II}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new qe;f.setAttribute("position",new Ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new ir(f,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bv,this.render=function(b,_,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;let S=e.getRenderTarget(),w=e.getActiveCubeFace(),E=e.getActiveMipmapLevel(),C=e.state;C.setBlending(si),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=b.length;T<D;T++){let P=b[T],L=P.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;s.copy(L.mapSize);let R=L.getFrameExtents();if(s.multiply(R),n.copy(L.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(n.x=Math.floor(d/R.x),s.x=n.x*R.x,L.mapSize.x=n.x),s.y>d&&(n.y=Math.floor(d/R.y),s.y=n.y*R.y,L.mapSize.y=n.y)),L.map===null){let k=this.type!==Ph?{minFilter:It,magFilter:It}:{};L.map=new At(s.x,s.y,k),L.map.texture.name=P.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let V=L.getViewportCount();for(let k=0;k<V;k++){let z=L.getViewport(k);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),L.updateMatrices(P,k),r=L.getFrustum(),x(_,A,L.camera,P,this.type)}L.isPointLightShadow!==!0&&this.type===Ph&&v(L,A),L.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(S,w,E)};function v(b,_){let A=t.update(g);u.defines.VSM_SAMPLES!==b.blurSamples&&(u.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new At(s.x,s.y)),u.uniforms.shadow_pass.value=b.map.texture,u.uniforms.resolution.value=b.mapSize,u.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(_,null,A,u,g,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(_,null,A,p,g,null)}function y(b,_,A,S,w,E){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let D=C.uuid,P=_.uuid,L=h[D];L===void 0&&(L={},h[D]=L);let R=L[P];R===void 0&&(R=C.clone(),L[P]=R),C=R}return C.visible=_.visible,C.wireframe=_.wireframe,E===Ph?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,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=S,C.farDistance=w),C}function x(b,_,A,S,w){if(b.visible===!1)return;if(b.layers.test(_.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&w===Ph)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,L=D.length;P<L;P++){let R=D[P],V=T[R.materialIndex];if(V&&V.visible){let k=y(b,V,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,k,b,R)}}}else if(T.visible){let D=y(b,T,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,D,b,null)}}let E=b.children;for(let C=0,T=E.length;C<T;C++)x(E[C],_,A,S,w)}}function OI(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,ne=new $e,ge=null,we=new $e(0,0,0,0);return{setMask:function(Ge){ge!==Ge&&!Y&&(e.colorMask(Ge,Ge,Ge,Ge),ge=Ge)},setLocked:function(Ge){Y=Ge},setClear:function(Ge,gt,Ut,Pi,ua){ua===!0&&(Ge*=Pi,gt*=Pi,Ut*=Pi),ne.set(Ge,gt,Ut,Pi),we.equals(ne)===!1&&(e.clearColor(Ge,gt,Ut,Pi),we.copy(ne))},reset:function(){Y=!1,ge=null,we.set(-1,0,0,0)}}}function n(){let Y=!1,ne=null,ge=null,we=null;return{setTest:function(Ge){Ge?ie(2929):Q(2929)},setMask:function(Ge){ne!==Ge&&!Y&&(e.depthMask(Ge),ne=Ge)},setFunc:function(Ge){if(ge!==Ge){switch(Ge){case $E:e.depthFunc(512);break;case eC:e.depthFunc(519);break;case tC:e.depthFunc(513);break;case Bm:e.depthFunc(515);break;case iC:e.depthFunc(514);break;case rC:e.depthFunc(518);break;case sC:e.depthFunc(516);break;case nC:e.depthFunc(517);break;default:e.depthFunc(515)}ge=Ge}},setLocked:function(Ge){Y=Ge},setClear:function(Ge){we!==Ge&&(e.clearDepth(Ge),we=Ge)},reset:function(){Y=!1,ne=null,ge=null,we=null}}}function a(){let Y=!1,ne=null,ge=null,we=null,Ge=null,gt=null,Ut=null,Pi=null,ua=null;return{setTest:function(Nt){Y||(Nt?ie(2960):Q(2960))},setMask:function(Nt){ne!==Nt&&!Y&&(e.stencilMask(Nt),ne=Nt)},setFunc:function(Nt,Vs,Ar){(ge!==Nt||we!==Vs||Ge!==Ar)&&(e.stencilFunc(Nt,Vs,Ar),ge=Nt,we=Vs,Ge=Ar)},setOp:function(Nt,Vs,Ar){(gt!==Nt||Ut!==Vs||Pi!==Ar)&&(e.stencilOp(Nt,Vs,Ar),gt=Nt,Ut=Vs,Pi=Ar)},setLocked:function(Nt){Y=Nt},setClear:function(Nt){ua!==Nt&&(e.clearStencil(Nt),ua=Nt)},reset:function(){Y=!1,ne=null,ge=null,we=null,Ge=null,gt=null,Ut=null,Pi=null,ua=null}}}let o=new s,l=new n,h=new a,d=new WeakMap,c=new WeakMap,u={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,E=!1,C=null,T=null,D=null,P=null,L=null,R=e.getParameter(35661),V=!1,k=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(z)[1]),V=k>=1):z.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),V=k>=2);let X=null,H={},G=e.getParameter(3088),N=e.getParameter(2978),q=new $e().fromArray(G),j=new $e().fromArray(N);function W(Y,ne,ge){let we=new Uint8Array(4),Ge=e.createTexture();e.bindTexture(Y,Ge),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let gt=0;gt<ge;gt++)e.texImage2D(ne+gt,0,6408,1,1,0,6408,5121,we);return Ge}let U={};U[3553]=W(3553,3553,1),U[34067]=W(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(Bm),Me(!1),Pe(xy),ie(2884),Ae(si);function ie(Y){u[Y]!==!0&&(e.enable(Y),u[Y]=!0)}function Q(Y){u[Y]!==!1&&(e.disable(Y),u[Y]=!1)}function re(Y,ne){return p[Y]!==ne?(e.bindFramebuffer(Y,ne),p[Y]=ne,r&&(Y===36009&&(p[36160]=ne),Y===36160&&(p[36009]=ne)),!0):!1}function Z(Y,ne){let ge=g,we=!1;if(Y)if(ge=f.get(ne),ge===void 0&&(ge=[],f.set(ne,ge)),Y.isWebGLMultipleRenderTargets){let Ge=Y.texture;if(ge.length!==Ge.length||ge[0]!==36064){for(let gt=0,Ut=Ge.length;gt<Ut;gt++)ge[gt]=36064+gt;ge.length=Ge.length,we=!0}}else ge[0]!==36064&&(ge[0]=36064,we=!0);else ge[0]!==1029&&(ge[0]=1029,we=!0);we&&(i.isWebGL2?e.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function ue(Y){return m!==Y?(e.useProgram(Y),m=Y,!0):!1}let ae={[Fo]:32774,[GE]:32778,[VE]:32779};if(r)ae[Sy]=32775,ae[Ay]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(ae[Sy]=Y.MIN_EXT,ae[Ay]=Y.MAX_EXT)}let se={[HE]:0,[WE]:1,[qE]:768,[B_]:770,[JE]:776,[ZE]:774,[YE]:772,[XE]:769,[R_]:771,[KE]:775,[QE]:773};function Ae(Y,ne,ge,we,Ge,gt,Ut,Pi){if(Y===si){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),Y!==jE){if(Y!==y||Pi!==E){if((x!==Fo||A!==Fo)&&(e.blendEquation(32774),x=Fo,A=Fo),Pi)switch(Y){case Jo:e.blendFuncSeparate(1,771,1,771);break;case by:e.blendFunc(1,1);break;case wy:e.blendFuncSeparate(0,769,0,1);break;case _y:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Jo:e.blendFuncSeparate(770,771,1,771);break;case by:e.blendFunc(770,1);break;case wy:e.blendFuncSeparate(0,769,0,1);break;case _y:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,_=null,S=null,w=null,y=Y,E=Pi}return}Ge=Ge||ne,gt=gt||ge,Ut=Ut||we,(ne!==x||Ge!==A)&&(e.blendEquationSeparate(ae[ne],ae[Ge]),x=ne,A=Ge),(ge!==b||we!==_||gt!==S||Ut!==w)&&(e.blendFuncSeparate(se[ge],se[we],se[gt],se[Ut]),b=ge,_=we,S=gt,w=Ut),y=Y,E=!1}function Se(Y,ne){Y.side===yr?Q(2884):ie(2884);let ge=Y.side===xi;ne&&(ge=!ge),Me(ge),Y.blending===Jo&&Y.transparent===!1?Ae(si):Ae(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 we=Y.stencilWrite;h.setTest(we),we&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),ve(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ie(32926):Q(32926)}function Me(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function Pe(Y){Y!==UE?(ie(2884),Y!==T&&(Y===xy?e.cullFace(1029):Y===FE?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=Y}function xe(Y){Y!==D&&(V&&e.lineWidth(Y),D=Y)}function ve(Y,ne,ge){Y?(ie(32823),(P!==ne||L!==ge)&&(e.polygonOffset(ne,ge),P=ne,L=ge)):Q(32823)}function Re(Y){Y?ie(3089):Q(3089)}function Qe(Y){Y===void 0&&(Y=33984+R-1),X!==Y&&(e.activeTexture(Y),X=Y)}function B(Y,ne,ge){ge===void 0&&(X===null?ge=33984+R-1:ge=X);let we=H[ge];we===void 0&&(we={type:void 0,texture:void 0},H[ge]=we),(we.type!==Y||we.texture!==ne)&&(X!==ge&&(e.activeTexture(ge),X=ge),e.bindTexture(Y,ne||U[Y]),we.type=Y,we.texture=ne)}function I(){let Y=H[X];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ce(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ye(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Oe(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Be(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Xe(Y){q.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),q.copy(Y))}function Ue(Y){j.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function pt(Y,ne){let ge=c.get(ne);ge===void 0&&(ge=new WeakMap,c.set(ne,ge));let we=ge.get(Y);we===void 0&&(we=e.getUniformBlockIndex(ne,Y.name),ge.set(Y,we))}function Ot(Y,ne){let ge=c.get(ne).get(Y);d.get(ne)!==ge&&(e.uniformBlockBinding(ne,ge,Y.__bindingPointIndex),d.set(ne,ge))}function Jt(){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={},X=null,H={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,E=!1,C=null,T=null,D=null,P=null,L=null,q.set(0,0,e.canvas.width,e.canvas.height),j.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:ue,setBlending:Ae,setMaterial:Se,setFlipSided:Me,setCullFace:Pe,setLineWidth:xe,setPolygonOffset:ve,setScissorTest:Re,activeTexture:Qe,bindTexture:B,unbindTexture:I,compressedTexImage2D:$,compressedTexImage3D:me,texImage2D:Be,texImage3D:Ie,updateUBOMapping:pt,uniformBlockBinding:Ot,texStorage2D:de,texStorage3D:De,texSubImage2D:ce,texSubImage3D:ye,compressedTexSubImage2D:Oe,compressedTexSubImage3D:Ee,scissor:Xe,viewport:Ue,reset:Jt}}function BI(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,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(B,I){return v?new OffscreenCanvas(B,I):uu("canvas")}function x(B,I,$,me){let ce=1;if((B.width>me||B.height>me)&&(ce=me/Math.max(B.width,B.height)),ce<1||I===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){let ye=I?du:Math.floor,Oe=ye(ce*B.width),Ee=ye(ce*B.height);g===void 0&&(g=y(Oe,Ee));let de=$?y(Oe,Ee):g;return de.width=Oe,de.height=Ee,de.getContext("2d").drawImage(B,0,0,Oe,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+Oe+"x"+Ee+")."),de}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function b(B){return km(B.width)&&km(B.height)}function _(B){return o?!1:B.wrapS!==Yt||B.wrapT!==Yt||B.minFilter!==It&&B.minFilter!==st}function A(B,I){return B.generateMipmaps&&I&&B.minFilter!==It&&B.minFilter!==st}function S(B){e.generateMipmap(B)}function w(B,I,$,me,ce=!1){if(o===!1)return I;if(B!==null){if(e[B]!==void 0)return e[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ye=I;return I===6403&&($===5126&&(ye=33326),$===5131&&(ye=33325),$===5121&&(ye=33321)),I===33319&&($===5126&&(ye=33328),$===5131&&(ye=33327),$===5121&&(ye=33323)),I===6408&&($===5126&&(ye=34836),$===5131&&(ye=34842),$===5121&&(ye=me===Je&&ce===!1?35907:32856),$===32819&&(ye=32854),$===32820&&(ye=32855)),(ye===33325||ye===33326||ye===33327||ye===33328||ye===34842||ye===34836)&&t.get("EXT_color_buffer_float"),ye}function E(B,I,$){return A(B,$)===!0||B.isFramebufferTexture&&B.minFilter!==It&&B.minFilter!==st?Math.log2(Math.max(I.width,I.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?I.mipmaps.length:1}function C(B){return B===It||B===My||B===kp?9728:9729}function T(B){let I=B.target;I.removeEventListener("dispose",T),P(I),I.isVideoTexture&&f.delete(I)}function D(B){let I=B.target;I.removeEventListener("dispose",D),R(I)}function P(B){let I=r.get(B);if(I.__webglInit===void 0)return;let $=B.source,me=m.get($);if(me){let ce=me[I.__cacheKey];ce.usedTimes--,ce.usedTimes===0&&L(B),Object.keys(me).length===0&&m.delete($)}r.remove(B)}function L(B){let I=r.get(B);e.deleteTexture(I.__webglTexture);let $=B.source,me=m.get($);delete me[I.__cacheKey],a.memory.textures--}function R(B){let I=B.texture,$=r.get(B),me=r.get(I);if(me.__webglTexture!==void 0&&(e.deleteTexture(me.__webglTexture),a.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let ce=0;ce<6;ce++)e.deleteFramebuffer($.__webglFramebuffer[ce]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[ce]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let ce=0;ce<$.__webglColorRenderbuffer.length;ce++)$.__webglColorRenderbuffer[ce]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[ce]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let ce=0,ye=I.length;ce<ye;ce++){let Oe=r.get(I[ce]);Oe.__webglTexture&&(e.deleteTexture(Oe.__webglTexture),a.memory.textures--),r.remove(I[ce])}r.remove(I),r.remove(B)}let V=0;function k(){V=0}function z(){let B=V;return B>=l&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l),V+=1,B}function X(B){let I=[];return I.push(B.wrapS),I.push(B.wrapT),I.push(B.wrapR||0),I.push(B.magFilter),I.push(B.minFilter),I.push(B.anisotropy),I.push(B.internalFormat),I.push(B.format),I.push(B.type),I.push(B.generateMipmaps),I.push(B.premultiplyAlpha),I.push(B.flipY),I.push(B.unpackAlignment),I.push(B.encoding),I.join()}function H(B,I){let $=r.get(B);if(B.isVideoTexture&&Re(B),B.isRenderTargetTexture===!1&&B.version>0&&$.__version!==B.version){let me=B.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,B,I);return}}i.bindTexture(3553,$.__webglTexture,33984+I)}function G(B,I){let $=r.get(B);if(B.version>0&&$.__version!==B.version){Q($,B,I);return}i.bindTexture(35866,$.__webglTexture,33984+I)}function N(B,I){let $=r.get(B);if(B.version>0&&$.__version!==B.version){Q($,B,I);return}i.bindTexture(32879,$.__webglTexture,33984+I)}function q(B,I){let $=r.get(B);if(B.version>0&&$.__version!==B.version){re($,B,I);return}i.bindTexture(34067,$.__webglTexture,33984+I)}let j={[pn]:10497,[Yt]:33071,[Nm]:33648},W={[It]:9728,[My]:9984,[kp]:9986,[st]:9729,[pC]:9985,[pl]:9987};function U(B,I,$){if($?(e.texParameteri(B,10242,j[I.wrapS]),e.texParameteri(B,10243,j[I.wrapT]),(B===32879||B===35866)&&e.texParameteri(B,32882,j[I.wrapR]),e.texParameteri(B,10240,W[I.magFilter]),e.texParameteri(B,10241,W[I.minFilter])):(e.texParameteri(B,10242,33071),e.texParameteri(B,10243,33071),(B===32879||B===35866)&&e.texParameteri(B,32882,33071),(I.wrapS!==Yt||I.wrapT!==Yt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(B,10240,C(I.magFilter)),e.texParameteri(B,10241,C(I.minFilter)),I.minFilter!==It&&I.minFilter!==st&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let me=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===It||I.minFilter!==kp&&I.minFilter!==pl||I.type===xr&&t.has("OES_texture_float_linear")===!1||o===!1&&I.type===fl&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(e.texParameterf(B,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function ie(B,I){let $=!1;B.__webglInit===void 0&&(B.__webglInit=!0,I.addEventListener("dispose",T));let me=I.source,ce=m.get(me);ce===void 0&&(ce={},m.set(me,ce));let ye=X(I);if(ye!==B.__cacheKey){ce[ye]===void 0&&(ce[ye]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,$=!0),ce[ye].usedTimes++;let Oe=ce[B.__cacheKey];Oe!==void 0&&(ce[B.__cacheKey].usedTimes--,Oe.usedTimes===0&&L(I)),B.__cacheKey=ye,B.__webglTexture=ce[ye].texture}return $}function Q(B,I,$){let me=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(me=35866),I.isData3DTexture&&(me=32879);let ce=ie(B,I),ye=I.source;i.bindTexture(me,B.__webglTexture,33984+$);let Oe=r.get(ye);if(ye.version!==Oe.__version||ce===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Ee=_(I)&&b(I.image)===!1,de=x(I.image,Ee,!1,d);de=Qe(I,de);let De=b(de)||o,Be=n.convert(I.format,I.encoding),Ie=n.convert(I.type),Xe=w(I.internalFormat,Be,Ie,I.encoding,I.isVideoTexture);U(me,I,De);let Ue,pt=I.mipmaps,Ot=o&&I.isVideoTexture!==!0,Jt=Oe.__version===void 0||ce===!0,Y=E(I,de,De);if(I.isDepthTexture)Xe=6402,o?I.type===xr?Xe=36012:I.type===Hn?Xe=33190:I.type===Ua?Xe=35056:Xe=33189:I.type===xr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Fa&&Xe===6402&&I.type!==U_&&I.type!==Hn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Hn,Ie=n.convert(I.type)),I.format===Xa&&Xe===6402&&(Xe=34041,I.type!==Ua&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Ua,Ie=n.convert(I.type))),Jt&&(Ot?i.texStorage2D(3553,1,Xe,de.width,de.height):i.texImage2D(3553,0,Xe,de.width,de.height,0,Be,Ie,null));else if(I.isDataTexture)if(pt.length>0&&De){Ot&&Jt&&i.texStorage2D(3553,Y,Xe,pt[0].width,pt[0].height);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],Ot?i.texSubImage2D(3553,ne,0,0,Ue.width,Ue.height,Be,Ie,Ue.data):i.texImage2D(3553,ne,Xe,Ue.width,Ue.height,0,Be,Ie,Ue.data);I.generateMipmaps=!1}else Ot?(Jt&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,de.width,de.height,Be,Ie,de.data)):i.texImage2D(3553,0,Xe,de.width,de.height,0,Be,Ie,de.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){Ot&&Jt&&i.texStorage3D(35866,Y,Xe,pt[0].width,pt[0].height,de.depth);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],I.format!==Rr?Be!==null?Ot?i.compressedTexSubImage3D(35866,ne,0,0,0,Ue.width,Ue.height,de.depth,Be,Ue.data,0,0):i.compressedTexImage3D(35866,ne,Xe,Ue.width,Ue.height,de.depth,0,Ue.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage3D(35866,ne,0,0,0,Ue.width,Ue.height,de.depth,Be,Ie,Ue.data):i.texImage3D(35866,ne,Xe,Ue.width,Ue.height,de.depth,0,Be,Ie,Ue.data)}else{Ot&&Jt&&i.texStorage2D(3553,Y,Xe,pt[0].width,pt[0].height);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],I.format!==Rr?Be!==null?Ot?i.compressedTexSubImage2D(3553,ne,0,0,Ue.width,Ue.height,Be,Ue.data):i.compressedTexImage2D(3553,ne,Xe,Ue.width,Ue.height,0,Ue.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ot?i.texSubImage2D(3553,ne,0,0,Ue.width,Ue.height,Be,Ie,Ue.data):i.texImage2D(3553,ne,Xe,Ue.width,Ue.height,0,Be,Ie,Ue.data)}else if(I.isDataArrayTexture)Ot?(Jt&&i.texStorage3D(35866,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Be,Ie,de.data)):i.texImage3D(35866,0,Xe,de.width,de.height,de.depth,0,Be,Ie,de.data);else if(I.isData3DTexture)Ot?(Jt&&i.texStorage3D(32879,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Be,Ie,de.data)):i.texImage3D(32879,0,Xe,de.width,de.height,de.depth,0,Be,Ie,de.data);else if(I.isFramebufferTexture){if(Jt)if(Ot)i.texStorage2D(3553,Y,Xe,de.width,de.height);else{let ne=de.width,ge=de.height;for(let we=0;we<Y;we++)i.texImage2D(3553,we,Xe,ne,ge,0,Be,Ie,null),ne>>=1,ge>>=1}}else if(pt.length>0&&De){Ot&&Jt&&i.texStorage2D(3553,Y,Xe,pt[0].width,pt[0].height);for(let ne=0,ge=pt.length;ne<ge;ne++)Ue=pt[ne],Ot?i.texSubImage2D(3553,ne,0,0,Be,Ie,Ue):i.texImage2D(3553,ne,Xe,Be,Ie,Ue);I.generateMipmaps=!1}else Ot?(Jt&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,Be,Ie,de)):i.texImage2D(3553,0,Xe,Be,Ie,de);A(I,De)&&S(me),Oe.__version=ye.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function re(B,I,$){if(I.image.length!==6)return;let me=ie(B,I),ce=I.source;i.bindTexture(34067,B.__webglTexture,33984+$);let ye=r.get(ce);if(ce.version!==ye.__version||me===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Oe=I.isCompressedTexture||I.image[0].isCompressedTexture,Ee=I.image[0]&&I.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++)!Oe&&!Ee?de[ne]=x(I.image[ne],!1,!0,h):de[ne]=Ee?I.image[ne].image:I.image[ne],de[ne]=Qe(I,de[ne]);let De=de[0],Be=b(De)||o,Ie=n.convert(I.format,I.encoding),Xe=n.convert(I.type),Ue=w(I.internalFormat,Ie,Xe,I.encoding),pt=o&&I.isVideoTexture!==!0,Ot=ye.__version===void 0||me===!0,Jt=E(I,De,Be);U(34067,I,Be);let Y;if(Oe){pt&&Ot&&i.texStorage2D(34067,Jt,Ue,De.width,De.height);for(let ne=0;ne<6;ne++){Y=de[ne].mipmaps;for(let ge=0;ge<Y.length;ge++){let we=Y[ge];I.format!==Rr?Ie!==null?pt?i.compressedTexSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,we.data):i.compressedTexImage2D(34069+ne,ge,Ue,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):pt?i.texSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge,Ue,we.width,we.height,0,Ie,Xe,we.data)}}}else{Y=I.mipmaps,pt&&Ot&&(Y.length>0&&Jt++,i.texStorage2D(34067,Jt,Ue,de[0].width,de[0].height));for(let ne=0;ne<6;ne++)if(Ee){pt?i.texSubImage2D(34069+ne,0,0,0,de[ne].width,de[ne].height,Ie,Xe,de[ne].data):i.texImage2D(34069+ne,0,Ue,de[ne].width,de[ne].height,0,Ie,Xe,de[ne].data);for(let ge=0;ge<Y.length;ge++){let we=Y[ge].image[ne].image;pt?i.texSubImage2D(34069+ne,ge+1,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge+1,Ue,we.width,we.height,0,Ie,Xe,we.data)}}else{pt?i.texSubImage2D(34069+ne,0,0,0,Ie,Xe,de[ne]):i.texImage2D(34069+ne,0,Ue,Ie,Xe,de[ne]);for(let ge=0;ge<Y.length;ge++){let we=Y[ge];pt?i.texSubImage2D(34069+ne,ge+1,0,0,Ie,Xe,we.image[ne]):i.texImage2D(34069+ne,ge+1,Ue,Ie,Xe,we.image[ne])}}}A(I,Be)&&S(34067),ye.__version=ce.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function Z(B,I,$,me,ce){let ye=n.convert($.format,$.encoding),Oe=n.convert($.type),Ee=w($.internalFormat,ye,Oe,$.encoding);r.get(I).__hasExternalTextures||(ce===32879||ce===35866?i.texImage3D(ce,0,Ee,I.width,I.height,I.depth,0,ye,Oe,null):i.texImage2D(ce,0,Ee,I.width,I.height,0,ye,Oe,null)),i.bindFramebuffer(36160,B),ve(I)?u.framebufferTexture2DMultisampleEXT(36160,me,ce,r.get($).__webglTexture,0,xe(I)):(ce===3553||ce>=34069&&ce<=34074)&&e.framebufferTexture2D(36160,me,ce,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function ue(B,I,$){if(e.bindRenderbuffer(36161,B),I.depthBuffer&&!I.stencilBuffer){let me=33189;if($||ve(I)){let ce=I.depthTexture;ce&&ce.isDepthTexture&&(ce.type===xr?me=36012:ce.type===Hn&&(me=33190));let ye=xe(I);ve(I)?u.renderbufferStorageMultisampleEXT(36161,ye,me,I.width,I.height):e.renderbufferStorageMultisample(36161,ye,me,I.width,I.height)}else e.renderbufferStorage(36161,me,I.width,I.height);e.framebufferRenderbuffer(36160,36096,36161,B)}else if(I.depthBuffer&&I.stencilBuffer){let me=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,me,35056,I.width,I.height):ve(I)?u.renderbufferStorageMultisampleEXT(36161,me,35056,I.width,I.height):e.renderbufferStorage(36161,34041,I.width,I.height),e.framebufferRenderbuffer(36160,33306,36161,B)}else{let me=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let ce=0;ce<me.length;ce++){let ye=me[ce],Oe=n.convert(ye.format,ye.encoding),Ee=n.convert(ye.type),de=w(ye.internalFormat,Oe,Ee,ye.encoding),De=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,De,de,I.width,I.height):ve(I)?u.renderbufferStorageMultisampleEXT(36161,De,de,I.width,I.height):e.renderbufferStorage(36161,de,I.width,I.height)}}e.bindRenderbuffer(36161,null)}function ae(B,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,B),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),H(I.depthTexture,0);let $=r.get(I.depthTexture).__webglTexture,me=xe(I);if(I.depthTexture.format===Fa)ve(I)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,me):e.framebufferTexture2D(36160,36096,3553,$,0);else if(I.depthTexture.format===Xa)ve(I)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,me):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function se(B){let I=r.get(B),$=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!I.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");ae(I.__webglFramebuffer,B)}else if($){I.__webglDepthbuffer=[];for(let me=0;me<6;me++)i.bindFramebuffer(36160,I.__webglFramebuffer[me]),I.__webglDepthbuffer[me]=e.createRenderbuffer(),ue(I.__webglDepthbuffer[me],B,!1)}else i.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=e.createRenderbuffer(),ue(I.__webglDepthbuffer,B,!1);i.bindFramebuffer(36160,null)}function Ae(B,I,$){let me=r.get(B);I!==void 0&&Z(me.__webglFramebuffer,B,B.texture,36064,3553),$!==void 0&&se(B)}function Se(B){let I=B.texture,$=r.get(B),me=r.get(I);B.addEventListener("dispose",D),B.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=e.createTexture()),me.__version=I.version,a.memory.textures++);let ce=B.isWebGLCubeRenderTarget===!0,ye=B.isWebGLMultipleRenderTargets===!0,Oe=b(B)||o;if(ce){$.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)$.__webglFramebuffer[Ee]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),ye)if(s.drawBuffers){let Ee=B.texture;for(let de=0,De=Ee.length;de<De;de++){let Be=r.get(Ee[de]);Be.__webglTexture===void 0&&(Be.__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&&B.samples>0&&ve(B)===!1){let Ee=ye?I:[I];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let de=0;de<Ee.length;de++){let De=Ee[de];$.__webglColorRenderbuffer[de]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[de]);let Be=n.convert(De.format,De.encoding),Ie=n.convert(De.type),Xe=w(De.internalFormat,Be,Ie,De.encoding,B.isXRRenderTarget===!0),Ue=xe(B);e.renderbufferStorageMultisample(36161,Ue,Xe,B.width,B.height),e.framebufferRenderbuffer(36160,36064+de,36161,$.__webglColorRenderbuffer[de])}e.bindRenderbuffer(36161,null),B.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),ue($.__webglDepthRenderbuffer,B,!0)),i.bindFramebuffer(36160,null)}}if(ce){i.bindTexture(34067,me.__webglTexture),U(34067,I,Oe);for(let Ee=0;Ee<6;Ee++)Z($.__webglFramebuffer[Ee],B,I,36064,34069+Ee);A(I,Oe)&&S(34067),i.unbindTexture()}else if(ye){let Ee=B.texture;for(let de=0,De=Ee.length;de<De;de++){let Be=Ee[de],Ie=r.get(Be);i.bindTexture(3553,Ie.__webglTexture),U(3553,Be,Oe),Z($.__webglFramebuffer,B,Be,36064+de,3553),A(Be,Oe)&&S(3553)}i.unbindTexture()}else{let Ee=3553;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(o?Ee=B.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ee,me.__webglTexture),U(Ee,I,Oe),Z($.__webglFramebuffer,B,I,36064,Ee),A(I,Oe)&&S(Ee),i.unbindTexture()}B.depthBuffer&&se(B)}function Me(B){let I=b(B)||o,$=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let me=0,ce=$.length;me<ce;me++){let ye=$[me];if(A(ye,I)){let Oe=B.isWebGLCubeRenderTarget?34067:3553,Ee=r.get(ye).__webglTexture;i.bindTexture(Oe,Ee),S(Oe),i.unbindTexture()}}}function Pe(B){if(o&&B.samples>0&&ve(B)===!1){let I=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],$=B.width,me=B.height,ce=16384,ye=[],Oe=B.stencilBuffer?33306:36096,Ee=r.get(B),de=B.isWebGLMultipleRenderTargets===!0;if(de)for(let De=0;De<I.length;De++)i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,null),i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,null,0);i.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let De=0;De<I.length;De++){ye.push(36064+De),B.depthBuffer&&ye.push(Oe);let Be=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(Be===!1&&(B.depthBuffer&&(ce|=256),B.stencilBuffer&&(ce|=1024)),de&&e.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[De]),Be===!0&&(e.invalidateFramebuffer(36008,[Oe]),e.invalidateFramebuffer(36009,[Oe])),de){let Ie=r.get(I[De]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Ie,0)}e.blitFramebuffer(0,0,$,me,0,0,$,me,ce,9728),p&&e.invalidateFramebuffer(36008,ye)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),de)for(let De=0;De<I.length;De++){i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,Ee.__webglColorRenderbuffer[De]);let Be=r.get(I[De]).__webglTexture;i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,Be,0)}i.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function xe(B){return Math.min(c,B.samples)}function ve(B){let I=r.get(B);return o&&B.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Re(B){let I=a.render.frame;f.get(B)!==I&&(f.set(B,I),B.update())}function Qe(B,I){let $=B.encoding,me=B.format,ce=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===Fm||$!==Bs&&($===Je?o===!1?t.has("EXT_sRGB")===!0&&me===Rr?(B.format=Fm,B.minFilter=st,B.generateMipmaps=!1):I=q_.sRGBToLinear(I):(me!==Rr||ce!==Ni)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),I}this.allocateTextureUnit=z,this.resetTextureUnits=k,this.setTexture2D=H,this.setTexture2DArray=G,this.setTexture3D=N,this.setTextureCube=q,this.rebindTextures=Ae,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=Pe,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ve}function RI(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Ni)return 5121;if(n===vC)return 32819;if(n===yC)return 32820;if(n===fC)return 5120;if(n===mC)return 5122;if(n===U_)return 5123;if(n===gC)return 5124;if(n===Hn)return 5125;if(n===xr)return 5126;if(n===fl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===xC)return 6406;if(n===Rr)return 6408;if(n===bC)return 6409;if(n===wC)return 6410;if(n===Fa)return 6402;if(n===Xa)return 34041;if(n===Fm)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===_C)return 6403;if(n===SC)return 36244;if(n===F_)return 33319;if(n===AC)return 33320;if(n===MC)return 36249;if(n===jp||n===Gp||n===Vp||n===Hp)if(a===Je)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===jp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Gp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Vp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Hp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===jp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Gp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Vp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Hp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ey||n===Cy||n===Ty||n===Py)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===Ey)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Cy)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ty)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Py)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===EC)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Dy||n===Iy)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===Dy)return a===Je?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Iy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Ly||n===Oy||n===By||n===Ry||n===zy||n===Ny||n===Uy||n===Fy||n===ky||n===jy||n===Gy||n===Vy||n===Hy||n===Wy)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Ly)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Oy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===By)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ry)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===zy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ny)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Uy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Fy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ky)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===jy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Gy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Vy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Hy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Wy)return a===Je?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Wp)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===Wp)return a===Je?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===CC||n===qy||n===Xy||n===Yy)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===Wp)return o.COMPRESSED_RED_RGTC1_EXT;if(n===qy)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Xy)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Yy)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ua?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 zI=class extends Oi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Xo=class extends Mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},NI={type:"move"},yf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xo,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 Xo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),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 g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==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(NI)))}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 Xo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},gl=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:Fa,h!==Fa&&h!==Xa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===Fa&&(i=Hn),i===void 0&&h===Xa&&(i=Ua),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:It,this.minFilter=o!==void 0?o:It,this.flipY=!1,this.generateMipmaps=!1}},UI=class extends Ti{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(),g=null,m=null,v=[],y=[],x=new Set,b=new Map,_=new Oi;_.layers.enable(1),_.viewport=new $e;let A=new Oi;A.layers.enable(2),A.viewport=new $e;let S=[_,A],w=new zI;w.layers.enable(1),w.layers.enable(2);let E=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let N=v[G];return N===void 0&&(N=new yf,v[G]=N),N.getTargetRaySpace()},this.getControllerGrip=function(G){let N=v[G];return N===void 0&&(N=new yf,v[G]=N),N.getGripSpace()},this.getHand=function(G){let N=v[G];return N===void 0&&(N=new yf,v[G]=N),N.getHandSpace()};function T(G){let N=y.indexOf(G.inputSource);if(N===-1)return;let q=v[N];q!==void 0&&q.dispatchEvent({type:G.type,data:G.inputSource})}function D(){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",D),r.removeEventListener("inputsourceschange",P);for(let G=0;G<v.length;G++){let N=y[G];N!==null&&(y[G]=null,v[G].disconnect(N))}E=null,C=null,e.setRenderTarget(g),u=null,c=null,d=null,r=null,m=null,H.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){s=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(G){l=G},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(G){if(r=G,r!==null){if(g=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",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let N={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,N),r.updateRenderState({baseLayer:u}),m=new At(u.framebufferWidth,u.framebufferHeight,{format:Rr,type:Ni,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let N=null,q=null,j=null;f.depth&&(j=f.stencil?35056:33190,N=f.stencil?Xa:Fa,q=f.stencil?Ua:Hn);let W={colorFormat:32856,depthFormat:j,scaleFactor:s};d=new XRWebGLBinding(r,t),c=d.createProjectionLayer(W),r.updateRenderState({layers:[c]}),m=new At(c.textureWidth,c.textureHeight,{format:Rr,type:Ni,depthTexture:new gl(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,N),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let U=e.properties.get(m);U.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),H.setContext(r),H.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(G){for(let N=0;N<G.removed.length;N++){let q=G.removed[N],j=y.indexOf(q);j>=0&&(y[j]=null,v[j].disconnect(q))}for(let N=0;N<G.added.length;N++){let q=G.added[N],j=y.indexOf(q);if(j===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(q),j=U;break}else if(y[U]===null){y[U]=q,j=U;break}if(j===-1)break}let W=v[j];W&&W.connect(q)}}let L=new M,R=new M;function V(G,N,q){L.setFromMatrixPosition(N.matrixWorld),R.setFromMatrixPosition(q.matrixWorld);let j=L.distanceTo(R),W=N.projectionMatrix.elements,U=q.projectionMatrix.elements,ie=W[14]/(W[10]-1),Q=W[14]/(W[10]+1),re=(W[9]+1)/W[5],Z=(W[9]-1)/W[5],ue=(W[8]-1)/W[0],ae=(U[8]+1)/U[0],se=ie*ue,Ae=ie*ae,Se=j/(-ue+ae),Me=Se*-ue;N.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Me),G.translateZ(Se),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Pe=ie+Se,xe=Q+Se,ve=se-Me,Re=Ae+(j-Me),Qe=re*Q/xe*Pe,B=Z*Q/xe*Pe;G.projectionMatrix.makePerspective(ve,Re,Qe,B,Pe,xe)}function k(G,N){N===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(N.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(r===null)return;w.near=A.near=_.near=G.near,w.far=A.far=_.far=G.far,(E!==w.near||C!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),E=w.near,C=w.far);let N=G.parent,q=w.cameras;k(w,N);for(let W=0;W<q.length;W++)k(q[W],N);w.matrixWorld.decompose(w.position,w.quaternion,w.scale),G.matrix.copy(w.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let j=G.children;for(let W=0,U=j.length;W<U;W++)j[W].updateMatrixWorld(!0);q.length===2?V(w,_,A):w.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return w},this.getFoveation=function(){if(!(c===null&&u===null))return o},this.setFoveation=function(G){o=G,c!==null&&(c.fixedFoveation=G),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=G)},this.getPlanes=function(){return x};let z=null;function X(G,N){if(h=N.getViewerPose(l||n),p=N,h!==null){let q=h.views;u!==null&&(e.setRenderTargetFramebuffer(m,u.framebuffer),e.setRenderTarget(m));let j=!1;q.length!==w.cameras.length&&(w.cameras.length=0,j=!0);for(let W=0;W<q.length;W++){let U=q[W],ie=null;if(u!==null)ie=u.getViewport(U);else{let re=d.getViewSubImage(c,U);ie=re.viewport,W===0&&(e.setRenderTargetTextures(m,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(m))}let Q=S[W];Q===void 0&&(Q=new Oi,Q.layers.enable(W),Q.viewport=new $e,S[W]=Q),Q.matrix.fromArray(U.transform.matrix),Q.projectionMatrix.fromArray(U.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&w.matrix.copy(Q.matrix),j===!0&&w.cameras.push(Q)}}for(let q=0;q<v.length;q++){let j=y[q],W=v[q];j!==null&&W!==void 0&&W.update(j,N,l||n)}if(z&&z(G,N),N.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:N.detectedPlanes});let q=null;for(let j of x)N.detectedPlanes.has(j)||(q===null&&(q=[]),q.push(j));if(q!==null)for(let j of q)x.delete(j),b.delete(j),i.dispatchEvent({type:"planeremoved",data:j});for(let j of N.detectedPlanes)if(!x.has(j))x.add(j),b.set(j,N.lastChangedTime),i.dispatchEvent({type:"planeadded",data:j});else{let W=b.get(j);j.lastChangedTime>W&&(b.set(j,j.lastChangedTime),i.dispatchEvent({type:"planechanged",data:j}))}}p=null}let H=new K_;H.setAnimationLoop(X),this.setAnimationLoop=function(G){z=G},this.dispose=function(){}}};function FI(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,Z_(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),d(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),c(g,m),m.isMeshPhysicalMaterial&&u(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(n(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===xi&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===xi&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*b}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uv2Transform.value.copy(x.matrix))}function n(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function c(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function u(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===xi&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function kI(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=d(y),s[y.id]=b,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let A=t.render.frame;n[y.id]!==A&&(u(y),n[y.id]=A)}function d(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),_=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,_,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}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],b=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let A=0,S=b.length;A<S;A++){let w=b[A];if(p(w,A,_)===!0){let E=w.__offset,C=Array.isArray(w.value)?w.value:[w.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],L=g(P);typeof P=="number"?(w.__data[0]=P,e.bufferSubData(35345,E+T,w.__data)):P.isMatrix3?(w.__data[0]=P.elements[0],w.__data[1]=P.elements[1],w.__data[2]=P.elements[2],w.__data[3]=P.elements[0],w.__data[4]=P.elements[3],w.__data[5]=P.elements[4],w.__data[6]=P.elements[5],w.__data[7]=P.elements[0],w.__data[8]=P.elements[6],w.__data[9]=P.elements[7],w.__data[10]=P.elements[8],w.__data[11]=P.elements[0]):(P.toArray(w.__data,T),T+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,E,w.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let _=y.value;if(b[x]===void 0){if(typeof _=="number")b[x]=_;else{let A=Array.isArray(_)?_:[_],S=[];for(let w=0;w<A.length;w++)S.push(A[w].clone());b[x]=S}return!0}else if(typeof _=="number"){if(b[x]!==_)return b[x]=_,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],S=Array.isArray(_)?_:[_];for(let w=0;w<A.length;w++){let E=A[w];if(E.equals(S[w])===!1)return E.copy(S[w]),!0}}return!1}function f(y){let x=y.uniforms,b=0,_=16,A=0;for(let S=0,w=x.length;S<w;S++){let E=x[S],C={boundary:0,storage:0},T=Array.isArray(E.value)?E.value:[E.value];for(let D=0,P=T.length;D<P;D++){let L=T[D],R=g(L);C.boundary+=R.boundary,C.storage+=R.storage}if(E.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=b,S>0){A=b%_;let D=_-A;A!==0&&D-C.boundary<0&&(b+=_-A,E.__offset=b)}b+=C.storage}return A=b%_,A>0&&(b+=_-A),y.__size=b,y.__cache={},this}function g(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 m(y){let x=y.target;x.removeEventListener("dispose",m);let b=a.indexOf(x.__bindingPointIndex);a.splice(b,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 jI(){let e=uu("canvas");return e.style.display="block",e}function rS(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:jI(),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=Bs,this.physicallyCorrectLights=!1,this.toneMapping=gn,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,x=null,b=-1,_=null,A=new $e,S=new $e,w=null,E=t.width,C=t.height,T=1,D=null,P=null,L=new $e(0,0,E,C),R=new $e(0,0,E,C),V=!1,k=new Ev,z=!1,X=!1,H=null,G=new fe,N=new F,q=new M,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return x===null?T:1}let U=i;function ie(O,ee){for(let oe=0;oe<O.length;oe++){let J=O[oe],le=t.getContext(J,ee);if(le!==null)return le}return null}try{let O={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${Dl}`),t.addEventListener("webglcontextlost",Xe,!1),t.addEventListener("webglcontextrestored",Ue,!1),t.addEventListener("webglcontextcreationerror",pt,!1),U===null){let ee=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&ee.shift(),U=ie(ee,O),U===null)throw ie(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}U.getShaderPrecisionFormat===void 0&&(U.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(O){throw console.error("THREE.WebGLRenderer: "+O.message),O}let Q,re,Z,ue,ae,se,Ae,Se,Me,Pe,xe,ve,Re,Qe,B,I,$,me,ce,ye,Oe,Ee,de,De;function Be(){Q=new eD(U),re=new YP(U,Q,e),Q.init(re),Ee=new RI(U,Q,re),Z=new OI(U,Q,re),ue=new rD,ae=new bI,se=new BI(U,Q,Z,ae,re,Ee,ue),Ae=new ZP(g),Se=new $P(g),Me=new uT(U,re),de=new qP(U,Q,Me,re),Pe=new tD(U,Me,ue,de),xe=new oD(U,Pe,Me,ue),ce=new aD(U,re,se),I=new QP(ae),ve=new xI(g,Ae,Se,Q,re,de,I),Re=new FI(g,ae),Qe=new _I,B=new TI(Q,re),me=new WP(g,Ae,Se,Z,xe,d,a),$=new LI(g,xe,re),De=new kI(U,ue,re,Z),ye=new XP(U,Q,ue,re),Oe=new iD(U,Q,ue,re),ue.programs=ve.programs,g.capabilities=re,g.extensions=Q,g.properties=ae,g.renderLists=Qe,g.shadowMap=$,g.state=Z,g.info=ue}Be();let Ie=new UI(g,U);this.xr=Ie,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let O=Q.get("WEBGL_lose_context");O&&O.loseContext()},this.forceContextRestore=function(){let O=Q.get("WEBGL_lose_context");O&&O.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(O){O!==void 0&&(T=O,this.setSize(E,C,!1))},this.getSize=function(O){return O.set(E,C)},this.setSize=function(O,ee,oe){if(Ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=O,C=ee,t.width=Math.floor(O*T),t.height=Math.floor(ee*T),oe!==!1&&(t.style.width=O+"px",t.style.height=ee+"px"),this.setViewport(0,0,O,ee)},this.getDrawingBufferSize=function(O){return O.set(E*T,C*T).floor()},this.setDrawingBufferSize=function(O,ee,oe){E=O,C=ee,T=oe,t.width=Math.floor(O*oe),t.height=Math.floor(ee*oe),this.setViewport(0,0,O,ee)},this.getCurrentViewport=function(O){return O.copy(A)},this.getViewport=function(O){return O.copy(L)},this.setViewport=function(O,ee,oe,J){O.isVector4?L.set(O.x,O.y,O.z,O.w):L.set(O,ee,oe,J),Z.viewport(A.copy(L).multiplyScalar(T).floor())},this.getScissor=function(O){return O.copy(R)},this.setScissor=function(O,ee,oe,J){O.isVector4?R.set(O.x,O.y,O.z,O.w):R.set(O,ee,oe,J),Z.scissor(S.copy(R).multiplyScalar(T).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(O){Z.setScissorTest(V=O)},this.setOpaqueSort=function(O){D=O},this.setTransparentSort=function(O){P=O},this.getClearColor=function(O){return O.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(O=!0,ee=!0,oe=!0){let J=0;O&&(J|=16384),ee&&(J|=256),oe&&(J|=1024),U.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",Xe,!1),t.removeEventListener("webglcontextrestored",Ue,!1),t.removeEventListener("webglcontextcreationerror",pt,!1),Qe.dispose(),B.dispose(),ae.dispose(),Ae.dispose(),Se.dispose(),xe.dispose(),de.dispose(),De.dispose(),ve.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",we),Ie.removeEventListener("sessionend",Ge),H&&(H.dispose(),H=null),gt.stop()};function Xe(O){O.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Ue(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let O=ue.autoReset,ee=$.enabled,oe=$.autoUpdate,J=$.needsUpdate,le=$.type;Be(),ue.autoReset=O,$.enabled=ee,$.autoUpdate=oe,$.needsUpdate=J,$.type=le}function pt(O){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",O.statusMessage)}function Ot(O){let ee=O.target;ee.removeEventListener("dispose",Ot),Jt(ee)}function Jt(O){Y(O),ae.remove(O)}function Y(O){let ee=ae.get(O).programs;ee!==void 0&&(ee.forEach(function(oe){ve.releaseProgram(oe)}),O.isShaderMaterial&&ve.releaseShaderCache(O))}this.renderBufferDirect=function(O,ee,oe,J,le,ze){ee===null&&(ee=j);let rt=le.isMesh&&le.matrixWorld.determinant()<0,ot=bE(O,ee,oe,J,le);Z.setMaterial(J,rt);let ht=oe.index,Pt=1;J.wireframe===!0&&(ht=Pe.getWireframeAttribute(oe),Pt=2);let vt=oe.drawRange,ft=oe.attributes.position,Di=vt.start*Pt,dr=(vt.start+vt.count)*Pt;ze!==null&&(Di=Math.max(Di,ze.start*Pt),dr=Math.min(dr,(ze.start+ze.count)*Pt)),ht!==null?(Di=Math.max(Di,0),dr=Math.min(dr,ht.count)):ft!=null&&(Di=Math.max(Di,0),dr=Math.min(dr,ft.count));let Hs=dr-Di;if(Hs<0||Hs===1/0)return;de.setup(le,J,ot,oe,ht);let pa,$t=ye;if(ht!==null&&(pa=Me.get(ht),$t=Oe,$t.setIndex(pa)),le.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*W()),$t.setMode(1)):$t.setMode(4);else if(le.isLine){let mt=J.linewidth;mt===void 0&&(mt=1),Z.setLineWidth(mt*W()),le.isLineSegments?$t.setMode(1):le.isLineLoop?$t.setMode(2):$t.setMode(3)}else le.isPoints?$t.setMode(0):le.isSprite&&$t.setMode(4);if(le.isInstancedMesh)$t.renderInstances(Di,Hs,le.count);else if(oe.isInstancedBufferGeometry){let mt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Rp=Math.min(oe.instanceCount,mt);$t.renderInstances(Di,Hs,Rp)}else $t.render(Di,Hs)},this.compile=function(O,ee){function oe(J,le,ze){J.transparent===!0&&J.side===yr&&J.forceSinglePass===!1?(J.side=xi,J.needsUpdate=!0,Ar(J,le,ze),J.side=ns,J.needsUpdate=!0,Ar(J,le,ze),J.side=yr):Ar(J,le,ze)}u=B.get(O),u.init(),f.push(u),O.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(u.pushLight(J),J.castShadow&&u.pushShadow(J))}),u.setupLights(g.physicallyCorrectLights),O.traverse(function(J){let le=J.material;if(le)if(Array.isArray(le))for(let ze=0;ze<le.length;ze++){let rt=le[ze];oe(rt,O,J)}else oe(le,O,J)}),f.pop(),u=null};let ne=null;function ge(O){ne&&ne(O)}function we(){gt.stop()}function Ge(){gt.start()}let gt=new K_;gt.setAnimationLoop(ge),typeof self<"u"&>.setContext(self),this.setAnimationLoop=function(O){ne=O,Ie.setAnimationLoop(O),O===null?gt.stop():gt.start()},Ie.addEventListener("sessionstart",we),Ie.addEventListener("sessionend",Ge),this.render=function(O,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(ee),ee=Ie.getCamera()),O.isScene===!0&&O.onBeforeRender(g,O,ee,x),u=B.get(O,f.length),u.init(),f.push(u),G.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),k.setFromProjectionMatrix(G),X=this.localClippingEnabled,z=I.init(this.clippingPlanes,X),c=Qe.get(O,p.length),c.init(),p.push(c),Ut(O,ee,0,g.sortObjects),c.finish(),g.sortObjects===!0&&c.sort(D,P),z===!0&&I.beginShadows();let oe=u.state.shadowsArray;if($.render(oe,O,ee),z===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(c,O),u.setupLights(g.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let le=0,ze=J.length;le<ze;le++){let rt=J[le];Pi(c,O,rt,rt.viewport)}}else Pi(c,O,ee);x!==null&&(se.updateMultisampleRenderTarget(x),se.updateRenderTargetMipmap(x)),O.isScene===!0&&O.onAfterRender(g,O,ee),de.resetDefaultState(),b=-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 Ut(O,ee,oe,J){if(O.visible===!1)return;if(O.layers.test(ee.layers)){if(O.isGroup)oe=O.renderOrder;else if(O.isLOD)O.autoUpdate===!0&&O.update(ee);else if(O.isLight)u.pushLight(O),O.castShadow&&u.pushShadow(O);else if(O.isSprite){if(!O.frustumCulled||k.intersectsSprite(O)){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}else if((O.isMesh||O.isLine||O.isPoints)&&(O.isSkinnedMesh&&O.skeleton.frame!==ue.render.frame&&(O.skeleton.update(),O.skeleton.frame=ue.render.frame),!O.frustumCulled||k.intersectsObject(O))){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;if(Array.isArray(rt)){let ot=ze.groups;for(let ht=0,Pt=ot.length;ht<Pt;ht++){let vt=ot[ht],ft=rt[vt.materialIndex];ft&&ft.visible&&c.push(O,ze,ft,oe,q.z,vt)}}else rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}let le=O.children;for(let ze=0,rt=le.length;ze<rt;ze++)Ut(le[ze],ee,oe,J)}function Pi(O,ee,oe,J){let le=O.opaque,ze=O.transmissive,rt=O.transparent;u.setupLightsView(oe),z===!0&&I.setGlobalState(g.clippingPlanes,oe),ze.length>0&&ua(le,ee,oe),J&&Z.viewport(A.copy(J)),le.length>0&&Nt(le,ee,oe),ze.length>0&&Nt(ze,ee,oe),rt.length>0&&Nt(rt,ee,oe),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function ua(O,ee,oe){let J=re.isWebGL2;H===null&&(H=new At(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?fl:Ni,minFilter:pl,samples:J&&n===!0?4:0})),g.getDrawingBufferSize(N),J?H.setSize(N.x,N.y):H.setSize(du(N.x),du(N.y));let le=g.getRenderTarget();g.setRenderTarget(H),g.clear();let ze=g.toneMapping;g.toneMapping=gn,Nt(O,ee,oe),g.toneMapping=ze,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),g.setRenderTarget(le)}function Nt(O,ee,oe){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let le=0,ze=O.length;le<ze;le++){let rt=O[le],ot=rt.object,ht=rt.geometry,Pt=J===null?rt.material:J,vt=rt.group;ot.layers.test(oe.layers)&&Vs(ot,ee,oe,ht,Pt,vt)}}function Vs(O,ee,oe,J,le,ze){O.onBeforeRender(g,ee,oe,J,le,ze),O.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,O.matrixWorld),O.normalMatrix.getNormalMatrix(O.modelViewMatrix),le.onBeforeRender(g,ee,oe,J,O,ze),le.transparent===!0&&le.side===yr&&le.forceSinglePass===!1?(le.side=xi,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=ns,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=yr):g.renderBufferDirect(oe,ee,J,le,O,ze),O.onAfterRender(g,ee,oe,J,le,ze)}function Ar(O,ee,oe){ee.isScene!==!0&&(ee=j);let J=ae.get(O),le=u.state.lights,ze=u.state.shadowsArray,rt=le.state.version,ot=ve.getParameters(O,le.state,ze,ee,oe),ht=ve.getProgramCacheKey(ot),Pt=J.programs;J.environment=O.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(O.isMeshStandardMaterial?Se:Ae).get(O.envMap||J.environment),Pt===void 0&&(O.addEventListener("dispose",Ot),Pt=new Map,J.programs=Pt);let vt=Pt.get(ht);if(vt!==void 0){if(J.currentProgram===vt&&J.lightsStateVersion===rt)return gy(O,ot),vt}else ot.uniforms=ve.getUniforms(O),O.onBuild(oe,ot,g),O.onBeforeCompile(ot,g),vt=ve.acquireProgram(ot,ht),Pt.set(ht,vt),J.uniforms=ot.uniforms;let ft=J.uniforms;(!O.isShaderMaterial&&!O.isRawShaderMaterial||O.clipping===!0)&&(ft.clippingPlanes=I.uniform),gy(O,ot),J.needsLights=_E(O),J.lightsStateVersion=rt,J.needsLights&&(ft.ambientLightColor.value=le.state.ambient,ft.lightProbe.value=le.state.probe,ft.directionalLights.value=le.state.directional,ft.directionalLightShadows.value=le.state.directionalShadow,ft.spotLights.value=le.state.spot,ft.spotLightShadows.value=le.state.spotShadow,ft.rectAreaLights.value=le.state.rectArea,ft.ltc_1.value=le.state.rectAreaLTC1,ft.ltc_2.value=le.state.rectAreaLTC2,ft.pointLights.value=le.state.point,ft.pointLightShadows.value=le.state.pointShadow,ft.hemisphereLights.value=le.state.hemi,ft.directionalShadowMap.value=le.state.directionalShadowMap,ft.directionalShadowMatrix.value=le.state.directionalShadowMatrix,ft.spotShadowMap.value=le.state.spotShadowMap,ft.spotLightMatrix.value=le.state.spotLightMatrix,ft.spotLightMap.value=le.state.spotLightMap,ft.pointShadowMap.value=le.state.pointShadowMap,ft.pointShadowMatrix.value=le.state.pointShadowMatrix);let Di=vt.getUniforms(),dr=Kd.seqWithValue(Di.seq,ft);return J.currentProgram=vt,J.uniformsList=dr,vt}function gy(O,ee){let oe=ae.get(O);oe.outputEncoding=ee.outputEncoding,oe.instancing=ee.instancing,oe.skinning=ee.skinning,oe.morphTargets=ee.morphTargets,oe.morphNormals=ee.morphNormals,oe.morphColors=ee.morphColors,oe.morphTargetsCount=ee.morphTargetsCount,oe.numClippingPlanes=ee.numClippingPlanes,oe.numIntersection=ee.numClipIntersection,oe.vertexAlphas=ee.vertexAlphas,oe.vertexTangents=ee.vertexTangents,oe.toneMapping=ee.toneMapping}function bE(O,ee,oe,J,le){ee.isScene!==!0&&(ee=j),se.resetTextureUnits();let ze=ee.fog,rt=J.isMeshStandardMaterial?ee.environment:null,ot=x===null?g.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Bs,ht=(J.isMeshStandardMaterial?Se:Ae).get(J.envMap||rt),Pt=J.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,vt=!!J.normalMap&&!!oe.attributes.tangent,ft=!!oe.morphAttributes.position,Di=!!oe.morphAttributes.normal,dr=!!oe.morphAttributes.color,Hs=J.toneMapped?g.toneMapping:gn,pa=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,$t=pa!==void 0?pa.length:0,mt=ae.get(J),Rp=u.state.lights;if(z===!0&&(X===!0||O!==_)){let ur=O===_&&J.id===b;I.setState(J,O,ur)}let zp=!1;J.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Rp.state.version||mt.outputEncoding!==ot||le.isInstancedMesh&&mt.instancing===!1||!le.isInstancedMesh&&mt.instancing===!0||le.isSkinnedMesh&&mt.skinning===!1||!le.isSkinnedMesh&&mt.skinning===!0||mt.envMap!==ht||J.fog===!0&&mt.fog!==ze||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==I.numPlanes||mt.numIntersection!==I.numIntersection)||mt.vertexAlphas!==Pt||mt.vertexTangents!==vt||mt.morphTargets!==ft||mt.morphNormals!==Di||mt.morphColors!==dr||mt.toneMapping!==Hs||re.isWebGL2===!0&&mt.morphTargetsCount!==$t)&&(zp=!0):(zp=!0,mt.__version=J.version);let fa=mt.currentProgram;zp===!0&&(fa=Ar(J,ee,le));let vy=!1,Jl=!1,Np=!1,Ai=fa.getUniforms(),ma=mt.uniforms;if(Z.useProgram(fa.program)&&(vy=!0,Jl=!0,Np=!0),J.id!==b&&(b=J.id,Jl=!0),vy||_!==O){if(Ai.setValue(U,"projectionMatrix",O.projectionMatrix),re.logarithmicDepthBuffer&&Ai.setValue(U,"logDepthBufFC",2/(Math.log(O.far+1)/Math.LN2)),_!==O&&(_=O,Jl=!0,Np=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let ur=Ai.map.cameraPosition;ur!==void 0&&ur.setValue(U,q.setFromMatrixPosition(O.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Ai.setValue(U,"isOrthographic",O.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||le.isSkinnedMesh)&&Ai.setValue(U,"viewMatrix",O.matrixWorldInverse)}if(le.isSkinnedMesh){Ai.setOptional(U,le,"bindMatrix"),Ai.setOptional(U,le,"bindMatrixInverse");let ur=le.skeleton;ur&&(re.floatVertexTextures?(ur.boneTexture===null&&ur.computeBoneTexture(),Ai.setValue(U,"boneTexture",ur.boneTexture,se),Ai.setValue(U,"boneTextureSize",ur.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 Up=oe.morphAttributes;if((Up.position!==void 0||Up.normal!==void 0||Up.color!==void 0&&re.isWebGL2===!0)&&ce.update(le,oe,J,fa),(Jl||mt.receiveShadow!==le.receiveShadow)&&(mt.receiveShadow=le.receiveShadow,Ai.setValue(U,"receiveShadow",le.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(ma.envMap.value=ht,ma.flipEnvMap.value=ht.isCubeTexture&&ht.isRenderTargetTexture===!1?-1:1),Jl&&(Ai.setValue(U,"toneMappingExposure",g.toneMappingExposure),mt.needsLights&&wE(ma,Np),ze&&J.fog===!0&&Re.refreshFogUniforms(ma,ze),Re.refreshMaterialUniforms(ma,J,T,C,H),Kd.upload(U,mt.uniformsList,ma,se)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Kd.upload(U,mt.uniformsList,ma,se),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Ai.setValue(U,"center",le.center),Ai.setValue(U,"modelViewMatrix",le.modelViewMatrix),Ai.setValue(U,"normalMatrix",le.normalMatrix),Ai.setValue(U,"modelMatrix",le.matrixWorld),le.previousModelViewMatrix&&Ai.setValue(U,"previousModelViewMatrix",le.previousModelViewMatrix),O.previousProjectionMatrix&&Ai.setValue(U,"previousProjectionMatrix",O.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let ur=J.uniformsGroups;for(let Fp=0,SE=ur.length;Fp<SE;Fp++)if(re.isWebGL2){let yy=ur[Fp];De.update(yy,fa),De.bind(yy,fa)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fa}function wE(O,ee){O.ambientLightColor.needsUpdate=ee,O.lightProbe.needsUpdate=ee,O.directionalLights.needsUpdate=ee,O.directionalLightShadows.needsUpdate=ee,O.pointLights.needsUpdate=ee,O.pointLightShadows.needsUpdate=ee,O.spotLights.needsUpdate=ee,O.spotLightShadows.needsUpdate=ee,O.rectAreaLights.needsUpdate=ee,O.hemisphereLights.needsUpdate=ee}function _E(O){return O.isMeshLambertMaterial||O.isMeshToonMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isShadowMaterial||O.isShaderMaterial&&O.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(O,ee,oe){ae.get(O.texture).__webglTexture=ee,ae.get(O.depthTexture).__webglTexture=oe;let J=ae.get(O);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=oe===void 0,J.__autoAllocateDepthBuffer||Q.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(O,ee){let oe=ae.get(O);oe.__webglFramebuffer=ee,oe.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(O,ee=0,oe=0){x=O,v=ee,y=oe;let J=!0,le=null,ze=!1,rt=!1;if(O){let ot=ae.get(O);ot.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):ot.__webglFramebuffer===void 0?se.setupRenderTarget(O):ot.__hasExternalTextures&&se.rebindTextures(O,ae.get(O.texture).__webglTexture,ae.get(O.depthTexture).__webglTexture);let ht=O.texture;(ht.isData3DTexture||ht.isDataArrayTexture||ht.isCompressedArrayTexture)&&(rt=!0);let Pt=ae.get(O).__webglFramebuffer;O.isWebGLCubeRenderTarget?(le=Pt[ee],ze=!0):re.isWebGL2&&O.samples>0&&se.useMultisampledRTT(O)===!1?le=ae.get(O).__webglMultisampledFramebuffer:le=Pt,A.copy(O.viewport),S.copy(O.scissor),w=O.scissorTest}else A.copy(L).multiplyScalar(T).floor(),S.copy(R).multiplyScalar(T).floor(),w=V;if(Z.bindFramebuffer(36160,le)&&re.drawBuffers&&J&&Z.drawBuffers(O,le),Z.viewport(A),Z.scissor(S),Z.setScissorTest(w),ze){let ot=ae.get(O.texture);U.framebufferTexture2D(36160,36064,34069+ee,ot.__webglTexture,oe)}else if(rt){let ot=ae.get(O.texture),ht=ee||0;U.framebufferTextureLayer(36160,36064,ot.__webglTexture,oe||0,ht)}b=-1},this.readRenderTargetPixels=function(O,ee,oe,J,le,ze,rt){if(!(O&&O.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=ae.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&rt!==void 0&&(ot=ot[rt]),ot){Z.bindFramebuffer(36160,ot);try{let ht=O.texture,Pt=ht.format,vt=ht.type;if(Pt!==Rr&&Ee.convert(Pt)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ft=vt===fl&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(vt!==Ni&&Ee.convert(vt)!==U.getParameter(35738)&&!(vt===xr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!ft){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=O.width-J&&oe>=0&&oe<=O.height-le&&U.readPixels(ee,oe,J,le,Ee.convert(Pt),Ee.convert(vt),ze)}finally{let ht=x!==null?ae.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,ht)}}},this.copyFramebufferToTexture=function(O,ee,oe=0){let J=Math.pow(2,-oe),le=Math.floor(ee.image.width*J),ze=Math.floor(ee.image.height*J);se.setTexture2D(ee,0),U.copyTexSubImage2D(3553,oe,0,0,O.x,O.y,le,ze),Z.unbindTexture()},this.copyTextureToTexture=function(O,ee,oe,J=0){let le=ee.image.width,ze=ee.image.height,rt=Ee.convert(oe.format),ot=Ee.convert(oe.type);se.setTexture2D(oe,0),U.pixelStorei(37440,oe.flipY),U.pixelStorei(37441,oe.premultiplyAlpha),U.pixelStorei(3317,oe.unpackAlignment),ee.isDataTexture?U.texSubImage2D(3553,J,O.x,O.y,le,ze,rt,ot,ee.image.data):ee.isCompressedTexture?U.compressedTexSubImage2D(3553,J,O.x,O.y,ee.mipmaps[0].width,ee.mipmaps[0].height,rt,ee.mipmaps[0].data):U.texSubImage2D(3553,J,O.x,O.y,rt,ot,ee.image),J===0&&oe.generateMipmaps&&U.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(O,ee,oe,J,le=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ze=O.max.x-O.min.x+1,rt=O.max.y-O.min.y+1,ot=O.max.z-O.min.z+1,ht=Ee.convert(J.format),Pt=Ee.convert(J.type),vt;if(J.isData3DTexture)se.setTexture3D(J,0),vt=32879;else if(J.isDataArrayTexture)se.setTexture2DArray(J,0),vt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,J.flipY),U.pixelStorei(37441,J.premultiplyAlpha),U.pixelStorei(3317,J.unpackAlignment);let ft=U.getParameter(3314),Di=U.getParameter(32878),dr=U.getParameter(3316),Hs=U.getParameter(3315),pa=U.getParameter(32877),$t=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;U.pixelStorei(3314,$t.width),U.pixelStorei(32878,$t.height),U.pixelStorei(3316,O.min.x),U.pixelStorei(3315,O.min.y),U.pixelStorei(32877,O.min.z),oe.isDataTexture||oe.isData3DTexture?U.texSubImage3D(vt,le,ee.x,ee.y,ee.z,ze,rt,ot,ht,Pt,$t.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(vt,le,ee.x,ee.y,ee.z,ze,rt,ot,ht,$t.data)):U.texSubImage3D(vt,le,ee.x,ee.y,ee.z,ze,rt,ot,ht,Pt,$t),U.pixelStorei(3314,ft),U.pixelStorei(32878,Di),U.pixelStorei(3316,dr),U.pixelStorei(3315,Hs),U.pixelStorei(32877,pa),le===0&&J.generateMipmaps&&U.generateMipmap(vt),Z.unbindTexture()},this.initTexture=function(O){O.isCubeTexture?se.setTextureCube(O,0):O.isData3DTexture?se.setTexture3D(O,0):O.isDataArrayTexture||O.isCompressedArrayTexture?se.setTexture2DArray(O,0):se.setTexture2D(O,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var GI=class extends rS{};GI.prototype.isWebGL1Renderer=!0;var sS=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 sS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Jn=class extends Mt{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}},VI=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Um,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Nr()}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=Nr()),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=Nr()),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}}},Fi=new M,Gm=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++)Fi.fromBufferAttribute(this,t),Fi.applyMatrix4(e),this.setXYZ(t,Fi.x,Fi.y,Fi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Fi.fromBufferAttribute(this,t),Fi.applyNormalMatrix(e),this.setXYZ(t,Fi.x,Fi.y,Fi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Fi.fromBufferAttribute(this,t),Fi.transformDirection(e),this.setXYZ(t,Fi.x,Fi.y,Fi.z);return this}setX(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Dt(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=fn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=fn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=fn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=fn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Dt(t,this.array),i=Dt(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=Dt(t,this.array),i=Dt(i,this.array),r=Dt(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=Dt(t,this.array),i=Dt(i,this.array),r=Dt(r,this.array),s=Dt(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 Gm(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}}},nS=class extends Mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},pu=class extends ci{constructor(e=null,t=1,i=1,r,s,n,a,o,l=It,h=It,d,c){super(null,n,a,o,l,h,r,s,d,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},P1=new fe,HI=new fe,Pv=class{constructor(e=[],t=[]){this.uuid=Nr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new fe;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,n=e.length;s<n;s++){let a=e[s]?e[s].matrixWorld:HI;P1.multiplyMatrices(a,t[s]),P1.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Pv(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=V_(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new pu(t,e,e,Rr,xr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],n=t[s];n===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),n=new nS),this.bones.push(n),this.boneInverses.push(new fe().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let n=t[r];e.bones.push(n.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},WI=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}},oa=class extends yc{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}},D1=new M,I1=new M,L1=new fe,xf=new Il,ed=new _r,fu=class extends Mt{constructor(e=new qe,t=new oa){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++)D1.fromBufferAttribute(t,r-1),I1.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=D1.distanceTo(I1);e.setAttribute("lineDistance",new Le(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(),ed.copy(i.boundingSphere),ed.applyMatrix4(r),ed.radius+=s,e.ray.intersectsSphere(ed)===!1)return;L1.copy(r).invert(),xf.copy(e.ray).applyMatrix4(L1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new M,h=new M,d=new M,c=new M,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=u){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),xf.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 g=Math.max(0,n.start),m=Math.min(f.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=u){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),xf.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}}}}},O1=new M,B1=new M,bc=class extends fu{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)O1.fromBufferAttribute(t,r),B1.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+O1.distanceTo(B1);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},qI=class extends ci{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:st,this.magFilter=s!==void 0?s:st,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)}},ks=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 F:new M);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 M,r=[],s=[],n=[],a=new M,o=new fe;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new M)}s[0]=new M,n[0]=new M;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(hi(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(hi(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}},np=class extends ks{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 F,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}},XI=class extends np{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function Dv(){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 td=new M,bf=new Dv,wf=new Dv,_f=new Dv,YI=class extends ks{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 M){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]:(td.subVectors(r[0],r[1]).add(r[0]),l=td);let d=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(td.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=td),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),g=Math.pow(c.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),bf.initNonuniformCatmullRom(l.x,d.x,c.x,h.x,p,f,g),wf.initNonuniformCatmullRom(l.y,d.y,c.y,h.y,p,f,g),_f.initNonuniformCatmullRom(l.z,d.z,c.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(bf.initCatmullRom(l.x,d.x,c.x,h.x,this.tension),wf.initCatmullRom(l.y,d.y,c.y,h.y,this.tension),_f.initCatmullRom(l.z,d.z,c.z,h.z,this.tension));return i.set(bf.calc(o),wf.calc(o),_f.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 M().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function R1(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 QI(e,t){let i=1-e;return i*i*t}function ZI(e,t){return 2*(1-e)*e*t}function KI(e,t){return e*e*t}function kh(e,t,i,r){return QI(e,t)+ZI(e,i)+KI(e,r)}function JI(e,t){let i=1-e;return i*i*i*t}function $I(e,t){let i=1-e;return 3*i*i*e*t}function eL(e,t){return 3*(1-e)*e*e*t}function tL(e,t){return e*e*e*t}function jh(e,t,i,r,s){return JI(e,t)+$I(e,i)+eL(e,r)+tL(e,s)}var $r=class extends ks{constructor(e=new F,t=new F,i=new F,r=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(jh(e,r.x,s.x,n.x,a.x),jh(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}},Jd=class extends ks{constructor(e=new M,t=new M,i=new M,r=new M){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(jh(e,r.x,s.x,n.x,a.x),jh(e,r.y,s.y,n.y,a.y),jh(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}},ss=class extends ks{constructor(e=new F,t=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new F){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 F;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}},aS=class extends ks{constructor(e=new M,t=new M){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new M){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}},sa=class extends ks{constructor(e=new F,t=new F,i=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new F){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(kh(e,r.x,s.x,n.x),kh(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}},iL=class extends ks{constructor(e=new M,t=new M,i=new M){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(kh(e,r.x,s.x,n.x),kh(e,r.y,s.y,n.y),kh(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}},Iv=class extends ks{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new F){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(R1(a,o.x,l.x,h.x,d.x),R1(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 F().fromArray(r))}return this}},rL=Object.freeze({__proto__:null,ArcCurve:XI,CatmullRomCurve3:YI,CubicBezierCurve:$r,CubicBezierCurve3:Jd,EllipseCurve:np,LineCurve:ss,LineCurve3:aS,QuadraticBezierCurve:sa,QuadraticBezierCurve3:iL,SplineCurve:Iv}),oS=class extends ks{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 ss(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 rL[r.type]().fromJSON(r))}return this}},mu=class extends oS{constructor(e){super(),this.type="Path",this.currentPoint=new F,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 ss(this.currentPoint.clone(),new F(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new sa(this.currentPoint.clone(),new F(e,t),new F(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new $r(this.currentPoint.clone(),new F(e,t),new F(i,r),new F(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Iv(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 np(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}},lS=class extends qe{constructor(e=[new F(0,-.5),new F(.5,0),new F(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=hi(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,d=new M,c=new F,u=new M,p=new M,f=new M,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*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:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*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),b=Math.cos(y);for(let _=0;_<=e.length-1;_++){d.x=e[_].x*x,d.y=e[_].y,d.z=e[_].x*b,n.push(d.x,d.y,d.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let A=o[3*_+0]*x,S=o[3*_+1],w=o[3*_+0]*b;l.push(A,S,w)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,_=x+e.length,A=x+e.length+1,S=x+1;s.push(b,_,S),s.push(A,S,_)}this.setIndex(s),this.setAttribute("position",new Le(n,3)),this.setAttribute("uv",new Le(a,2)),this.setAttribute("normal",new Le(l,3))}static fromJSON(e){return new lS(e.points,e.segments,e.phiStart,e.phiLength)}},Lv=class extends qe{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=[],g=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Le(d,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(u,2));function v(){let x=new M,b=new M,_=0,A=(t-e)/i;for(let S=0;S<=s;S++){let w=[],E=S/s,C=E*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,P=D*o+a,L=Math.sin(P),R=Math.cos(P);b.x=C*L,b.y=-E*i+g,b.z=C*R,d.push(b.x,b.y,b.z),x.set(L,A,R).normalize(),c.push(x.x,x.y,x.z),u.push(D,1-E),w.push(p++)}f.push(w)}for(let S=0;S<r;S++)for(let w=0;w<s;w++){let E=f[w][S],C=f[w+1][S],T=f[w+1][S+1],D=f[w][S+1];h.push(E,C,D),h.push(C,T,D),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let b=p,_=new F,A=new M,S=0,w=x===!0?e:t,E=x===!0?1:-1;for(let T=1;T<=r;T++)d.push(0,g*E,0),c.push(0,E,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+a,P=Math.cos(D),L=Math.sin(D);A.x=w*L,A.y=g*E,A.z=w*P,d.push(A.x,A.y,A.z),c.push(0,E,0),_.x=P*.5+.5,_.y=L*.5*E+.5,u.push(_.x,_.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),S+=3}l.addGroup(m,S,x===!0?1:2),m+=S}}static fromJSON(e){return new Lv(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},hS=class extends Lv{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 hS(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ov=class extends qe{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 Le(s,3)),this.setAttribute("normal",new Le(s.slice(),3)),this.setAttribute("uv",new Le(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new M,x=new M,b=new M;for(let _=0;_<t.length;_+=3)u(t[_+0],y),u(t[_+1],x),u(t[_+2],b),o(y,x,b,v)}function o(v,y,x,b){let _=b+1,A=[];for(let S=0;S<=_;S++){A[S]=[];let w=v.clone().lerp(x,S/_),E=y.clone().lerp(x,S/_),C=_-S;for(let T=0;T<=C;T++)T===0&&S===_?A[S][T]=w:A[S][T]=w.clone().lerp(E,T/C)}for(let S=0;S<_;S++)for(let w=0;w<2*(_-S)-1;w++){let E=Math.floor(w/2);w%2===0?(c(A[S][E+1]),c(A[S+1][E]),c(A[S][E])):(c(A[S][E+1]),c(A[S+1][E+1]),c(A[S+1][E]))}}function l(v){let y=new M;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 M;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=g(v)/2/Math.PI+.5,b=m(v)/Math.PI+.5;n.push(x,1-b)}p(),d()}function d(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],b=n[v+4],_=Math.max(y,x,b),A=Math.min(y,x,b);_>.9&&A<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),b<.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 M,y=new M,x=new M,b=new M,_=new F,A=new F,S=new F;for(let w=0,E=0;w<s.length;w+=9,E+=6){v.set(s[w+0],s[w+1],s[w+2]),y.set(s[w+3],s[w+4],s[w+5]),x.set(s[w+6],s[w+7],s[w+8]),_.set(n[E+0],n[E+1]),A.set(n[E+2],n[E+3]),S.set(n[E+4],n[E+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=g(b);f(_,E+0,v,C),f(A,E+2,y,C),f(S,E+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=b/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Ov(e.vertices,e.indices,e.radius,e.details)}},cS=class extends Ov{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 cS(e.radius,e.detail)}},gu=class extends mu{constructor(e){super(e),this.uuid=Nr(),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 mu().fromJSON(r))}return this}},sL={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=dS(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=hL(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 tc(n,a,i,o,l,p,0),a}};function dS(e,t,i,r,s){let n,a;if(s===bL(e,t,i,r)>0)for(n=t;n<i;n+=r)a=z1(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=z1(n,e[n],e[n+1],a);return a&&ap(a,a.next)&&(rc(a),a=a.next),a}function Ya(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(ap(i,i.next)||Ft(i.prev,i,i.next)===0)){if(rc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function tc(e,t,i,r,s,n,a){if(!e)return;!a&&n&&fL(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?aL(e,r,s,n):nL(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),rc(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=oL(Ya(e),t,i),tc(e,t,i,r,s,n,2)):a===2&&lL(e,t,i,r,s,n):tc(Ya(e),t,i,r,s,n,1);break}}}function nL(e){let t=e.prev,i=e,r=e.next;if(Ft(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&&Yo(s,o,n,l,a,h,f.x,f.y)&&Ft(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function aL(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Ft(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,g=o>l?o>h?o:h:l>h?l:h,m=d>c?d>u?d:u:c>u?c:u,v=Vm(p,f,t,i,r),y=Vm(g,m,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Yo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Yo(o,d,l,c,h,u,b.x,b.y)&&Ft(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Yo(o,d,l,c,h,u,x.x,x.y)&&Ft(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Yo(o,d,l,c,h,u,b.x,b.y)&&Ft(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function oL(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!ap(s,n)&&uS(s,r,r.next,n)&&ic(s,n)&&ic(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),rc(r),rc(r.next),r=e=n),r=r.next}while(r!==e);return Ya(r)}function lL(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&vL(a,o)){let l=pS(a,o);a=Ya(a,a.next),l=Ya(l,l.next),tc(a,t,i,r,s,n,0),tc(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function hL(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=dS(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(gL(h));for(s.sort(cL),n=0;n<s.length;n++)i=dL(s[n],i);return i}function cL(e,t){return e.x-t.x}function dL(e,t){let i=uL(e,t);if(!i)return t;let r=pS(i,e);return Ya(r,r.next),Ya(i,i.next)}function uL(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&&Yo(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),ic(i,e)&&(c<d||c===d&&(i.x>s.x||i.x===s.x&&pL(s,i)))&&(s=i,d=c)),i=i.next;while(i!==o);return s}function pL(e,t){return Ft(e.prev,e,t.prev)<0&&Ft(t.next,e,e.next)<0}function fL(e,t,i,r){let s=e;do s.z===0&&(s.z=Vm(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,mL(s)}function mL(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 Vm(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 gL(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 Yo(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 vL(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!yL(e,t)&&(ic(e,t)&&ic(t,e)&&xL(e,t)&&(Ft(e.prev,e,t.prev)||Ft(e,t.prev,t))||ap(e,t)&&Ft(e.prev,e,e.next)>0&&Ft(t.prev,t,t.next)>0)}function Ft(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ap(e,t){return e.x===t.x&&e.y===t.y}function uS(e,t,i,r){let s=rd(Ft(e,t,i)),n=rd(Ft(e,t,r)),a=rd(Ft(i,r,e)),o=rd(Ft(i,r,t));return!!(s!==n&&a!==o||s===0&&id(e,i,t)||n===0&&id(e,r,t)||a===0&&id(i,e,r)||o===0&&id(i,t,r))}function id(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 rd(e){return e>0?1:e<0?-1:0}function yL(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&&uS(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function ic(e,t){return Ft(e.prev,e,e.next)<0?Ft(e,t,e.next)>=0&&Ft(e,e.prev,t)>=0:Ft(e,t,e.prev)<0||Ft(e,e.next,t)<0}function xL(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 pS(e,t){let i=new Hm(e.i,e.x,e.y),r=new Hm(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 z1(e,t,i,r){let s=new Hm(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 rc(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 Hm(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 bL(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 fS=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 fS.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];N1(e),U1(i,e);let n=e.length;t.forEach(N1);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,U1(i,t[o]);let a=sL.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function N1(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function U1(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var mS=class extends Ov{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 mS(e.radius,e.detail)}},Bv=class extends qe{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 M,c=new M,u=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&n==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let _=b/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),g.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],b=h[m+1][v],_=h[m+1][v+1];(m!==0||n>0)&&u.push(y,x,_),(m!==i-1||o<Math.PI)&&u.push(x,b,_)}this.setIndex(u),this.setAttribute("position",new Le(p,3)),this.setAttribute("normal",new Le(f,3)),this.setAttribute("uv",new Le(g,2))}static fromJSON(e){return new Bv(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},gS=class extends qe{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 M,c=new M,u=new M,p=new M,f=new M,g=new M,m=new M;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),g.subVectors(p,u),m.addVectors(p,u),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let b=0;b<=r;++b){let _=b/r*Math.PI*2,A=-t*Math.cos(_),S=t*Math.sin(_);d.x=u.x+(A*m.x+S*f.x),d.y=u.y+(A*m.y+S*f.y),d.z=u.z+(A*m.z+S*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(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),A=(r+1)*y+x,S=(r+1)*(y-1)+x;a.push(b,_,S),a.push(_,A,S)}this.setIndex(a),this.setAttribute("position",new Le(o,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(h,2));function v(y,x,b,_,A){let S=Math.cos(y),w=Math.sin(y),E=b/x*y,C=Math.cos(E);A.x=_*(2+C)*.5*S,A.y=_*(2+C)*w*.5,A.z=_*Math.sin(E)*.5}}static fromJSON(e){return new gS(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Dn(e,t,i){return vS(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function sd(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 vS(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function wL(e){function t(s,n){return e[s]-e[n]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function F1(e,t,i){let r=e.length,s=new e.constructor(r);for(let n=0,a=0;a!==r;++n){let o=i[n]*t;for(let l=0;l!==t;++l)s[a++]=e[o+l]}return s}function yS(e,t,i,r){let s=1,n=e[0];for(;n!==void 0&&n[r]===void 0;)n=e[s++];if(n===void 0)return;let a=n[r];if(a!==void 0)if(Array.isArray(a))do a=n[r],a!==void 0&&(t.push(n.time),i.push.apply(i,a)),n=e[s++];while(n!==void 0);else if(a.toArray!==void 0)do a=n[r],a!==void 0&&(t.push(n.time),a.toArray(i,i.length)),n=e[s++];while(n!==void 0);else do a=n[r],a!==void 0&&(t.push(n.time),i.push(a)),n=e[s++];while(n!==void 0)}var op=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];e:{t:{let n;i:{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 t}n=t.length;break i}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 t}n=i,i=0;break i}break e}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_(){}},_L=class extends op{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:Ho,endingEnd:Ho}}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 Wo:s=e,a=2*t-i;break;case hu: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 Wo:n=e,o=2*i-t;break;case hu: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,g=f*p,m=-c*g+2*c*f-c*p,v=(1+c)*g+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-u)*g+(1.5+u)*f+.5*p,x=u*g-u*f;for(let b=0;b!==a;++b)s[b]=m*n[h+b]+v*n[l+b]+y*n[o+b]+x*n[d+b];return s}},xS=class extends op{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}},SL=class extends op{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},js=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=sd(t,this.TimeBufferType),this.values=sd(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:sd(e.times,Array),values:sd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new SL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new _L(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ou:t=this.InterpolantFactoryMethodDiscrete;break;case lu:t=this.InterpolantFactoryMethodLinear;break;case qp: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 ou;case this.InterpolantFactoryMethodLinear:return lu;case this.InterpolantFactoryMethodSmooth:return qp}}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=Dn(i,s,n),this.values=Dn(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&&vS(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=Dn(this.times),t=Dn(this.values),i=this.getValueSize(),r=this.getInterpolation()===qp,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=Dn(e,0,n),this.values=Dn(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=Dn(this.times,0),t=Dn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};js.prototype.TimeBufferType=Float32Array;js.prototype.ValueBufferType=Float32Array;js.prototype.DefaultInterpolation=lu;var Rl=class extends js{};Rl.prototype.ValueTypeName="bool";Rl.prototype.ValueBufferType=Array;Rl.prototype.DefaultInterpolation=ou;Rl.prototype.InterpolantFactoryMethodLinear=void 0;Rl.prototype.InterpolantFactoryMethodSmooth=void 0;var bS=class extends js{};bS.prototype.ValueTypeName="color";var vu=class extends js{};vu.prototype.ValueTypeName="number";var AL=class extends op{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)it.slerpFlat(s,0,n,l-a,n,l,o);return s}},wc=class extends js{InterpolantFactoryMethodLinear(e){return new AL(this.times,this.values,this.getValueSize(),e)}};wc.prototype.ValueTypeName="quaternion";wc.prototype.DefaultInterpolation=lu;wc.prototype.InterpolantFactoryMethodSmooth=void 0;var zl=class extends js{};zl.prototype.ValueTypeName="string";zl.prototype.ValueBufferType=Array;zl.prototype.DefaultInterpolation=ou;zl.prototype.InterpolantFactoryMethodLinear=void 0;zl.prototype.InterpolantFactoryMethodSmooth=void 0;var yu=class extends js{};yu.prototype.ValueTypeName="vector";var Wm=class{constructor(e,t=-1,i,r=_v){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Nr(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let n=0,a=i.length;n!==a;++n)t.push(EL(i[n]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,n=i.length;s!==n;++s)t.push(js.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,n=[];for(let a=0;a<s;a++){let o=[],l=[];o.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let h=wL(o);o=F1(o,1,h),l=F1(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),n.push(new vu(".morphTargetInfluences["+t[a].name+"]",o,l).scale(1/i))}return new this(e,-1,n)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){let l=e[a],h=l.name.match(s);if(h&&h.length>1){let d=h[1],c=r[d];c||(r[d]=c=[]),c.push(l)}}let n=[];for(let a in r)n.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return n}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,d,c,u,p){if(c.length!==0){let f=[],g=[];yS(c,f,g,u),f.length!==0&&p.push(new h(d,f,g))}},r=[],s=e.name||"default",n=e.fps||30,a=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let c={},u;for(u=0;u<d.length;u++)if(d[u].morphTargets)for(let p=0;p<d[u].morphTargets.length;p++)c[d[u].morphTargets[p]]=-1;for(let p in c){let f=[],g=[];for(let m=0;m!==d[u].morphTargets.length;++m){let v=d[u];f.push(v.time),g.push(v.morphTarget===p?1:0)}r.push(new vu(".morphTargetInfluence["+p+"]",f,g))}o=c.length*n}else{let c=".bones["+t[h].name+"]";i(yu,c+".position",d,"pos",r),i(wc,c+".quaternion",d,"rot",r),i(yu,c+".scale",d,"scl",r)}}return r.length===0?null:new this(s,o,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function ML(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return vu;case"vector":case"vector2":case"vector3":case"vector4":return yu;case"color":return bS;case"quaternion":return wc;case"bool":case"boolean":return Rl;case"string":return zl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function EL(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ML(e.type);if(e.times===void 0){let i=[],r=[];yS(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var k1={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={}}},wS=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}}},CL=new wS,Rv=class{constructor(e){this.manager=e!==void 0?e:CL,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}},Zs={},TL=class extends Error{constructor(e,t){super(e),this.response=t}},qm=class extends Rv{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=k1.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Zs[e]!==void 0){Zs[e].push({onLoad:t,onProgress:i,onError:r});return}Zs[e]=[],Zs[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=Zs[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,g=new ReadableStream({start(m){v();function v(){d.read().then(({done:y,value:x})=>{if(y)m.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let _=0,A=h.length;_<A;_++){let S=h[_];S.onProgress&&S.onProgress(b)}m.enqueue(x),v()}})}}});return new Response(g)}else throw new TL(`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=>{k1.add(e,l);let h=Zs[e];delete Zs[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=Zs[e];if(h===void 0)throw this.manager.itemError(e),l;delete Zs[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}},_c=class extends Mt{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}},PL=class extends _c{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Sf=new fe,j1=new M,G1=new M,zv=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ev,this._frameExtents=new F(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;j1.setFromMatrixPosition(e.matrixWorld),t.position.copy(j1),G1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(G1),t.updateMatrixWorld(),Sf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sf),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Sf)}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}},DL=class extends zv{constructor(){super(new Oi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ec*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}},IL=class extends _c{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(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new DL}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}},V1=new fe,ah=new M,Af=new M,LL=class extends zv{constructor(){super(new Oi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(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 M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(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()),ah.setFromMatrixPosition(e.matrixWorld),i.position.copy(ah),Af.copy(i.position),Af.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Af),i.updateMatrixWorld(),r.makeTranslation(-ah.x,-ah.y,-ah.z),V1.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(V1)}},OL=class extends _c{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 LL}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}},BL=class extends zv{constructor(){super(new Cv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},RL=class extends _c{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mt.DEFAULT_UP),this.updateMatrix(),this.target=new Mt,this.shadow=new BL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},zL=class extends qe{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}},_S=class extends Rv{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new qm(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),g=Rc(p.type,f),m=new VI(g,p.stride);return m.uuid=p.uuid,t[u]=m,m}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 zL:new qe,a=e.data.index;if(a!==void 0){let c=Rc(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 Gm(f,u.itemSize,u.offset,u.normalized)}else{let f=Rc(u.type,u.array),g=u.isInstancedBufferAttribute?WI:Ye;p=new g(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,g=u.length;f<g;f++){let m=u[f],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new Gm(y,m.itemSize,m.offset,m.normalized)}else{let y=Rc(m.type,m.array);v=new Ye(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.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 M;d.center!==void 0&&c.fromArray(d.center),n.boundingSphere=new _r(c,d.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},NL=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=H1(),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=H1();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function H1(){return(typeof performance>"u"?Date:performance).now()}var UL=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,n;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,n=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,n=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,n=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=n,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,n=this.cumulativeWeight;if(n===0){for(let a=0;a!==r;++a)i[s+a]=i[a];n=t}else{n+=t;let a=t/n;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=n}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,n=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}n>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,n=r;s!==n;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let n=0;n!==s;++n)e[t+n]=e[i+n]}_slerp(e,t,i,r){it.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let n=this._workIndex*s;it.multiplyQuaternionsFlat(e,n,e,t,e,i),it.slerpFlat(e,t,e,t,e,n,r)}_lerp(e,t,i,r,s){let n=1-r;for(let a=0;a!==s;++a){let o=t+a;e[o]=e[o]*n+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let n=0;n!==s;++n){let a=t+n;e[a]=e[a]+e[i+n]*r}}},Nv="\\[\\]\\.:\\/",FL=new RegExp("["+Nv+"]","g"),Uv="[^"+Nv+"]",kL="[^"+Nv.replace("\\.","")+"]",jL=/((?:WC+[\/:])*)/.source.replace("WC",Uv),GL=/(WCOD+)?/.source.replace("WCOD",kL),VL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Uv),HL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Uv),WL=new RegExp("^"+jL+GL+VL+HL+"$"),qL=["material","materials","bones","map"],XL=class{constructor(e,t,i){let r=i||Ct.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()}},Ct=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Ct.parseTrackName(t),this.node=Ct.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 Ct.Composite(e,t,i):new Ct(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(FL,"")}static parseTrackName(e){let t=WL.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);qL.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=Ct.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}};Ct.Composite=XL;Ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ct.prototype.GetterByBindingType=[Ct.prototype._getValue_direct,Ct.prototype._getValue_array,Ct.prototype._getValue_arrayElement,Ct.prototype._getValue_toArray];Ct.prototype.SetterByBindingTypeAndVersioning=[[Ct.prototype._setValue_direct,Ct.prototype._setValue_direct_setNeedsUpdate,Ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_array,Ct.prototype._setValue_array_setNeedsUpdate,Ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_arrayElement,Ct.prototype._setValue_arrayElement_setNeedsUpdate,Ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_fromArray,Ct.prototype._setValue_fromArray_setNeedsUpdate,Ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var YL=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,n=s.length,a=new Array(n),o={endingStart:Ho,endingEnd:Ho};for(let l=0;l!==n;++l){let h=s[l].createInterpolant(null);a[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=j_,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,n=s/r,a=r/s;e.warp(1,n,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,n=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let o=a.parameterPositions,l=a.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/n,l[1]=t/n,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let n=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case TC:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(n),l[h].accumulateAdditive(a);break;case _v:default:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(n),l[h].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,n=i===wv;if(e===0)return s===-1?r:n&&(s&1)===1?t-r:r;if(i===k_){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,n)}else this._setEndings(!1,!1,n);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(n&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Wo,r.endingEnd=Wo):(e?r.endingStart=this.zeroSlopeAtStart?Wo:Ho:r.endingStart=hu,t?r.endingEnd=this.zeroSlopeAtEnd?Wo:Ho:r.endingEnd=hu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,n=this._weightInterpolant;n===null&&(n=r._lendControlInterpolant(),this._weightInterpolant=n);let a=n.parameterPositions,o=n.sampleValues;return a[0]=s,o[0]=t,a[1]=s+e,o[1]=i,this}},QL=new Float32Array(1),ZL=class extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,n=e._propertyBindings,a=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let d=0;d!==s;++d){let c=r[d],u=c.name,p=h[u];if(p!==void 0)++p.referenceCount,n[d]=p;else{if(p=n[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[d].binding.parsedPath;p=new UL(Ct.create(i,u,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),n[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,n=s[t];if(n===void 0)n={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=n;else{let a=n.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),n.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,n=this._actionsByClip,a=n[s],o=a.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let d=a.actionByRoot,c=(e._localRoot||this._root).uuid;delete d[c],o.length===0&&delete n[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,n=r[t];n===void 0&&(n={},r[t]=n),n[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,n=this._bindingsByRootAndName,a=n[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete a[s],Object.keys(a).length===0&&delete n[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new xS(new Float32Array(2),new Float32Array(2),1,QL),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,n=typeof e=="string"?Wm.findByName(r,e):e,a=n!==null?n.uuid:e,o=this._actionsByClip[a],l=null;if(i===void 0&&(n!==null?i=n.blendMode:i=_v),o!==void 0){let d=o.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=o.knownActions[0],n===null&&(n=l._clip)}if(n===null)return null;let h=new YL(this,n,t,i);return this._bindAction(h,l),this._addInactiveAction(h,a,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Wm.findByName(i,e):e,n=s?s.uuid:e,a=this._actionsByClip[n];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),n=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,n);let a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(n);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let n=s.knownActions;for(let a=0,o=n.length;a!==o;++a){let l=n[a];this._deactivateAction(l);let h=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=h,t[h]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let n in i){let a=i[n].actionByRoot,o=a[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let n in s){let a=s[n];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},pe=class{constructor(e){this.value=e}clone(){return new pe(this.value.clone===void 0?this.value:this.value.clone())}},SS=class{constructor(e,t,i=0,r=1/0){this.ray=new Il(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Av,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 Xm(e,this,i,t),i.sort(W1),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Xm(e[r],this,i,t);return i.sort(W1),i}};function W1(e,t){return e.distance-t.distance}function Xm(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++)Xm(s[n],t,i,!0)}}var q1=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(hi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},X1=new F,KL=class{constructor(e=new F(1/0,1/0),t=new F(-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=X1.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 X1.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)}},Y1=new M,nd=new M,Ur=class{constructor(e=new M,t=new M){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){Y1.subVectors(e,this.start),nd.subVectors(this.end,this.start);let i=nd.dot(nd),r=nd.dot(Y1)/i;return t&&(r=hi(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)}},Q1=new M,JL=class extends Mt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new qe,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 Le(r,3));let s=new oa({fog:!1,toneMapped:!1});this.cone=new bc(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),Q1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Q1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},$L=class extends ir{constructor(e,t,i){let r=new Bv(t,4,2),s=new xc({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)}},Z1=new M,ad=new M,K1=new M,eO=class extends Mt{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 qe;r.setAttribute("position",new Le([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new oa({fog:!1,toneMapped:!1});this.lightPlane=new fu(r,s),this.add(this.lightPlane),r=new qe,r.setAttribute("position",new Le([0,0,0,0,0,1],3)),this.targetLine=new fu(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),Z1.setFromMatrixPosition(this.light.matrixWorld),ad.setFromMatrixPosition(this.light.target.matrixWorld),K1.subVectors(ad,Z1),this.lightPlane.lookAt(ad),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(ad),this.targetLine.scale.z=K1.length()}},od=new M,kt=new Ol,xu=class extends bc{constructor(e){let t=new qe,i=new oa({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 Le(r,3)),t.setAttribute("color",new Le(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;kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Wt("c",t,e,kt,0,0,-1),Wt("t",t,e,kt,0,0,1),Wt("n1",t,e,kt,-i,-r,-1),Wt("n2",t,e,kt,i,-r,-1),Wt("n3",t,e,kt,-i,r,-1),Wt("n4",t,e,kt,i,r,-1),Wt("f1",t,e,kt,-i,-r,1),Wt("f2",t,e,kt,i,-r,1),Wt("f3",t,e,kt,-i,r,1),Wt("f4",t,e,kt,i,r,1),Wt("u1",t,e,kt,i*.7,r*1.1,-1),Wt("u2",t,e,kt,-i*.7,r*1.1,-1),Wt("u3",t,e,kt,0,r*2,-1),Wt("cf1",t,e,kt,-i,0,1),Wt("cf2",t,e,kt,i,0,1),Wt("cf3",t,e,kt,0,-r,1),Wt("cf4",t,e,kt,0,r,1),Wt("cn1",t,e,kt,-i,0,-1),Wt("cn2",t,e,kt,i,0,-1),Wt("cn3",t,e,kt,0,-r,-1),Wt("cn4",t,e,kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Wt(e,t,i,r,s,n,a){od.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],od.x,od.y,od.z)}}var bu=class extends bc{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 qe;s.setIndex(new Ye(i,1)),s.setAttribute("position",new Le(r,3)),super(s,new oa({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()}},tO=class extends bc{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 qe;r.setAttribute("position",new Le(t,3)),r.setAttribute("color",new Le(i,3));let s=new oa({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:Dl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dl);var oh=".",Fv=Symbol("target"),AS=Symbol("unsubscribe");function Ym(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function iO(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Cs=Array.isArray;function kv(e){return typeof e=="symbol"}var rO={after:(e,t)=>Cs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Cs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=oh),kv(t)?e+t.toString():e+t):e,initial:e=>{if(Cs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(oh);return t===-1?"":e.slice(0,t)},last:e=>{if(Cs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(oh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Cs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(oh);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(oh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Lr=rO;function sO(e){return typeof e=="object"&&typeof e.next=="function"}function nO(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[Fv].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 J1(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&kv(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var aO=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,Lr.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 Qm(e){return toString.call(e)==="[object Object]"}function ld(){return!0}function _o(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var MS=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),oO=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),ES={push:ld,pop:ld,shift:ld,unshift:ld,copyWithin:_o,reverse:_o,sort:_o,splice:_o,flat:_o,fill:_o},lO=new Set([...MS,...oO,...Object.keys(ES)]);function hd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var CS=["keys","values","entries"],TS=new Set(["has","toString"]),PS={add:hd,clear:hd,delete:hd,forEach:hd},hO=new Set([...TS,...Object.keys(PS),...CS]);function cd(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 cO=new Set([...TS,"get"]),DS={set:cd,clear:cd,delete:cd,forEach:cd},dO=new Set([...cO,...Object.keys(DS),...CS]),na=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 MS.has(e)}_shallowClone(e){let t=e;if(Qm(e))t={...e};else if(Cs(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?(Cs(r)?this._onIsChanged=ES[t]:r instanceof Set?this._onIsChanged=PS[t]:r instanceof Map&&(this._onIsChanged=DS[t]),r):i}update(e,t,i){let r=Lr.after(e,this._path);if(t!=="length"){let s=this.clone;Lr.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],Lr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},$1=class extends na{static isHandledMethod(e){return lO.has(e)}},uO=class extends na{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},ex=class extends na{static isHandledMethod(e){return hO.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)}},tx=class extends na{static isHandledMethod(e){return dO.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)}},pO=class extends na{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)}},fO=class extends na{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)}},ko=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Qm(e)||Cs(e)||Ym(e)}static isHandledMethod(e,t){return Qm(e)?na.isHandledMethod(t):Cs(e)?$1.isHandledMethod(t):e instanceof Set?ex.isHandledMethod(t):e instanceof Map?tx.isHandledMethod(t):Ym(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=na;Cs(e)?r=$1:e instanceof Date?r=uO:e instanceof Set?r=ex:e instanceof Map?r=tx:e instanceof WeakSet?r=pO:e instanceof WeakMap&&(r=fO),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=ko.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}},mO={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},jv=(e,t,i={})=>{i={...mO,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new aO(s),h=typeof i.onValidate=="function",d=new ko(h),c=(y,x,b,_,A)=>!h||d.isCloning||i.onValidate(Lr.concat(l.getPath(y),x),b,_,A)===!0,u=(y,x,b,_)=>{!J1(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,b,_)},p=(y,x,b,_,A)=>{d.isCloning?d.update(y,x,_):t(Lr.concat(y,x),b,_,A)},f=y=>y&&(y[r]||y),g=(y,x,b,_)=>iO(y)||b==="constructor"||n&&!ko.isHandledMethod(x,b)||J1(l,i,b)||l.isGetInvariant(x,b)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,Lr.concat(_,b),m,r)),m={get(y,x,b){if(kv(x)){if(x===r||x===Fv)return y;if(x===AS&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=Ym(y)?Reflect.get(y,x):Reflect.get(y,x,b);return g(_,y,x)},set(y,x,b,_){b=f(b);let A=y[r]||y,S=A[x];if(s(S,b)&&x in y)return!0;let w=c(y,x,b,S);return w&&l.setProperty(A,x,b,_,S)?(u(y,x,y[x],S),!0):!w},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let _=y[x];c(y,x,b.value,_)&&l.defineProperty(y,x,b,_)&&u(y,x,b.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),_=c(y,x,void 0,b);return _&&l.deleteProperty(y,x,b)?(u(y,x,void 0,b),!0):!_},apply(y,x,b){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,b);if((o===!1||o!==!0&&!o.includes(y.name))&&ko.isHandledType(_)){let A=Lr.initial(l.getPath(y)),S=ko.isHandledMethod(_,y.name);d.start(_,A,b);let w=Reflect.apply(y,d.preferredThisArg(y,x,_),S?b.map(T=>f(T)):b),E=d.isChanged(_,s),C=d.stop();if(ko.isHandledType(w)&&S&&(x instanceof Map&&y.name==="get"&&(A=Lr.concat(A,b[0])),w=l.getProxy(w,A,m)),E){let T={name:y.name,args:b,result:w},D=d.isCloning?Lr.initial(A):A,P=d.isCloning?Lr.last(A):"";c(Lr.get(e,D),P,_,C,T)?p(D,P,_,C,T):d.undo(_)}return(x instanceof Map||x instanceof Set)&&sO(w)?nO(w,y,x,A,g):w}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};jv.target=e=>e&&e[Fv]||e;jv.unsubscribe=e=>e[AS]||e;var ix=jv,gO=typeof global=="object"&&global&&global.Object===Object&&global,IS=gO,vO=typeof self=="object"&&self&&self.Object===Object&&self,yO=IS||vO||Function("return this")(),os=yO,xO=os.Symbol,kr=xO,LS=Object.prototype,bO=LS.hasOwnProperty,wO=LS.toString,lh=kr?kr.toStringTag:void 0;function _O(e){var t=bO.call(e,lh),i=e[lh];try{e[lh]=void 0;var r=!0}catch{}var s=wO.call(e);return r&&(t?e[lh]=i:delete e[lh]),s}var SO=_O,AO=Object.prototype,MO=AO.toString;function EO(e){return MO.call(e)}var CO=EO,TO="[object Null]",PO="[object Undefined]",rx=kr?kr.toStringTag:void 0;function DO(e){return e==null?e===void 0?PO:TO:rx&&rx in Object(e)?SO(e):CO(e)}var Ja=DO;function IO(e){return e!=null&&typeof e=="object"}var bn=IO,LO="[object Symbol]";function OO(e){return typeof e=="symbol"||bn(e)&&Ja(e)==LO}var lp=OO;function BO(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 OS=BO,RO=Array.isArray,zs=RO,zO=1/0,sx=kr?kr.prototype:void 0,nx=sx?sx.toString:void 0;function BS(e){if(typeof e=="string")return e;if(zs(e))return OS(e,BS)+"";if(lp(e))return nx?nx.call(e):"";var t=e+"";return t=="0"&&1/e==-zO?"-0":t}var NO=BS,UO=/\s/;function FO(e){for(var t=e.length;t--&&UO.test(e.charAt(t)););return t}var kO=FO,jO=/^\s+/;function GO(e){return e&&e.slice(0,kO(e)+1).replace(jO,"")}var VO=GO;function HO(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var as=HO,ax=0/0,WO=/^[-+]0x[0-9a-f]+$/i,qO=/^0b[01]+$/i,XO=/^0o[0-7]+$/i,YO=parseInt;function QO(e){if(typeof e=="number")return e;if(lp(e))return ax;if(as(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=as(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=VO(e);var i=qO.test(e);return i||XO.test(e)?YO(e.slice(2),i?2:8):WO.test(e)?ax:+e}var ox=QO;function ZO(e){return e}var KO=ZO,JO="[object AsyncFunction]",$O="[object Function]",e4="[object GeneratorFunction]",t4="[object Proxy]";function i4(e){if(!as(e))return!1;var t=Ja(e);return t==$O||t==e4||t==JO||t==t4}var RS=i4,r4=os["__core-js_shared__"],Mf=r4,lx=function(){var e=/[^.]+$/.exec(Mf&&Mf.keys&&Mf.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function s4(e){return!!lx&&lx in e}var n4=s4,a4=Function.prototype,o4=a4.toString;function l4(e){if(e!=null){try{return o4.call(e)}catch{}try{return e+""}catch{}}return""}var $a=l4,h4=/[\\^$.*+?()[\]{}|]/g,c4=/^\[object .+?Constructor\]$/,d4=Function.prototype,u4=Object.prototype,p4=d4.toString,f4=u4.hasOwnProperty,m4=RegExp("^"+p4.call(f4).replace(h4,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g4(e){if(!as(e)||n4(e))return!1;var t=RS(e)?m4:c4;return t.test($a(e))}var v4=g4;function y4(e,t){return e?.[t]}var x4=y4;function b4(e,t){var i=x4(e,t);return v4(i)?i:void 0}var eo=b4,w4=eo(os,"WeakMap"),Zm=w4,hx=Object.create,_4=function(){function e(){}return function(t){if(!as(t))return{};if(hx)return hx(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),S4=_4;function A4(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 M4=A4;function E4(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var C4=E4,T4=800,P4=16,D4=Date.now;function I4(e){var t=0,i=0;return function(){var r=D4(),s=P4-(r-i);if(i=r,s>0){if(++t>=T4)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var L4=I4;function O4(e){return function(){return e}}var B4=O4,R4=function(){try{var e=eo(Object,"defineProperty");return e({},"",{}),e}catch{}}(),wu=R4,z4=wu?function(e,t){return wu(e,"toString",{configurable:!0,enumerable:!1,value:B4(t),writable:!0})}:KO,N4=z4,U4=L4(N4),F4=U4;function k4(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var j4=k4,G4=9007199254740991,V4=/^(?:0|[1-9]\d*)$/;function H4(e,t){var i=typeof e;return t=t??G4,!!t&&(i=="number"||i!="symbol"&&V4.test(e))&&e>-1&&e%1==0&&e<t}var Gv=H4;function W4(e,t,i){t=="__proto__"&&wu?wu(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var zS=W4;function q4(e,t){return e===t||e!==e&&t!==t}var Vv=q4,X4=Object.prototype,Y4=X4.hasOwnProperty;function Q4(e,t,i){var r=e[t];(!(Y4.call(e,t)&&Vv(r,i))||i===void 0&&!(t in e))&&zS(e,t,i)}var Hv=Q4;function Z4(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?zS(i,o,l):Hv(i,o,l)}return i}var Sc=Z4,cx=Math.max;function K4(e,t,i){return t=cx(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=cx(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),M4(e,this,o)}}var J4=K4,$4=9007199254740991;function eB(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=$4}var Wv=eB;function tB(e){return e!=null&&Wv(e.length)&&!RS(e)}var NS=tB,iB=Object.prototype;function rB(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||iB;return e===i}var qv=rB;function sB(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var nB=sB,aB="[object Arguments]";function oB(e){return bn(e)&&Ja(e)==aB}var dx=oB,US=Object.prototype,lB=US.hasOwnProperty,hB=US.propertyIsEnumerable,cB=dx(function(){return arguments}())?dx:function(e){return bn(e)&&lB.call(e,"callee")&&!hB.call(e,"callee")},Xv=cB;function dB(){return!1}var uB=dB,FS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ux=FS&&typeof module=="object"&&module&&!module.nodeType&&module,pB=ux&&ux.exports===FS,px=pB?os.Buffer:void 0,fB=px?px.isBuffer:void 0,mB=fB||uB,_u=mB,gB="[object Arguments]",vB="[object Array]",yB="[object Boolean]",xB="[object Date]",bB="[object Error]",wB="[object Function]",_B="[object Map]",SB="[object Number]",AB="[object Object]",MB="[object RegExp]",EB="[object Set]",CB="[object String]",TB="[object WeakMap]",PB="[object ArrayBuffer]",DB="[object DataView]",IB="[object Float32Array]",LB="[object Float64Array]",OB="[object Int8Array]",BB="[object Int16Array]",RB="[object Int32Array]",zB="[object Uint8Array]",NB="[object Uint8ClampedArray]",UB="[object Uint16Array]",FB="[object Uint32Array]",zt={};zt[IB]=zt[LB]=zt[OB]=zt[BB]=zt[RB]=zt[zB]=zt[NB]=zt[UB]=zt[FB]=!0;zt[gB]=zt[vB]=zt[PB]=zt[yB]=zt[DB]=zt[xB]=zt[bB]=zt[wB]=zt[_B]=zt[SB]=zt[AB]=zt[MB]=zt[EB]=zt[CB]=zt[TB]=!1;function kB(e){return bn(e)&&Wv(e.length)&&!!zt[Ja(e)]}var jB=kB;function GB(e){return function(t){return e(t)}}var Yv=GB,kS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gh=kS&&typeof module=="object"&&module&&!module.nodeType&&module,VB=Gh&&Gh.exports===kS,Ef=VB&&IS.process,HB=function(){try{var e=Gh&&Gh.require&&Gh.require("util").types;return e||Ef&&Ef.binding&&Ef.binding("util")}catch{}}(),vl=HB,fx=vl&&vl.isTypedArray,WB=fx?Yv(fx):jB,jS=WB,qB=Object.prototype,XB=qB.hasOwnProperty;function YB(e,t){var i=zs(e),r=!i&&Xv(e),s=!i&&!r&&_u(e),n=!i&&!r&&!s&&jS(e),a=i||r||s||n,o=a?nB(e.length,String):[],l=o.length;for(var h in e)(t||XB.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Gv(h,l)))&&o.push(h);return o}var GS=YB;function QB(e,t){return function(i){return e(t(i))}}var VS=QB,ZB=VS(Object.keys,Object),KB=ZB,JB=Object.prototype,$B=JB.hasOwnProperty;function eR(e){if(!qv(e))return KB(e);var t=[];for(var i in Object(e))$B.call(e,i)&&i!="constructor"&&t.push(i);return t}var tR=eR;function iR(e){return NS(e)?GS(e):tR(e)}var Qv=iR;function rR(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var sR=rR,nR=Object.prototype,aR=nR.hasOwnProperty;function oR(e){if(!as(e))return sR(e);var t=qv(e),i=[];for(var r in e)r=="constructor"&&(t||!aR.call(e,r))||i.push(r);return i}var lR=oR;function hR(e){return NS(e)?GS(e,!0):lR(e)}var Zv=hR,cR=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dR=/^\w*$/;function uR(e,t){if(zs(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||lp(e)?!0:dR.test(e)||!cR.test(e)||t!=null&&e in Object(t)}var pR=uR,fR=eo(Object,"create"),sc=fR;function mR(){this.__data__=sc?sc(null):{},this.size=0}var gR=mR;function vR(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var yR=vR,xR="__lodash_hash_undefined__",bR=Object.prototype,wR=bR.hasOwnProperty;function _R(e){var t=this.__data__;if(sc){var i=t[e];return i===xR?void 0:i}return wR.call(t,e)?t[e]:void 0}var SR=_R,AR=Object.prototype,MR=AR.hasOwnProperty;function ER(e){var t=this.__data__;return sc?t[e]!==void 0:MR.call(t,e)}var CR=ER,TR="__lodash_hash_undefined__";function PR(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=sc&&t===void 0?TR:t,this}var DR=PR;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=gR;Nl.prototype.delete=yR;Nl.prototype.get=SR;Nl.prototype.has=CR;Nl.prototype.set=DR;var mx=Nl;function IR(){this.__data__=[],this.size=0}var LR=IR;function OR(e,t){for(var i=e.length;i--;)if(Vv(e[i][0],t))return i;return-1}var hp=OR,BR=Array.prototype,RR=BR.splice;function zR(e){var t=this.__data__,i=hp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():RR.call(t,i,1),--this.size,!0}var NR=zR;function UR(e){var t=this.__data__,i=hp(t,e);return i<0?void 0:t[i][1]}var FR=UR;function kR(e){return hp(this.__data__,e)>-1}var jR=kR;function GR(e,t){var i=this.__data__,r=hp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var VR=GR;function Ul(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])}}Ul.prototype.clear=LR;Ul.prototype.delete=NR;Ul.prototype.get=FR;Ul.prototype.has=jR;Ul.prototype.set=VR;var cp=Ul,HR=eo(os,"Map"),nc=HR;function WR(){this.size=0,this.__data__={hash:new mx,map:new(nc||cp),string:new mx}}var qR=WR;function XR(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var YR=XR;function QR(e,t){var i=e.__data__;return YR(t)?i[typeof t=="string"?"string":"hash"]:i.map}var dp=QR;function ZR(e){var t=dp(this,e).delete(e);return this.size-=t?1:0,t}var KR=ZR;function JR(e){return dp(this,e).get(e)}var $R=JR;function ez(e){return dp(this,e).has(e)}var tz=ez;function iz(e,t){var i=dp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var rz=iz;function Fl(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])}}Fl.prototype.clear=qR;Fl.prototype.delete=KR;Fl.prototype.get=$R;Fl.prototype.has=tz;Fl.prototype.set=rz;var up=Fl,sz="Expected a function";function Kv(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(sz);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(Kv.Cache||up),i}Kv.Cache=up;var nz=Kv,az=500;function oz(e){var t=nz(e,function(r){return i.size===az&&i.clear(),r}),i=t.cache;return t}var lz=oz,hz=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cz=/\\(\\)?/g,dz=lz(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(hz,function(i,r,s,n){t.push(s?n.replace(cz,"$1"):r||i)}),t}),uz=dz;function pz(e){return e==null?"":NO(e)}var fz=pz;function mz(e,t){return zs(e)?e:pR(e,t)?[e]:uz(fz(e))}var kl=mz,gz=1/0;function vz(e){if(typeof e=="string"||lp(e))return e;var t=e+"";return t=="0"&&1/e==-gz?"-0":t}var pp=vz;function yz(e,t){t=kl(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[pp(t[i++])];return i&&i==r?e:void 0}var HS=yz;function xz(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Jv=xz,gx=kr?kr.isConcatSpreadable:void 0;function bz(e){return zs(e)||Xv(e)||!!(gx&&e&&e[gx])}var wz=bz;function WS(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=wz),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?WS(o,t-1,i,r,s):Jv(s,o):r||(s[s.length]=o)}return s}var _z=WS;function Sz(e){var t=e==null?0:e.length;return t?_z(e,1):[]}var Az=Sz;function Mz(e){return F4(J4(e,void 0,Az),e+"")}var qS=Mz,Ez=VS(Object.getPrototypeOf,Object),$v=Ez,Cz="[object Object]",Tz=Function.prototype,Pz=Object.prototype,XS=Tz.toString,Dz=Pz.hasOwnProperty,Iz=XS.call(Object);function Lz(e){if(!bn(e)||Ja(e)!=Cz)return!1;var t=$v(e);if(t===null)return!0;var i=Dz.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&XS.call(i)==Iz}var Oz=Lz;function Bz(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 Rz=Bz;function zz(){this.__data__=new cp,this.size=0}var Nz=zz;function Uz(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var Fz=Uz;function kz(e){return this.__data__.get(e)}var jz=kz;function Gz(e){return this.__data__.has(e)}var Vz=Gz,Hz=200;function Wz(e,t){var i=this.__data__;if(i instanceof cp){var r=i.__data__;if(!nc||r.length<Hz-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new up(r)}return i.set(e,t),this.size=i.size,this}var qz=Wz;function jl(e){var t=this.__data__=new cp(e);this.size=t.size}jl.prototype.clear=Nz;jl.prototype.delete=Fz;jl.prototype.get=jz;jl.prototype.has=Vz;jl.prototype.set=qz;var $d=jl;function Xz(e,t){return e&&Sc(t,Qv(t),e)}var Yz=Xz;function Qz(e,t){return e&&Sc(t,Zv(t),e)}var Zz=Qz,YS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vx=YS&&typeof module=="object"&&module&&!module.nodeType&&module,Kz=vx&&vx.exports===YS,yx=Kz?os.Buffer:void 0,xx=yx?yx.allocUnsafe:void 0;function Jz(e,t){if(t)return e.slice();var i=e.length,r=xx?xx(i):new e.constructor(i);return e.copy(r),r}var $z=Jz;function e5(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 t5=e5;function i5(){return[]}var QS=i5,r5=Object.prototype,s5=r5.propertyIsEnumerable,bx=Object.getOwnPropertySymbols,n5=bx?function(e){return e==null?[]:(e=Object(e),t5(bx(e),function(t){return s5.call(e,t)}))}:QS,e0=n5;function a5(e,t){return Sc(e,e0(e),t)}var o5=a5,l5=Object.getOwnPropertySymbols,h5=l5?function(e){for(var t=[];e;)Jv(t,e0(e)),e=$v(e);return t}:QS,ZS=h5;function c5(e,t){return Sc(e,ZS(e),t)}var d5=c5;function u5(e,t,i){var r=t(e);return zs(e)?r:Jv(r,i(e))}var KS=u5;function p5(e){return KS(e,Qv,e0)}var Km=p5;function f5(e){return KS(e,Zv,ZS)}var JS=f5,m5=eo(os,"DataView"),Jm=m5,g5=eo(os,"Promise"),$m=g5,v5=eo(os,"Set"),eg=v5,wx="[object Map]",y5="[object Object]",_x="[object Promise]",Sx="[object Set]",Ax="[object WeakMap]",Mx="[object DataView]",x5=$a(Jm),b5=$a(nc),w5=$a($m),_5=$a(eg),S5=$a(Zm),Ma=Ja;(Jm&&Ma(new Jm(new ArrayBuffer(1)))!=Mx||nc&&Ma(new nc)!=wx||$m&&Ma($m.resolve())!=_x||eg&&Ma(new eg)!=Sx||Zm&&Ma(new Zm)!=Ax)&&(Ma=function(e){var t=Ja(e),i=t==y5?e.constructor:void 0,r=i?$a(i):"";if(r)switch(r){case x5:return Mx;case b5:return wx;case w5:return _x;case _5:return Sx;case S5:return Ax}return t});var ac=Ma,A5=Object.prototype,M5=A5.hasOwnProperty;function E5(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&M5.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var C5=E5,T5=os.Uint8Array,Su=T5;function P5(e){var t=new e.constructor(e.byteLength);return new Su(t).set(new Su(e)),t}var t0=P5;function D5(e,t){var i=t?t0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var I5=D5,L5=/\w*$/;function O5(e){var t=new e.constructor(e.source,L5.exec(e));return t.lastIndex=e.lastIndex,t}var B5=O5,Ex=kr?kr.prototype:void 0,Cx=Ex?Ex.valueOf:void 0;function R5(e){return Cx?Object(Cx.call(e)):{}}var z5=R5;function N5(e,t){var i=t?t0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var U5=N5,F5="[object Boolean]",k5="[object Date]",j5="[object Map]",G5="[object Number]",V5="[object RegExp]",H5="[object Set]",W5="[object String]",q5="[object Symbol]",X5="[object ArrayBuffer]",Y5="[object DataView]",Q5="[object Float32Array]",Z5="[object Float64Array]",K5="[object Int8Array]",J5="[object Int16Array]",$5="[object Int32Array]",eN="[object Uint8Array]",tN="[object Uint8ClampedArray]",iN="[object Uint16Array]",rN="[object Uint32Array]";function sN(e,t,i){var r=e.constructor;switch(t){case X5:return t0(e);case F5:case k5:return new r(+e);case Y5:return I5(e,i);case Q5:case Z5:case K5:case J5:case $5:case eN:case tN:case iN:case rN:return U5(e,i);case j5:return new r;case G5:case W5:return new r(e);case V5:return B5(e);case H5:return new r;case q5:return z5(e)}}var nN=sN;function aN(e){return typeof e.constructor=="function"&&!qv(e)?S4($v(e)):{}}var oN=aN,lN="[object Map]";function hN(e){return bn(e)&&ac(e)==lN}var cN=hN,Tx=vl&&vl.isMap,dN=Tx?Yv(Tx):cN,uN=dN,pN="[object Set]";function fN(e){return bn(e)&&ac(e)==pN}var mN=fN,Px=vl&&vl.isSet,gN=Px?Yv(Px):mN,vN=gN,yN=1,xN=2,bN=4,$S="[object Arguments]",wN="[object Array]",_N="[object Boolean]",SN="[object Date]",AN="[object Error]",eA="[object Function]",MN="[object GeneratorFunction]",EN="[object Map]",CN="[object Number]",tA="[object Object]",TN="[object RegExp]",PN="[object Set]",DN="[object String]",IN="[object Symbol]",LN="[object WeakMap]",ON="[object ArrayBuffer]",BN="[object DataView]",RN="[object Float32Array]",zN="[object Float64Array]",NN="[object Int8Array]",UN="[object Int16Array]",FN="[object Int32Array]",kN="[object Uint8Array]",jN="[object Uint8ClampedArray]",GN="[object Uint16Array]",VN="[object Uint32Array]",Bt={};Bt[$S]=Bt[wN]=Bt[ON]=Bt[BN]=Bt[_N]=Bt[SN]=Bt[RN]=Bt[zN]=Bt[NN]=Bt[UN]=Bt[FN]=Bt[EN]=Bt[CN]=Bt[tA]=Bt[TN]=Bt[PN]=Bt[DN]=Bt[IN]=Bt[kN]=Bt[jN]=Bt[GN]=Bt[VN]=!0;Bt[AN]=Bt[eA]=Bt[LN]=!1;function eu(e,t,i,r,s,n){var a,o=t&yN,l=t&xN,h=t&bN;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!as(e))return e;var d=zs(e);if(d){if(a=C5(e),!o)return C4(e,a)}else{var c=ac(e),u=c==eA||c==MN;if(_u(e))return $z(e,o);if(c==tA||c==$S||u&&!s){if(a=l||u?{}:oN(e),!o)return l?d5(e,Zz(a,e)):o5(e,Yz(a,e))}else{if(!Bt[c])return s?e:{};a=nN(e,c,o)}}n||(n=new $d);var p=n.get(e);if(p)return p;n.set(e,a),vN(e)?e.forEach(function(m){a.add(eu(m,t,i,m,e,n))}):uN(e)&&e.forEach(function(m,v){a.set(v,eu(m,t,i,v,e,n))});var f=h?l?JS:Km:l?Zv:Qv,g=d?void 0:f(e);return j4(g||e,function(m,v){g&&(v=m,m=e[v]),Hv(a,v,eu(m,t,i,v,e,n))}),a}var iA=eu,HN=1,WN=4;function qN(e){return iA(e,HN|WN)}var fp=qN,XN="__lodash_hash_undefined__";function YN(e){return this.__data__.set(e,XN),this}var QN=YN;function ZN(e){return this.__data__.has(e)}var KN=ZN;function Au(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new up;++t<i;)this.add(e[t])}Au.prototype.add=Au.prototype.push=QN;Au.prototype.has=KN;var JN=Au;function $N(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 eU=$N;function tU(e,t){return e.has(t)}var iU=tU,rU=1,sU=2;function nU(e,t,i,r,s,n){var a=i&rU,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&sU?new JN:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var f=e[c],g=t[c];if(r)var m=a?r(g,f,c,t,e,n):r(f,g,c,e,t,n);if(m!==void 0){if(m)continue;u=!1;break}if(p){if(!eU(t,function(v,y){if(!iU(p,y)&&(f===v||s(f,v,i,r,n)))return p.push(y)})){u=!1;break}}else if(!(f===g||s(f,g,i,r,n))){u=!1;break}}return n.delete(e),n.delete(t),u}var rA=nU;function aU(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var oU=aU;function lU(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var hU=lU,cU=1,dU=2,uU="[object Boolean]",pU="[object Date]",fU="[object Error]",mU="[object Map]",gU="[object Number]",vU="[object RegExp]",yU="[object Set]",xU="[object String]",bU="[object Symbol]",wU="[object ArrayBuffer]",_U="[object DataView]",Dx=kr?kr.prototype:void 0,Cf=Dx?Dx.valueOf:void 0;function SU(e,t,i,r,s,n,a){switch(i){case _U:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case wU:return!(e.byteLength!=t.byteLength||!n(new Su(e),new Su(t)));case uU:case pU:case gU:return Vv(+e,+t);case fU:return e.name==t.name&&e.message==t.message;case vU:case xU:return e==t+"";case mU:var o=oU;case yU:var l=r&cU;if(o||(o=hU),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=dU,a.set(e,t);var d=rA(o(e),o(t),r,s,n,a);return a.delete(e),d;case bU:if(Cf)return Cf.call(e)==Cf.call(t)}return!1}var AU=SU,MU=1,EU=Object.prototype,CU=EU.hasOwnProperty;function TU(e,t,i,r,s,n){var a=i&MU,o=Km(e),l=o.length,h=Km(t),d=h.length;if(l!=d&&!a)return!1;for(var c=l;c--;){var u=o[c];if(!(a?u in t:CU.call(t,u)))return!1}var p=n.get(e),f=n.get(t);if(p&&f)return p==t&&f==e;var g=!0;n.set(e,t),n.set(t,e);for(var m=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)){g=!1;break}m||(m=u=="constructor")}if(g&&!m){var b=e.constructor,_=t.constructor;b!=_&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof _=="function"&&_ instanceof _)&&(g=!1)}return n.delete(e),n.delete(t),g}var PU=TU,DU=1,Ix="[object Arguments]",Lx="[object Array]",dd="[object Object]",IU=Object.prototype,Ox=IU.hasOwnProperty;function LU(e,t,i,r,s,n){var a=zs(e),o=zs(t),l=a?Lx:ac(e),h=o?Lx:ac(t);l=l==Ix?dd:l,h=h==Ix?dd:h;var d=l==dd,c=h==dd,u=l==h;if(u&&_u(e)){if(!_u(t))return!1;a=!0,d=!1}if(u&&!d)return n||(n=new $d),a||jS(e)?rA(e,t,i,r,s,n):AU(e,t,l,i,r,s,n);if(!(i&DU)){var p=d&&Ox.call(e,"__wrapped__"),f=c&&Ox.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return n||(n=new $d),s(g,m,i,r,n)}}return u?(n||(n=new $d),PU(e,t,i,r,s,n)):!1}var OU=LU;function sA(e,t,i,r,s){return e===t?!0:e==null||t==null||!bn(e)&&!bn(t)?e!==e&&t!==t:OU(e,t,i,r,sA,s)}var BU=sA;function RU(e,t){return e!=null&&t in Object(e)}var zU=RU;function NU(e,t,i){t=kl(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=pp(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&&Wv(s)&&Gv(a,s)&&(zs(e)||Xv(e)))}var UU=NU;function FU(e,t){return e!=null&&UU(e,t,zU)}var kU=FU,jU=function(){return os.Date.now()},Tf=jU,GU="Expected a function",VU=Math.max,HU=Math.min;function WU(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(GU);t=ox(t)||0,as(i)&&(d=!!i.leading,c="maxWait"in i,n=c?VU(ox(i.maxWait)||0,t):n,u="trailing"in i?!!i.trailing:u);function p(A){var S=r,w=s;return r=s=void 0,h=A,a=e.apply(w,S),a}function f(A){return h=A,o=setTimeout(v,t),d?p(A):a}function g(A){var S=A-l,w=A-h,E=t-S;return c?HU(E,n-w):E}function m(A){var S=A-l,w=A-h;return l===void 0||S>=t||S<0||c&&w>=n}function v(){var A=Tf();if(m(A))return y(A);o=setTimeout(v,g(A))}function y(A){return o=void 0,u&&r?p(A):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?a:y(Tf())}function _(){var A=Tf(),S=m(A);if(r=arguments,s=this,l=A,S){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=b,_}var i0=WU;function qU(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var XU=qU;function YU(e,t){return t.length<2?e:HS(e,Rz(t,0,-1))}var QU=YU;function ZU(e,t){return BU(e,t)}var r0=ZU;function KU(e,t){return t=kl(t,e),e=QU(e,t),e==null||delete e[pp(XU(t))]}var JU=KU;function $U(e){return Oz(e)?void 0:e}var eF=$U,tF=1,iF=2,rF=4,sF=qS(function(e,t){var i={};if(e==null)return i;var r=!1;t=OS(t,function(n){return n=kl(n,e),r||(r=n.length>1),n}),Sc(e,JS(e),i),r&&(i=iA(i,tF|iF|rF,eF));for(var s=t.length;s--;)JU(i,t[s]);return i}),tg=sF;function nF(e,t,i,r){if(!as(e))return e;t=kl(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=pp(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=as(d)?d:Gv(t[s+1])?[]:{})}Hv(o,l,h),o=o[l]}return e}var aF=nF;function oF(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=HS(e,a);i(o,a)&&aF(n,kl(a,e),o)}return n}var lF=oF;function hF(e,t){return lF(e,t,function(i,r){return kU(e,r)})}var cF=hF,dF=qS(function(e,t){return e==null?{}:cF(e,t)}),vn=dF,uF="Expected a function";function pF(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(uF);return as(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),i0(e,t,{leading:r,maxWait:t,trailing:s})}var fF=pF;function mF(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Qa(e,t){return Object.setPrototypeOf(e,t),e}var gF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),vF=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),yF=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||mp&&"ontouchend"in document,xF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,bF=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,wF=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},_F=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},SF=()=>typeof window>"u"?void 0:new URLSearchParams(window.location.search).get("desktop-app-version")??"0.0.6",AF=gF(),Mq=AF?SF():void 0,mp=vF(),nA=yF(),MF=xF(),br=bF(),Bx=wF(),Rx=Number(_F());function aA(e){return Array.isArray(e)?e:[e]}function EF(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 ud(e){return mp?e.metaKey:e.ctrlKey}var Ve=[],Mu={},Ih={},tu={};function oA(e){Ve.includes(e)||Ve.push(e)}function el(e){delete Mu[e.pointerId];for(let t=0;t<Ve.length;t++)if(Ve[t].pointerId===e.pointerId){Ve.splice(t,1);break}}function CF(){Ve.splice(0,Ve.length)}function Eu(e){if(e.pointerType!=="touch")return;let t=Mu[e.pointerId];t===void 0&&(t={x:0,y:0},Mu[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Pf(e){let t=e.pointerId===Ve[0].pointerId?Ve[1]:Ve[0];return Mu[t.pointerId]}function lA(e){Ih[e.key]=!0,tu[e.key]=tu[e.key]===void 0?1:tu[e.key]+1}function hA(e){if(mp&&Ih.Meta)for(let t in Ih)Ih[t]=!1;else Ih[e.key]=!1;tu={}}function TF(e){e.addEventListener("pointerdown",oA,!0),e.addEventListener("pointerdown",Eu,!0),e.addEventListener("pointermove",Eu,!0),e.addEventListener("pointerup",el,!0),e.addEventListener("pointercancel",el,!0),e.addEventListener("pointerleave",el,!0),window.addEventListener("keydown",lA,!0),window.addEventListener("keyup",hA,!0)}function PF(e){e.removeEventListener("pointerdown",oA,!0),e.removeEventListener("pointerdown",Eu,!0),e.removeEventListener("pointermove",Eu,!0),e.removeEventListener("pointerup",el,!0),e.removeEventListener("pointercancel",el,!0),e.removeEventListener("pointerleave",el,!0),window.removeEventListener("keydown",lA,!0),window.removeEventListener("keyup",hA,!0)}var cA,DF=new Promise(e=>{cA=e}),pd;function IF(){if(pd)return pd;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.424/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});cA(a)}return pd=e(),pd}var dA,LF=new Promise(e=>{dA=e}),fd;function OF(){if(fd)return fd;async function e(){let t=await import("./physics.js");await t.init(),dA(t)}return fd=e(),fd}var ii=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,ii.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,ii.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,ii.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function s0(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"&&s0(r)}return Object.freeze(e)}function BF(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 uA=class extends Error{};function Df(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Wn(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 n0(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 RF(){return typeof process<"u"}function pA(e,t){for(let i of e)t(i.id,i.data)!==!0&&pA(i.children,t)}function fA(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)fA(i,t)}var nr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,nr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)s0(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&fA(i,t)}}traverse(e){pA(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,nr.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 uA("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)=>BF(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 Wn(0,i,i);{let s=r[0].fi;return Wn(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 Wn(a,a+i,i)}else return Wn(s.fi,n.fi,i)}}},Cu;(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})(Cu||(Cu={}));var et=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,et.prototype)}deepFreeze(){let e=0;for(;e<this.length;)s0(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 RF()||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 Wn(0,t,t);{let r=i[0].fi;return Wn(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 Wn(n,n+t,t)}else return Wn(r.fi,s.fi,t)}}};function yl(e){return e&&typeof e=="object"&&e instanceof di}var di=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&&!yl(i))return null;r+=1}i=i?Df(i):new di;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=Df(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Df(o);l[e.path[r-1]]=i,i=l}else{let l=new di;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,di.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},$n;(e=>{function t(s,n){return oc(s,n)??s}e.apply=t;function i(s,n){return o0(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=Ls.zoomOnce(l,o[a]),l===void 0)return n;if(!yl(l))return;a+=1}if(l===void 0)return n;if(yl(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=a0([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})($n||($n={}));function a0(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=oc(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=a0(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 zF(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=oc(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 oc(e,t){if(!yl(t))return t;if(e instanceof nr){let i=a0(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof et)return zF(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=oc(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 di)return o0(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=oc(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 o0(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!yl(t))return t;if(!yl(e))return $n.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 di;for(let s of i){let n=o0(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function NF(e,t){let i={cur:[],result:[],len:0};return e=lc(e,t,i)??e,[e,i.result]}function Tu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Pu(e){e&&(e.len-=1)}function UF(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function mA(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=lc(n.data,t,Tu(i,a));Pu(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=mA(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 FF(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=lc(n.data,t,Tu(i,a));return Pu(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 lc(e,t,i){if(e instanceof nr){let r=mA(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof et)return FF(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=lc(n,t,Tu(i,a));return Pu(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"&&!n0(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=lc(a,t,Tu(i,n));Pu(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");UF(i)}return r}else return}}var ig;(e=>{function t(i,r){let s=Ls.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})(ig||(ig={}));var wr;(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 di&&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 nr||l instanceof et||l instanceof ii?u=l.runOp(h):u=Cu.runOp(l,h)),u!==void 0)if(u!==null){let g=u.data;for(let m=c.length-1;m>=0;m--){let v=d[m],y=c[m];if(y instanceof nr){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof et){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof ii){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof di){let x={...y,[v]:g};g=Object.setPrototypeOf(x,di.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=g;g=[...y],g[v]=x}else g={...y,[v]:g};else return null}return{data:g,actual:{...u.actual,path:d},reverse:{...u.reverse,path:d}}}else return null;let p=d[c.length],f;if(l instanceof nr){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})(wr||(wr={}));var zx;(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=>wr.subsumed(c,u))),...d]}e.compress=n;function a(h,d){return h.every(c=>d.every(u=>wr.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 g=Ls.zoom(c,[...f.path,f.id]),m=wr.apply(c,{...f,type:2});if(m!==null){c=m.data;let[v,y]=NF(c,{[f.id]:g});c=v;for(let x of y){let b=x[x.length-1];x.splice(x.length-1,1),u.push({type:0,path:x,props:{[b]:g}}),p.push({type:0,path:x,props:{[b]:f.id}})}p.push(m.reverse),u.push(m.actual)}}else{let g=wr.apply(c,f);g!==null&&(u.push(g.actual),c=g.data,p.push(g.reverse))}}catch(g){if(g instanceof uA)return null;throw g}return{data:c,actual:u,reverse:p.reverse()}}e.apply=l})(zx||(zx={}));var gA=Symbol(),kF=Symbol(),gp=Symbol(),Ac=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof yA);){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[gp];i&&i(),delete this._children[e]}}}},jF=class extends Ac{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,Cu.runOp(this._current,e),e.path)}},GF=class extends Ac{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,ii.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},vA={get(e,t){if(t===gp)return()=>{e._parent=null};if(t===gA)return e._current;if(t===kF)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=vp(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]}}},VF={...vA,set(e,t,i){let r={type:0,props:{[t]:wi(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}},HF={...vA,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}},l0=class extends Ac{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[gp]=()=>{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=vp(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)}},h0=class extends Ac{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[gp]=()=>{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=vp(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 If(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Ls.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var yA=class extends Ac{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){If(this.ts,t,e),If(this.actual,i,e),If(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function vp(e,t,i){return i instanceof nr?new l0(e,t,i):i instanceof et?new h0(e,t,i):i instanceof ii?new Proxy(new GF(e,t,i),HF):i!==null&&typeof i=="object"?n0(i)?i:new Proxy(new jF(e,t,i),VF):i}function xA(e){let t=new yA(e);return[vp(t,"",e),t]}function Du(e,t){let[i,r]=xA(e);return t(i),r.result()}function wi(e){return e instanceof l0||e instanceof h0?e._current:e!==null&&typeof e=="object"?e[gA]:e}var Ls;(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 nr||n instanceof l0)&&typeof a=="string"||(n instanceof et||n instanceof h0)&&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})(Ls||(Ls={}));function WF(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 zr(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 bA=class{},Nx=class extends bA{constructor(e){super(),this.id=e}},Ux=class extends bA{constructor(e){super(),this.data=e}},rg;try{rg=new TextDecoder}catch{}var Te,ea,K=0,wA=[],sg=wA,ng=0,er={},yt,qn,Or=0,Ts=0,gr,yn,Qi=[],bt,Fx={useRecords:!1,mapsAsObjects:!0},_A=class{},SA=new _A;SA.name="MessagePack 0xC1";var xl=!1,Iu=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(Te)return PA(()=>(og(),this?this.unpack(e,t):Iu.prototype.unpack.call(Fx,e,t)));ea=t>-1?t:e.length,K=0,ng=0,Ts=0,qn=null,sg=wA,gr=null,Te=e;try{bt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Te=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 Iu){if(er=this,this.structures)return yt=this.structures,md();(!yt||yt.length>0)&&(yt=[])}else er=Fx,(!yt||yt.length>0)&&(yt=[]);return md()}unpackMultiple(e,t){let i,r=0;try{xl=!0;let s=e.length,n=this?this.unpack(e,s):xp.unpack(e,s);if(t){for(t(n);K<s;)if(r=K,t(md())===!1)return}else{for(i=[n];K<s;)r=K,i.push(md());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{xl=!1,og()}}_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 md(){try{if(!er.trusted&&!xl){let t=yt.sharedLength||0;t<yt.length&&(yt.length=t)}let e=Gt();if(K==ea)yt.restoreStructures&&kx(),yt=null,Te=null,yn&&(yn=null);else if(K>ea){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!xl)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw yt.restoreStructures&&kx(),og(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function kx(){for(let e in yt.restoreStructures)yt[e]=yt.restoreStructures[e];yt.restoreStructures=null}function Gt(){let e=Te[K++];if(e<160)if(e<128){if(e<64)return e;{let t=yt[e&63]||er.getStructures&&AA()[e&63];return t?(t.read||(t.read=c0(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,er.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[EA()]=Gt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gt(),Gt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gt();return t}else if(e<192){let t=e-160;if(Ts>=K)return qn.slice(K-Or,(K+=t)-Or);if(Ts==0&&ea<140){let i=t<16?d0(t):MA(t);if(i!=null)return i}return ag(t)}else{let t;switch(e){case 192:return null;case 193:return gr?(t=Gt(),t>0?gr[1].slice(gr.position1,gr.position1+=t):gr[0].slice(gr.position0,gr.position0-=t)):SA;case 194:return!1;case 195:return!0;case 196:return Lf(Te[K++]);case 197:return t=bt.getUint16(K),K+=2,Lf(t);case 198:return t=bt.getUint32(K),K+=4,Lf(t);case 199:return xa(Te[K++]);case 200:return t=bt.getUint16(K),K+=2,xa(t);case 201:return t=bt.getUint32(K),K+=4,xa(t);case 202:if(t=bt.getFloat32(K),er.useFloat32>2){let i=u0[(Te[K]&127)<<1|Te[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=bt.getFloat64(K),K+=8,t;case 204:return Te[K++];case 205:return t=bt.getUint16(K),K+=2,t;case 206:return t=bt.getUint32(K),K+=4,t;case 207:return er.int64AsNumber?(t=bt.getUint32(K)*4294967296,t+=bt.getUint32(K+4)):t=bt.getBigUint64(K),K+=8,t;case 208:return bt.getInt8(K++);case 209:return t=bt.getInt16(K),K+=2,t;case 210:return t=bt.getInt32(K),K+=4,t;case 211:return er.int64AsNumber?(t=bt.getInt32(K)*4294967296,t+=bt.getUint32(K+4)):t=bt.getBigInt64(K),K+=8,t;case 212:if(t=Te[K++],t==114)return Wx(Te[K++]&63);{let i=Qi[t];if(i)return i.read?(K++,i.read(Gt())):i.noBuffer?(K++,i()):i(Te.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Te[K],t==114?(K++,Wx(Te[K++]&63,Te[K++])):xa(2);case 214:return xa(4);case 215:return xa(8);case 216:return xa(16);case 217:return t=Te[K++],Ts>=K?qn.slice(K-Or,(K+=t)-Or):XF(t);case 218:return t=bt.getUint16(K),K+=2,Ts>=K?qn.slice(K-Or,(K+=t)-Or):YF(t);case 219:return t=bt.getUint32(K),K+=4,Ts>=K?qn.slice(K-Or,(K+=t)-Or):QF(t);case 220:return t=bt.getUint16(K),K+=2,Gx(t);case 221:return t=bt.getUint32(K),K+=4,Gx(t);case 222:return t=bt.getUint16(K),K+=2,Vx(t);case 223:return t=bt.getUint32(K),K+=4,Vx(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 qF=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function c0(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>qF.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Gt);return e.highByte===0&&(e.read=jx(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=Gt()}return r}return i.count=0,e.highByte===0?jx(t,i):i}var jx=(e,t)=>function(){let i=Te[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=yt[r]||AA()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=c0(s,e)),s.read()};function AA(){let e=PA(()=>(Te=null,er.getStructures()));return yt=er._mergeStructures(e,yt)}var ag=yp,XF=yp,YF=yp,QF=yp;function yp(e){let t;if(e<16&&(t=d0(e)))return t;if(e>64&&rg)return rg.decode(Te.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Te[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Te[K++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Te[K++]&63,a=Te[K++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Te[K++]&63,a=Te[K++]&63,o=Te[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+=vi.apply(String,r),r.length=0)}return r.length>0&&(t+=vi.apply(String,r)),t}function Gx(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gt();return t}function Vx(e){if(er.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[EA()]=Gt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gt(),Gt());return t}}var vi=String.fromCharCode;function MA(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Te[K++];if((s&128)>0){K=t;return}i[r]=s}return vi.apply(String,i)}function d0(e){if(e<4)if(e<2){if(e===0)return"";{let t=Te[K++];if((t&128)>1){K-=1;return}return vi(t)}}else{let t=Te[K++],i=Te[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return vi(t,i);let r=Te[K++];if((r&128)>0){K-=3;return}return vi(t,i,r)}else{let t=Te[K++],i=Te[K++],r=Te[K++],s=Te[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return vi(t,i,r,s);{let n=Te[K++];if((n&128)>0){K-=5;return}return vi(t,i,r,s,n)}}else if(e<8){let n=Te[K++],a=Te[K++];if((n&128)>0||(a&128)>0){K-=6;return}if(e<7)return vi(t,i,r,s,n,a);let o=Te[K++];if((o&128)>0){K-=7;return}return vi(t,i,r,s,n,a,o)}else{let n=Te[K++],a=Te[K++],o=Te[K++],l=Te[K++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return vi(t,i,r,s,n,a,o,l);{let h=Te[K++];if((h&128)>0){K-=9;return}return vi(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Te[K++],d=Te[K++];if((h&128)>0||(d&128)>0){K-=10;return}if(e<11)return vi(t,i,r,s,n,a,o,l,h,d);let c=Te[K++];if((c&128)>0){K-=11;return}return vi(t,i,r,s,n,a,o,l,h,d,c)}else{let h=Te[K++],d=Te[K++],c=Te[K++],u=Te[K++];if((h&128)>0||(d&128)>0||(c&128)>0||(u&128)>0){K-=12;return}if(e<14){if(e===12)return vi(t,i,r,s,n,a,o,l,h,d,c,u);{let p=Te[K++];if((p&128)>0){K-=13;return}return vi(t,i,r,s,n,a,o,l,h,d,c,u,p)}}else{let p=Te[K++],f=Te[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return vi(t,i,r,s,n,a,o,l,h,d,c,u,p,f);let g=Te[K++];if((g&128)>0){K-=15;return}return vi(t,i,r,s,n,a,o,l,h,d,c,u,p,f,g)}}}}}function Lf(e){return er.copyBuffers?Uint8Array.prototype.slice.call(Te,K,K+=e):Te.subarray(K,K+=e)}function xa(e){let t=Te[K++];if(Qi[t])return Qi[t](Te.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var Hx=new Array(4096);function EA(){let e=Te[K++];if(e>=160&&e<192){if(e=e-160,Ts>=K)return qn.slice(K-Or,(K+=e)-Or);if(!(Ts==0&&ea<180))return ag(e)}else return K--,Gt();let t=(e<<5^(e>1?bt.getUint16(K):e>0?Te[K]:0))&4095,i=Hx[t],r=K,s=K+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=bt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Te[r++],n!=i[a++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],Hx[t]=i,i.bytes=e;r<s;)n=bt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Te[r++],i.push(n);let o=e<16?d0(e):MA(e);return o!=null?i.string=o:i.string=ag(e)}var Wx=(e,t)=>{var i=Gt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=yt[e];return s&&s.isShared&&((yt.restoreStructures||(yt.restoreStructures=[]))[e]=s),yt[e]=i,i.read=c0(i,r),i.read()},CA=typeof self=="object"?self:global;Qi[0]=()=>{};Qi[0].noBuffer=!0;Qi[101]=()=>{let e=Gt();return(CA[e[0]]||Error)(e[1])};Qi[105]=e=>{let t=bt.getUint32(K-4);yn||(yn=new Map);let i=Te[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};yn.set(t,s);let n=Gt();return s.used?Object.assign(r,n):(s.target=n,n)};Qi[112]=e=>{let t=bt.getUint32(K-4),i=yn.get(t);return i.used=!0,i.target};Qi[115]=()=>new Set(Gt());var TA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Qi[116]=e=>{let t=e[0],i=TA[t];if(!i)throw new Error("Could not find typed array for code "+t);return new CA[i](Uint8Array.prototype.slice.call(e,1).buffer)};Qi[120]=()=>{let e=Gt();return new RegExp(e[0],e[1])};Qi[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,gr=[Gt(),Gt()],gr.position0=0,gr.position1=0;let r=K;K=i;try{return Gt()}finally{K=r}};Qi[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 PA(e){let t=ea,i=K,r=ng,s=Or,n=Ts,a=qn,o=sg,l=yn,h=gr,d=new Uint8Array(Te.slice(0,ea)),c=yt,u=yt.slice(0,yt.length),p=er,f=xl,g=e();return ea=t,K=i,ng=r,Or=s,Ts=n,qn=a,sg=o,yn=l,gr=h,Te=d,xl=f,yt=c,yt.splice(0,yt.length,...u),er=p,bt=new DataView(Te.buffer,Te.byteOffset,Te.byteLength),g}function og(){Te=null,yn=null,yt=null}function ZF(e){e.unpack?Qi[e.type]=e.unpack:Qi[e.type]=e}var u0=new Array(147);for(let e=0;e<256;e++)u0[e]=+("1e"+Math.floor(45.15-e*.30103));var xp=new Iu({useRecords:!1}),Eq=xp.unpack,Cq=xp.unpackMultiple,Tq=xp.unpack,KF={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},JF=new Float32Array(1),Pq=new Uint8Array(JF.buffer,0,4),iu;try{iu=new TextEncoder}catch{}var Lu,p0,bp=typeof Buffer<"u",Of=bp?Buffer.allocUnsafeSlow:Uint8Array,DA=bp?Buffer:Uint8Array,qx=bp?4294967296:2144337920,he,qt,te=0,cs,ds=null,$F=/[\u0080-\uFFFF]/,hh=Symbol("record-id"),IA=class extends Iu{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=DA.prototype.utf8Write?function(S,w,E){return he.utf8Write(S,w,E)}:iu&&iu.encodeInto?function(S,w){return iu.encodeInto(S,he.subarray(w)).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,g=u+64,m=u+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(S,w){if(he||(he=new Of(8192),qt=new DataView(he.buffer,0,8192),te=0),cs=he.length-10,cs-te<2048?(he=new Of(he.length),qt=new DataView(he.buffer,0,he.length),cs=he.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(ds=["",""],he[te++]=214,he[te++]=98,ds.position=te-i,te+=4):ds=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let E=r.sharedLength||0;if(E>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<E;C++){let T=r[C];if(!T)continue;let D,P=r.transitions;for(let L=0,R=T.length;L<R;L++){let V=T[L];D=P[V],D||(D=P[V]=Object.create(null)),P=D}P[hh]=C+64}o=E}d||(r.nextId=E+64)}s&&(s=!1),n=r||[];try{if(b(S),ds){qt.setUint32(ds.position+i,te-ds.position-i);let E=ds;ds=null,b(E[0]),b(E[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>cs&&A(te),h.offset=te;let E=tk(he.subarray(i,te),a.idsToInsert);return a=null,E}return w&ik?(he.start=i,he.end=te,he):he.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 E=0,C=v.length;E<C;E++)v[E][hh]=0;v=[]}if(s&&h.saveStructures){let E=r.sharedLength||u;r.length>E&&(r=r.slice(0,E));let C=he.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=E,C)}}w&rk&&(te=i)}};let b=S=>{te>cs&&(he=A(te));var w=typeof S,E;if(w==="string"){let C=S.length;if(ds&&C>=8&&C<4096){let P=$F.test(S);ds[P?0:1]+=S,he[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>cs&&(he=A(te+D)),C<64||!l){let P,L,R,V=te+T;for(P=0;P<C;P++)L=S.charCodeAt(P),L<128?he[V++]=L:L<2048?(he[V++]=L>>6|192,he[V++]=L&63|128):(L&64512)===55296&&((R=S.charCodeAt(P+1))&64512)===56320?(L=65536+((L&1023)<<10)+(R&1023),P++,he[V++]=L>>18|240,he[V++]=L>>12&63|128,he[V++]=L>>6&63|128,he[V++]=L&63|128):(he[V++]=L>>12|224,he[V++]=L>>6&63|128,he[V++]=L&63|128);E=V-te-T}else E=l(S,te+T,D);E<32?he[te++]=160|E:E<256?(T<2&&he.copyWithin(te+2,te+1,te+1+E),he[te++]=217,he[te++]=E):E<65536?(T<3&&he.copyWithin(te+3,te+2,te+2+E),he[te++]=218,he[te++]=E>>8,he[te++]=E&255):(T<5&&he.copyWithin(te+5,te+3,te+3+E),he[te++]=219,qt.setUint32(te,E),te+=4),te+=E}else if(w==="number")if(S>>>0===S)S<64?he[te++]=S:S<256?(he[te++]=204,he[te++]=S):S<65536?(he[te++]=205,he[te++]=S>>8,he[te++]=S&255):(he[te++]=206,qt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?he[te++]=256+S:S>=-128?(he[te++]=208,he[te++]=S+256):S>=-32768?(he[te++]=209,qt.setInt16(te,S),te+=2):(he[te++]=210,qt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){he[te++]=202,qt.setFloat32(te,S);let T;if(C<4||(T=S*u0[(he[te]&127)<<1|he[te+1]>>7])>>0===T){te+=4;return}else te--}he[te++]=203,qt.setFloat64(te,S),te+=8}else if(w==="object")if(!S)he[te++]=192;else{if(a){let T=a.get(S);if(T){if(!T.id){let D=a.idsToInsert||(a.idsToInsert=[]);T.id=D.push(T)}he[te++]=214,he[te++]=112,qt.setUint32(te,T.id),te+=4;return}else a.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)_(S,!0);else if(C===Array){E=S.length,E<16?he[te++]=144|E:E<65536?(he[te++]=220,he[te++]=E>>8,he[te++]=E&255):(he[te++]=221,qt.setUint32(te,E),te+=4);for(let T=0;T<E;T++)b(S[T])}else if(C===Map){E=S.size,E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,qt.setUint32(te,E),te+=4);for(let[T,D]of S)b(T),b(D)}else{for(let T=0,D=Lu.length;T<D;T++){let P=p0[T];if(S instanceof P){let L=Lu[T];if(L.write){L.type&&(he[te++]=212,he[te++]=L.type,he[te++]=0),b(L.write.call(this,S));return}let R=he,V=qt,k=te;he=null;let z;try{z=L.pack.call(this,S,X=>(he=R,R=null,te+=X,te>cs&&A(te),{target:he,targetView:qt,position:te-X}),b)}finally{R&&(he=R,qt=V,te=k,cs=he.length-10)}z&&(z.length+te>cs&&A(z.length+te),te=ek(z,he,te,L.type));return}}_(S,!S.hasOwnProperty)}}else if(w==="boolean")he[te++]=S?195:194;else if(w==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))he[te++]=211,qt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)he[te++]=207,qt.setBigUint64(te,S);else if(this.largeBigIntToFloat)he[te++]=203,qt.setFloat64(te,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(w==="undefined")this.encodeUndefinedAsNil?he[te++]=192:(he[te++]=212,he[te++]=0,he[te++]=0);else if(w==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+w)},_=this.useRecords===!1?this.variableMapSize?S=>{let w=Object.keys(S),E=w.length;E<16?he[te++]=128|E:E<65536?(he[te++]=222,he[te++]=E>>8,he[te++]=E&255):(he[te++]=223,qt.setUint32(te,E),te+=4);let C;for(let T=0;T<E;T++)b(C=w[T]),b(S[C])}:(S,w)=>{he[te++]=222;let E=te-i;te+=2;let C=0;for(let T in S)(w||S.hasOwnProperty(T))&&(b(T),b(S[T]),C++);he[E+++i]=C>>8,he[E+i]=C&255}:S=>{let w=Object.keys(S),E,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let P=0,L=w.length;P<L;P++){let R=w[P];E=C[R],E||(E=C[R]=Object.create(null),T++),C=E}let D=C[hh];if(D)D>=96&&f?(he[te++]=((D-=96)&31)+96,he[te++]=D>>5):he[te++]=D;else{D=n.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(w)?(D=n.nextOwnId,D<m||(D=g),n.nextOwnId=D+1):(D>=m&&(D=g),n.nextId=D+1);let P=w.highByte=D>=96&&f?D-96>>5:-1;C[hh]=D,n[D-64]=w,D<g?(w.isShared=!0,n.sharedLength=D-63,s=!0,P>=0?(he[te++]=(D&31)+96,he[te++]=P):he[te++]=D):(P>=0?(he[te++]=213,he[te++]=114,he[te++]=(D&31)+96,he[te++]=P):(he[te++]=212,he[te++]=114,he[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[hh]=0),v.push(C),b(w))}for(let P=0,L=w.length;P<L;P++)b(S[w[P]])},A=S=>{let w;if(S>16777216){if(S-i>qx)throw new Error("Packed buffer would be larger than maximum buffer size");w=Math.min(qx,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else w=(Math.max(S-i<<2,he.length-1)>>12)+1<<12;let E=new Of(w);return qt=new DataView(E.buffer,0,w),he.copy?he.copy(E,0,i,S):E.set(he.slice(i,S)),te-=i,i=0,cs=E.length-10,he=E}}useBuffer(e){he=e,qt=new DataView(he.buffer,he.byteOffset,he.byteLength),te=0}};p0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,_A];Lu=[{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?Xx(e,16,t):Yx(bp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==DA&&this.structuredClone?Xx(e,TA.indexOf(i.name),t):Yx(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function Xx(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 Yx(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 ek(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 tk(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 Gl(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)");p0.unshift(e.Class),Lu.unshift(e)}ZF(e)}var LA=new IA({useRecords:!1}),Dq=LA.pack,Iq=LA.pack,{NEVER:Lq,ALWAYS:Oq,DECIMAL_ROUND:Bq,DECIMAL_FIT:Rq}=KF,ik=512,rk=1024,Qx=new IA({structuredClone:!0});Gl({Class:ii.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ii.prototype),e}});Gl({Class:et.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,et.prototype),e}});Gl({Class:nr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,nr.prototype),e}});Gl({Class:Nx.prototype.constructor,type:4,write(e){return e.id},read(e){return new Nx(e)}});Gl({Class:Ux.prototype.constructor,type:5,write(e){return e.data},read(e){return new Ux(e)}});Gl({Class:di.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,di.prototype),e}});function sk(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 lg(e){if(n0(e))return e;if(Array.isArray(e))return e.map(lg);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=lg(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var hg;(e=>{function t(s){return Qx.pack(s)}e.serialize=t;function i(s){return Qx.unpack(s)}e.deserialize=i;function r(s){return sk(t(lg(s))).toString()}e.checksum=r})(hg||(hg={}));var us={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition"],Scroll:["Transition","Animation","Create"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset"],GameControl:["Transition","Animation","Audio","Video","Create"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"]},Zx;(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})(Zx||(Zx={}));var Ou;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Ou||(Ou={}));var cg;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Ou.propertyDefaultData(s),rOperand:{...Ou.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})(cg||(cg={}));var Kx;(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:cg.distanceDefaultData(r)}}e.defaultData=i})(Kx||(Kx={}));var Jx;(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}})(Jx||(Jx={}));var dg;(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})(dg||(dg={}));var ug;(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})(ug||(ug={}));var $x;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new et}}e.defaultData=i})($x||($x={}));var eb;(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})(eb||(eb={}));var tb;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new et}}e.defaultData=i})(tb||(tb={}));var ib;(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})(ib||(ib={}));var rb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,toggle:!1,target:"all",triggeringObjects:[],actions:new et,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(rb||(rb={}));var Vl="personal camera",Vh="a218fcc3-276b-49b9-b485-49037fd14f5f",nk=2960946,jr=5526619,Qo;(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})(Qo||(Qo={}));var ja;(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})(ja||(ja={}));var Bu;(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})(Bu||(Bu={}));var bl;(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})(bl||(bl={}));var Vi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.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(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function n(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=n;function a(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=a;function o(l,h,d){return{r:l.r+(h.r-l.r)*d,g:l.g+(h.g-l.g)*d,b:l.b+(h.b-l.b)*d}}e.lerp=o})(Vi||(Vi={}));var es;(e=>{e.white={...Vi.white,a:1},e.transparent={...Vi.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{...Vi.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 Vi.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})(es||(es={}));var pg;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(pg||(pg={}));var sb;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(sb||(sb={}));var nb;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(nb||(nb={}));var kn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(kn||(kn={}));var Za;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Za||(Za={}));var wl;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(wl||(wl={}));var Xn;(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(OA.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;BA.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;RA.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;zA.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;NA.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;UA.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(Xn||(Xn={}));var fg;(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})(fg||(fg={}));var OA=["count"],BA=["radius","start","end","position","scale","rotation"],RA=["position","scale","rotation"],zA=["count","size"],NA=["count","position","scale","rotation"],UA=["strength","scale","rotation","position","movement","seed","freqScale"],mg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(mg||(mg={}));var gg;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:es.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(gg||(gg={}));var _l;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(_l||(_l={}));var vg;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(vg||(vg={}));var yg;(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})(yg||(yg={}));var xg;(e=>e.defaultData={...yg.defaultData,...vg.defaultData})(xg||(xg={}));var Ru;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Ru||(Ru={}));var ab;(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==="pattern"||i==="light"}e.is=t})(ab||(ab={}));function ak(e){return e.type!=="displace"}var ob;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(ob||(ob={}));var FA=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],ok=["wrapping","image","video","name"],Ji;(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){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Ru.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:Vi.fromHex(jr)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Vi.fromHex(6710886),a:1},colorB:{...Vi.fromHex(6710886),a:1},colorC:{...Vi.fromHex(16777215),a:1},colorD:{...Vi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:es.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:es.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:es.fromHexAndA(0,1),contourColor:es.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{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Vi.fromHex(0),a:1},colorB:{...Vi.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Ji||(Ji={}));var zi;(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:Ji.defaultData("light",h),id:d}),u.push({fi:1,data:Ji.defaultData("color"),id:c}),{layers:u}}e.defaultTwoLayerData=a;function o(h,d="phong",c="layer1",u="layer2"){let p=Ji.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:Ji.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,d="phong",c="layer1",u="layer2"){let p=Ji.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:Ji.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(zi||(zi={}));var zu;(e=>{function t(){return{points:new et,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(zu||(zu={}));var Nu;(e=>{function t(){return{points:new et,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Nu||(Nu={}));var kA={type:"Ellipse",width:100,height:100,spikes:16,angle:360,innerRadius:0},bg;(e=>{function t(i,r){let s={...i};return GA.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(bg||(bg={}));var jA={shape:kA,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},GA=["depth","offset","angle","twist","startScale","endScale"],Uu;(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})(Uu||(Uu={}));var wg;(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,bg.merge(s.extrusion,r.extrusion))),s}e.merge=t})(wg||(wg={}));var tl;(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:Nu.defaultData(),extrusion:jA};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:zu.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};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}e.defaultData=t})(tl||(tl={}));var lb=["width","height","depth"],_g;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Vi.white,near:.1,far:2e3})(_g||(_g={}));var Fu;(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}}})(Fu||(Fu={}));var Sg;(e=>e.defaultData={softShadowQuality:"low"})(Sg||(Sg={}));var Ag;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Ag||(Ag={}));var Mg;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Mg||(Mg={}));var Sl;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Sl||(Sl={}));var Eg;(e=>e.defaultData={playCamera:Vl,gameControlObject:null})(Eg||(Eg={}));var Cg;(e=>e.defaultData={backgroundColor:es.fromHexAndA(nk,1),postprocessing:Fu.defaultData,fog:_g.defaultData,globalPhysics:Sl.defaultData,ambient:Ag.defaultData,ao:Mg.defaultData,shadow:Sg.defaultData,publish:Eg.defaultData})(Cg||(Cg={}));var hb;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(hb||(hb={}));var Al;(e=>{e.identity={...pg.identity,hiddenMatrix:bl.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 mF({position:ja.isEqual(s.position,n.position)?void 0:n.position,rotation:ja.isEqual(s.rotation,n.rotation)?void 0:n.rotation,scale:ja.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:bl.isEqual(s.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})}e.diff=r})(Al||(Al={}));var Xi;(e=>e.defaultData={states:new et,events:new et,visible:!0,raycastLock:!1,physics:_l.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Al.identity,cloner:null})(Xi||(Xi={}));var cb;(e=>e.defaultData={type:"Empty",...Xi.defaultData})(cb||(cb={}));var db;(e=>e.defaultData={type:"Component",...Xi.defaultData})(db||(db={}));var il;(e=>e.defaultData={type:"Mesh",...Xi.defaultData,...xg.defaultData})(il||(il={}));var hc;(e=>e.defaultData={...Xi.defaultData,...Al.identity,position:[0,0,wl.DefaultTargetOffset],...wl.defaultData})(hc||(hc={}));var Tg;(e=>{function t(i){return{...Xi.defaultData,...gg.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Tg||(Tg={}));var ku;(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})(ku||(ku={}));var Yn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Xi.defaultData,...s,component:r,overrides:new di,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Al.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Yn||(Yn={}));var Ml;(e=>e.defaultData={type:"Page",...Xi.defaultData,physics:{..._l.defaultData,fusedBody:!1},...Cg.defaultData,camera:hc.defaultData})(Ml||(Ml={}));var Pg;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:bl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:_l.defaultData,states:new et,events:new et,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...wl.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",...Xi.defaultData,...il.defaultData,geometry:tl.defaultData("RectangleGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Xi.defaultData,...il.defaultData,geometry:tl.defaultData("BooleanGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Xi.defaultData,...il.defaultData,geometry:tl.defaultData("TextGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")}))(Pg||(Pg={}));var Oa;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new di}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new di})))):Za.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=Du(o.material,l=>{if(typeof l!="string")for(let[h,d]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&Ji.patch(c,d)}}).data),o.materials&&a.materials&&(o.materials=Du(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&&Ji.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:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let v={path:[...c,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,u]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...fg.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,Al.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})}),Za.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:wg.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Xn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Xn.merge(o.cloner,a.cloner)});else if(mg.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=Vi.clone(l.color))}return o}e.patch=s})(Oa||(Oa={}));var ju;(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})(ju||(ju={}));var Ga;(e=>e.defaultData={orbitControls:ju.defaultData,playPage:Vh,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",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"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Ga||(Ga={}));var Dg;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Dg||(Dg={}));var Ig;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Ig||(Ig={}));var rl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Dg.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Ig.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(rl||(rl={}));var cc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,n){r.traverseFrom(s,(a,o)=>{if(o.type==="Instance"){let l=r.data(o.component);l&&n(a,o,l.events)}else n(a,o,o.events)})}e.traverseModuleInstances=i})(cc||(cc={}));var Lg;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=[],a=Pg.defaultMeshObject;s.withLight===!0&&n.push({fi:-1,data:Tg.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]});let o=new nr;return o.push({fi:1,id:Vh,data:{...Ml.defaultData,name:"Scene 1"},children:n}),o}e.defaultData={objects:t(),publish:Ga.defaultData,styles:rl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new nr,publish:Ga.defaultData,styles:rl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Ga.defaultData,styles:rl.defaultData()}};function i(s){return{...e.defaultData,objects:Qa(s,nr.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(Lg||(Lg={}));var Gu;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Gu||(Gu={}));var Og;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Qa(s,ii.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Gu.emptyImage,name:"AI generated image"}),Qa(n,ii.prototype)}e.defaultImages=i;function r(){return{materials:new ii,images:new ii,videos:new ii,colors:new ii,audios:new ii,fonts:new ii}}e.emptyData=r})(Og||(Og={}));var Bg;(e=>e.list=["idle","move","jump","run"])(Bg||(Bg={}));var Vu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new et,move:new et,jump:new et,run:new et},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:es.fromHexAndA(3728051,1)}}))(Vu||(Vu={}));function ub(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={...vn(wi(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={...wi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function jn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Gn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=zi.defaultData(),s=r.materials[n]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function lk(e){Object.assign(e.scene.publish,{orbitControls:{...ju.defaultData,...wi(e.scene.publish.orbitControls)}})}function hk(e){Object.assign(e.scene.publish.settings,{video:{...Ga.defaultData.settings.video,...wi(e.scene.publish.settings.video)}})}function ck(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((FA.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(ok.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 dk(e){e.scene.publish.withBackground=!0}function uk(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function pk(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 fk(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 mk(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=wi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=wi(i).booleanExclude!==!0)}})}function gk(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 vk(e){function t(r){Object.setPrototypeOf(r,di.prototype),r.texture&&Object.setPrototypeOf(r.texture,di.prototype)}function i(r){Object.setPrototypeOf(r,di.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=wi(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=wi(l).layers;i(h),l.layers=h}})})}function pb(e){e.layers===void 0&&Object.assign(e,zi.defaultTwoLayerData("lambert"))}function Bf(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={...wi(t),colors:i,steps:r};Object.assign(t,s)}})}function yk(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function fb(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Bf(r)}):"material"in i&&typeof i.material!="string"&&Bf(i.material)}),Object.values(e.shared.materials).forEach(t=>Bf(t))}function xk(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 bk(e){e.shared.audios=Qa({},ii.prototype)}function wk(e){e.shared.videos=Qa({},ii.prototype)}function _k(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 Sk(e){Object.entries(wi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(wi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function Ak(e){e.scene.publish.settings.web.preload=!1}function mb(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 gb(e){e.layers&&e.layers.forEach(t=>{ak(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function Mk(e){e.shared.fonts=Qa({},ii.prototype)}function Ek(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 Ck(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=zi.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=Ek(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Xi.defaultData,...il.defaultData,flatShading:!1,wireframe:!1,geometry:{...tl.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:wi(s.states),events:wi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=wi(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 Tk(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:nt.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,vn(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:nt.generateUUID(),data:h},{fi:1,id:nt.generateUUID(),data:u})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function Pk(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={...vn(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...vn(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:nt.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function vb(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Ji.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function yb(e){jn(e,vb),Gn(e,vb)}function Dk(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function Ik(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 Lk(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=zi.defaultTwoLayerData("phong"))})}function Ok(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 Bk(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 Rk(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 zk(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function Nk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function Uk(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function Fk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Vu.defaultDataThirdPerson.navmesh)})})}function kk(e){e.scene.styles||(e.scene.styles=rl.defaultData())}function xb(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function jk(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Gn(e,xb),jn(e,xb)}function Gk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new et})})})}function Vk(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function bb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function Hk(e,t){if(t<1&&(Gn(e,ub),jn(e,ub),e.schema=1),t<2&&(lk(e),e.schema=2),t<3&&(ck(e),e.schema=3),t<4&&(dk(e),e.schema=4),t<5&&(uk(e),e.schema=5),t<6&&(pk(e),e.schema=6),t<7&&(fk(e),e.schema=7),t<8&&(e.schema=8),t<9&&(fb(e),e.schema=9),t<10&&(yk(e),e.schema=10),t<11&&(xk(e),e.schema=11),t<12&&(fb(e),e.schema=12),t<13&&(bk(e),e.schema=13),t<14&&(_k(e),e.schema=14),t<15&&(Sk(e),e.schema=15),t<16&&(Ak(e),e.schema=16),t<17&&(Gn(e,mb),jn(e,mb),e.schema=17),t<18&&(Gn(e,pb),jn(e,pb),e.schema=18),t<19&&(hk(e),e.schema=19),t<20&&(Mk(e),Ck(e),e.schema=20),t<21&&(Tk(e),Pk(e),e.schema=21),t<22&&(yb(e),e.schema=22),t<23&&(Dk(e),e.schema=23),t<24&&(Ik(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(wk(e),t<25&&(e.schema=25)),t<26&&(mk(e),e.schema=26),t<27&&(gk(e),e.schema=27),t<28&&(yb(e),e.schema=28),t<29&&(vk(e),e.schema=29),t<30&&(Lk(e),e.schema=30),t<31&&(Ok(e),e.schema=31),t<33&&(Bk(e),e.schema=33),t<34&&(Rk(e),e.schema=34),t<35&&(zk(e),e.schema=35),t<36&&(Nk(e),e.schema=36),t<37&&(Uk(e),e.schema=37),t<38&&(Gn(e,gb),jn(e,gb),e.schema=38),t<39&&(Fk(e),e.schema=39),t<40&&(kk(e),e.schema=40),t<41&&(jk(e),e.schema=41),t<42&&(Gk(e),e.schema=42),t<43&&(Vk(e),e.schema=43),t<99){Gn(e,bb),jn(e,bb),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Vl);let i=wi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Vh,r.insertBefore(null,null,[{id:Vh,data:{...Ml.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:vn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:vn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Sl.defaultData,...vn(e.scene.environment,"usePhysics","gravity")},camera:wi(e.scene.ownerCamera)??Ml.defaultData.camera,name:"Scene"},children:[]}]);for(let a of i)a.id!==Lg.TRASH_CAN_ID&&r.move(Vh,a.fi,a.id);let s=0,n=0;e.shared.penumbraSize&&e.scene.objects.traverse((a,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(n,1)],n+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,_l.defaultData)),o.physics!==void 0&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function wb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function Wk(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var _b=102;function qk(e){let t=e.schema??0;t!==_b&&(console.warn("updating from ",t,"to ",_b),Hk(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Ga.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Gn(e,wb),jn(e,wb),e.schema=101),t<102&&(Wk(e),e.schema=102))}function Ba(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 qe,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=Sb(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 g=0;g<a[d].length;++g)p.push(a[d][g][u]);let f=Sb(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 Sb(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 Xk=Math.pow(2,-24),gd=class{constructor(){}};function Ps(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 Ab(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 Mb(e,t){t.set(e)}function Eb(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 vd(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 ch(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 Yk(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 Qk(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 Rf(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,g=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],_=e[y+1],A=b-_,S=b+_;A<n&&(n=A),S>l&&(l=S),v&&b<c&&(c=b),v&&b>f&&(f=b);let w=e[y+2],E=e[y+3],C=w-E,T=w+E;C<a&&(a=C),T>h&&(h=T),v&&w<u&&(u=w),v&&w>g&&(g=w);let D=e[y+4],P=e[y+5],L=D-P,R=D+P;L<o&&(o=L),R>d&&(d=R),v&&D<p&&(p=D),v&&D>m&&(m=D)}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]=g,s[5]=m)}function Zk(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 Kk(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 sn=32,Jk=(e,t)=>e.candidate-t.candidate,In=new Array(sn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),yd=new Float32Array(6);function $k(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=Ab(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=Ab(e),a!==-1&&(o=e6(i,r,s,a));else if(n===2){let l=ch(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)/sn;if(s<sn/4){let g=[...In];g.length=s;let m=0;for(let y=d;y<c;y+=6,m++){let x=g[m];x.candidate=i[y+2*u],x.count=0;let{bounds:b,leftCacheBounds:_,rightCacheBounds:A}=x;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,_[S]=1/0,_[S+3]=-1/0,b[S]=1/0,b[S+3]=-1/0;vd(y,i,b)}g.sort(Jk);let v=s;for(let y=0;y<v;y++){let x=g[y];for(;y+1<v&&g[y+1].candidate===x.candidate;)g.splice(y+1,1),v--}for(let y=d;y<c;y+=6){let x=i[y+2*u];for(let b=0;b<v;b++){let _=g[b];x>=_.candidate?vd(y,i,_.rightCacheBounds):(vd(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=g[y],b=x.count,_=s-x.count,A=x.leftCacheBounds,S=x.rightCacheBounds,w=0;b!==0&&(w=ch(A)/l);let E=0;_!==0&&(E=ch(S)/l);let C=1+1.25*(w*b+E*_);C<h&&(a=u,h=C,o=x.candidate)}}else{for(let v=0;v<sn;v++){let y=In[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=d;v<c;v+=6){let y=~~((i[v+2*u]-p)/f);y>=sn&&(y=sn-1);let x=In[y];x.count++,vd(v,i,x.bounds)}let g=In[sn-1];Mb(g.bounds,g.rightCacheBounds);for(let v=sn-2;v>=0;v--){let y=In[v],x=In[v+1];Eb(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<sn-1;v++){let y=In[v],x=y.count,b=y.bounds,_=In[v+1].rightCacheBounds;x!==0&&(m===0?Mb(b,yd):Eb(b,yd,yd)),m+=x;let A=0,S=0;m!==0&&(A=ch(yd)/l);let w=s-m;w!==0&&(S=ch(_)/l);let E=1+1.25*(A*m+S*w);E<h&&(a=u,h=E,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function e6(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 t6(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,n=new Float32Array(s*6),a=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let d=["getX","getY","getZ"];for(let c=0;c<s;c++){let u=c*3,p=c*6,f,g,m;a?(f=r[u+0],g=r[u+1],m=r[u+2]):(f=r[u+0]*h+l,g=r[u+1]*h+l,m=r[u+2]*h+l);for(let v=0;v<3;v++){let y,x,b;a?(y=i[d[v]](f),x=i[d[v]](g),b=i[d[v]](m)):(y=o[f+v],x=o[g+v],b=o[m+v]);let _=y;x<_&&(_=x),b<_&&(_=b);let A=y;x>A&&(A=x),b>A&&(A=b);let S=(A-_)/2,w=v*2;n[p+w+0]=_+S,n[p+w+1]=S+(Math.abs(_)+S)*Xk,_<t[v]&&(t[v]=_),A>t[v+3]&&(t[v+3]=A)}}return n}function i6(e,t){function i(v){u&&u(v/p)}function r(v,y,x,b=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 A=$k(v.boundingData,b,a,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let S=Kk(o,a,y,x,A);if(S===y||S===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let w=new gd,E=y,C=S-y;v.left=w,w.boundingData=new Float32Array(6),Rf(a,E,C,w.boundingData,n),r(w,E,C,n,_+1);let T=new gd,D=S,P=x-C;v.right=T,T.boundingData=new Float32Array(6),Rf(a,D,P,T.boundingData,n),r(T,D,P,n,_+1)}return v}Yk(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=t6(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,g=[],m=Qk(e);if(m.length===1){let v=m[0],y=new gd;y.boundingData=s,Zk(a,v.offset,v.count,n),r(y,v.offset,v.count,n),g.push(y)}else for(let v of m){let y=new gd;y.boundingData=new Float32Array(6),Rf(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),g.push(y)}return g}function r6(e,t){let i=i6(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,g=c.boundingData;for(let m=0;m<6;m++)r[u+m]=g[m];if(f){let m=c.offset,v=c.count;return s[u+6]=m,n[p+14]=v,n[p+15]=65535,d+32}else{let m=c.left,v=c.right,y=c.splitAxis,x;if(x=h(d+32,m),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 Ns=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}};Ns.prototype.setFromBox=function(){let e=new M;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 zq=function(){let e=new Ns;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}}}(),s6=function(){let e=new M,t=new M,i=new M;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,r.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,g,m;f!==0?g=(d*c-p*u)/f:g=0,m=(d+g*c)/u,n.x=g,n.y=m}}(),f0=function(){let e=new F,t=new M,i=new M;return function(r,s,n,a){s6(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}}}}(),n6=function(){let e=new M,t=new M,i=new vr,r=new Ur;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}}(),a6=1e-15;function So(e){return Math.abs(e)<a6}var wn=class extends Bi{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M),this.satBounds=new Array(4).fill().map(()=>new Ns),this.points=[this.a,this.b,this.c],this.sphere=new _r,this.plane=new vr,this.needsUpdate=!0}intersectsSphere(e){return n6(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}};wn.prototype.closestPointToSegment=function(){let e=new M,t=new M,i=new Ur;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]),f0(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)}}();wn.prototype.intersectsTriangle=function(){let e=new wn,t=new Array(3),i=new Array(3),r=new Ns,s=new Ns,n=new M,a=new M,o=new M,l=new M,h=new Ur,d=new Ur,c=new Ur;return function(u,p=null,f=!1){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let g=this.plane,m=u.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let _=0;_<4;_++){let A=v[_],S=y[_];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let x=u.satBounds,b=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let A=x[_],S=b[_];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let _=0;_<4;_++){let A=y[_];for(let S=0;S<4;S++){let w=b[S];if(n.crossVectors(A,w),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let L=v[P],R=v[(P+1)%3];h.start.copy(L),h.end.copy(R),h.delta(a);let V=y?d.start:d.end,k=So(m.distanceToPoint(L));if(So(m.normal.dot(a))&&k){d.copy(h),x=2;break}if((m.intersectLine(h,V)||k)&&!So(V.distanceTo(R))){if(x++,y)break;y=!0}}if(x===1&&u.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(x!==2)return!1;let b=u.points,_=!1,A=0;for(let P=0;P<3;P++){let L=b[P],R=b[(P+1)%3];h.start.copy(L),h.end.copy(R),h.delta(o);let V=_?c.start:c.end,k=So(g.distanceToPoint(L));if(So(g.normal.dot(o))&&k){c.copy(h),A=2;break}if((g.intersectLine(h,V)||k)&&!So(V.distanceTo(R))){if(A++,_)break;_=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==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),w=d.end.dot(a),E=c.start.dot(a),C=c.end.dot(a),T=w<E,D=S<C;return S!==C&&E!==w&&T===D?!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)}}}();wn.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();wn.prototype.distanceToTriangle=function(){let e=new M,t=new M,i=["a","b","c"],r=new Ur,s=new Ur;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],g=i[(p+1)%3];s.set(n[f],n[g]),f0(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Us=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new M,this.max=new M,this.matrix=new fe,this.invMatrix=new fe,this.points=new Array(8).fill().map(()=>new M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new Ns),this.alignedSatBounds=new Array(3).fill().map(()=>new Ns),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Us.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}}();Us.prototype.intersectsBox=function(){let e=new Ns;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}}();Us.prototype.intersectsTriangle=function(){let e=new wn,t=new Array(3),i=new Ns,r=new Ns,s=new M;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}}();Us.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}}();Us.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Us.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Ur),i=new Array(12).fill().map(()=>new Ur),r=new M,s=new M;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 g=0;g<8;g++){let m=u[g];s.copy(m).clamp(d,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(g+1)%3,x=(g+2)%3,b=m<<y|v<<x,_=1<<g|m<<y|v<<x,A=u[b],S=u[_];t[f].set(A,S);let w=e[g],E=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[w]=d[w],D[E]=m?d[E]:c[E],D[C]=v?d[C]:c[E],P[w]=c[w],P[E]=m?d[E]:c[E],P[C]=v?d[C]:c[E],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=g?c.x:d.x,s.y=m?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 g=0;g<12;g++){let m=t[g];for(let v=0;v<12;v++){let y=i[v];f0(m,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 Ao=new M,Mo=new M,Eo=new M,xd=new F,bd=new F,wd=new F,Cb=new M,Tb=new M,Pb=new M,_d=new M;function o6(e,t,i,r,s,n){let a;return n===xi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==yr,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function l6(e,t,i,r,s,n,a,o,l){Ao.fromBufferAttribute(t,n),Mo.fromBufferAttribute(t,a),Eo.fromBufferAttribute(t,o);let h=o6(e,Ao,Mo,Eo,_d,l);if(h){r&&(xd.fromBufferAttribute(r,n),bd.fromBufferAttribute(r,a),wd.fromBufferAttribute(r,o),h.uv=Bi.getInterpolation(_d,Ao,Mo,Eo,xd,bd,wd,new F)),s&&(xd.fromBufferAttribute(s,n),bd.fromBufferAttribute(s,a),wd.fromBufferAttribute(s,o),h.uv1=Bi.getInterpolation(_d,Ao,Mo,Eo,xd,bd,wd,new F)),i&&(Cb.fromBufferAttribute(i,n),Tb.fromBufferAttribute(i,a),Pb.fromBufferAttribute(i,o),h.normal=Bi.getInterpolation(_d,Ao,Mo,Eo,Cb,Tb,Pb,new M),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let d={a:n,b:a,c:o,normal:new M,materialIndex:0};Bi.getNormal(Ao,Mo,Eo,d.normal),h.face=d,h.faceIndex=n}return h}function VA(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),{position:h,normal:d,uv:c,uv1:u}=e.attributes,p=l6(i,h,d,c,u,a,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function h6(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)VA(e,t,i,a,n)}function c6(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=VA(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}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 Db(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 HA=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 Vn(e,t){return t[e+15]===65535}function sl(e,t){return t[e+6]}function dc(e,t){return t[e+14]}function uc(e){return e+8}function pc(e,t){return t[e+6]}function d6(e,t){return t[e+7]}var Zo=new Kt,Hu=new M,u6=["x","y","z"];function Rg(e,t,i,r,s){let n=e*2,a=Hl,o=ta,l=ia;if(Vn(n,o)){let h=sl(e,l),d=dc(n,o);h6(t,i,r,h,d,s)}else{let h=uc(e);Wu(h,a,r,Hu)&&Rg(h,t,i,r,s);let d=pc(e,l);Wu(d,a,r,Hu)&&Rg(d,t,i,r,s)}}function zg(e,t,i,r){let s=e*2,n=Hl,a=ta,o=ia;if(Vn(s,a)){let l=sl(e,o),h=dc(s,a);return c6(t,i,r,l,h)}else{let l=d6(e,o),h=u6[l],d=r.direction[h]>=0,c,u;d?(c=uc(e),u=pc(e,o)):(c=pc(e,o),u=uc(e));let p=Wu(c,n,r,Hu)?zg(c,t,i,r):null;if(p){let g=p.point[h];if(d?g<=n[u+l]:g>=n[u+l+3])return p}let f=Wu(u,n,r,Hu)?zg(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var p6=function(){let e,t,i=[],r=new HA(()=>new Kt);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,b=ta,_=ia;for(;!Vn(x,b);)y=uc(y),x=y*2;return sl(y,_)}function p(y){let x=y*2,b=ta,_=ia;for(;!Vn(x,b);)y=pc(y,_),x=y*2;return sl(y,_)+dc(x,b)}let f=n*2,g=Hl,m=ta,v=ia;if(Vn(f,m)){let y=sl(n,v),x=dc(f,m);return Ps(n,g,e),l(y,x,!1,c,d+n,e)}else{let y=uc(n),x=pc(n,v),b=y,_=x,A,S,w,E;if(h&&(w=e,E=t,Ps(b,g,w),Ps(_,g,E),A=h(w),S=h(E),S<A)){b=x,_=y;let V=A;A=S,S=V,w=E}w||(w=e,Ps(b,g,w));let C=Vn(b*2,m),T=o(w,C,A,c+1,d+b),D;if(T===2){let V=u(b),k=p(b)-V;D=l(V,k,!0,c+1,d+b,w)}else D=T&&s(b,a,o,l,h,d,c+1);if(D)return!0;E=t,Ps(_,g,E);let P=Vn(_*2,m),L=o(E,P,S,c+1,d+_),R;if(L===2){let V=u(_),k=p(_)-V;R=l(V,k,!0,c+1,d+_,E)}else R=L&&s(_,a,o,l,h,d,c+1);return!!R}}}(),f6=function(){let e=new wn,t=new wn,i=new fe,r=new Us,s=new Us;return function n(a,o,l,h,d=null){let c=a*2,u=Hl,p=ta,f=ia;if(d===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),d=r),Vn(c,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,x=l.attributes.position,b=sl(a,f),_=dc(c,p);if(i.copy(h).invert(),l.boundsTree)return Ps(a,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>s.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=b*3,w=(_+b)*3;S<w;S+=3)if(Ms(t,S,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,S=_+b*3;A<S;A+=3){Ms(e,A,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let w=0,E=y.count;w<E;w+=3)if(Ms(t,w,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=a+8,m=f[a+6];return Ps(g,u,Zo),!!(d.intersectsBox(Zo)&&n(g,o,l,h,d)||(Ps(m,u,Zo),d.intersectsBox(Zo)&&n(m,o,l,h,d)))}}}();function Wu(e,t,i,r){return Ps(e,t,Zo),i.intersectBox(Zo,r)}var Ng=[],ru,Hl,ta,ia;function Lh(e){ru&&Ng.push(ru),ru=e,Hl=new Float32Array(e),ta=new Uint16Array(e),ia=new Uint32Array(e)}function Sd(){ru=null,Hl=null,ta=null,ia=null,Ng.length&&Lh(Ng.pop())}var zf=Symbol("skip tree generation"),Nf=new Kt,Uf=new Kt,Co=new fe,ba=new Us,dh=new Us,uh=new M,Ad=new M,m6=new M,g6=new M,v6=new M,Ib=new Kt,ps=new HA(()=>new wn),Hh=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."),Hh.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."),Hh.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 Hh(t,{...i,[zf]:!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,[zf]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[zf]||(this._roots=r6(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Kt))),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,n,a,o,l=0,h=this._roots;for(let c=0,u=h.length;c<u;c++)s=h[c],n=new Uint32Array(s),a=new Uint16Array(s),o=new Float32Array(s),d(0,l),l+=s.byteLength;function d(c,u,p=!1){let f=c*2;if(a[f+15]===65535){let g=n[c+6],m=a[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,_=-1/0,A=-1/0;for(let S=3*g,w=3*(g+m);S<w;S++){let E=i[S],C=r.getX(E),T=r.getY(E),D=r.getZ(E);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>_&&(_=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==_||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=_,o[c+5]=A,!0):!1}else{let g=c+8,m=n[c+6],v=g+u,y=m+u,x=p,b=!1,_=!1;e?x||(b=e.has(v),_=e.has(y),x=!b&&!_):(b=!0,_=!0);let A=x||b,S=x||_,w=!1;A&&(w=d(g,u,x));let E=!1;S&&(E=d(m,u,x));let C=w||E;if(C)for(let T=0;T<3;T++){let D=g+T,P=m+T,L=o[D],R=o[D+3],V=o[P],k=o[P+3];o[c+T]=L<V?L:V,o[c+T+3]=R>k?R:k}return C}}}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=ns){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(Lh(i[h]),Rg(0,r,c,e,s),Sd(),a){let p=o[h].materialIndex;for(let f=u,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=ns){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;Lh(i[h]);let u=zg(0,r,c,e);Sd(),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(Lh(s),r=f6(0,i,e,t),Sd(),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,g)=>{let m=p*3;return c(u,m,m+1,m+2,f,g)}}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=ps.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(u,p,f,g,m)=>c(u,p,f,g,m)?!0:Db(u,p,r,l,f,g,s)}else o||(l?o=(c,u,p,f)=>Db(c,u,r,l,p,f,s):o=(c,u,p)=>p);let h=!1,d=0;for(let c of this._roots){if(Lh(c),h=p6(0,r,a,o,n,d),Sd(),h)break;d+=c.byteLength}return ps.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;Co.copy(t).invert();let h=ps.getPrimitive(),d=ps.getPrimitive();if(s){let u=function(p,f,g,m,v,y,x,b){for(let _=g,A=g+m;_<A;_++){Ms(d,_*3,o,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=p,w=p+f;S<w;S++)if(Ms(h,S*3,n,a),h.needsUpdate=!0,s(h,d,S,_,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,x,b,_){return p(f,g,m,v,y,x,b,_)?!0:u(f,g,m,v,y,x,b,_)}}else r=u}e.getBoundingBox(Uf),Uf.applyMatrix4(t);let c=this.shapecast({intersectsBounds:u=>Uf.intersectsBox(u),intersectsRange:(u,p,f,g,m,v)=>(Nf.copy(v),Nf.applyMatrix4(Co),e.shapecast({intersectsBounds:y=>Nf.intersectsBox(y),intersectsRange:(y,x,b,_,A)=>r(u,p,y,x,g,m,_,A)}))});return ps.releasePrimitive(h),ps.releasePrimitive(d),c}intersectsBox(e,t){return ba.set(e.min,e.max,t),ba.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ba.intersectsBox(i),intersectsTriangle:i=>ba.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(),ba.set(e.boundingBox.min,e.boundingBox.max,t),ba.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,d=e.index,c=ps.getPrimitive(),u=ps.getPrimitive(),p=Ad,f=m6,g=null,m=null;r&&(g=g6,m=v6);let v=1/0,y=null,x=null;return Co.copy(t).invert(),dh.matrix.copy(Co),this.shapecast({boundsTraverseOrder:b=>ba.distanceToBox(b),intersectsBounds:(b,_,A)=>A<v&&A<n?(_&&(dh.min.copy(b.min),dh.max.copy(b.max),dh.needsUpdate=!0),!0):!1,intersectsRange:(b,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>dh.distanceToBox(A),intersectsBounds:(A,S,w)=>w<v&&w<n,intersectsRange:(A,S)=>{for(let w=A*3,E=(A+S)*3;w<E;w+=3){Ms(u,w,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=b*3,T=(b+_)*3;C<T;C+=3){Ms(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(u,p,g);if(D<v&&(f.copy(p),m&&m.copy(g),v=D,y=C/3,x=w/3),D<s)return!0}}}});{let A=d?d.count:h.count;for(let S=0,w=A;S<w;S+=3){Ms(u,S,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let E=b*3,C=(b+_)*3;E<C;E+=3){Ms(c,E,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(u,p,g);if(T<v&&(f.copy(p),m&&m.copy(g),v=T,y=E/3,x=S/3),T<s)return!0}}}}}),ps.releasePrimitive(c),ps.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(m):r.point=m.clone(),r.point.applyMatrix4(Co),f.applyMatrix4(Co),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=>(uh.copy(e).clamp(h.min,h.max),uh.distanceToSquared(e)),intersectsBounds:(h,d,c)=>c<a&&c<n,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,uh);let c=e.distanceToSquared(uh);return c<a&&(Ad.copy(uh),a=c,o=d),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Ad):t.point=Ad.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Ps(0,new Float32Array(t),Ib),e.union(Ib)}),e}},ph=Pl(OE()),y6=.5*(Math.sqrt(3)-1),fh=(3-Math.sqrt(3))/6,x6=1/3,fs=1/6,Nq=(Math.sqrt(5)-1)/4,Uq=(5-Math.sqrt(5))/20,Wh=e=>Math.floor(e)|0,Lb=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]),Ff=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 kf(e=Math.random){let t=WA(e),i=new Float64Array(t).map(s=>Lb[s%12*2]),r=new Float64Array(t).map(s=>Lb[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*y6,d=Wh(s+h),c=Wh(n+h),u=(d+c)*fh,p=d-u,f=c-u,g=s-p,m=n-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let x=g-v+fh,b=m-y+fh,_=g-1+2*fh,A=m-1+2*fh,S=d&255,w=c&255,E=.5-g*g-m*m;if(E>=0){let D=S+t[w],P=i[D],L=r[D];E*=E,a=E*E*(P*g+L*m)}let C=.5-x*x-b*b;if(C>=0){let D=S+v+t[w+y],P=i[D],L=r[D];C*=C,o=C*C*(P*x+L*b)}let T=.5-_*_-A*A;if(T>=0){let D=S+1+t[w+1],P=i[D],L=r[D];T*=T,l=T*T*(P*_+L*A)}return 70*(a+o+l)}}function b6(e=Math.random){let t=WA(e),i=new Float64Array(t).map(n=>Ff[n%12*3]),r=new Float64Array(t).map(n=>Ff[n%12*3+1]),s=new Float64Array(t).map(n=>Ff[n%12*3+2]);return function(n,a,o){let l,h,d,c,u=(n+a+o)*x6,p=Wh(n+u),f=Wh(a+u),g=Wh(o+u),m=(p+f+g)*fs,v=p-m,y=f-m,x=g-m,b=n-v,_=a-y,A=o-x,S,w,E,C,T,D;b>=_?_>=A?(S=1,w=0,E=0,C=1,T=1,D=0):b>=A?(S=1,w=0,E=0,C=1,T=0,D=1):(S=0,w=0,E=1,C=1,T=0,D=1):_<A?(S=0,w=0,E=1,C=0,T=1,D=1):b<A?(S=0,w=1,E=0,C=0,T=1,D=1):(S=0,w=1,E=0,C=1,T=1,D=0);let P=b-S+fs,L=_-w+fs,R=A-E+fs,V=b-C+2*fs,k=_-T+2*fs,z=A-D+2*fs,X=b-1+3*fs,H=_-1+3*fs,G=A-1+3*fs,N=p&255,q=f&255,j=g&255,W=.6-b*b-_*_-A*A;if(W<0)l=0;else{let re=N+t[q+t[j]];W*=W,l=W*W*(i[re]*b+r[re]*_+s[re]*A)}let U=.6-P*P-L*L-R*R;if(U<0)h=0;else{let re=N+S+t[q+w+t[j+E]];U*=U,h=U*U*(i[re]*P+r[re]*L+s[re]*R)}let ie=.6-V*V-k*k-z*z;if(ie<0)d=0;else{let re=N+C+t[q+T+t[j+D]];ie*=ie,d=ie*ie*(i[re]*V+r[re]*k+s[re]*z)}let Q=.6-X*X-H*H-G*G;if(Q<0)c=0;else{let re=N+1+t[q+1+t[j+1]];Q*=Q,c=Q*Q*(i[re]*X+r[re]*H+s[re]*G)}return 32*(l+h+d+c)}}function WA(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 Xr=new Bi,w6=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;Xr.a.fromBufferAttribute(e,r),Xr.b.fromBufferAttribute(e,r+1),Xr.c.fromBufferAttribute(e,r+2),s*=Xr.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),Xr.a.fromBufferAttribute(this.positionAttribute,e*3),Xr.b.fromBufferAttribute(this.positionAttribute,e*3+1),Xr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Xr.a,r).addScaledVector(Xr.b,s).addScaledVector(Xr.c,1-(r+s)),Xr.getNormal(i),this}},_6=Pl(O_()),S6=new fe,A6=new fe,M6=new fe,fc;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(fc||(fc={}));var m0=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new fe,this.copyPreviousMatrix=!0,this.hiddenMatrix=new fe,this.matrixWorldRigid=new fe,this.shearScale=new fe,this.shearScaleInv=new fe}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Mt&&(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)}traverseChildren(t,i=0){for(let r of this.children)fc.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)fc.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,_6.SVD)(i),a=S6.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=A6.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=M6.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 fe().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof fe?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},E6=class extends m0(Mt){},C6=e=>e.type==="Mesh",Ri=class extends E6{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 Ri(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 C6(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}},Pa=new M,Da=new M,nl=new fe,qA=[new M(-1,1,1),new M(-1,-1,1),new M(1,-1,1),new M(1,1,1),new M(-1,1,-1),new M(-1,-1,-1),new M(1,-1,-1),new M(1,1,-1)],T6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],P6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Ob=(e,t,i)=>{e.updateEntityBoxSize(Pa,Da),nl.copy(t).multiply(e.matrixWorld),Da.x===0&&Da.y===0&&Da.z===0?i.push(new M(Pa.x,Pa.y,Pa.z).applyMatrix4(nl)):qA.forEach(r=>{i.push(r.clone().multiply(Da).add(Pa).applyMatrix4(nl))})},Bb=class extends Kt{constructor(){super(...arguments),this.matrix=new fe,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 fe().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 M);return}Ob(s,t,r)}}):Ob(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(nl.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Da).multiplyScalar(.5),this.getCenter(Pa),nl.copy(this.matrix).setPosition(Pa),this.vertices=qA.map(e=>e.clone().multiply(Da).applyMatrix4(nl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=T6.map(([e,t])=>new Ur(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new M))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=P6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},Qn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},D6=class extends oS{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}},Ug=.001;function Fg(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Ug}function jf(e,t){let i=new M(...e.position),r=new M(...e.controlNext.position),s=new M(...t.controlPrevious.position),n=new M(...t.position);return Fg(i,r,n)&&Fg(i,s,n)}function XA(e){let t=e.points.map(d=>new M(...d.data.position)),i=[e.points[0]],r=new M(...i[0].data.position);for(let d=0;d<e.points.length-1;d++)Fg(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 M(...c.position),p=new M(...c.controlPrevious.position),f=new M(...c.controlNext.position),g={position:u,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(d===0||d===a-1)){o[d]={...g,removedLength:0};continue}let m=s&&d==0?a-1:d-1,v=s&&d==a-1?0:d+1,y=i[m].data,x=i[v].data,b=new M(...y.position),_=new M(...x.position),A=b.clone().sub(u).normalize(),S=_.clone().sub(u).normalize();Object.assign(g,{prevDir:A,nextDir:S});let w=jf(y,c),E=jf(c,x);if(!w||!E)o[d]={...g,removedLength:0};else{let C=A.clone().add(S).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[d]={...g,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 g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/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],g=null;if(!jf(i[c].data,i[u].data))p.position.distanceTo(f.position)>Ug&&(g=new Jd(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>Ug&&(g=new Jd(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*d+1]=g}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),g=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),b=m.clone().multiplyScalar(-g).add(x),_=u.distanceTo(b)/u.distanceTo(v),A=c.prevDir.clone().multiplyScalar(_*u.distanceTo(p)).add(u),S=A.clone().lerp(b,2),w=p.clone().lerp(A,4/3),E=f.clone().lerp(S,4/3);l[2*d]=new Jd(p,w,E,f)}let h=new D6;return l.forEach(d=>{d&&h.add(d)}),h}var ut;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ut||(ut={}));var cn=e=>ut.is(e),I6={type:"completeState",isfromEntity:!0},g0=e=>class extends m0(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 Bb,this._recursiveBBox=new Bb,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(ut.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ut.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ut.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)Oa.toOps(this.data,s.data).forEach(n=>{let a=ig.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=Oa.patch(this.data,s),Oa.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(ut.is(i[r]))return i[r];if(ut.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ut.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=>{ut.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)cn(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}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 tg(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??bl.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)ut.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ut.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return tg(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=zr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let c=Ls.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=Ls.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Oa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),zr(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($n.apply(c.component.data,c.overrideData),r))}}else{let d=r.scene.findInstance([this.uuid,...l]);if(d){let c=Ls.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=ku.resolve(i.overrides,l),d.updateByOp(t,wr.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 Yn.rootOverrideProps)d in t.props&&(h===void 0&&(h={}),h[d]=t.props[d]);h&&(l={...t,props:h})}else for(let h of Yn.rootOverrideProps)if(zr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=$n.filterOp(h.overrideData,l);d&&h.updateByOp(d,wr.applySimple(h.data,d),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=$n.filterOp(h.overrideData,t);if(d){let c;n===h.data&&t===d?c=i:c=wr.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&&!Za.is(t.props.type)&&Qn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Qn.changeEntityProptotype(this,i,r);for(let s of this.children)ut.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),zr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),zr(t.path,["cloner"])!==null){let s=wr.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;if(o.geometry.path.points.length<=1)return;let l=XA(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 fe;a.updateMatrixWorld();let u=new fe().multiplyMatrices(c.clone().invert(),a.matrixWorld);d.applyMatrix4(u);let p={position:d.toArray(),rotation:o.rotation};if(n==="tangential"){let f=new fe().extractRotation(a.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(d),m=new fe().lookAt(d,g,new M(0,1,0)),v=new yi().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(I6)})}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()),i&&"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 Qn.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 Qn.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)}},YA=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 QA(h,d,r,s,n,a,o,l*Math.PI/180,c,c,u,p):f=new Lv(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 Ln(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Rb(e){return new F(e.y,-e.x)}var QA=class extends qe{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=[],g=[],m=[],v=0,y=i/2,x=new M,b=new M;u&&e==0&&(e=l),u&&t==0&&(t=h);let _=new F(e,y),A=new F(t,-y),S=null,w=null,E=null,C=null,T=_.clone().sub(A),D=0,P=0,L=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,L=t-D);let R=_.clone();R.x-=D;let V=Math.PI-T.angle(),k=T.angle(),z=Math.tan(k/2),X=Math.tan(V/2),H=z+X,G=c?H:X,N=c?H:z;if(l=Math.min(l,(e-P)/G,T.length()/H),h=Math.min(h,(t-L)/N,T.length()/H),l>0){let Q=l/z;S=_.clone().sub(new F(Q,l)),c&&(E=S.clone(),E.x-=D-H*l),_.sub(T.clone().setLength(Q))}if(h>0){let Q=h/X;w=A.clone().sub(new F(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=w.clone(),C.x-=D-H*h,R.sub(T.clone().setLength(Q)))}T=_.clone().sub(A);let q=T.length()<.5,j=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,ue=Z*o+a,ae=new F(Math.sin(ue),Math.cos(ue));C&&w?(W(re,Z,ae,V,h,C,-1,!0),W(re,Z,ae,k,h,w,-1,!1)):w?(U(re,ae,w.x,0,-1),W(re,Z,ae,k,h,w,-1,!1)):n||U(re,ae,t,L,-1);let se=Rb(T).normalize();if(Ln(se,ae,x),!q)for(let Ae=0;Ae<=s;Ae++){let Se=Ae/s,Me=T.clone().multiplyScalar(Se).add(A);Ln(Me,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}if(E&&S?(W(re,Z,ae,V,l,S,1,!1),W(re,Z,ae,k,l,E,1,!0)):S?(W(re,Z,ae,V,l,S,1,!1),U(re,ae,S.x,0,1)):n||U(re,ae,e,P,1),c&&!q){let Ae=Rb(T).multiplyScalar(-1).normalize();Ln(Ae,ae,x);for(let Se=0;Se<=s;Se++){let Me=Se/s,Pe=T.clone().multiplyScalar(-Me).add(R);Ln(Pe,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}}c&&!n&&re.push(re[0]),j.push(re)}for(let Q=0;Q<j.length-1;Q++)for(let re=0;re<j[0].length-1;re++){if(n&&c&&re==s)continue;let Z=j[Q][re],ue=j[Q+1][re],ae=j[Q+1][re+1],se=j[Q][re+1],Ae=f[ae*3+0],Se=f[ae*3+2];p.push(Z,ue,se),(Ae!=0||Se!=0)&&p.push(ue,ae,se)}o<Math.PI*2&&(ie(-1,j[0],a),ie(1,j[j.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Le(f,3)),this.setAttribute("normal",new Le(g,3)),this.setAttribute("uv",new Le(m,2));function W(Q,re,Z,ue,ae,se,Ae,Se){for(let Me=0;Me<d+1;Me++){let Pe=Me/d,xe=Ae<0?Pe:1-Pe;Se&&(xe-=1),xe*=ue;let ve=new F(Math.sin(xe),Math.cos(xe)*Ae),Re=ve.clone().multiplyScalar(ae).add(se);Ln(Re,Z,b),f.push(b.x,b.y,b.z),Ln(ve,Z,x),g.push(x.x,x.y,x.z),m.push(re,.5+b.y/i),Q.push(v++)}}function U(Q,re,Z,ue,ae){let se=new M,Ae=new F,Se=[Z,ue];ae<0&&Se.reverse();for(let Me of Se)Ae.set(Me,y*ae),Ln(Ae,re,se),f.push(se.x,se.y,se.z),g.push(0,ae,0),m.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let ue=new F(Math.sin(Z),Math.cos(Z)),ae=new F(-Math.cos(Z),Math.sin(Z)),se=new M,Ae=Q<0?(Pe,xe,ve)=>p.push(Pe,xe,ve):(Pe,xe,ve)=>p.push(Pe,ve,xe),Se=new F((e+t+P+L)/4,0);Ln(Se,ue,se),f.push(se.x,se.y,se.z),g.push(ae.x,0,ae.y),m.push(.5,.5);let Me=v++;for(let Pe of re){let xe=f.slice(Pe*3,Pe*3+3);f.push(...xe),g.push(ae.x,0,ae.y);let ve=m.slice(Pe*2,Pe*2+2);m.push(...ve),v++}for(let Pe=Me+1;Pe<v-1;Pe++)Ae(Me,Pe,Pe+1);Ae(Me,v-1,Me+1)}}},L6=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 QA(0,t/2,r,s,n,a,o,l*Math.PI/180,h,d,c,0,!0):u=new hS(t/2,r,s,n,a),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},O6=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 Rs(t,i,r,s,n,a):h=new B6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Gf=Math.PI/2,B6=class extends qe{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;g("z","y","x",-1,-1,i,t,e,n,s,0),g("z","y","x",1,-1,i,t,-e,n,s,1),g("x","z","y",1,1,e,i,t,r,n,2),g("x","z","y",1,-1,e,i,-t,r,n,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("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 Le(d,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(u,2));function g(y,x,b,_,A,S,w,E,C,T,D){let P=(S-2*a)/C,L=(w-2*a)/T,R=S/2-a,V=w/2-a,k=E/2,z=C+1,X=T+1,H=0,G=0,N=new M;for(let q=0;q<X;q++){let j=q*L-V;for(let W=0;W<z;W++){let U=W*P-R;N[y]=U*_,N[x]=j*A,N[b]=k,d.push(N.x,N.y,N.z),N[y]=0,N[x]=0,N[b]=E>0?1:-1,c.push(N.x,N.y,N.z),u.push(W/C),u.push(1-q/T),H+=1}}for(let q=0;q<T;q++)for(let j=0;j<C;j++){let W=p+j+z*q,U=p+j+z*(q+1),ie=p+(j+1)+z*(q+1),Q=p+(j+1)+z*q;h.push(W,U,Q),h.push(U,ie,Q),G+=6}l.addGroup(f,G,D),f+=G,p+=H}function m(y,x,b,_,A,S,w,E,C,T,D){let P=(w-2*a)/T,L=w/2-a,R=E/2-a,V=C/2,k=T+1,z=0,X=0,H=new M,G=new M;for(let N=0;N<o+1;N++){let q=N/o*Gf,j=Math.sin(q)*a,W=(1-Math.cos(q))*a,U=Math.sin(q),ie=Math.cos(q);H[x]=(R+j)*A,H[b]=(V-W)*S,G[y]=0,G[x]=U*Math.sign(H[x]),G[b]=ie*Math.sign(H[b]);for(let Q=0;Q<k;Q++){let re=Q*P-L;H[y]=re*_,d.push(H.x,H.y,H.z),c.push(G.x,G.y,G.z),u.push(Q/T),u.push(0),z+=1}}for(let N=0;N<o;N++)for(let q=0;q<T;q++){let j=p+q+k*N,W=p+q+k*(N+1),U=p+(q+1)+k*(N+1),ie=p+(q+1)+k*N;h.push(j,W,ie),h.push(W,U,ie),X+=6}l.addGroup(f,X,D),f+=X,p+=z}function v(y,x,b){let _=new M,A=new M(e/2,t/2,i/2);A.subScalar(a);let S=[],w=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=Gf*(1-C/o),P=Math.cos(D),L=Math.sin(D),R=0;for(let V=0;V<=C;V++){let k=Math.cos(R),z=Math.sin(R);_.x=P*k,_.y=L,_.z=P*z;let X=A.clone().addScaledVector(_,a);d.push(y*X.x,x*X.y,b*X.z),c.push(y*_.x,x*_.y,b*_.z),u.push(0,0),T.push(p++),R+=Gf/C}S.push(T)}let E=S.length-1;for(let C=0;C<E;C++){let T=S[C],D=S[C+1],P=T.length-1;w(T[0],D[1],D[0]);for(let L=1;L<=P;L++)w(T[L-1],T[L],D[L]),w(T[L],D[L+1],D[L])}}}},v0=class extends qe{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),d(),this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(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 M,p=u.clone(),f=new Bi,g=s*r,m=r-g,v=n+1,y=new M,x=(k,z)=>y.subVectors(k,z).normalize(),b=(k,z)=>Array(k).fill(void 0).map(z),_=b(e.length/3,(k,z)=>new M().fromArray(e,z*3).setLength(r)),A=[],S=1e6;for(let k=0;k<_.length;k++){let z=_[k],X=[],H,G,N,q=1e10,j=-1;for(;(j=t.indexOf(k,j+1))!=-1;){let Q=j-j%3;H=t[Q+(j+1)%3],G=t[Q+(j+2)%3],N=z.distanceToSquared(_[H]),q=Math.min(q,N),X.push([H,G,N])}q+=1e-6;let W=[],U=0,ie=X.length;for(let Q=0;Q<ie;Q++){[H,G,N]=X[U];let re=A[H]?.includes(k)==!0;N<=q&&W.push(H+ +re*S),U=X.findIndex(Z=>Z[0]==G)}A.push(W)}let w=[];{let k=0,z=0,X,H,G=c==3;for(let N=0;N<=n;N++){X=N*(N+1)/2,H=(N+1)*(N+2)/2;for(let q=0;q<n-N;q++)[k,z]=[X+q+N+2,H+q+N+3],w.push(X,H,...G?[z,X]:[k,H],z,k),[X,H]=[k,z];w.push(X,H,X+n+2)}}let E=u.clone(),C=u.clone(),T=u.clone(),D=u.clone(),P=u.clone(),L=[],R=b(_.length,()=>b(c,()=>u.clone()));for(let k=0;k<_.length;k++){u.copy(_[k]).normalize(),E.copy(u).multiplyScalar(m);let z=A[k];for(let W=0;W<z.length;W++){let U=z[W],ie=z[(W+1)%c];f.setFromPointsAndIndices(_,k,U%S,ie%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(E,R[k][W])}let X=[],H=[],G=[],N=new M;n==0&&[...R[k]].reduce((W,U)=>W.add(U),N).multiplyScalar(1/c);for(let W=0;W<c;W++){let U=[],ie=(W-1+c)%c,Q=R[k][ie],re=R[k][W];u.copy(Q).sub(E),p.copy(re).sub(E);let Z=E.angleTo(u),ue=u.angleTo(p),ae=Math.cos(Z)*g;n==0?C.copy(N):C.copy(E).setLength(m+ae),H.push(ae);let se=[C,Q,re];for(let Ae=0;Ae<2;Ae++){let Se=se[Ae],Me=se[Ae+1];D.subVectors(Se,E),P.subVectors(Me,E),T.crossVectors(D,P).normalize();for(let Pe=0;Pe<v;Pe++){let xe=[Z,ue][Ae]*Pe/v;u.copy(D).applyAxisAngle(T,xe).add(E),X.push(u.clone()),Ae&&(x(u,E),U.push([Pe==0?Se:u.clone(),y.clone()]))}Ae&&(x(Me,E),U.push([Me,y.clone()]))}G.push(U)}L.push(G);let q=2*v,j=2;for(let W=0;W<c;W++){let U=q*W,ie=q*((W+1)%c),Q=[X[U]];for(let Z=1;Z<v;Z++){D=X[U+Z],P=X[ie+Z],Q.push(D);for(let ue=1,ae=Z-j+1;ue<=ae;ue++)u.lerpVectors(D,P,ue/(ae+1)),u.sub(E).setLength(H[W]).add(E),Q.push(u.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(X[Z+v+U]);Q.push(X[ie+v]);let re=w.map(Z=>Q[Z]);a.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,E),[y.x,y.y,y.z])).flat())}}let V=[];for(let k=0;k<A.length;k++)for(let z=0;z<c;z++){let X=A[k][z];if(X<S){let H=A[X].findIndex(q=>q%S==k),G=L[k][z],N=L[X][H];for(let q=0;q<v;q++){let j=G[q],W=N[v-q],U=G[q+1],ie=N[v-(q+1)];[j,W,U,U,W,ie].forEach(Q=>{a.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}V.push(G[0][0],N[v][0],G[v][0],N[0][0])}}for(;V.length;){let k,z,X,H;[k,z]=V.splice(0,2);let G=[k];for(;k!=z;)G.push(z),X=V.indexOf(z),H=X%2,z=V.splice(X-H,2)[1-H];y.subVectors(G[0],G[1]).cross(u.subVectors(G[0],G[2])).normalize();let N=y.dot(G[0])<0;N&&y.negate();for(let q=1;q<=G.length-2;q++)[G[q+ +N],G[q+1-+N],G[0]].forEach(j=>{a.push(j.x,j.y,j.z),l.push(y.x,y.y,y.z)})}}function d(){let c=new M;for(let A=0;A<a.length;A+=3){c.x=a[A+0],c.y=a[A+1],c.z=a[A+2];let S=b(c)/2/Math.PI+.5,w=_(c)/Math.PI+.5;o.push(S,1-w)}let u=new M,p=new M,f=new M,g=new M,m=new F,v=new F,y=new F,x=(A,S,w,E)=>{E<0&&A.x===1&&(o[S]=A.x-1),w.x===0&&w.z===0&&(o[S]=E/2/Math.PI+.5)};for(let A=0,S=0;A<a.length;A+=9,S+=6){u.set(a[A+0],a[A+1],a[A+2]),p.set(a[A+3],a[A+4],a[A+5]),f.set(a[A+6],a[A+7],a[A+8]),m.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),y.set(o[S+4],o[S+5]),g.copy(u).add(p).add(f).divideScalar(3);let w=b(g);x(m,S+0,u,w),x(v,S+2,p,w),x(y,S+4,f,w)}for(let A=0;A<o.length;A+=6){let S=o[A+0],w=o[A+2],E=o[A+4],C=Math.max(S,w,E),T=Math.min(S,w,E);C>.9&&T<.1&&(S<.2&&(o[A+0]+=1),w<.2&&(o[A+2]+=1),E<.2&&(o[A+4]+=1))}function b(A){return Math.atan2(A.z,-A.x)}function _(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new v0(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},R6=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 ZA(t*.5,n,a):new cS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},ZA=class extends v0{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 ZA(e.radius,e.corner,e.cornerSides)}},mh=1e-12,y0=class{constructor(e){this.position=new F,this.startPosition=new F,this.uuid=nt.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 y0(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},kg=class extends y0{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new kg(this.parent).copy(this)}},al=class extends y0{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new kg(this),new kg(this))}static create(e,t){let i=new al(e,new F(...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 al(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 F,t=new F){let[i,r]=this.computeTangents();return i&&r&&(zb(i,e),zb(r,t)),[e,t]}computeTangent(e=new F){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new F){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function zb(e,t=new F){let i=e.length();return t.set(-e.y/i,e.x/i)}var x0=e=>e,Wl=new F,wp=new F,z6=new F,N6=new F,U6=new F,F6=new F,KA=new M,JA=new M;function k6(e){let t=new F;t.addVectors(e.v0,Wl.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new F;return i.addVectors(e.v2,wp.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new $r(e.v0,t,i,e.v2)}function Oh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function j6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function G6(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function $A(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 V6(e,t,i){return Ub(e,t)&&Ub(t,i)&&jg(e.position,t.position,i.position)}function jg(e,t,i){return Wl.copy(t).sub(e).cross(wp.copy(i).sub(e))===0}function H6(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 W6(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function q6(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 $A(t,e,i)>Math.PI&&(d*=-1),Oh(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 Nb(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Ub(e,t){return jg(e.position,e.controls[1].position,t.position)&&jg(e.position,t.controls[0].position,t.position)}function X6(e,t,i,r,s=.5){let n=Wl.subVectors(t,e).multiplyScalar(s).add(e),a=wp.subVectors(i,t).multiplyScalar(s).add(t),o=z6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=N6.subVectors(a,n).multiplyScalar(s).add(n),d=U6.subVectors(o,a).multiplyScalar(s).add(a),c=o,u=F6.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 Y6(e,t,i=12,r=!0){let s=JA.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=x0(t[l]),d=Wl,c=Va(h,i);o.push(c);for(let u=0;u<=c;u++)if(h instanceof $r||h instanceof sa||h instanceof ss){if(h.getPoint(u/c,d),s.set(d.x,d.y,0),n!==void 0&&G6(n,s))continue;n===void 0&&(n=KA),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 Q6(e,t,i,r=12,s=!0){let n=JA.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,d=x0(t[l]),c=Wl,u=Va(d,r);o.push(u);for(let p=0;p<=u;p++)if(d instanceof $r||d instanceof sa||d instanceof ss){if(d.getPoint(p/u,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=KA:(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 Fb(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=Va(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Va(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Va(e[0].roundedCurveCorner,t)*.5),r}function Va(e,t=12){return e&&e instanceof np?t*2:e&&(e instanceof ss||e instanceof aS)?1:e&&e instanceof Iv?t*e.points.length:t}function Z6(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=x0(t[a]),l=Va(o,i),h=Wl;for(let d=0;d<=l;d++)if(o instanceof $r||o instanceof sa||o instanceof ss){if(o.getPoint(d/l,h),s!==void 0&&j6(s,h,mh))continue;s===void 0&&(s=wp),s.copy(h),e.push(h.x,h.y),n++}}return Oh(e[0],e[e.length-2],mh)&&Oh(e[1],e[e.length-1],mh)&&(e.pop(),e.pop()),r&&n>1&&!(Oh(e[n-1],e[1],mh)&&Oh(e[n-2],e[0],mh))&&(e.push(e[0],e[1]),n++),e}var Vf=new F,K6=new F,J6=new F,$6=new F,e8=new F,t8=new F,Vt=class extends gu{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new vr(new M(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=nt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Vt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>al.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Vt.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=Vf.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=nt.generateUUID()){let r;e instanceof F?r=e:r=new F(e,t);let s=new al(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 Y6(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Fb(this.points,e,!1),this.roundedCurveDivisions=Fb(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return Q6(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),Z6(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=Va(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(Nb(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Vf.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){Nb(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&&V6(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(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,x=v/f,b=h.getPointAt(y,Vf),_=d.getPointAt(x,K6);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(d,u,x,void 0,_);let A;if(this.useCubicForRoundedCorners){let S=$A(b,s.position,_)/2,w=Math.tan(S)*b.distanceTo(s.position),[E,C]=H6(b,_,w,J6,$6),T=W6(E,C,s.position),[D,P]=q6(T,b,_,w,e8,t8);A=new $r(b.clone(),D.clone(),P.clone(),_.clone())}else A=new sa(b.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof ss)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=X6(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 Vt(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 al(nt.generateUUID(),new F(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 Vt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof $r&&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 sa&&(r[n]=k6(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 $r?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof ss&&(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 $r?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof ss&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof gu&&(this.shapeHoles=e.holes.map(r=>{let s=new Vt;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)}},Gg=Math.PI*2;function Hf({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function i8(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 kb(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 r8(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 g=f*s/n*o,m=f*-n/s*a,v=g+(e+i)/2,y=m+(t+r)/2,x=(a-g)/s,b=(o-m)/n,_=(-a-g)/s,A=(-o-m)/n,S=kb(1,0,x,b),w=kb(x,b,_,A);return!h&&w>0&&(w-=Gg),h&&w<0&&(w+=Gg),{centerx:v,centery:y,ang1:S,ang2:w}}function s8({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=r8(e,t,i,r,s,n,h,d,a,o),{ang1:p,ang2:f}=u,{centerx:g,centery:m}=u,v=Math.abs(f)/(Gg/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(i8(p,f)),p+=f;return l.map(x=>{let{x:b,y:_}=Hf(x[0],s,n,g,m),{x:A,y:S}=Hf(x[1],s,n,g,m),{x:w,y:E}=Hf(x[2],s,n,g,m);return{x1:b,y1:_,x2:A,y2:S,x:w,y:E}})}var St;(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"})(St||(St={}));var ri;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ri||(ri={}));function He(e,t){if(!e)throw t||"Assertion Failed!"}var Ne=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){He(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){He(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){He(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){He(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}(),gh=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}(),Md=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}(),jo=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}(),jb=function(){function e(){var t=new jo,i=new gh,r=new Md(0),s=new Md(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 Md(0),r=new Md(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;He(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;He(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 jo,i=new jo,r=new gh,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 jo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new gh;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 gh;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 jo;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 gh;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&&Ne.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Ne.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){He(s.prev===n),l=s.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(He(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){He(a.prev===o),l=a.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(He(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)He(l.Sym.next===h.Sym),He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Org!==null),He(l.Dst!==null),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l);He(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}(),Gb=function(){function e(){this.handle=null}return e}(),Vb=function(){function e(){this.key=null,this.node=0}return e}(),n8=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 Gb,this.handles[r]=new Vb;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,He(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 Gb;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new Vb}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;He(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}(),Wf=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}(),Hb=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),a8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new Hb,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 Hb;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}(),o8=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?Ne.vertLeq(n.Org,a.Org)?Ne.edgeSign(a.Dst,n.Org,a.Org)<=0:Ne.edgeSign(n.Dst,a.Org,n.Org)>=0:Ne.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Ne.edgeSign(n.Dst,s,n.Org)>=0;var o=Ne.edgeEval(n.Dst,s,n.Org),l=Ne.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&He(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){He(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 Wf;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 St.ODD:return(i&1)!==0;case St.NONZERO:return i!==0;case St.POSITIVE:return i>0;case St.NEGATIVE:return i<0;case St.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 He(Ne.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,He(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=Ne.vertL1dist(i,t),n=Ne.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(Ne.vertLeq(s.Org,n.Org)){if(Ne.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Ne.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(Ne.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(He(!Ne.vertEq(s.Dst,n.Dst)),Ne.vertLeq(s.Dst,n.Dst)){if(Ne.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(Ne.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 jo,p,f;if(He(!Ne.vertEq(h,l)),He(Ne.edgeSign(l,t.event,a)<=0),He(Ne.edgeSign(h,t.event,o)>=0),He(a!==t.event&&o!==t.event),He(!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(Ne.vertLeq(a,o)){if(Ne.edgeSign(h,a,o)>0)return!1}else if(Ne.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Ne.intersect(l,a,h,o,u),He(Math.min(a.t,l.t)<=u.t),He(u.t<=Math.max(o.t,h.t)),He(Math.min(h.s,l.s)<=u.s),He(u.s<=Math.max(o.s,a.s)),Ne.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Ne.vertLeq(a,o)?a:o,Ne.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Ne.vertEq(u,a)||Ne.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Ne.vertEq(l,t.event)&&Ne.edgeSign(l,t.event,u)>=0||!Ne.vertEq(h,t.event)&&Ne.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):(Ne.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),Ne.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),Ne.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),Ne.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}Ne.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,Ne.vertEq(s.Org,r)){He(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Ne.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}He(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(He(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Ne.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 Wf;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Ne.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Ne.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);He(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 Wf,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 a8(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||(He(i.fixUpperEdge),He(++r===1)),He(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,Ne.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 n8(n,Ne.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,He(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||!Ne.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}(),l8=function(){function e(){this.mesh=new jb,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=St.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],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,f[m]=i,l[m]=n,p[m]=i;for(i=g.next;i!==g;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=g.next;i!==g;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(;Ne.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ne.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Ne.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Ne.edgeGoesLeft(s.Lnext)||Ne.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&&(Ne.edgeGoesRight(r.Lprev)||Ne.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===ri.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===ri.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 jb),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=St.ODD),i===void 0&&(i=ri.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_(),o8.computeInterior(this,a);var o=this.mesh;return i===ri.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===ri.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Zn(e){var t=e.windingRule,i=t===void 0?St.ODD:t,r=e.elementType,s=r===void 0?ri.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,g=e.debug,m=g===void 0?!1:g;if(!u&&f)throw new Error("Contours can't be empty");if(u){var v=new l8;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:m?v.mesh:void 0}}}var Fq=St.ODD,kq=St.NONZERO,jq=St.POSITIVE,Gq=St.NEGATIVE,Vq=St.ABS_GEQ_TWO,Hq=ri.POLYGONS,Wq=ri.CONNECTED_POLYGONS,qq=ri.BOUNDARY_CONTOURS,Vg=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*Vg.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*Vg.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);t?(a.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),o.set(this.normals),l.set(this.uvs)),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)}},e2=Vg;e2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var h8=Pl(RE()),b0={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},t2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},i2={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},qf=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),w0=class extends qe{constructor(e,t,i=0,r=12,s=3,n=St.ODD,a=!1){super(),this.forPathBevel=a,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(E=>{let C=E.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],L=C[D-0];T.push(P,L)}return T}),h=[],d=[];for(let E=0;E<o.length;E+=2)d.push([o[E],o[E+1]]);h.push(d);for(let E=0;E<l.length;E++){let C=l[E],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c=h[0].length?(0,h8.default)(h).distance:i;i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let u;try{u=Zn({windingRule:n,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{u=b0}let p;try{p=Zn({windingRule:St.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=t2}if(!u)throw new Error("error generating geometry");let f=u.elementCount;if(p){u.elementCount+=p.elementCount;for(let E=0;E<p.elements.length;E++){let C=p.elements[E],T=E%2===0?u.vertexCount:0;u.elements.push(C+T)}for(let E=0;E<p.vertexIndices.length;E++){let C=p.vertexIndices[E],T=u.vertexCount;u.vertexIndices.push(C+T)}for(let E=0;E<p.vertices.length;E++){let C=p.vertices[E];u.vertices.push(C)}}let g=1/0,m=-1/0,v=1/0,y=-1/0;for(let E=0,C=u.vertexCount;E<C;E++){let T=E*2,D=u.vertices[T+0],P=u.vertices[T+1];D<g&&(g=D),D>m&&(m=D),P<v&&(v=P),P>y&&(y=P)}this._minX=g,this._minY=v,this._width=m-g,this._height=y-v,this._buffer=new e2(this._computeBufferEstimatedSize(u));let x=[],b=[];for(let E=u.elementCount-1;E>=0;E--){let C=E>=f,T=E*2,D=u.elements[T+0],P=u.elements[T+1],L=D+P,R={start:D,count:P,normals:[],continuous:[],concave:[]},V=D,k=L-1,z=D+1,X=this._shape.roundedCurves.length;do{let j=V-D,W=u.vertices[k*2+0],U=u.vertices[k*2+1],ie=u.vertices[V*2+0],Q=u.vertices[V*2+1],re=u.vertices[z*2+0],Z=u.vertices[z*2+1],ue=ie-W,ae=Q-U,se=Math.sqrt(ue*ue+ae*ae);ue/=se,ae/=se;let Ae=ie-re,Se=Q-Z,Me=Math.sqrt(Ae*Ae+Se*Se);Ae/=Me,Se/=Me,R.normals[j*2+0]=-Se,R.normals[j*2+1]=Ae,R.concave[j]=ue*Se-ae*Ae>0;let Pe=u.vertexIndices[V];if(Array.isArray(Pe))R.continuous[j]=!1;else{let[xe,ve]=this._shape.getCurveIndexFromVertexId(Pe-1,!0);if(ve>0&&ve<1)R.continuous[j]=!0;else{let Re=ve===1?xe+1:xe-1;Re=(Re+X)%X;let Qe=ve===1?0:1,B=this._shape.roundedCurves[xe].getTangent(ve),I=this._shape.roundedCurves[Re].getTangent(Qe);R.continuous[j]=B.dot(I)>.95}}C&&(R.normals[j*2+0]*=-1,R.normals[j*2+1]*=-1),[k,V,z]=[V,z,z+1],z>=L&&(z-=P)}while(z!==D+1);let H=[];H.push({bevelI:0,angle:0,size:0,boundary:{vertices:u.vertices.slice(D*2,L*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((j,W)=>[W,W]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:u.vertices.slice(D*2,L*2)});let G=0;for(let j=1;j<=this._bevelSegments;j++){let W=j/this._bevelSegments*Math.PI/2,U=(1-Math.cos(W))*this._bevel,ie=[],Q=[],re=[],Z=[],ue=0;for(let se=0;se<P;se++){let Ae=se*2,Se=(se-1+P)%P*2,Me=u.vertices[R.start*2+Ae+0],Pe=u.vertices[R.start*2+Ae+1],xe=-R.normals[Se+0]*U,ve=-R.normals[Se+1]*U,Re=-R.normals[Ae+0]*U,Qe=-R.normals[Ae+1]*U;if(R.concave[se]||!R.concave[se]&&C){let B=Math.atan2(ve,xe),I=Math.atan2(Qe,Re);I>B&&(I-=Math.PI*2);let $=I-B;if(R.continuous[se]||C){let me=B+$/2,ce=Math.cos(me)*U,ye=Math.sin(me)*U;ie[2*ue+0]=Me+ce*(C?-1:1),ie[2*ue+1]=Pe+ye*(C?-1:1),Z[ue]=se,ue++}else{let me=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let ce=0;ce<=me;ce++){let ye=B+$*(ce/me),Oe=Math.cos(ye)*U,Ee=Math.sin(ye)*U;ie[2*ue+0]=Me+Oe,ie[2*ue+1]=Pe+Ee,Z[ue]=se,ue++}}}else ie[2*ue+0]=Me+xe,ie[2*ue+1]=Pe+ve,Z[ue]=se,Q[se]=ue,ue++,ie[2*ue+0]=Me,ie[2*ue+1]=Pe,Z[ue]=se,ue++,ie[2*ue+0]=Me+Re,ie[2*ue+1]=Pe+Qe,Z[ue]=se,re[se]=ue,ue++}let ae=Zn({windingRule:St.POSITIVE,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:se=>{let Ae=se.Org.idx,Se=Z[Ae],Me=Z[(Ae+1)%Z.length];se.idx=[Se,Me],se.Sym.idx=[Me,Se]},vertexIdCallback:se=>{let Ae=se.Lprev.idx;return[Ae?Ae[1]:0,se.idx?se.idx[0]:0]}});if(!ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!ae.vertexCount){let se=(j-1)/this._bevelSegments*Math.PI/2;G=(1-Math.sin(se))*this._bevel;break}for(let se=0;se<ae.vertexIndices.length;se++){let[Ae,Se]=ae.vertexIndices[se];if(Ae===Se)continue;let Me=Se;Se<Ae&&(Me+=P);for(let Pe=Ae;Pe<Me;Pe++){let xe=Pe%P,ve=(Pe+1)%P;if(!R.continuous[xe]||!R.continuous[ve]){ae.vertexIndices[se]=[Ae,xe],ae.vertexIndices.splice(se+1,0,[ve,Se]),ae.vertices.splice((se+1)*2,0,ae.vertices[se*2],ae.vertices[se*2+1]);break}}}H.push({bevelI:j,angle:W,size:U,boundary:ae,reverseMap:Z,insetPoints:ie})}let N=(j,W,U)=>{let ie=0,Q=j.boundary.vertexIndices.length;for(;ie<Q&&U(j.boundary.vertexIndices[W]);)W=(W+1)%Q,ie++;return ie},q=x.length;for(let j=1;j<H.length;j++){let W=H[j-1],U=H[j],ie=W.boundary.vertexIndices.length,Q=U.boundary.vertexIndices.length;if(!ie||!Q)break;let re=R.concave.length,Z=0,ue=qf(Z,P);for(;!W.boundary.vertexIndices.filter(ue).length||!U.boundary.vertexIndices.filter(ue).length;)Z++,ue=qf(Z,P);let ae=W.boundary.vertexIndices.findIndex(ue),se=U.boundary.vertexIndices.findIndex(ue);do ae=(ae+1)%ie;while(ue(W.boundary.vertexIndices[ae]));do se=(se+1)%Q;while(ue(U.boundary.vertexIndices[se]));Z=(Z+1)%P;let Ae=Z,Se=0,Me=this._buildBevelVert(R,W,(ae-1+ie)%ie,void 0,Se),Pe=this._buildBevelVert(R,U,(se-1+Q)%Q,void 0,Se),xe=Me,ve=Pe,Re,Qe,B=!1;do{Se=(Z||re)/re,ue=qf(Z,P);let I=N(W,ae,ue),$=N(U,se,ue),me=B;if(B=!1,I&&!$){for(let ce=0;ce<I;ce++)Re=this._buildBevelVert(R,W,(ae+ce)%ie,ce/(I-1),Se),x.push(xe.topN,Re.topP,ve.topN),a===!1&&x.push(Re.bottomP,xe.bottomN,ve.bottomN),xe=Re;B=!0}else if(!I&&$)for(let ce=0;ce<$;ce++)Qe=this._buildBevelVert(R,U,(se+ce)%Q,ce/($-1),Se),x.push(ve.topN,xe.topP,Qe.topP),a===!1&&x.push(xe.bottomP,ve.bottomN,Qe.bottomP),ve=Qe;else if(I&&$)if(Re=this._buildBevelVert(R,W,ae,0,Se),Qe=this._buildBevelVert(R,U,se,0,Se),me?(x.push(xe.topN,Qe.topP,ve.topN),x.push(xe.topN,Re.topP,Qe.topP),a===!1&&(x.push(Qe.bottomP,xe.bottomN,ve.bottomN),x.push(Qe.bottomP,Re.bottomP,xe.bottomN))):(x.push(ve.topN,xe.topN,Re.topP),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&(x.push(Re.bottomP,xe.bottomN,ve.bottomN),x.push(Re.bottomP,ve.bottomN,Qe.bottomP))),xe=Re,ve=Qe,I===$)for(let ce=1;ce<I;ce++)Re=this._buildBevelVert(R,W,(ae+ce)%ie,ce/(I-1),Se),Qe=this._buildBevelVert(R,U,(se+ce)%Q,ce/($-1),Se),x.push(xe.topN,Re.topP,ve.topN),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&(x.push(Re.bottomP,xe.bottomN,ve.bottomN),x.push(Re.bottomP,ve.bottomN,Qe.bottomP)),xe=Re,ve=Qe;else if(I>$){let ce=I/$,ye=0;for(let Oe=1;Oe<I;Oe++)Re=this._buildBevelVert(R,W,(ae+Oe)%ie,Oe/(I-1),Se),x.push(xe.topN,Re.topP,ve.topN),a===!1&&x.push(Re.bottomP,xe.bottomN,ve.bottomN),xe=Re,Oe>(ye+1)*ce&&(ye++,Qe=this._buildBevelVert(R,U,(se+ye)%Q,ye/($-1),Se),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&x.push(Re.bottomP,ve.bottomN,Qe.bottomP),ve=Qe)}else{let ce=$/I,ye=0;for(let Oe=1;Oe<$;Oe++)Qe=this._buildBevelVert(R,U,(se+Oe)%Q,Oe/($-1),Se),x.push(ve.topN,Re.topP,Qe.topP),a===!1&&x.push(Re.bottomP,ve.bottomN,Qe.bottomP),ve=Qe,Oe>(ye+1)*ce&&(ye++,Re=this._buildBevelVert(R,W,(ae+ye)%ie,ye/(I-1),Se),x.push(xe.topN,Re.topP,ve.topN),a===!1&&x.push(Re.bottomP,xe.bottomN,ve.bottomN),xe=Re)}ae=(ae+I)%ie,se=(se+$)%Q,Z=(Z+1)%re}while(Z!==Ae)}if(a===!1&&this._depth>this._bevel*2&&this._buildWall(H,R,x),C){let j=[];for(let W=x.length-1;W>=q+2;W-=3){let U=x[W-2],ie=x[W-1],Q=x[W-0];j.push(Q,ie,U)}x.splice(q,x.length-q,...j)}if(C){let j=[];for(let W=H[H.length-1].boundary.vertices.length-1;W>=1;W-=2){let U=H[H.length-1].boundary.vertices[W-1],ie=H[H.length-1].boundary.vertices[W-0];j.push(U,ie)}b.push(j)}if(!C){let j=H[H.length-1],W;try{W=Zn({windingRule:H.length>1?St.POSITIVE:St.ODD,elementType:ri.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...b]})}catch{W=i2}if(!W)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let U=0;U<W.elementCount*3;U+=3){let ie=this._buildSurfaceVert(W,W.elements[U+0],G),Q=this._buildSurfaceVert(W,W.elements[U+1],G),re=this._buildSurfaceVert(W,W.elements[U+2],G);x.push(ie.top,Q.top,re.top),a===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ye(Uint32Array.from(x),1),A=new Ye(this._buffer.positions,3),S=new Ye(this._buffer.normals,3),w=new Ye(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,w.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",w),this.setIndex(_)}_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,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],n=e.vertices[t*2+1],a=(s-this._minX)/this._width,o=(n-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,d=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=n,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=n,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let n=`${t.bevelI}:${i}`;if(n in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[n].pathBevelUCoord))return this.vertexCache[n];let[a,o]=t.boundary.vertexIndices[i],l,h,d,c;a!==o?(h=a,l=o,c=!1,d=e.continuous[h]&&e.continuous[l]):(l=a,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||c);let u=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,g=l*2,m=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,_=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),_=1);let A=e.normals[g+0],S=e.normals[g+1],w=e.normals[m+0],E=e.normals[m+1];if(c){let L=w-A,R=E-S;A=A+L*(1-r),S=S+R*(1-r);let V=Math.sqrt(A*A+S*S);A/=V,S/=V}let C=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*u,this._buffer.normals[T+1]=S*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*u,this._buffer.normals[T+4]=S*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b),d||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=w*u,this._buffer.normals[T+1]=E*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=w*u,this._buffer.normals[T+4]=E*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b)),this.vertexCache[n]=P,P}clone(){let e=new w0(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fp(this.userData),e}},r2=class extends qe{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=St.ODD,this.elementType=ri.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:St.ODD,elementType:ri.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,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!a&&!o)break}if(!a&&!o)try{n=Zn({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=b0}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,g=-1/0;for(let y=0,x=d;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1];_<u&&(u=_),_>p&&(p=_),A<f&&(f=A),A>g&&(g=A)}let m=p-u,v=g-f;for(let y=0,x=d;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1],S=(_-u)/m,w=(A-f)/v;this._positionAttribute.setXYZ(y,_,A,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,w)}for(let y=0,x=c;y<x;y++){let b=y*3,_=n.elements[b+0],A=n.elements[b+1],S=n.elements[b+2];this._indexAttribute.setX(b+0,_),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,S)}}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 r2(this._shape,this._curveSegments);return e.userData=fp(this.userData),e}},s2=class extends w0{constructor(e,t,i=0,r=12,s=3,n=St.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 s2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fp(this.userData),e}},to=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:St.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 Vt?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Vt(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Vt(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 r2(e.shape,s,{windingRule:a}):o=new s2(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},n2=Math.PI*2,_0=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 Vt?e.shape:new Vt,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=c8(h,d,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=to.create({shape:h,parameters:{subdivisions:u,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function c8(e,t,i,r,s,n){if(r>=n2)return s>30||s%4===0?(u8(e,t,i,n),Math.round(s/4)):Wb(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=s8({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?d8(e,a.x,a.y,h,s,t,i,n):Wb(e,r,s,t,i,n)}function d8(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(ol(t,i));for(let h=0,d=r.length;h<d;h++){let c=r[h],u=e.points[h],p=ol(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?a2(e,n,a,o):e.addPoint(ol(0,0)),l}function Wb(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(ol(h,d))}return t<n2?n>0?a2(e,r,s,n):e.addPoint(ol(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&o2(e,r,s,n)),1}function u8(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(Ed(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(Ed(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(Ed(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(Ed(s,n-i,s+o,n-i,s-o,n-i)),r>0&&o2(e,t,i,r)}function ol(e,t){return new al(nt.generateUUID(),new F(e,t))}function Ed(e,t,i,r,s,n){let a=ol(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function a2(e,t,i,r){l2(e,t,i,r).forEach(s=>e.addPoint(s))}function o2(e,t,i,r){let s=l2(e,t,i,r),n=new Vt;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function l2(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new F(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=nt.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 p8=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 h2(!1,t,i,r,s,n,a,o,l,h,d,c);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},Xf=new $o([0,0,0],1),h2=class extends qe{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 M,f=new M,g=p(),m=p(),v=p(),y,x,b,_,A,S,w,E,C=p(),T=p(),D=p(),P=p(),L=p(),R=p(),V=p(),k=p(),z=i-2*o+.001,X=z/n,H=Math.ceil(a*n),G=H+1,N=z/H,q=-z/2,j=h+1,W=2*Math.PI/h,U=Math.PI/2/c,ie=.01,Q=Math.min((1-d/100)*o,o-ie),re=o-Q,Z=0,ue=2,ae=c*ue+ue,se=j*ae/ue,Ae=se+j*G,Se=j*(G+ae),[Me,Pe,xe]=[3,3,2].map(De=>Array(Se*De).fill(0)),ve=[],Re=s-o;function Qe(De,Be){let Ie=Math.PI/2;S=Be*N,E=2*Math.PI*(S%X)/X+Ie,S+=q,w=Math.sin(E)*Re,A=Math.cos(E)*Re,e?De.set(A,w,S):De.set(A,S,w)}Qe(f,-1e-10),Qe(g,0),C.copy(f),Qe(f,1);let B=f.distanceTo(g),I=u?0:re+Q,$=B*H+2*I,me=Q,ce=$-I;for(let De=0;De<=H;De++){Qe(m,De),k.subVectors(m,C).normalize(),C.copy(m),R.copy(m).setComponent(+e+1,0).normalize(),V.crossVectors(k,R).normalize();let Be=De===0,Ie=De===H,Xe=Be?3*Math.PI/2:U,Ue=Be?me:ce,pt=Be?j:Ae,Ot=Be?0:Se-j,Jt=k.clone().multiplyScalar(Be?-re:re).add(m),Y=k.clone().multiplyScalar(Be?-1:1).normalize();for(let ne=0;ne<j;ne++){let ge=ne*W;if(T.addVectors(f.copy(R).multiplyScalar(o*Math.cos(ge)),g.copy(V).multiplyScalar(o*Math.sin(ge))),D.copy(T).normalize(),Be||Ie){u||(Z=Ot+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=Jt.getComponent(we),Pe[Z*3+we]=Y.getComponent(we)}),xe[Z*2]=+Ie,xe[Z*2+1]=ne/h),g.copy(D).multiplyScalar(Q),v.addVectors(m,g);for(let we=0;we<c;we++){let Ge=we*U+Xe;P.addVectors(f.copy(k).multiplyScalar(re*Math.sin(Ge)),g.copy(D).multiplyScalar(re*Math.cos(Ge))),L.copy(P).normalize(),g.addVectors(v,P),P.normalize(),Z=pt+we*j+ne,[0,1,2].forEach(Ut=>{Me[Z*3+Ut]=g.getComponent(Ut),Pe[Z*3+Ut]=L.getComponent(Ut)});let gt=+Be+Math.sin(Ge);xe[Z*2]=(Ue+re*gt)/$,xe[Z*2+1]=ne/h}}g.addVectors(m,T),Z=se+De*j+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=g.getComponent(we),Pe[Z*3+we]=D.getComponent(we)}),xe[Z*2]=(I+De*B)/$,xe[Z*2+1]=ne/h}}let ye=G+2*c+ue,Oe=1,[Ee,de]=[+u,ye-1];for(let De=Ee;De<=de-1;De++){let Be=u&&De===de-1;for(let Ie=0;Ie<j-1;Ie++)y=De*j+Ie,x=y+1,b=(Be?Ie:y)+j,_=(Be?Ie+1:x)+j,De===0?ve.push(x,_,b):De===ye-2?ve.push(y,x,b):ve.push(y,x,b,x,_,b)}this.setIndex(ve),this.setAttribute("position",new Le(Me,3)),this.setAttribute("normal",new Le(Pe,3)),this.setAttribute("uv",new Le(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,n,a,o,l=6*(t-1)*e.radialSegments,h=t,d=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,n=s+1,a=(d?c:s)+i,o=(d?c+1:n)+i,r[l++]=s,r[l++]=n,r[l++]=a,r[l++]=n,r[l++]=o,r[l++]=a;return r.length=l,Xf.array=r,Xf.count=r.length,Xf}},f8=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 c2(t*.5,n,a):new mS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},c2=class extends v0{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 c2(e.radius,e.corner,e.cornerSides)}},m8=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 gu;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 lS(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ms=new fe,Yf=new Mt,Cd=new M,qu=class extends Ti{constructor(){super(),this.uuid=nt.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 bi().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 ms.makeRotationX(e),this.applyMatrix4(ms),this}rotateY(e){return ms.makeRotationY(e),this.applyMatrix4(ms),this}rotateZ(e){return ms.makeRotationZ(e),this.applyMatrix4(ms),this}translate(e,t,i){return ms.makeTranslation(e,t,i),this.applyMatrix4(ms),this}scale(e,t,i){return ms.makeScale(e,t,i),this.applyMatrix4(ms),this}lookAt(e){return Yf.lookAt(e),Yf.updateMatrix(),this.applyMatrix4(Yf.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 M().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new je().fromBufferAttribute(a,c));function h(c,u,p,f){let g=a===void 0?[]:[t.colors[c].clone(),t.colors[u].clone(),t.colors[p].clone()],m=n===void 0?[]:[new M().fromBufferAttribute(n,c),new M().fromBufferAttribute(n,u),new M().fromBufferAttribute(n,p)],v=new Hg(c,u,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new F().fromBufferAttribute(o,c),new F().fromBufferAttribute(o,u),new F().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new F().fromBufferAttribute(l,c),new F().fromBufferAttribute(l,u),new F().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 g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),u.materialIndex):h(g,g+1,g+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(Cd).negate(),this.translate(Cd.x,Cd.y,Cd.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new fe;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 M,t=new M;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 M;if(e){let i=new M,r=new M;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 qu;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 M,h={a:new M,b:new M,c:new M};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 Kt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _r),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 bi().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,g,m=p.vertexNormals,v=p.vertexColors,y=new Hg(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,b=m.length;x<b;x++)f=m[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)g=v[x],y.vertexColors.push(g.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,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[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 M(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],g=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,g),A=h(A,2,m),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),A=h(A,7,_),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let S=this.faceVertexUvs[0][p];i.push(u(S[0]),u(S[1]),u(S[2]))}if(y&&i.push(d(f.normal)),x){let S=f.vertexNormals;i.push(d(S[0]),d(S[1]),d(S[2]))}if(b&&i.push(c(f.color)),_){let S=f.vertexColors;i.push(c(S[0]),c(S[1]),c(S[2]))}}function h(p,f,g){return g?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 qu().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,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++){let b=m[y];v.push(b.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,g=s[c].vertices.length;f<g;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,g=s[c].normals.length;f<g;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,g=n[c].vertexNormals.length;f<g;f++){let m=n[c].vertexNormals[f],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=n[c].faceNormals.length;f<g;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 g8().fromGeometry(this),t=new qe,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Td.call(new Ye(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Td.call(new Ye(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",qb.call(new Ye(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",Xb.call(new Ye(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",Xb.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 Le(l.data.length*3,3);h.name=l.name,s.push(Td.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Le(e.skinIndices.length*4,4);t.setAttribute("skinIndex",Yb.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Le(e.skinWeights.length*4,4);t.setAttribute("skinWeight",Yb.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 qe,i=e.geometry;if(e.isPoints||e.isLine){let r=new Le(i.vertices.length*3,3),s=new Le(i.colors.length*3,3);if(t.setAttribute("position",Td.call(r,i.vertices)),t.setAttribute("color",qb.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Le(i.lineDistances.length,1);t.setAttribute("lineDistance",v8.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}};qu.prototype.isGeometry=!0;var g8=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 m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,d=h.length,c;if(d>0){c=[];for(let m=0;m<d;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let u=e.skinIndices,p=e.skinWeights,f=u.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];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 b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][m];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new F,new F,new F))}if(n===!0){let b=r[1][m];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new F,new F,new F))}for(let b=0;b<o;b++){let _=a[b].vertices;l[b].data.push(_[v.a],_[v.b],_[v.c])}for(let b=0;b<d;b++){let _=h[b].vertexNormals[m];c[b].data.push(_.a,_.b,_.c)}f&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),g&&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}},Hg=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 M,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 v8(e){return this.array.set(e),this}function qb(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 Xb(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 F),t[i++]=n.x,t[i++]=n.y}return this}function Td(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 M),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function Yb(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 y8=["a","b","c"];function x8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Qf(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function Zf(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 b8(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],Zf(a.a,a.b,e,r,a,i),Zf(a.b,a.c,e,r,a,i),Zf(a.c,a.a,e,r,a,i)}function Pd(e,t,i,r,s){e.push(new Hg(t,i,r,void 0,void 0,s))}function To(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Dd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var w8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof qe?e=new qu().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 M,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;b8(o,l,c,u);let p=[],f,g,m,v,y,x,b;for(let ie of Array.from(u.keys())){for(g=u.get(ie),m=new M,y=3/8,x=1/8,b=g.faces.length,b!=2&&(y=.5,x=0,b!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),n=0;n<b;n++){for(v=g.faces[n],a=0;a<3&&(f=o[x8(v,y8[a])],!(f!==g.a&&f!==g.b));a++);f&&t.add(f)}t.multiplyScalar(x),m.add(t),g.newEdge=p.length,p.push(m)}let _,A,S,w,E,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],E=c[r].edges,i=E.length,i==3?_=3/16:i>3&&(_=3/(8*i)),A=1-i*Number(_),S=_,i<=2&&(i==2?(A=3/4,S=1/8):i==1||i==0),T=C.clone().multiplyScalar(A),t.set(0,0,0),n=0;n<i;n++)w=E[n],f=w.a!==C?w.a:w.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),D.push(T)}let P=D.concat(p),L=D.length,R,V,k,z=[],X=[],H,G,N,q,j=new F,W=new F,U=new F;for(r=0,s=l.length;r<s;r++)v=l[r],R=Number(Qf(v.a,v.b,u).newEdge)+L,V=Number(Qf(v.b,v.c,u).newEdge)+L,k=Number(Qf(v.c,v.a,u).newEdge)+L,Pd(z,R,V,k,v.materialIndex),Pd(z,v.a,R,k,v.materialIndex),Pd(z,v.b,V,R,v.materialIndex),Pd(z,v.c,k,V,v.materialIndex),d&&(H=h[r],G=H[0],N=H[1],q=H[2],j.set(To(G.x,N.x),To(G.y,N.y)),W.set(To(N.x,q.x),To(N.y,q.y)),U.set(To(G.x,q.x),To(G.y,q.y)),Dd(X,j,W,U),Dd(X,G,j,U),Dd(X,N,W,j),Dd(X,q,U,W));e.vertices=P,e.faces=z,d&&(e.faceVertexUvs[0]=X)}},ai=new M,_8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new qe().copy(new Rs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ai),r={width:ai.x,height:ai.y,depth:ai.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 qe().copy(new Rs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ai)):ai.set(a.width,a.height,a.depth),(t!==ai.x||i!==ai.y||r!==ai.z)&&n.scale(ai.x===0?1:t/ai.x,ai.y===0?1:i/ai.y,ai.z===0?1:r/ai.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new w8(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 _S(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ai);let n=100/ai.x;Object.assign(s.parameters,{width:100,height:ai.y*n,depth:ai.z*n}),t(this.build(s))})}},d2=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 Vt?e.shape:new Vt,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 g=0;g<r;g++){let m=p*g,v=c+Math.sin(m)*h,y=u+Math.cos(m)*d;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=to.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},S8=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 M8(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function vh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Kf(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 A8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var M8=class extends qe{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),g=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new M(0,-u,0),x=new M(0,u,0),b=new F(e,-u),_=new F(f,-u),A=new F(0,x.y).sub(_),S=new F(0,x.y).sub(b),w=new F(A.y,-A.x).normalize(),E=new F(S.y,-S.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new M(w.x,w.y,0),X=new M(Math.cos(g)*z.x,z.y,Math.sin(g)*z.x);T=z.angleTo(X)}let D=n/Math.tan((Math.PI-A.angle())/2),P=n/Math.tan((Math.PI-T)/2),L=new M;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),d.push(0,0);let z=c++,X=[],H=b.clone(),G=D/Math.cos(Math.PI/i);H.x-=G;for(let N=0;N<i;N++){let q=N/i*Math.PI*2+p,j=new F(Math.sin(q),Math.cos(q));vh(H,j,L),l.push(L.x,L.y,L.z),h.push(0,-1,0),d.push(0,0),X.push(c++)}for(let N=0;N<X.length;N++)o.push(X[N],z,X[(N+1)%X.length])}let R=[];{let z=new M,X=new M,H=new M,G=new M,N=new M,q=new M;for(let j=0;j<i;j++){let W=j/i*Math.PI*2+p,U=(j+.5)/i*Math.PI*2+p,ie=(j+1)/i*Math.PI*2+p,Q=new F(Math.sin(W),Math.cos(W)),re=new F(Math.sin(U),Math.cos(U)),Z=new F(Math.sin(ie),Math.cos(ie));vh(b,Q,X),vh(b,Z,H),vh(w,re,z),Kf(x,X,H,P,P,G),l.push(G.x,G.y,G.z),Kf(X,x,H,P,D,N),l.push(N.x,N.y,N.z),Kf(H,X,x,D,P,q),l.push(q.x,q.y,q.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 ue=c++,ae=c++,se=c++;if(o.push(ue,ae,se),n>0){{let Me=X.clone().add(H).multiplyScalar(.5),Pe=x.clone().sub(Me).normalize(),xe=y.clone().sub(Me).normalize().add(Pe).normalize().multiplyScalar(-1),ve=q.clone().sub(N);V(Me,ve,xe,A.angle())}let Ae,Se;{let Me=new M;vh(E,Z,Me);let Pe=q.clone().add(G).multiplyScalar(.5);Pe=A8(Pe,H,x);let xe=q.clone().sub(G);[Ae,Se]=V(Pe,xe,Me,T,G.y)}{let Me=Ae,Pe=Me.clone().setY(0).normalize(),xe=new M(0,-1,0),ve=Pe.clone().cross(xe);k(Me,Pe,xe,ve)}R.concat(Se);{let Me=A.angle(),Pe=Math.PI-Me,xe=x.clone();xe.y-=n/Math.sin(Me-Math.PI/2);let ve=new M,Re=[];for(let B=0;B<a;B++){let I=[],$=Math.PI/2-Pe*B/a,me=Math.cos($),ce=Math.sin($),ye=U;for(let Oe=0;Oe<=B;Oe++){let Ee=Math.cos(ye),de=Math.sin(ye);z.x=me*de,z.y=ce,z.z=me*Ee,ve.copy(xe).addScaledVector(z,n),l.push(ve.x,ve.y,ve.z),h.push(z.x,z.y,z.z),d.push(0,0),I.push(c++),ye+=Math.PI*2/B/i}Re.push(I)}Se.reverse(),Re.push(Se);let Qe=Re.length-1;for(let B=0;B<Qe;B++){let I=Re[B],$=Re[B+1],me=I.length-1;o.push($[1],I[0],$[0]);for(let ce=1;ce<=me;ce++)o.push(I[ce],I[ce-1],$[ce]),o.push($[ce+1],I[ce],$[ce])}}}}}this.setIndex(o),this.setAttribute("position",new Le(l,3)),this.setAttribute("normal",new Le(h,3)),this.setAttribute("uv",new Le(d,2));function V(z,X,H,G,N){let q=-G/2,j=(Math.PI-G)/2,W=X.clone().normalize().cross(H);z.addScaledVector(H,-n/Math.sin(j));let U=new M,ie=new M,Q=1,re=c,Z=[];for(let ue=0;ue<=a;ue++){let ae=q+ue/a*G;ie.set(0,0,0),ie.addScaledVector(W,Math.sin(ae)),ie.addScaledVector(H,Math.cos(ae));for(let se=0;se<=Q;se++){let Ae=se/Q-.5;if(U.copy(z),U.addScaledVector(X,Ae),U.addScaledVector(ie,n),N!=null){let Se=Math.max(0,U.y-N);U.addScaledVector(X,-Se/X.y)}l.push(U.x,U.y,U.z),h.push(ie.x,ie.y,ie.z),d.push(0,0),se===0&&Z.push(c),c++}}for(let ue=0;ue<a;ue++)for(let ae=0;ae<Q;ae++){let se=re+ae+(Q+1)*ue,Ae=se+(Q+1),Se=Ae+1,Me=se+1;o.push(se,Ae,Me),o.push(Ae,Se,Me)}return[z.clone().addScaledVector(X,.5),Z]}function k(z,X,H,G){let N=Math.PI/2,q=S.angle()-N,j=[],W=new M,U=new M;for(let Q=0;Q<=a;Q++){let re=[],Z=Q/a;for(let ue=0;ue<=Q;ue++){let ae=((Q?ue/Q:0)-.5)*v,se=Math.cos(ae),Ae=Math.sin(ae),Se=Math.atan(Math.tan(q)*se),Me=(N+Se)*Z,Pe=Math.cos(Me),xe=Math.sin(Me);W.set(0,0,0),W.addScaledVector(X,xe*se),W.addScaledVector(H,Pe),W.addScaledVector(G,xe*Ae),U.copy(z).addScaledVector(W,n),l.push(U.x,U.y,U.z),h.push(W.x,W.y,W.z),d.push(0,0),re.push(c++)}j.push(re)}let ie=j.length-1;for(let Q=0;Q<ie;Q++){let re=j[Q],Z=j[Q+1],ue=re.length-1;o.push(re[0],Z[1],Z[0]);for(let ae=1;ae<=ue;ae++)o.push(re[ae-1],re[ae],Z[ae]),o.push(re[ae],Z[ae+1],Z[ae])}}}},u2=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 Vt?e.shape:new Vt,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(b,_,A){return _>i&&A>r?Math.min(b*i/_,b*r/A):_>i?b*i/_:A>r?b*r/A:b}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,g=c.x,m=c.y,v=d.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,_=t.points.length;b<_;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=to.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},E8=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 Bv(.5*t,s,n,a,o,l,h);return d.scale(1,i/t,r/t),Object.assign(d,{userData:{...e,type:"SphereGeometry"}})}},C8=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 rp(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},T8=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 P8(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},P8=class extends qe{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=(ie=0,Q=0,re=0)=>new M(ie,Q,re),p=u(),f=u(),[g,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[b,_,A]=[u(y,-g,+v),u(y,-g,-v),u(y,+g,-v)],S=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),w=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-g;let E=Math.cos(r)*t-v,C=b.z-h;r<=c?(A.z=Math.min(E,C),A.z==C&&(A.y-=(E-C)/Math.tan(c-r))):_.z=Math.min(_.z-E-v,b.z-h),p.subVectors(b,_),f.subVectors(A,_);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),L=p.clone().normalize().add(f.normalize()).setLength(P).add(_);p.set(0,S(r,!0),w(r,!0)),d.push([A,p.clone()]);let R=(Math.PI-r)/n;for(let ie=0;ie<=n;ie++){let Q=c+r+ie*R;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(L),f.set(0,S(Q),w(Q)),d.push([p.clone(),f.clone()])}d.push([b,u(0,1,0)]);let V=Math.sin(R/2)*D*2,k=d.length-1,z=d[0][0].distanceTo(d[1][0]),X=d[k-1][0].distanceTo(d[k][0]),H=z+V*n+X;d[0].push(1);for(let ie=0;ie<=n;ie++)d[ie+1].push(1-(z+ie*V)/H);d[k].push(0);let[G,N,q]=d[0],j,W,U;for(let ie=1;ie<d.length;ie++)[j,W,U]=d[ie],a.push(y,G.y,G.z,y,j.y,j.z,x,G.y,G.z,x,G.y,G.z,y,j.y,j.z,x,j.y,j.z),o.push(0,N.y,N.z,0,W.y,W.z,0,N.y,N.z,0,N.y,N.z,0,W.y,W.z,0,W.y,W.z),l.push(0,q,0,U,1,q,1,q,0,U,1,U),[G,N,q]=[j,W,U];this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(o,3)),this.setAttribute("uv",new Le(l,2))}},p2=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 Vt?e.shape:new Vt,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,g=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=u*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let b=0;b<s;b++){let _=g*b,A=p+Math.sin(_)*c,S=f+Math.cos(_)*u;d.addPoint(d.createPoint(A,S))}}else for(let b=0;b<s;b++){let _=p+Math.cos(m)*c,A=f+Math.sin(m)*u;d.addPoint(d.createPoint(_,A)),m+=g,_=p+Math.cos(m)*v,A=f+Math.sin(m)*y,b<=s,d.addPoint(d.createPoint(_,A)),m+=g}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let x=to.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},D8=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 rp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},I8=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=L8(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 L8(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 h2(!0,e,t,i,r,s,n,a,o,l,h,d)}var O8=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 gS(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},B8=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 Vt?e.shape:new Vt,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=to.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function R8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var z8=new fe,N8=new fe;function U8(e,t,i){let r=[new M,new M,new M],s=[new M,new M,new M];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=nt.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new fe().makeBasis(r[0],r[1],r[2])}var F8=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??_0.create({parameters:kA}).userData.shape;return{path:e.path??Nu.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...jA,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new k8(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new qe,{userData:{...e,type:"PathGeometry"}})}},k8=class extends qe{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)||!R8(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 k=0;k<o;k++){let z=this.inputs.path.isClosed?(k+n)%e.length:Math.min(k+n,e.length-1);l.push(e[z].clone()),h.push(t[z].clone())}let d=(k,z,X)=>{l[k]=l[k].clone().lerp(l[z],X),h[k]=U8(h[k],h[z],X)},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 k=l.length-1;l[k].copy(l[0]),h[k].copy(h[0])}this._applyPathModifiers(h,c,p);let{bevel:g,bevelSides:m}=this.inputs.parameters.extrusion,v=g>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:b,vertices:_}=this._computeShapePoints(y),A=0,S;v==="round"&&(S=new w0(this.inputs.shapeData,2*g,g,y,m,void 0,!0),A=S.getAttribute("position").count);let w=0,E=0;b.sort((k,z)=>k.start-z.start),b.forEach(k=>{k.verticesStart=w,k.verticesCount=k.continuous.reduce((z,X,H)=>z+(H===0||!X?2:1),0),E+=k.verticesCount,w=E});let C=E*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=Zn({windingRule:St.ODD,elementType:ri.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=i2}D=T.vertexCount}let P=C+2*D+A*2,L=C+2*D,R={positions:new Float32Array(P*3),normals:new Float32Array(P*3),uvs:new Float32Array(P*2)},V=[];if(b.forEach(k=>{this._extrudeRegion(k,_,h,l,R,V,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,V,R,h[0],l[0],!1),this._closeEnd(T,C+D,V,R,h[h.length-1],l[l.length-1],!0)),S){R.positions.set(S.getAttribute("position").array,L*3),R.normals.set(S.getAttribute("normal").array,L*3),R.uvs.set(S.getAttribute("uv").array,L*2);let k=V.length;V.push(...S.getIndex().array.map(H=>H+L)),L+=A,R.positions.set(S.getAttribute("position").array,L*3),R.normals.set(S.getAttribute("normal").array,L*3),R.uvs.set(S.getAttribute("uv").array,L*2);let z=V.length;V.push(...S.getIndex().array.map(H=>H+L)),this.setAttribute("position",new Ye(R.positions,3)),this.setAttribute("normal",new Ye(R.normals,3)),this.setAttribute("uv",new Ye(R.uvs,2)),this.setIndex(V);let X=z8;X.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(X,L,P),X.copy(h[0]).setPosition(l[0]).multiply(N8.makeScale(1,1,-1)),this.applyMatrix4OnRange(X,L-A,L),this.reverseIndicesOnRange(k,z)}else this.setAttribute("position",new Ye(R.positions,3)),this.setAttribute("normal",new Ye(R.normals,3)),this.setAttribute("uv",new Ye(R.uvs,2)),this.setIndex(V)}_extractPathPoints(){let e=XA(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 M,n=new M,a=new M,o=new M,l=new M(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),x=v.clone().sub(g).normalize(),b=y.clone().add(x).normalize();a.copy(b),f===0&&(b.equals(l)||b.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(b).normalize(),A=b.clone().cross(_).normalize();l.copy(A),o.copy(_),f===0&&(s.copy(A),n.copy(b));let S=new fe().makeBasis(_,A,b);t.push(S)}let h=r?n:a,d=r?s:new M(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 g=new fe().makeRotationZ(u*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new fe,h=new fe;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(nt.lerp(s,s+n,u));let p=nt.lerp(a,o,u);h.makeScale(p,p,p),d.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=St.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),g=[];for(let m=f.length-1;m>=1;m-=2){let v=f[m-1],y=f[m-0];g.push(v,y)}return g}),n;try{n=Zn({windingRule:t,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=b0}let a;try{a=Zn({windingRule:St.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=t2}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],g=p%2===0?n.vertexCount:0;n.elements.push(f+g)}for(let p=0;p<a.vertexIndices.length;p++){let f=a.vertexIndices[p],g=n.vertexCount;n.vertexIndices.push(f+g)}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 g=p*2,m=n.vertices[g+0],v=n.vertices[g+1];m<l&&(l=m),m>h&&(h=m),v<d&&(d=v),v>c&&(c=v)}let u=[];for(let p=n.elementCount-1;p>=0;p--){let f=p>=o,g=p*2,m=n.elements[g+0],v=n.elements[g+1],y=m+v,x={start:m,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};u.push(x);let b=m,_=y-1,A=m+1,S=i.roundedCurves.length;do{let w=b-m,E=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[b*2+0],D=n.vertices[b*2+1],P=n.vertices[A*2+0],L=n.vertices[A*2+1],R=T-E,V=D-C,k=Math.sqrt(R*R+V*V);R/=k,V/=k;let z=T-P,X=D-L,H=Math.sqrt(z*z+X*X);z/=H,X/=H,x.normals[w*2+0]=-X,x.normals[w*2+1]=z;let G=n.vertexIndices[b];if(Array.isArray(G))x.continuous[w]=!1;else{let[N,q]=i.getCurveIndexFromVertexId(G-1,!0);if(q>0&&q<1)x.continuous[w]=!0;else{let j=q===1?N+1:N-1;j=(j+S)%S;let W=q===1?0:1,U=i.roundedCurves[N].getTangent(q),ie=i.roundedCurves[j].getTangent(W);x.continuous[w]=U.dot(ie)>.95}}f&&(x.normals[w*2+0]*=-1,x.normals[w*2+1]*=-1),[_,b,A]=[b,A,A+1],A>=y&&(A-=v)}while(A!==m+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 M,l=new M,h=new M,d=new M,c=new F;i.forEach((p,f)=>{let g=r[f],m=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(g),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,m,h,d,c),m++,!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,m,h,d,c),m++}}});let u=i.length-1;for(let p=0;p<u;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=f+m,b=f+y,_=g+y,A=g+m;e.isHole?n.push(x,_,b,x,A,_):n.push(x,b,_,x,_,A),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new M(0,0,a?-1:1).applyMatrix4(s),h=new M,d=new F;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,g=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(f,g,m)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new bi().getNormalMatrix(e).elements,n,a,o,l,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let c=h.array,u=d.array,p=h.itemSize;for(let f=t*p,g=i*p;f<g;f+=p){if(f===t)debugger;n=c[f+0],a=c[f+1],o=c[f+2],l=1/(r[3]*n+r[7]*a+r[11]*o+r[15]),c[f+0]=(r[0]*n+r[4]*a+r[8]*o+r[12])*l,c[f+1]=(r[1]*n+r[5]*a+r[9]*o+r[13])*l,c[f+2]=(r[2]*n+r[6]*a+r[10]*o+r[14])*l,n=u[f+0],a=u[f+1],o=u[f+2],u[f+0]=s[0]*n+s[3]*a+s[6]*o,u[f+1]=s[1]*n+s[4]*a+s[7]*o,u[f+2]=s[2]*n+s[5]*a+s[8]*o}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),n=i.getX(r+1),a=i.getX(r+2);i.setXYZ(r,a,n,s)}i.needsUpdate=!0}}};function f2(){let e=new qe;return e.setAttribute("position",new Ye(new Float32Array([]),3)),e.setIndex(new Ye(new Uint16Array([]),1)),e}var j8=f2().attributes,G8=12,V8=1,m2=class extends qe{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,j8),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=H8(e,t,h),{shapes:c,charWidths:u,charCoords:p}=t.generateShapes(d,e),f=i*.5,g=r*.5,m=c.map(x=>new Vt().fromShape(x));this.vectorShapes=m;let v=m.map(x=>to.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?St.NONZERO:St.ODD,subdivisions:this.isLowResolution&&s>0?V8:G8}})),y=v.length?Ba(v):f2();y.translate(-f,g,0),this.dispose(),this.wrappedText=d,this.charCoords=p,this.charWidths=u,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,b])=>{this.setAttribute(x,b)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Qa(new qe,m2.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 H8(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 g2,S0=new Promise(e=>{g2=e}),Qb=!1,Id;function W8(){if(Qb)return;if(Id)return Id;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.423/build",[i,r]=await Promise.all([import("./process.js".toString()),fetch(`${t}/process.wasm`).then(a=>a.arrayBuffer())]),s=i.default,n=await s({wasmBinary:r});g2(n),Qb=!0}return Id=e(),Id}function Xu(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=Vt.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 _S().parse(e);else{if(e.type==="SubdivGeometry")return new Hi(e,i);if(e.type==="TextGeometry")return new m2(e,t)}let s;try{s=ew(r)}catch(n){console.error(n)}if(!s){let n=Vt.createFromState(zu.defaultData(),100,100);r.shape=n,s=ew(r)}return s}var q8=new fe;function Wg(e,t,i,r){let s=e.position.array,n=e.normal.array,a=q8.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 Ld=new Kt,Po=new M,Fe;S0.then(e=>{Fe=e});var Zb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Kb=new Uint32Array([0,1,2,3]),Jb=new Uint8Array([4]),Hi=class extends qe{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=ja.div(t,i);this.subdividedGeometry&&Wg(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Wg(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(Po.fromArray(r));let n=Po.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}=Hi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Rs(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&&(Hi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new _r,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Ld.setFromBufferAttribute(t),Ld.getCenter(i),e.boundingSphere.radius=i.distanceTo(Ld.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ld.getSize(Po);let r={width:Po.x,height:Po.y,depth:Po.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&&(Fe.free_bvh(t),Fe.free_subdivision_surface(t));try{s=Hi.allocate(e,r)}catch(l){console.error(l,e),s=Hi.allocate({positionWASM:Zb,indexWASM:Kb,verticesPerFaceWASM:Jb},r)}if(Fe.set_destination_refinement_level(s,0),n=Hi.buildLevel(s,!0,o),e.subdivisions>0)try{Fe.set_destination_refinement_level(s,e.subdivisions),a=Hi.buildLevel(s,!1,o)}catch{try{Fe.set_destination_refinement_level(s,e.subdivisions-1),a=Hi.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||e.path!==void 0?t.geometry:Xu(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let n,a,o,l;({positions:n,triIndices:l}=_p(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,c=d+e.radialSegments*3;h=[d,c]}return{indices:a,verticesPerFace:o}=v2(n,l,r,h),{positions:n,indices:a,verticesPerFace:o}}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=Zb,r=Kb,s=Jb);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,g=Fe._malloc(u),m=new Float32Array(Fe.HEAPF32.buffer,g,d),v=new Uint32Array(Fe.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new fe().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Fe.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Fe.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Fe._free(g),x}static buildLevel(e,t,i,r,s){let n=s?Fe.get_mesh_data2(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i,s.elements):Fe.get_mesh_data(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i),a=8,o=Fe.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,d=Fe.HEAPU32[o[h]>>2],c=Fe.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=Fe.HEAPU32[o[h]>>2],p=Fe.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=Fe.HEAPU32[o[h]>>2],g=Fe.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Fe.HEAPU32[o[h]>>2],v=Fe.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new qe;if(y.setIndex(new $o(v,1)),y.setAttribute("position",new Le(c,3)),y.setAttribute("normal",new Le(p,3)),t){y.setAttribute("faceMap",new $o(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ye(x,4))}return Fe.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,Fe.free_mesh_data(n)}static freeSubdivPointer(e){Fe.free_bvh(e),Fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Fe.get_wireframe_data_for_base_level(e),s=4,n=Fe.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Fe.HEAPU32[n[o]>>2],h=Fe.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let d=Fe.HEAPU32[n[o]>>2],c=Fe.HEAPU32.subarray(d>>2,(d>>2)+a[o]);if(t===void 0){let u=new qe;u.setAttribute("position",new Le(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Ye(p,3)),u.setIndex(new $o(c,1)),Fe.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Fe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Fe.set_destination_refinement_level(e,t);let s=i?Fe.get_topological_data2(e,r?Fe.Level.CONTROL:Fe.Level.REFINED,i.elements):Fe.get_topological_data(e,r?Fe.Level.CONTROL:Fe.Level.REFINED),n=6,a=Fe.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Fe.HEAPU32[a[l]>>2],d=new Float32Array(Fe.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Fe.HEAPU32[a[l]>>2],u=new Uint32Array(Fe.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Fe.HEAPU32[a[l]>>2],f=new Uint8Array(Fe.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Fe.free_topological_data(s),{positions:d,indices:u,verticesPerFace:f}}},$b=["getX","getY","getZ"];function _p(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[$b[u]](d)*o)},`;if(c in i)n.push(i[c]);else{for(let u=0;u<3;u++)a.push(e[$b[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 Od=new M,Jf=new M,$f=new M,em=new M;function v2(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 l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let d=0;for(let u=0;u<l.length;u+=2)d+=(l[u]-l[(u===0?l.length:u)-2])*(l[u+1]+l[(u===0?l.length:u)-1]);e.length=0;let c=0;if(d<0)for(let u=0;u<l.length;u+=2)e.push(l[u],l[u+1],0),s.push(c++);else for(let u=l.length-2;u>=0;u-=2)e.push(l[u],l[u+1],0),s.push(c++);return n.push(c),{indices:s,verticesPerFace:n}}let a=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===a||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===a||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===a||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Od.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),Jf.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),$f.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),em.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),Jf.sub(Od).normalize(),$f.sub(Od).normalize(),em.sub(Od).normalize();let l=Jf.cross($f).dot(em);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:o>=r[d]&&o<r[d+1])?(s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),n.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],d=0;for(let c=0,u=0;c<e.length;c+=3,u++)e[c+2]===0&&(l.push(u),d++),e[c+2]===a&&h.push(u);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),n.push(d,d)}return{indices:s,verticesPerFace:n}}var on={};IE(on,{calcBoolean:()=>K8,calcBooleanTopological:()=>Z8,freeMeshSet:()=>tj,getMeshSet:()=>J8,hasOpenEdges:()=>$8,transformMeshSet:()=>ej});var y2,X8=new Promise(e=>{y2=e}),Bd;function Y8(){if(Bd)return Bd;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.423/build",[i,r]=await Promise.all([import("./boolean.js".toString()),fetch(`${t}/boolean.wasm`).then(a=>a.arrayBuffer())]),s=i.default,n=await s({wasmBinary:r});y2(n)}return Bd=e(),Bd}var at,ll;X8.then(e=>at=e);function Q8(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:n,triIndices:a}=_p(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=v2(n,a,e);o=h.length,r=[];for(let d=0,c=0;d<o;d++){r.push(h[d]);for(let u=0;u<h[d];u++)r.push(l[c++])}}else{let l=a.length;r=Array(l+l/3),o=0;for(let h=0,d=0;d<r.length;)r[d++]=3,o++,r[d++]=a[h++],r[d++]=a[h++],r[d++]=a[h++]}return{positions:n,faceIndices:r,nFaces:o}}function x2(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=at._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(at.HEAPU32.buffer,n,t):new Float32Array(at.HEAPF32.buffer,n,t)).set(e,0),n}function b2(e){switch(e){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function Z8(e,t){ll===void 0&&(ll=at.init_csg());let i=x2(e),r=at.csg_calc_topological(ll,i,e.length,b2(t));at._free(i);let s=6,n=at.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=at.HEAPU32[n[o]>>2],h=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let d=at.HEAPU32[n[o]>>2],c=new Uint32Array(at.HEAPU32.subarray(d>>2,(d>>2)+a[o]));o++;let u=at.HEAPU32[n[o]>>2],p=new Uint8Array(at.HEAPU32.subarray(u>>2,(u>>2)+a[o]));return at.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function K8(e,t,i,r){ll===void 0&&(ll=at.init_csg());let s=x2(e),n=at.csg_calc(ll,s,e.length,r,b2(t));at._free(s);let a=5,o=at.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,d=at.HEAPU32[o[h]>>2],c=at.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=at.HEAPU32[o[h]>>2],p=at.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Le(c,3)),i.setAttribute("normal",new Le(p,3));let g=at.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new _r),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},at.free_mesh_data(n),f}function J8(e,t,i){if(at===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let b=0;b<m.verticesPerFace[v];b++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=Q8(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=at._malloc(d),f=new Float32Array(at.HEAPF32.buffer,p,l),g=new Uint32Array(at.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),at.get_csg_mesh(p,a,p+c,o,n)}function $8(e){return at.has_open_edges(e)}function ej(e,t){at.transform_csg_mesh(e,t.elements)}function tj(e){at.free_csg_mesh(e)}var ij={ConeGeometry:L6,CubeGeometry:O6,CylinderGeometry:YA,DodecahedronGeometry:R6,EllipseGeometry:_0,HelixGeometry:p8,IcosahedronGeometry:f8,LatheGeometry:m8,NonParametricGeometry:_8,PolygonGeometry:d2,PyramidGeometry:S8,RectangleGeometry:u2,SphereGeometry:E8,PlaneGeometry:C8,BackdropGeometry:T8,StarGeometry:p2,TextFrameGeometry:D8,TorusGeometry:I8,TorusKnotGeometry:O8,TriangleGeometry:B8,PathGeometry:F8,VectorGeometry:to},ew=e=>ij[e.type].create(e);function yh(e){return e!==null&&"booleanOp"in e}var w2=class extends g0(ir){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new fe}updateVisible(){super.updateVisible(),this.visible=!yh(this.parent)&&this.visible,yh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(on.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),yh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof w2&&(e.freeBooleanPointer(),yh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&yh(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},Rd=new Kt;function A0(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)}Rd.min.set(n,a,o),Rd.max.set(l,h,d),Rd.getCenter(r),Rd.getSize(s).multiplyScalar(.5)}var rj=new qe,sj=new xc,lr=class extends w2{constructor(e,t){super(rj,sj),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?A0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},tw=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}},la=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=nt.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 la&&(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}},nj=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}},tr=new nj,Et=class extends la{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=nt.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}},hr=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))}},Ci=class extends hr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof F?e:new F(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)}},Ir=class extends hr{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof M?e:new M(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)}},ar=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}},ln=class extends hr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof ar?e:new ar(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)}},aj=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,iw=/[a-z_0-9]+/gi,_e=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=iw.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&&tr.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=tr.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||tr.getKeyword(c,e),g.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&&tr.contains(p)&&e.include(tr.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=aj.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(iw);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=""}}},oj=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,_2=class extends Et{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||_2.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=oj.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)}},_t=_2;_t.PI="PI",_t.PI2="PI2",_t.RECIPROCAL_PI="RECIPROCAL_PI",_t.RECIPROCAL_PI2="RECIPROCAL_PI2",_t.LOG2="LOG2",_t.EPSILON="EPSILON";var lj=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 g2,S0=new Promise(e=>{g2=e}),Qb=!1,Id;function W8(){if(Qb)return;if(Id)return Id;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.424/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});g2(a),Qb=!0}return Id=e(),Id}function Xu(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=Vt.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 _S().parse(e);else{if(e.type==="SubdivGeometry")return new Hi(e,i);if(e.type==="TextGeometry")return new m2(e,t)}let s;try{s=ew(r)}catch(n){console.error(n)}if(!s){let n=Vt.createFromState(zu.defaultData(),100,100);r.shape=n,s=ew(r)}return s}var q8=new fe;function Wg(e,t,i,r){let s=e.position.array,n=e.normal.array,a=q8.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 Ld=new Kt,Po=new M,Fe;S0.then(e=>{Fe=e});var Zb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Kb=new Uint32Array([0,1,2,3]),Jb=new Uint8Array([4]),Hi=class extends qe{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=ja.div(t,i);this.subdividedGeometry&&Wg(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Wg(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(Po.fromArray(r));let n=Po.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}=Hi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Rs(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&&(Hi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new _r,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Ld.setFromBufferAttribute(t),Ld.getCenter(i),e.boundingSphere.radius=i.distanceTo(Ld.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ld.getSize(Po);let r={width:Po.x,height:Po.y,depth:Po.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&&(Fe.free_bvh(t),Fe.free_subdivision_surface(t));try{s=Hi.allocate(e,r)}catch(l){console.error(l,e),s=Hi.allocate({positionWASM:Zb,indexWASM:Kb,verticesPerFaceWASM:Jb},r)}if(Fe.set_destination_refinement_level(s,0),n=Hi.buildLevel(s,!0,o),e.subdivisions>0)try{Fe.set_destination_refinement_level(s,e.subdivisions),a=Hi.buildLevel(s,!1,o)}catch{try{Fe.set_destination_refinement_level(s,e.subdivisions-1),a=Hi.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||e.path!==void 0?t.geometry:Xu(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let n,a,o,l;({positions:n,triIndices:l}=_p(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,c=d+e.radialSegments*3;h=[d,c]}return{indices:a,verticesPerFace:o}=v2(n,l,r,h),{positions:n,indices:a,verticesPerFace:o}}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=Zb,r=Kb,s=Jb);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,g=Fe._malloc(u),m=new Float32Array(Fe.HEAPF32.buffer,g,d),v=new Uint32Array(Fe.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new fe().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?Fe.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Fe.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Fe._free(g),x}static buildLevel(e,t,i,r,s){let n=s?Fe.get_mesh_data2(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i,s.elements):Fe.get_mesh_data(e,t?Fe.Level.CONTROL:Fe.Level.REFINED,i),a=8,o=Fe.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,d=Fe.HEAPU32[o[h]>>2],c=Fe.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=Fe.HEAPU32[o[h]>>2],p=Fe.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=Fe.HEAPU32[o[h]>>2],g=Fe.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Fe.HEAPU32[o[h]>>2],v=Fe.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new qe;if(y.setIndex(new $o(v,1)),y.setAttribute("position",new Le(c,3)),y.setAttribute("normal",new Le(p,3)),t){y.setAttribute("faceMap",new $o(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ye(x,4))}return Fe.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,Fe.free_mesh_data(n)}static freeSubdivPointer(e){Fe.free_bvh(e),Fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Fe.get_wireframe_data_for_base_level(e),s=4,n=Fe.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Fe.HEAPU32[n[o]>>2],h=Fe.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let d=Fe.HEAPU32[n[o]>>2],c=Fe.HEAPU32.subarray(d>>2,(d>>2)+a[o]);if(t===void 0){let u=new qe;u.setAttribute("position",new Le(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Ye(p,3)),u.setIndex(new $o(c,1)),Fe.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Fe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Fe.set_destination_refinement_level(e,t);let s=i?Fe.get_topological_data2(e,r?Fe.Level.CONTROL:Fe.Level.REFINED,i.elements):Fe.get_topological_data(e,r?Fe.Level.CONTROL:Fe.Level.REFINED),n=6,a=Fe.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Fe.HEAPU32[a[l]>>2],d=new Float32Array(Fe.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Fe.HEAPU32[a[l]>>2],u=new Uint32Array(Fe.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Fe.HEAPU32[a[l]>>2],f=new Uint8Array(Fe.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Fe.free_topological_data(s),{positions:d,indices:u,verticesPerFace:f}}},$b=["getX","getY","getZ"];function _p(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[$b[u]](d)*o)},`;if(c in i)n.push(i[c]);else{for(let u=0;u<3;u++)a.push(e[$b[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 Od=new M,Jf=new M,$f=new M,em=new M;function v2(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 l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let d=0;for(let u=0;u<l.length;u+=2)d+=(l[u]-l[(u===0?l.length:u)-2])*(l[u+1]+l[(u===0?l.length:u)-1]);e.length=0;let c=0;if(d<0)for(let u=0;u<l.length;u+=2)e.push(l[u],l[u+1],0),s.push(c++);else for(let u=l.length-2;u>=0;u-=2)e.push(l[u],l[u+1],0),s.push(c++);return n.push(c),{indices:s,verticesPerFace:n}}let a=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===a||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===a||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===a||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Od.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),Jf.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),$f.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),em.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),Jf.sub(Od).normalize(),$f.sub(Od).normalize(),em.sub(Od).normalize();let l=Jf.cross($f).dot(em);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:o>=r[d]&&o<r[d+1])?(s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),n.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],d=0;for(let c=0,u=0;c<e.length;c+=3,u++)e[c+2]===0&&(l.push(u),d++),e[c+2]===a&&h.push(u);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),n.push(d,d)}return{indices:s,verticesPerFace:n}}var on={};IE(on,{calcBoolean:()=>K8,calcBooleanTopological:()=>Z8,freeMeshSet:()=>tj,getMeshSet:()=>J8,hasOpenEdges:()=>$8,transformMeshSet:()=>ej});var y2,X8=new Promise(e=>{y2=e}),Bd;function Y8(){if(Bd)return Bd;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.424/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});y2(a)}return Bd=e(),Bd}var at,ll;X8.then(e=>at=e);function Q8(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:n,triIndices:a}=_p(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=v2(n,a,e);o=h.length,r=[];for(let d=0,c=0;d<o;d++){r.push(h[d]);for(let u=0;u<h[d];u++)r.push(l[c++])}}else{let l=a.length;r=Array(l+l/3),o=0;for(let h=0,d=0;d<r.length;)r[d++]=3,o++,r[d++]=a[h++],r[d++]=a[h++],r[d++]=a[h++]}return{positions:n,faceIndices:r,nFaces:o}}function x2(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=at._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(at.HEAPU32.buffer,n,t):new Float32Array(at.HEAPF32.buffer,n,t)).set(e,0),n}function b2(e){switch(e){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function Z8(e,t){ll===void 0&&(ll=at.init_csg());let i=x2(e),r=at.csg_calc_topological(ll,i,e.length,b2(t));at._free(i);let s=6,n=at.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=at.HEAPU32[n[o]>>2],h=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let d=at.HEAPU32[n[o]>>2],c=new Uint32Array(at.HEAPU32.subarray(d>>2,(d>>2)+a[o]));o++;let u=at.HEAPU32[n[o]>>2],p=new Uint8Array(at.HEAPU32.subarray(u>>2,(u>>2)+a[o]));return at.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function K8(e,t,i,r){ll===void 0&&(ll=at.init_csg());let s=x2(e),n=at.csg_calc(ll,s,e.length,r,b2(t));at._free(s);let a=5,o=at.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,d=at.HEAPU32[o[h]>>2],c=at.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=at.HEAPU32[o[h]>>2],p=at.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Le(c,3)),i.setAttribute("normal",new Le(p,3));let g=at.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new _r),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},at.free_mesh_data(n),f}function J8(e,t,i){if(at===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let b=0;b<m.verticesPerFace[v];b++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=Q8(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=at._malloc(d),f=new Float32Array(at.HEAPF32.buffer,p,l),g=new Uint32Array(at.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),at.get_csg_mesh(p,a,p+c,o,n)}function $8(e){return at.has_open_edges(e)}function ej(e,t){at.transform_csg_mesh(e,t.elements)}function tj(e){at.free_csg_mesh(e)}var ij={ConeGeometry:L6,CubeGeometry:O6,CylinderGeometry:YA,DodecahedronGeometry:R6,EllipseGeometry:_0,HelixGeometry:p8,IcosahedronGeometry:f8,LatheGeometry:m8,NonParametricGeometry:_8,PolygonGeometry:d2,PyramidGeometry:S8,RectangleGeometry:u2,SphereGeometry:E8,PlaneGeometry:C8,BackdropGeometry:T8,StarGeometry:p2,TextFrameGeometry:D8,TorusGeometry:I8,TorusKnotGeometry:O8,TriangleGeometry:B8,PathGeometry:F8,VectorGeometry:to},ew=e=>ij[e.type].create(e);function yh(e){return e!==null&&"booleanOp"in e}var w2=class extends g0(ir){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new fe}updateVisible(){super.updateVisible(),this.visible=!yh(this.parent)&&this.visible,yh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(on.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),yh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof w2&&(e.freeBooleanPointer(),yh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&yh(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},Rd=new Kt;function A0(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)}Rd.min.set(n,a,o),Rd.max.set(l,h,d),Rd.getCenter(r),Rd.getSize(s).multiplyScalar(.5)}var rj=new qe,sj=new xc,lr=class extends w2{constructor(e,t){super(rj,sj),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?A0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},tw=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}},la=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=nt.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 la&&(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}},nj=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}},tr=new nj,Et=class extends la{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=nt.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}},hr=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))}},Ci=class extends hr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof F?e:new F(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)}},Ir=class extends hr{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof M?e:new M(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)}},ar=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}},ln=class extends hr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof ar?e:new ar(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)}},aj=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,iw=/[a-z_0-9]+/gi,_e=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=iw.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&&tr.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=tr.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||tr.getKeyword(c,e),g.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&&tr.contains(p)&&e.include(tr.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=aj.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(iw);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=""}}},oj=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,_2=class extends Et{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||_2.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=oj.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)}},_t=_2;_t.PI="PI",_t.PI2="PI2",_t.RECIPROCAL_PI="RECIPROCAL_PI",_t.RECIPROCAL_PI2="RECIPROCAL_PI2",_t.LOG2="LOG2",_t.EPSILON="EPSILON";var lj=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3141
3141
|
)*?)}`,"gim"),hj=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),S2=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=lj.exec(e);if(t){let i=t[2],r;for(;r=hj.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},M0=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)}};tr.addKeyword("uv",function(){return new M0});tr.addKeyword("uv2",function(){return new M0(1)});var Go=class extends Et{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Go.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Bs:return["Linear"];case Je:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=Go.Nodes[this.method],n=e.include(s);if(n===Go.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=Go.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Go.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Ds=Go;Ds.Nodes={LinearToLinear:new _e(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3142
3142
|
`)),sRGBToLinear:new _e(["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 _e(["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(`
|
|
@@ -5349,7 +5349,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
5349
5349
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result} * ${c}, ${a.result} );
|
|
5350
5350
|
}
|
|
5351
5351
|
`),o&&d.push(o.code,`outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),l?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&d.push(`gl_FragColor.a *= ${h.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
|
|
5352
|
-
`)}return t}},Pj=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;)this.dispose(t.src,t.data),this.cache.delete(t.src),t=t.next,t.prev=this.head,this.head.next=t;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}},Dj=class extends Pj{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},tm;function Ij(e){return typeof e=="string"?e:(tm||(tm=new Dj),tm.load(e))}var Lj=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Oj=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},X2=class extends Lj{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isVideo=e.type==="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let s of r){let n=this[s];n&&(n.image=this.img,n.needsUpdate=!0)}this.shared.requestRender()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=n=>{r=n.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=Ij(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let i;return this.isVideo?i=new qI(this.img,void 0,e,e):i=new ci(this.img,void 0,e,e),this.loaded&&(i.needsUpdate=!0),this[e]=i,i}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}},Ra=class extends X2{};function qi(e,t){return t.color(e)}function Bj(e,t){switch(e.type){case"fresnel":return Nj(e,t);case"gradient":return Uj(e);case"depth":return Fj(e);case"normal":return kj(e);case"noise":return jj(e,t);case"rainbow":return Gj(e);case"toon":return Vj(e,t);case"outline":return Hj(e,t);case"transmission":return Wj(e,t);case"color":return zj(e,t);case"pattern":return qj(e,t)}}function Rj(e){return{type:e.type}}function ls(e){let{alpha:t,mode:i,isMask:r}=e;return{...Rj(e),alpha:t,mode:i,isMask:r}}function zj(e,t){return{...ls(e),color:qi(e.color,t)}}function Nj(e,t){let{bias:i,scale:r,intensity:s,factor:n,color:a,isMask:o}=e;return{...ls(e),color:qi(a,t),bias:i,scale:r,intensity:s,factor:n}}function Uj(e){let{gradientType:t,smooth:i,colors:r,steps:s,angle:n,offset:a,morph:o}=e;return{...ls(e),gradientType:t,smooth:i,colors:r.map(l=>new $e(l[0],l[1],l[2],l[3])),num:r.length,steps:s,offset:new F(...a),morph:new F(...o),angle:n}}function Fj(e){let{gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:a,direction:o,colors:l,steps:h,smooth:d}=e;return{...ls(e),gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:new M(...a),direction:o?new M(...o):new M(1,0,0),colors:l.map(c=>c!==void 0?new $e(c[0],c[1],c[2],c[3]):new $e(0,0,0,0)),steps:h.slice(0,l.length),smooth:d}}function kj(e){let{cnormal:t}=e;return{...ls(e),cnormal:new M(t[0],t[1],t[2])}}function jj(e,t){return{...ls(e),scale:e.scale,move:e.move,fA:new F(...e.fA),fB:new F(...e.fB),size:new M(...e.size),distortion:new F(...e.distortion),colorA:qi(e.colorA,t),colorB:qi(e.colorB,t),colorC:qi(e.colorC,t),colorD:qi(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function Gj(e){return{...ls(e),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new M(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new M(...e.offset)}}function Vj(e,t){return{...ls(e),positioning:e.positioning,colors:e.colors.map(i=>new $e(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new M(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:qi(e.shadowColor,t),offset:new M(...e.offset)}}function Hj(e,t){return{...ls(e),outlineColor:qi(e.outlineColor,t),contourColor:qi(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new M(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function Wj(e,t){return{...ls(e),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function qj(e,t){return{...ls(e),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new F(...e.offset),colorA:qi(e.colorA,t),colorB:qi(e.colorB,t),frequency:new F(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new F(...e.vertical),horizontal:new F(...e.horizontal),sides:e.sides}}var Yu=class extends ar{},Y2={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Q2={depth:["colors"]};function Xj(e,t,i){if(t==="isMask")return!0;let r=Y2[e.type],s=Q2[e.type];if(s!==void 0){let n=e.color;if(s.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function Z2(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,n=e;if("image"in n){let a=n.image,o=t.image(a),l=r;l.image instanceof Ra||l.image.deref(),l.image=o}if("video"in n){let a=n.video,o=t.video(a),l=r;l.image instanceof Ra||l.image.deref(),l.image=o}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("repeat"in n||"offset"in n){let a="mat",o=i.uniforms[`f${i.id}_${a}`];"repeat"in n&&(o.repeat=n.repeat),"offset"in n&&(o.offset=n.offset),o.updateMatrix()}return s}function Yj(e,t,i,r){let s=!1;for(let[n,a]of Object.entries(e)){if(n==="bumpMap"||n==="roughnessMap"){s=!0;continue}if(!n||a===void 0)continue;if(J2(n,i,r)){n==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${n}`];if(!!o&&!(o instanceof E0))switch(s=s||Xj(i,n,a),o.constructor){case Ht:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof Yu?o.value=new ar(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case ln:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof Yu?o.value=new ar(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Ci:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]);break}case Ir:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case un:{Z2(a,t,i);break}case Ca:{o.value=a.map(l=>new $e(...l));break}default:{o.value=a;break}}}return s}var Ha=class{constructor(e,t,i,r){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let s in r)this.uniforms[`f${this.id}_${s}`]=r[s];for(let s in i)J2(s,this,i)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return hn.createLigherLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.image(i.texture.image):r.video(i.texture.video),n=new Xg(s,i.texture.wrapping),a=new bj(s),o=new wj(i.texture.repeat,i.texture.offset),l=new Ce(i.crop?1:0),h=new Tt(i.projection??0),d=new Tt(["x","y","z"].indexOf(i.axis)??0),c=new Tt(i.side??0),u=new Ci(i.size?new F(i.size[0],i.size[1]):new F(100,100)),p=new Ce(i.blending??0),f=new Ce(i.alpha??1),g=new Tt(i.mode??0),m=new Wi(i.isMask??!1),v=new C0(n,a,l,h,d,c,u,p,o,f,g,m),y=new Rt(v.calpha,"f");return new jt(e,t,i,{texture:n,textureSize:a,crop:l,projection:h,axis:d,side:c,size:u,blending:p,mat:o,alpha:f,mode:g,isMask:m},v,g,y,m)}else if(i.type==="matcap"){let s=r.image(i.texture.image),n=new Xg(s,i.texture.wrapping),a=new Ce(i.alpha??1),o=new Tt(i.mode??0),l=new Wi(i.isMask??!1),h=new O2(n,a,o,l),d=new Rt(h.calpha,"f");return new jt(e,t,i,{texture:n,alpha:a,mode:o,isMask:l},h,o,d,l)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new Ir(new M(...i.offset)),n=new Ce(i.scale??10),a=new Ce(i.intensity??8),o=new Ce(i.movement??1),l=new Tt(i.noiseType??0),h=new Tt(i.voronoiStyle??0),d=new Ce(i.smoothness??.5),c=new Ce(i.seed??0),u=new Ce(i.highCut??1),p=new Ce(i.lowCut??0),f=new Tt(i.quality??1),g=new W2(a,o,s,h,d,c,u,p,f,n,l);return new K2(e,t,i,{offset:s,scale:n,intensity:a,movement:o,noiseType:l,voronoiStyle:h,smoothness:d,seed:c,highCut:u,lowCut:p,quality:f},g)}else throw new Error;else return Kj(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):Yj(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?Z2(r.props,i.shared,this):!0;return!1}dispose(){if(Qj(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Ra||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},jt=class extends Ha{constructor(e,t,i,r,s,n,a,o){super(e,t,i,r),this.params=r,this.color=s,this.mode=n,this.alpha=a,this.isMask=o}},K2=class extends Ha{constructor(e,t,i,r,s){super(e,t,i,r),this.position=s}},hn=class extends Ha{constructor(e,t,i,r,s){super(e,t,i,s),this.node=r}static createLigherLayer(e,t,i,r){let s,n=new Ce(i.alpha),a=new Tt(i.mode),o=new Ce(i.bumpMapIntensity),l=new Ce(i.alphaOverride),h;if(!i.visible)s=new q2,h={};else if(i.category==="lambert"){s=new Mj;let d=new Ht(r.color(i.emissive)??0),c=new Wi(i.occlusion??!0);h={emissive:d,occlusion:c},s.emissive=d,s.occlusion=c}else if(i.category==="toon"){s=new Tj;let d=new Ce(i.shininess??30),c=new Ht(r.color(i.specular)??1118481);h={shininess:d,specular:c},s.shininess=d,s.specular=c}else if(i.category==="physical"){s=new Cj;let d=new Ce(i.roughness??.3),c=new Ce(i.metalness??0),u=new Ce(i.reflectivity??.5),p=new Wi(i.occlusion??!0);h={roughness:d,metalness:c,reflectivity:u,occlusion:p},s.roughness=d,s.metalness=c,s.reflectivity=u,s.occlusion=p}else{s=new Ej;let d=new Ce(i.shininess??30),c=new Ht(i.specular!==void 0?r.color(i.specular)??1118481:1118481),u=new Wi(i.occlusion??!0);h={shininess:d,specular:c,occlusion:u},s.shininess=d,s.specular=c,s.occlusion=u}return s.alpha=new Ce(1),s.shadingAlpha=n,s.shadingBlend=a,s.bumpMapIntensity=o,s.alphaOverride=l,h.alpha=s.shadingAlpha,h.mode=s.shadingBlend,h.bumpMapIntensity=s.bumpMapIntensity,h.alphaOverride=s.alphaOverride,new hn(e,t,i,s,h)}get category(){return this.node.category}};function Qj(e){let t=e instanceof Ha?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Cr(e){return{alpha:new Ce(e.alpha??1),mode:new Tt(e.mode??0),isMask:new Wi(e.isMask??!1)}}function Zj(e,t,i,r){switch(e.type){case"color":{let s=new Ht(r.color??jr),n=Cr(r),a=new Yg(s,n.alpha),o=new Rt(a.calpha,"f");return new jt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}case"fresnel":{let s=new Ht(r.color??16777215),n=new Ce(r.bias??.1),a=new Ce(r.scale??1),o=new Ce(r.intensity??2),l=new Ce(r.factor??1),h=Cr(r),d=new _j(s,n,a,o,l,h.alpha,h.mode,h.isMask),c=new Rt(d.calpha,"f");return new jt(t,i,e,{color:s,bias:n,scale:a,intensity:o,factor:l,...h},d,h.mode,c,h.isMask)}case"rainbow":{let s=new Ce(r.filmThickness??30),n=new Ce(r.movement??0),a=new Ir(r.wavelengths??new M(0,0,0)),o=new Ce(r.noiseStrength??0),l=new Ce(r.noiseScale??1),h=new Ir(r.offset??new M(0,0,0)),d=Cr(r),c=new F2(s,n,a,o,l,h,d.alpha,d.isMask),u=new Rt(c.calpha,"f");return new jt(t,i,e,{filmThickness:s,movement:n,wavelengths:a,noiseStrength:o,noiseScale:l,offset:h,...d},c,d.mode,u,d.isMask)}case"transmission":{let s=new Ce(r.thickness??10),n=new Ce(r.ior??1.5),a=new Ce(r.roughness??.5),o=ke.transmissionSize,l=ke.transmissionRenderTarget,h=ke.transmissionRenderTargetDepth,d=window.innerWidth,c=window.innerHeight,u=d>=c?new Ci(c/d,1):new Ci(1,d/c),p=Cr(r),f=new V2(s,n,a,o,l,h,u,p.alpha),g=new Rt(f.calpha,"f");return new jt(t,i,e,{thickness:s,ior:n,roughness:a,aspectRatio:u,...p},f,p.mode,g,p.isMask)}case"toon":{let s=new Tt(r.positioning??0),n;r.colors?n=new Ca(r.colors.length,r.colors):(n=new Ca(10,new $e(0,0,0,1)),n.value[1]=new $e(1,1,1,1));let a;r.steps?a=new Ea(r.steps.length,r.steps):(a=new Ea(10,1),a.value[0]=0);let o=new Ir(r.source??new M(0,0,0)),l=new Wi(r.isWorldSpace??!0),h=new Ce(r.noiseStrength??0),d=new Ce(r.noiseScale??1),c=new ln(r.shadowColor),u=new Ir(r.offset??new M(0,0,0)),p=Cr(r),f=new j2(s,n,a,o,l,h,d,c,u,p.alpha),g=new Rt(f.calpha,"f");return new jt(t,i,e,{positioning:s,colors:n,steps:a,source:o,isWorldSpace:l,noiseStrength:h,noiseScale:d,shadowColor:c,offset:u,...p},f,p.mode,g,p.isMask)}case"outline":{let s=new Ht(r.outlineColor??16777215),n=new Ht(r.contourColor??16777215),a=new Ce(r.outlineWidth??.1),o=new Ce(r.contourWidth??.1),l=new Ce(r.outlineThreshold??.1),h=new Ce(r.contourThreshold??.1),d=new Ce(r.outlineSmoothing??.1),c=new Ce(r.contourFrequency??.1),u=new Ir(r.contourDirection??new M(0,1,0)),p=new Wi(r.positionalLines??!1),f=new Wi(r.compensation??!0),g=ke.normalRenderTarget,m=ke.normalRenderTargetDepth,v=ke.pixelRatioNode,y=ke.resolution,x=Cr(r),b=new z2(s,n,a,o,l,h,d,c,u,p,f,y,g,m,v,x.alpha),_=new Rt(b.calpha,"f");return new jt(t,i,e,{outlineColor:s,contourColor:n,outlineWidth:a,contourWidth:o,outlineThreshold:l,contourThreshold:h,outlineSmoothing:d,contourFrequency:c,contourDirection:u,positionalLines:p,compensation:f,...x},b,x.mode,_,x.isMask)}case"depth":{let s=new Tt(r.gradientType??0),n=new Wi(r.smooth??!1),a=new Ce(r.near??50),o=new Ce(r.far??200),l=new Ce(r.isVector??1),h=new Ce(r.isWorldSpace??0),d=new Ir(r.origin??new M),c=new Ir(r.direction??new M),u;r.colors?u=new Ca(r.colors.length,r.colors):(u=new Ca(2,new $e(0,0,0,1)),u.value[1]=new $e(1,1,1,1));let p;r.steps?p=new Ea(r.steps.length,r.steps):(p=new Ea(2,1),p.value[0]=0);let f=Cr(r),g=new P2(s,n,a,o,l,h,d,c,u,p,f.alpha,f.isMask),m=new Rt(g.calpha,"f");return new jt(t,i,e,{gradientType:s,smooth:n,near:a,far:o,isVector:l,isWorldSpace:h,origin:d,direction:c,colors:u,steps:p,...f},g,f.mode,m,f.isMask)}case"noise":{let s=new Ce(r.scale??1),n=new Ir(r.size??new M(100,100,100)),a=new Ce(r.move??1),o=new Ci(r.fA??new F(1.7,9.2)),l=new Ci(r.fB??new F(8.3,2.8)),h=new Ci(r.distortion??new F(1,1)),d=new ln(r.colorA),c=new ln(r.colorB),u=new ln(r.colorC),p=new ln(r.colorD),f=new Tt(r.noiseType??0),g=new Tt(r.voronoiStyle??0),m=new Ce(r.highCut??1),v=new Ce(r.lowCut??0),y=new Ce(r.smoothness??.5),x=new Ce(r.seed??.5),b=new Tt(r.quality??1),_=Cr(r),A=new B2(s,n,a,o,l,h,d,c,u,p,_.alpha,f,_.isMask,g,m,v,y,x,b),S=new Rt(A.calpha,"f");return new jt(t,i,e,{scale:s,size:n,move:a,fA:o,fB:l,distortion:h,colorA:d,colorB:c,colorC:u,colorD:p,noiseType:f,..._,voronoiStyle:g,highCut:m,lowCut:v,smoothness:y,seed:x,quality:b},A,_.mode,S,_.isMask)}case"normal":{let s=new Ir(r.cnormal??new M(1,1,1)),n=Cr(r),a=new T2(s,n.alpha),o=new Rt(a.calpha,"f");return new jt(t,i,e,{cnormal:s,...n},a,n.mode,o,n.isMask)}case"gradient":{let s=new Tt(r.gradientType??0),n=new Wi(r.smooth??!1),a;r.colors?a=new Ca(r.colors.length,r.colors):(a=new Ca(10,new $e(0,0,0,1)),a.value[1]=new $e(1,1,1,1));let o;r.steps?o=new Ea(r.steps.length,r.steps):(o=new Ea(10,1),o.value[0]=0);let l=new Ci(r.offset??new F(0,0)),h=new Ci(r.morph??new F(0,0)),d=new Ce(r.angle??0),c=Cr(r),u=new I2(s,n,a,o,l,h,d,c.alpha,c.isMask),p=new Rt(u.calpha,"f");return new jt(t,i,e,{gradientType:s,smooth:n,colors:a,steps:o,offset:l,morph:h,angle:d,...c},u,c.mode,p,c.isMask)}case"pattern":{let s=new Tt(r.style??0),n=new Tt(r.projection??0),a=new Tt(["x","y","z"].indexOf(r.axis)??0),o=new Ce(r.blending??0),l=new Ci(r.offset??new F(0,0)),h=new ln(r.colorA),d=new ln(r.colorB),c=new Ci(r.frequency??new F(10,10)),u=new Ce(r.size??.5),p=new Ce(r.variation??0),f=new Ce(r.smoothness??.5),g=new Ce(r.zigzag??0),m=new Ce(r.rotation??0),v=new Ci(r.vertical??new F(0,1)),y=new Ci(r.horizontal??new F(0,1)),x=new Tt(r.sides??6),b=Cr(r),_=new N2(s,n,a,o,l,h,d,c,u,p,f,g,m,v,y,x,b.alpha,b.isMask),A=new Rt(_.calpha,"f");return new jt(t,i,e,{style:s,projection:n,axis:a,blending:o,offset:l,colorA:h,colorB:d,frequency:c,size:u,variation:p,smoothness:f,zigzag:g,rotation:m,vertical:v,horizontal:y,sides:x,...b},_,b.mode,A,b.isMask)}default:{let s=new Ht(1,0,0,1),n=Cr(r),a=new Yg(s,n.alpha),o=new Rt(a.calpha,"f");return new jt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}}}function Kj(e,t,i,r){let s=Bj(i,r);return Zj(i,e,t,s)}function J2(e,t,i){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=i.intensity*(i.visible?1:0),r):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=i.alpha*(i.visible?1:0),i.type==="outline"&&e==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=i.compensation&&i.visible)}return r}}function Qu(e,t){let i=0,r=e.layers.find(s=>s.data.type==="light");if(r&&r.data.alphaOverride<1)return!0;for(let s of e.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let n=s.data.visible?s.data.alpha:0;if(n===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let a of s.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&s.data.type==="noise"){let a=t.color(s.data.colorA).a,o=t.color(s.data.colorB).a,l=t.color(s.data.colorC).a,h=t.color(s.data.colorD).a,d=Math.min(a,Math.min(o,Math.min(l,h)));d<1&&(n=d)}i+=(1-i)*n}}return i<1}var aa=class extends Lt{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.cacheKey="",this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Jj=class extends aa{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i){return this.root.getFlavor(e,t,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},P0=class extends aa{constructor(e,t){super(),this.data=e,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,i){let r=i?6:(e?3:0)+t;if(r===0)return this;this.flavors===void 0&&(this.flavors=[]),r-=1;let s=this.flavors[r];return s===void 0&&(s=new Jj(e,t,i,this),this.flavors[r]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let i=e.layers??zi.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>Ha.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Qu(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof hn),this.lightLayer===void 0&&(this.lightLayer=new hn(0,"",{...Ji.defaultData("light","phong"),visible:!1},new q2,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(s=>s instanceof hn);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let s=0;s<this.layers.length;++s){let n=this.layers[s];n instanceof jt&&n.color instanceof C0&&(n.uuid===i&&(e.node.bumpMap=n.color),n.uuid===r&&(e.node.roughnessMap=n.color))}}updateByOp(e,t,i){if(t!==void 0?this.data=t:t=this.data,this.transparent=Qu(t,i.shared),e.path[0]==="layers"){this.data=t;let r=i.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let n=Ha.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,n),i.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let n=this.layers.findIndex(o=>o.uuid===e.id),a=this.layers[n];this.layers.splice(n,1),this.layers.splice(e.localIndex,0,a),i.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let n=this.layers.find(a=>a.uuid===s);if(n){let a=t.layers.data(s);if(n.updateByOp({...e,path:e.path.slice(2)},a,i)){let o=Ha.create(this.layerIdGen++,s,a,r);this.layers.splice(this.layers.findIndex(l=>l.uuid===s),1,o),this.onUpdate()}}}}else this.reset(t,i)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof jt?t.color.mask=void 0:t instanceof hn&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof jt&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof hn?r.node.mask=new Ki(t.color,t.alpha,Ki.MUL):r instanceof jt&&(r.isMask.value||(r.color.mask=new Ki(t.color,t.alpha,Ki.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof jt),t=this.layers.findIndex(i=>i instanceof hn);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let s=this.layers[r];if(s instanceof jt){if(s.isMask.value)continue;i=new aw(i,s.color,s.alpha,s.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Rt("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof hn);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof jt){if(r.isMask.value)continue;e=new aw(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof K2);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Ki(t,e[i].position,Ki.ADD),t=new Ki(t,new Ce(.5).setReadonly(!0),Ki.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,s,n)=>Math.min(Math.max(r,s),n);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let i=(Y2[t.type]??[]).map(o=>t[o]),r=(Q2[t.type]??[]).map(o=>t[o]?.length??0),s=[...i,...r],n="isMask"in t&&t.isMask,a=`"${t.type}-${t.visible}-${n}"`;s.length?e+=`[${a}, "${s.join('","')}"],`:e+=a}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new xj;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof jt){let t=e.params.texture;if(t instanceof Xg&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(aa.prototype,{properties:{get:function(){return this.fragment.properties}}});var Zg=class extends P0{},$j=Pl(zE()),ow=new Map;function eG(e){if(typeof e=="string")return e;let t=ow.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},ow.set(e,t)),t.url}var Nh=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:eG(e),format:"wav"},this.sound=new $j.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},tG=class{constructor(){this.type="ShapePath",this.color=new je,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new mu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,n){return this.currentPath?.bezierCurveTo(e,t,i,r,s,n),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,f,g,m){let v=p.x,y=f.x,x=g.x,b=m.x,_=p.y,A=f.y,S=g.y,w=m.y,E=(b-x)*(_-S)-(w-S)*(v-x),C=(y-v)*(_-S)-(A-_)*(v-x),T=(w-S)*(y-v)-(b-x)*(A-_),D=E/T,P=C/T;if(T===0&&E!==0||D<=0||D>=1||P<0||P>1)return null;if(E===0&&T===0){for(let L=0;L<2;L++)if(r(L===0?g:m,p,f),t.loc===e.ORIGIN){let R=L===0?g:m;return{x:R.x,y:R.y,t:t.t}}else if(t.loc===e.BETWEEN){let R=+(v+t.t*(y-v)).toPrecision(10),V=+(_+t.t*(A-_)).toPrecision(10);return{x:R,y:V,t:t.t}}return null}else{for(let V=0;V<2;V++)if(r(V===0?g:m,p,f),t.loc===e.ORIGIN){let k=V===0?g:m;return{x:k.x,y:k.y,t:t.t}}let L=+(v+D*(y-v)).toPrecision(10),R=+(_+D*(A-_)).toPrecision(10);return{x:L,y:R,t:D}}}function r(p,f,g){let m=g.x-f.x,v=g.y-f.y,y=p.x-f.x,x=p.y-f.y,b=m*x-y*v;if(p.x===f.x&&p.y===f.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===g.x&&p.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(b<-Number.EPSILON){t.loc=e.LEFT;return}if(b>Number.EPSILON){t.loc=e.RIGHT;return}if(m*y<0||v*x<0){t.loc=e.BEHIND;return}if(Math.sqrt(m*m+v*v)<Math.sqrt(y*y+x*x)){t.loc=e.BEYOND;return}let _;m!==0?_=y/m:_=x/v,t.loc=e.BETWEEN,t.t=_}function s(p,f){let g=[],m=[];for(let v=1;v<p.length;v++){let y=p[v-1],x=p[v];for(let b=1;b<f.length;b++){let _=f[b-1],A=f[b],S=i(y,x,_,A);S!==null&&g.find(w=>w.t<=S.t+Number.EPSILON&&w.t>=S.t-Number.EPSILON)===void 0&&(g.push(S),m.push(new F(S.x,S.y)))}}return m}function n(p,f,g){let m=new F;f.getCenter(m);let v=[];return g.forEach(y=>{y.boundingBox.containsPoint(m)&&s(p,y.points).forEach(x=>{v.push({identifier:y.identifier,isCW:y.isCW,point:x})})}),v.sort((y,x)=>y.point.x-x.point.x),v}function a(p,f,g,m,v){(v==null||v==="")&&(v="nonzero");let y=new F;p.boundingBox.getCenter(y);let x=[new F(g,y.y),new F(m,y.y)],b=n(x,p.boundingBox,f);b.sort((C,T)=>C.point.x-T.point.x);let _=[],A=[];b.forEach(C=>{C.identifier===p.identifier?_.push(C):A.push(C)});let S=_[0].point.x,w=[],E=0;for(;E<A.length&&A[E].point.x<S;)w.length>0&&w[w.length-1]===A[E].identifier?w.pop():w.push(A[E].identifier),E++;if(w.push(p.identifier),v==="evenodd"){let C=w.length%2===0,T=w[w.length-2];return{identifier:p.identifier,isHole:C,for:T}}else if(v==="nonzero"){let C=!0,T=null,D=null;for(let P=0;P<w.length;P++){let L=w[P];f[L]&&(C?(D=f[L].isCW,C=!1,T=L):D!==f[L].isCW&&(D=f[L].isCW,C=!0))}return{identifier:p.identifier,isHole:C,for:T}}else console.warn('fill-rule: "'+v+'" is currently not implemented.')}let o=0,l=999999999,h=-999999999,d=[];this.subPaths.forEach(p=>{let f=p.getPoints(),g=-999999999,m=999999999,v=-999999999,y=999999999;for(let x=0;x<f.length;x++){let b=f[x];b.y>g&&(g=b.y),b.y<m&&(m=b.y),b.x>v&&(v=b.x),b.x<y&&(y=b.x)}h<=v&&(h=v+1),l>=y&&(l=y-1),f.length&&d.push({curves:p.curves,points:f,isCW:fS.isClockWise(f),identifier:o++,boundingBox:new KL(new F(y,m),new F(v,g))})});let c=d.map(p=>a(p,d,l,h,this.userData?.style.fillRule)),u=[];return d.forEach(p=>{let f=c[p.identifier];if(f&&!f.isHole){let g=new gu;g.curves=p.curves,c.filter(m=>m?.isHole&&m.for===p.identifier).forEach(m=>{if(m){let v=d[m.identifier],y=new mu;y.curves=v.curves,g.holes.push(y)}}),u.push(g)}}),u}},$2,lw=new Promise(e=>{$2=e}),hw=!1,zd;function iG(){if(hw)return;if(zd)return zd;async function e(){let t=await import("./opentype.js".toString());$2(t),hw=!0}return zd=e(),zd}var rG=class{async load(e,t,i=()=>{}){let{load:r}=await lw;r(e,(s,n)=>{s||!n?i(s??"Something went wrong"):t(n)})}async parse(e){let{parse:t,Bidi:i}=await lw;try{let r=t(e),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function sG(e){return await(await fetch(e)).arrayBuffer()}var nG=new rG;async function cw(e){let t,i,r=!1;if(e.url?(t=await sG(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer),t){let s=await nG.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}}function aG(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var oG=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,d=String.fromCharCode(i[l].unicode),c=s[a];if(aG(h,c)||o)n.push({char:d,index:h,replacements:[c.state.glyphIndex],replacementChars:[c.char]}),a++;else{let u=c.char,p="",f=[c.state.glyphIndex],g=[],m=!1;for(;!m;)a++,p=t.charAt(a),u+=p,f.push(e.charToGlyphIndex(p)),g=e.stringToGlyphs(u),g.length===1&&g[0].index===h&&(m=!0),a>t.length&&(m=!0);n.push({char:d,index:h,replacements:f,replacementChars:Array.from(u)}),a++}}return n}generateShapes(e,t){if(!this._isLoaded)return;let i=this.font,r=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,n=e.map(v=>this.getTextWidth(v,t)),a=t.width,o=this.getCharWidth(`
|
|
5352
|
+
`)}return t}},Pj=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;)this.dispose(t.src,t.data),this.cache.delete(t.src),t=t.next,t.prev=this.head,this.head.next=t;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}},Dj=class extends Pj{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},tm;function Ij(e){return typeof e=="string"?e:(tm||(tm=new Dj),tm.load(e))}var Lj=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Oj=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},X2=class extends Lj{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isVideo=e.type==="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let s of r){let n=this[s];n&&(n.image=this.img,n.needsUpdate=!0)}this.shared.requestRender()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=n=>{r=n.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=Ij(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let i;return this.isVideo?i=new qI(this.img,void 0,e,e):i=new ci(this.img,void 0,e,e),this.loaded&&(i.needsUpdate=!0),this[e]=i,i}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}},Ra=class extends X2{};function qi(e,t){return t.color(e)}function Bj(e,t){switch(e.type){case"fresnel":return Nj(e,t);case"gradient":return Uj(e);case"depth":return Fj(e);case"normal":return kj(e);case"noise":return jj(e,t);case"rainbow":return Gj(e);case"toon":return Vj(e,t);case"outline":return Hj(e,t);case"transmission":return Wj(e,t);case"color":return zj(e,t);case"pattern":return qj(e,t)}}function Rj(e){return{type:e.type}}function ls(e){let{alpha:t,mode:i,isMask:r}=e;return{...Rj(e),alpha:t,mode:i,isMask:r}}function zj(e,t){return{...ls(e),color:qi(e.color,t)}}function Nj(e,t){let{bias:i,scale:r,intensity:s,factor:n,color:a,isMask:o}=e;return{...ls(e),color:qi(a,t),bias:i,scale:r,intensity:s,factor:n}}function Uj(e){let{gradientType:t,smooth:i,colors:r,steps:s,angle:n,offset:a,morph:o}=e;return{...ls(e),gradientType:t,smooth:i,colors:r.map(l=>new $e(l[0],l[1],l[2],l[3])),num:r.length,steps:s,offset:new F(...a),morph:new F(...o),angle:n}}function Fj(e){let{gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:a,direction:o,colors:l,steps:h,smooth:d}=e;return{...ls(e),gradientType:t,near:i,far:r,isVector:s,isWorldSpace:n,origin:new M(...a),direction:o?new M(...o):new M(1,0,0),colors:l.map(c=>c!==void 0?new $e(c[0],c[1],c[2],c[3]):new $e(0,0,0,0)),steps:h.slice(0,l.length),smooth:d}}function kj(e){let{cnormal:t}=e;return{...ls(e),cnormal:new M(t[0],t[1],t[2])}}function jj(e,t){return{...ls(e),scale:e.scale,move:e.move,fA:new F(...e.fA),fB:new F(...e.fB),size:new M(...e.size),distortion:new F(...e.distortion),colorA:qi(e.colorA,t),colorB:qi(e.colorB,t),colorC:qi(e.colorC,t),colorD:qi(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function Gj(e){return{...ls(e),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new M(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new M(...e.offset)}}function Vj(e,t){return{...ls(e),positioning:e.positioning,colors:e.colors.map(i=>new $e(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new M(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:qi(e.shadowColor,t),offset:new M(...e.offset)}}function Hj(e,t){return{...ls(e),outlineColor:qi(e.outlineColor,t),contourColor:qi(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new M(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function Wj(e,t){return{...ls(e),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function qj(e,t){return{...ls(e),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new F(...e.offset),colorA:qi(e.colorA,t),colorB:qi(e.colorB,t),frequency:new F(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new F(...e.vertical),horizontal:new F(...e.horizontal),sides:e.sides}}var Yu=class extends ar{},Y2={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Q2={depth:["colors"]};function Xj(e,t,i){if(t==="isMask")return!0;let r=Y2[e.type],s=Q2[e.type];if(s!==void 0){let n=e.color;if(s.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function Z2(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,n=e;if("image"in n){let a=n.image,o=t.image(a),l=r;l.image instanceof Ra||l.image.deref(),l.image=o}if("video"in n){let a=n.video,o=t.video(a),l=r;l.image instanceof Ra||l.image.deref(),l.image=o}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("repeat"in n||"offset"in n){let a="mat",o=i.uniforms[`f${i.id}_${a}`];"repeat"in n&&(o.repeat=n.repeat),"offset"in n&&(o.offset=n.offset),o.updateMatrix()}return s}function Yj(e,t,i,r){let s=!1;for(let[n,a]of Object.entries(e)){if(n==="bumpMap"||n==="roughnessMap"){s=!0;continue}if(!n||a===void 0)continue;if(J2(n,i,r)){n==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${n}`];if(!!o&&!(o instanceof E0))switch(s=s||Xj(i,n,a),o.constructor){case Ht:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof Yu?o.value=new ar(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case ln:if(typeof a=="string"){let l=t.getColor(a);l&&(o.value=l);break}else{let l=a;o.value instanceof Yu?o.value=new ar(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Ci:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]);break}case Ir:{let l=a;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case un:{Z2(a,t,i);break}case Ca:{o.value=a.map(l=>new $e(...l));break}default:{o.value=a;break}}}return s}var Ha=class{constructor(e,t,i,r){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let s in r)this.uniforms[`f${this.id}_${s}`]=r[s];for(let s in i)J2(s,this,i)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return hn.createLigherLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.image(i.texture.image):r.video(i.texture.video),n=new Xg(s,i.texture.wrapping),a=new bj(s),o=new wj(i.texture.repeat,i.texture.offset),l=new Ce(i.crop?1:0),h=new Tt(i.projection??0),d=new Tt(["x","y","z"].indexOf(i.axis)??0),c=new Tt(i.side??0),u=new Ci(i.size?new F(i.size[0],i.size[1]):new F(100,100)),p=new Ce(i.blending??0),f=new Ce(i.alpha??1),g=new Tt(i.mode??0),m=new Wi(i.isMask??!1),v=new C0(n,a,l,h,d,c,u,p,o,f,g,m),y=new Rt(v.calpha,"f");return new jt(e,t,i,{texture:n,textureSize:a,crop:l,projection:h,axis:d,side:c,size:u,blending:p,mat:o,alpha:f,mode:g,isMask:m},v,g,y,m)}else if(i.type==="matcap"){let s=r.image(i.texture.image),n=new Xg(s,i.texture.wrapping),a=new Ce(i.alpha??1),o=new Tt(i.mode??0),l=new Wi(i.isMask??!1),h=new O2(n,a,o,l),d=new Rt(h.calpha,"f");return new jt(e,t,i,{texture:n,alpha:a,mode:o,isMask:l},h,o,d,l)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new Ir(new M(...i.offset)),n=new Ce(i.scale??10),a=new Ce(i.intensity??8),o=new Ce(i.movement??1),l=new Tt(i.noiseType??0),h=new Tt(i.voronoiStyle??0),d=new Ce(i.smoothness??.5),c=new Ce(i.seed??0),u=new Ce(i.highCut??1),p=new Ce(i.lowCut??0),f=new Tt(i.quality??1),g=new W2(a,o,s,h,d,c,u,p,f,n,l);return new K2(e,t,i,{offset:s,scale:n,intensity:a,movement:o,noiseType:l,voronoiStyle:h,smoothness:d,seed:c,highCut:u,lowCut:p,quality:f},g)}else throw new Error;else return Kj(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):Yj(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?Z2(r.props,i.shared,this):!0;return!1}dispose(){if(Qj(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Ra||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},jt=class extends Ha{constructor(e,t,i,r,s,n,a,o){super(e,t,i,r),this.params=r,this.color=s,this.mode=n,this.alpha=a,this.isMask=o}},K2=class extends Ha{constructor(e,t,i,r,s){super(e,t,i,r),this.position=s}},hn=class extends Ha{constructor(e,t,i,r,s){super(e,t,i,s),this.node=r}static createLigherLayer(e,t,i,r){let s,n=new Ce(i.alpha),a=new Tt(i.mode),o=new Ce(i.bumpMapIntensity),l=new Ce(i.alphaOverride),h;if(!i.visible)s=new q2,h={};else if(i.category==="lambert"){s=new Mj;let d=new Ht(r.color(i.emissive)??0),c=new Wi(i.occlusion??!0);h={emissive:d,occlusion:c},s.emissive=d,s.occlusion=c}else if(i.category==="toon"){s=new Tj;let d=new Ce(i.shininess??30),c=new Ht(r.color(i.specular)??1118481);h={shininess:d,specular:c},s.shininess=d,s.specular=c}else if(i.category==="physical"){s=new Cj;let d=new Ce(i.roughness??.3),c=new Ce(i.metalness??0),u=new Ce(i.reflectivity??.5),p=new Wi(i.occlusion??!0);h={roughness:d,metalness:c,reflectivity:u,occlusion:p},s.roughness=d,s.metalness=c,s.reflectivity=u,s.occlusion=p}else{s=new Ej;let d=new Ce(i.shininess??30),c=new Ht(i.specular!==void 0?r.color(i.specular)??1118481:1118481),u=new Wi(i.occlusion??!0);h={shininess:d,specular:c,occlusion:u},s.shininess=d,s.specular=c,s.occlusion=u}return s.alpha=new Ce(1),s.shadingAlpha=n,s.shadingBlend=a,s.bumpMapIntensity=o,s.alphaOverride=l,h.alpha=s.shadingAlpha,h.mode=s.shadingBlend,h.bumpMapIntensity=s.bumpMapIntensity,h.alphaOverride=s.alphaOverride,new hn(e,t,i,s,h)}get category(){return this.node.category}};function Qj(e){let t=e instanceof Ha?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Cr(e){return{alpha:new Ce(e.alpha??1),mode:new Tt(e.mode??0),isMask:new Wi(e.isMask??!1)}}function Zj(e,t,i,r){switch(e.type){case"color":{let s=new Ht(r.color??jr),n=Cr(r),a=new Yg(s,n.alpha),o=new Rt(a.calpha,"f");return new jt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}case"fresnel":{let s=new Ht(r.color??16777215),n=new Ce(r.bias??.1),a=new Ce(r.scale??1),o=new Ce(r.intensity??2),l=new Ce(r.factor??1),h=Cr(r),d=new _j(s,n,a,o,l,h.alpha,h.mode,h.isMask),c=new Rt(d.calpha,"f");return new jt(t,i,e,{color:s,bias:n,scale:a,intensity:o,factor:l,...h},d,h.mode,c,h.isMask)}case"rainbow":{let s=new Ce(r.filmThickness??30),n=new Ce(r.movement??0),a=new Ir(r.wavelengths??new M(0,0,0)),o=new Ce(r.noiseStrength??0),l=new Ce(r.noiseScale??1),h=new Ir(r.offset??new M(0,0,0)),d=Cr(r),c=new F2(s,n,a,o,l,h,d.alpha,d.isMask),u=new Rt(c.calpha,"f");return new jt(t,i,e,{filmThickness:s,movement:n,wavelengths:a,noiseStrength:o,noiseScale:l,offset:h,...d},c,d.mode,u,d.isMask)}case"transmission":{let s=new Ce(r.thickness??10),n=new Ce(r.ior??1.5),a=new Ce(r.roughness??.5),o=ke.transmissionSize,l=ke.transmissionRenderTarget,h=ke.transmissionRenderTargetDepth,d=window.innerWidth,c=window.innerHeight,u=d>=c?new Ci(c/d,1):new Ci(1,d/c),p=Cr(r),f=new V2(s,n,a,o,l,h,u,p.alpha),g=new Rt(f.calpha,"f");return new jt(t,i,e,{thickness:s,ior:n,roughness:a,aspectRatio:u,...p},f,p.mode,g,p.isMask)}case"toon":{let s=new Tt(r.positioning??0),n;r.colors?n=new Ca(r.colors.length,r.colors):(n=new Ca(10,new $e(0,0,0,1)),n.value[1]=new $e(1,1,1,1));let a;r.steps?a=new Ea(r.steps.length,r.steps):(a=new Ea(10,1),a.value[0]=0);let o=new Ir(r.source??new M(0,0,0)),l=new Wi(r.isWorldSpace??!0),h=new Ce(r.noiseStrength??0),d=new Ce(r.noiseScale??1),c=new ln(r.shadowColor),u=new Ir(r.offset??new M(0,0,0)),p=Cr(r),f=new j2(s,n,a,o,l,h,d,c,u,p.alpha),g=new Rt(f.calpha,"f");return new jt(t,i,e,{positioning:s,colors:n,steps:a,source:o,isWorldSpace:l,noiseStrength:h,noiseScale:d,shadowColor:c,offset:u,...p},f,p.mode,g,p.isMask)}case"outline":{let s=new Ht(r.outlineColor??16777215),n=new Ht(r.contourColor??16777215),a=new Ce(r.outlineWidth??.1),o=new Ce(r.contourWidth??.1),l=new Ce(r.outlineThreshold??.1),h=new Ce(r.contourThreshold??.1),d=new Ce(r.outlineSmoothing??.1),c=new Ce(r.contourFrequency??.1),u=new Ir(r.contourDirection??new M(0,1,0)),p=new Wi(r.positionalLines??!1),f=new Wi(r.compensation??!0),g=ke.normalRenderTarget,m=ke.normalRenderTargetDepth,v=ke.pixelRatioNode,y=ke.resolution,x=Cr(r),b=new z2(s,n,a,o,l,h,d,c,u,p,f,y,g,m,v,x.alpha),_=new Rt(b.calpha,"f");return new jt(t,i,e,{outlineColor:s,contourColor:n,outlineWidth:a,contourWidth:o,outlineThreshold:l,contourThreshold:h,outlineSmoothing:d,contourFrequency:c,contourDirection:u,positionalLines:p,compensation:f,...x},b,x.mode,_,x.isMask)}case"depth":{let s=new Tt(r.gradientType??0),n=new Wi(r.smooth??!1),a=new Ce(r.near??50),o=new Ce(r.far??200),l=new Ce(r.isVector??1),h=new Ce(r.isWorldSpace??0),d=new Ir(r.origin??new M),c=new Ir(r.direction??new M),u;r.colors?u=new Ca(r.colors.length,r.colors):(u=new Ca(2,new $e(0,0,0,1)),u.value[1]=new $e(1,1,1,1));let p;r.steps?p=new Ea(r.steps.length,r.steps):(p=new Ea(2,1),p.value[0]=0);let f=Cr(r),g=new P2(s,n,a,o,l,h,d,c,u,p,f.alpha,f.isMask),m=new Rt(g.calpha,"f");return new jt(t,i,e,{gradientType:s,smooth:n,near:a,far:o,isVector:l,isWorldSpace:h,origin:d,direction:c,colors:u,steps:p,...f},g,f.mode,m,f.isMask)}case"noise":{let s=new Ce(r.scale??1),n=new Ir(r.size??new M(100,100,100)),a=new Ce(r.move??1),o=new Ci(r.fA??new F(1.7,9.2)),l=new Ci(r.fB??new F(8.3,2.8)),h=new Ci(r.distortion??new F(1,1)),d=new ln(r.colorA),c=new ln(r.colorB),u=new ln(r.colorC),p=new ln(r.colorD),f=new Tt(r.noiseType??0),g=new Tt(r.voronoiStyle??0),m=new Ce(r.highCut??1),v=new Ce(r.lowCut??0),y=new Ce(r.smoothness??.5),x=new Ce(r.seed??.5),b=new Tt(r.quality??1),_=Cr(r),A=new B2(s,n,a,o,l,h,d,c,u,p,_.alpha,f,_.isMask,g,m,v,y,x,b),S=new Rt(A.calpha,"f");return new jt(t,i,e,{scale:s,size:n,move:a,fA:o,fB:l,distortion:h,colorA:d,colorB:c,colorC:u,colorD:p,noiseType:f,..._,voronoiStyle:g,highCut:m,lowCut:v,smoothness:y,seed:x,quality:b},A,_.mode,S,_.isMask)}case"normal":{let s=new Ir(r.cnormal??new M(1,1,1)),n=Cr(r),a=new T2(s,n.alpha),o=new Rt(a.calpha,"f");return new jt(t,i,e,{cnormal:s,...n},a,n.mode,o,n.isMask)}case"gradient":{let s=new Tt(r.gradientType??0),n=new Wi(r.smooth??!1),a;r.colors?a=new Ca(r.colors.length,r.colors):(a=new Ca(10,new $e(0,0,0,1)),a.value[1]=new $e(1,1,1,1));let o;r.steps?o=new Ea(r.steps.length,r.steps):(o=new Ea(10,1),o.value[0]=0);let l=new Ci(r.offset??new F(0,0)),h=new Ci(r.morph??new F(0,0)),d=new Ce(r.angle??0),c=Cr(r),u=new I2(s,n,a,o,l,h,d,c.alpha,c.isMask),p=new Rt(u.calpha,"f");return new jt(t,i,e,{gradientType:s,smooth:n,colors:a,steps:o,offset:l,morph:h,angle:d,...c},u,c.mode,p,c.isMask)}case"pattern":{let s=new Tt(r.style??0),n=new Tt(r.projection??0),a=new Tt(["x","y","z"].indexOf(r.axis)??0),o=new Ce(r.blending??0),l=new Ci(r.offset??new F(0,0)),h=new ln(r.colorA),d=new ln(r.colorB),c=new Ci(r.frequency??new F(10,10)),u=new Ce(r.size??.5),p=new Ce(r.variation??0),f=new Ce(r.smoothness??.5),g=new Ce(r.zigzag??0),m=new Ce(r.rotation??0),v=new Ci(r.vertical??new F(0,1)),y=new Ci(r.horizontal??new F(0,1)),x=new Tt(r.sides??6),b=Cr(r),_=new N2(s,n,a,o,l,h,d,c,u,p,f,g,m,v,y,x,b.alpha,b.isMask),A=new Rt(_.calpha,"f");return new jt(t,i,e,{style:s,projection:n,axis:a,blending:o,offset:l,colorA:h,colorB:d,frequency:c,size:u,variation:p,smoothness:f,zigzag:g,rotation:m,vertical:v,horizontal:y,sides:x,...b},_,b.mode,A,b.isMask)}default:{let s=new Ht(1,0,0,1),n=Cr(r),a=new Yg(s,n.alpha),o=new Rt(a.calpha,"f");return new jt(t,i,e,{color:s,...n},a,n.mode,o,n.isMask)}}}function Kj(e,t,i,r){let s=Bj(i,r);return Zj(i,e,t,s)}function J2(e,t,i){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=i.intensity*(i.visible?1:0),r):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=i.alpha*(i.visible?1:0),i.type==="outline"&&e==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=i.compensation&&i.visible)}return r}}function Qu(e,t){let i=0,r=e.layers.find(s=>s.data.type==="light");if(r&&r.data.alphaOverride<1)return!0;for(let s of e.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let n=s.data.visible?s.data.alpha:0;if(n===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let a of s.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&s.data.type==="noise"){let a=t.color(s.data.colorA).a,o=t.color(s.data.colorB).a,l=t.color(s.data.colorC).a,h=t.color(s.data.colorD).a,d=Math.min(a,Math.min(o,Math.min(l,h)));d<1&&(n=d)}i+=(1-i)*n}}return i<1}var aa=class extends Lt{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.cacheKey="",this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Jj=class extends aa{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i){return this.root.getFlavor(e,t,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},P0=class extends aa{constructor(e,t){super(),this.data=e,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,i){let r=i?6:(e?3:0)+t;if(r===0)return this;this.flavors===void 0&&(this.flavors=[]),r-=1;let s=this.flavors[r];return s===void 0&&(s=new Jj(e,t,i,this),this.flavors[r]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let i=e.layers??zi.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>Ha.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Qu(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof hn),this.lightLayer===void 0&&(this.lightLayer=new hn(0,"",{...Ji.defaultData("light","phong"),visible:!1},new q2,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(s=>s instanceof hn);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let s=0;s<this.layers.length;++s){let n=this.layers[s];n instanceof jt&&n.color instanceof C0&&(n.uuid===i&&(e.node.bumpMap=n.color),n.uuid===r&&(e.node.roughnessMap=n.color))}}updateByOp(e,t,i){if(t!==void 0?this.data=t:t=this.data,this.transparent=Qu(t,i.shared),e.path[0]==="layers"){this.data=t;let r=i.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let n=Ha.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,n),i.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let n=this.layers.findIndex(o=>o.uuid===e.id),a=this.layers[n];this.layers.splice(n,1),this.layers.splice(e.localIndex,0,a),i.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let n=this.layers.find(a=>a.uuid===s);if(n){let a=t.layers.data(s);if(n.updateByOp({...e,path:e.path.slice(2)},a,i)){let o=Ha.create(this.layerIdGen++,s,a,r);this.layers.splice(this.layers.findIndex(l=>l.uuid===s),1,o),this.onUpdate()}}}}else this.reset(t,i)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof jt?t.color.mask=void 0:t instanceof hn&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof jt&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof hn?r.node.mask=new Ki(t.color,t.alpha,Ki.MUL):r instanceof jt&&(r.isMask.value||(r.color.mask=new Ki(t.color,t.alpha,Ki.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof jt),t=this.layers.findIndex(i=>i instanceof hn);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let s=this.layers[r];if(s instanceof jt){if(s.isMask.value)continue;i=new aw(i,s.color,s.alpha,s.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Rt("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof hn);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof jt){if(r.isMask.value)continue;e=new aw(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof K2);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Ki(t,e[i].position,Ki.ADD),t=new Ki(t,new Ce(.5).setReadonly(!0),Ki.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,s,n)=>Math.min(Math.max(r,s),n);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let i=(Y2[t.type]??[]).map(o=>t[o]),r=(Q2[t.type]??[]).map(o=>t[o]?.length??0),s=[...i,...r],n="isMask"in t&&t.isMask,a=`"${t.type}-${t.visible}-${n}"`;s.length?e+=`[${a}, "${s.join('","')}"],`:e+=a}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new xj;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof jt){let t=e.params.texture;if(t instanceof Xg&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(aa.prototype,{properties:{get:function(){return this.fragment.properties}}});var Zg=class extends P0{},$j=Pl(zE()),ow=new Map;function eG(e){if(typeof e=="string")return e;let t=ow.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},ow.set(e,t)),t.url}var Nh=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:eG(e),format:"wav"},this.sound=new $j.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},tG=class{constructor(){this.type="ShapePath",this.color=new je,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new mu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,n){return this.currentPath?.bezierCurveTo(e,t,i,r,s,n),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,f,g,m){let v=p.x,y=f.x,x=g.x,b=m.x,_=p.y,A=f.y,S=g.y,w=m.y,E=(b-x)*(_-S)-(w-S)*(v-x),C=(y-v)*(_-S)-(A-_)*(v-x),T=(w-S)*(y-v)-(b-x)*(A-_),D=E/T,P=C/T;if(T===0&&E!==0||D<=0||D>=1||P<0||P>1)return null;if(E===0&&T===0){for(let L=0;L<2;L++)if(r(L===0?g:m,p,f),t.loc===e.ORIGIN){let R=L===0?g:m;return{x:R.x,y:R.y,t:t.t}}else if(t.loc===e.BETWEEN){let R=+(v+t.t*(y-v)).toPrecision(10),V=+(_+t.t*(A-_)).toPrecision(10);return{x:R,y:V,t:t.t}}return null}else{for(let V=0;V<2;V++)if(r(V===0?g:m,p,f),t.loc===e.ORIGIN){let k=V===0?g:m;return{x:k.x,y:k.y,t:t.t}}let L=+(v+D*(y-v)).toPrecision(10),R=+(_+D*(A-_)).toPrecision(10);return{x:L,y:R,t:D}}}function r(p,f,g){let m=g.x-f.x,v=g.y-f.y,y=p.x-f.x,x=p.y-f.y,b=m*x-y*v;if(p.x===f.x&&p.y===f.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===g.x&&p.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(b<-Number.EPSILON){t.loc=e.LEFT;return}if(b>Number.EPSILON){t.loc=e.RIGHT;return}if(m*y<0||v*x<0){t.loc=e.BEHIND;return}if(Math.sqrt(m*m+v*v)<Math.sqrt(y*y+x*x)){t.loc=e.BEYOND;return}let _;m!==0?_=y/m:_=x/v,t.loc=e.BETWEEN,t.t=_}function s(p,f){let g=[],m=[];for(let v=1;v<p.length;v++){let y=p[v-1],x=p[v];for(let b=1;b<f.length;b++){let _=f[b-1],A=f[b],S=i(y,x,_,A);S!==null&&g.find(w=>w.t<=S.t+Number.EPSILON&&w.t>=S.t-Number.EPSILON)===void 0&&(g.push(S),m.push(new F(S.x,S.y)))}}return m}function n(p,f,g){let m=new F;f.getCenter(m);let v=[];return g.forEach(y=>{y.boundingBox.containsPoint(m)&&s(p,y.points).forEach(x=>{v.push({identifier:y.identifier,isCW:y.isCW,point:x})})}),v.sort((y,x)=>y.point.x-x.point.x),v}function a(p,f,g,m,v){(v==null||v==="")&&(v="nonzero");let y=new F;p.boundingBox.getCenter(y);let x=[new F(g,y.y),new F(m,y.y)],b=n(x,p.boundingBox,f);b.sort((C,T)=>C.point.x-T.point.x);let _=[],A=[];b.forEach(C=>{C.identifier===p.identifier?_.push(C):A.push(C)});let S=_[0].point.x,w=[],E=0;for(;E<A.length&&A[E].point.x<S;)w.length>0&&w[w.length-1]===A[E].identifier?w.pop():w.push(A[E].identifier),E++;if(w.push(p.identifier),v==="evenodd"){let C=w.length%2===0,T=w[w.length-2];return{identifier:p.identifier,isHole:C,for:T}}else if(v==="nonzero"){let C=!0,T=null,D=null;for(let P=0;P<w.length;P++){let L=w[P];f[L]&&(C?(D=f[L].isCW,C=!1,T=L):D!==f[L].isCW&&(D=f[L].isCW,C=!0))}return{identifier:p.identifier,isHole:C,for:T}}else console.warn('fill-rule: "'+v+'" is currently not implemented.')}let o=0,l=999999999,h=-999999999,d=[];this.subPaths.forEach(p=>{let f=p.getPoints(),g=-999999999,m=999999999,v=-999999999,y=999999999;for(let x=0;x<f.length;x++){let b=f[x];b.y>g&&(g=b.y),b.y<m&&(m=b.y),b.x>v&&(v=b.x),b.x<y&&(y=b.x)}h<=v&&(h=v+1),l>=y&&(l=y-1),f.length&&d.push({curves:p.curves,points:f,isCW:fS.isClockWise(f),identifier:o++,boundingBox:new KL(new F(y,m),new F(v,g))})});let c=d.map(p=>a(p,d,l,h,this.userData?.style.fillRule)),u=[];return d.forEach(p=>{let f=c[p.identifier];if(f&&!f.isHole){let g=new gu;g.curves=p.curves,c.filter(m=>m?.isHole&&m.for===p.identifier).forEach(m=>{if(m){let v=d[m.identifier],y=new mu;y.curves=v.curves,g.holes.push(y)}}),u.push(g)}}),u}},$2,lw=new Promise(e=>{$2=e}),hw=!1,zd;function iG(){if(hw)return;if(zd)return zd;async function e(){let t=await import("./opentype.js");$2(t),hw=!0}return zd=e(),zd}var rG=class{async load(e,t,i=()=>{}){let{load:r}=await lw;r(e,(s,n)=>{s||!n?i(s??"Something went wrong"):t(n)})}async parse(e){let{parse:t,Bidi:i}=await lw;try{let r=t(e),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function sG(e){return await(await fetch(e)).arrayBuffer()}var nG=new rG;async function cw(e){let t,i,r=!1;if(e.url?(t=await sG(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer),t){let s=await nG.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}}function aG(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var oG=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=cw(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,d=String.fromCharCode(i[l].unicode),c=s[a];if(aG(h,c)||o)n.push({char:d,index:h,replacements:[c.state.glyphIndex],replacementChars:[c.char]}),a++;else{let u=c.char,p="",f=[c.state.glyphIndex],g=[],m=!1;for(;!m;)a++,p=t.charAt(a),u+=p,f.push(e.charToGlyphIndex(p)),g=e.stringToGlyphs(u),g.length===1&&g[0].index===h&&(m=!0),a>t.length&&(m=!0);n.push({char:d,index:h,replacements:f,replacementChars:Array.from(u)}),a++}}return n}generateShapes(e,t){if(!this._isLoaded)return;let i=this.font,r=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,n=e.map(v=>this.getTextWidth(v,t)),a=t.width,o=this.getCharWidth(`
|
|
5353
5353
|
`,t),l=t.horizontalAlign===1?o:0,h=this.computeSpaceWidthForLine(e,0,t),d=this.getLineInitialOffsetX(n[0],a,t.horizontalAlign,e[0],o),c=this.getLineInitialOffsetY(s,e.length,t.height,r,t.verticalAlign),u=[],p=e.map(v=>[]),f=e.map(v=>[]),g;for(let v=0;v<e.length;v++){let y=e[v],x={features:{liga:!0}},b=[];try{b=i.stringToGlyphs(y,x)}catch(A){console.warn(A)}d=this.getLineInitialOffsetX(n[v],a,t.horizontalAlign,y,o);let _=[];try{_=this.reverseLigaturesTable(i,y,b)}catch(A){console.warn(A)}h=this.computeSpaceWidthForLine(e,v,t);for(let A=0;A<b.length;A++){let S=b[A],w=S.index===0?`
|
|
5354
5354
|
`:S.unicode?String.fromCharCode(S.unicode):void 0,E=_[A],C=0,T=0;A===0&&t.horizontalAlign===2&&S.leftSideBearing!==void 0&&(T=-S.leftSideBearing*r),g&&(C=i.getKerningValue(S,g)*r),d+=T+C;let D=0;if(w===`
|
|
5355
5355
|
`)D=l;else if(w===" ")D=h;else{let P=this.createPath(S,r,d,c,t);P&&(D=P.offsetX-(C+T),u.push(P.path))}if(E.replacements.length===1)f[v].push([d,c]),p[v].push(D);else{let P=E.replacements.map(k=>(i.glyphs.get(k).advanceWidth??0)*r),L=P.reduce((k,z)=>k+=z,0),R=P.map(k=>k/L),V=d;for(let k=0;k<R.length;k++){let z=D*R[k];f[v].push([V,c]),p[v].push(z),V+=z}}d+=D,g=S}c-=s}let m=[];for(let v=0,y=u.length;v<y;v++)m.push(...u[v].toShapes());return{shapes:m,charWidths:p,lineWidths:n,charCoords:f}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(e,t,i,r,s){return(i===3||i===2)&&r.indexOf(`
|
|
@@ -6235,7 +6235,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
|
|
|
6235
6235
|
}
|
|
6236
6236
|
`,pm=new Lt({vertexShader:VH,fragmentShader:HH,uniforms:{depthContrast:{value:1}}}),Rw=new ci,WH=class extends rS{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new F,this.pipeline=new NH(this),this.dummyCamra=new Yi,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(s=!0,n=!0,a=!0)=>{let o=this.getContext(),l=0;s&&(l|=o.COLOR_BUFFER_BIT),n&&(l|=o.DEPTH_BUFFER_BIT),a&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=bv;let r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio!==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._resizeTransmission(s,n),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}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new At(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:st,magFilter:st,wrapS:Yt,wrapT:Yt,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return ke.transmissionLod.value===1}set hdTransmission(e){ke.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new At(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:pl,magFilter:st,wrapS:Yt,wrapT:Yt,depthBuffer:!1}),this.transmissionDepthTarget=new At(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:It,magFilter:It,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new At(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:It,magFilter:It,type:xr,depthTexture:new gl(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof Yi?pm.uniforms.depthContrast.value=(i.far-i.near)/1e4:pm.uniforms.depthContrast.value=1,t.overrideMaterial=pm,this.render(t,i),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?ov:null,i.layers.enable(0),i.layers.enable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamra.updateCameraState(t.dataPatched);let r=t.height,s=t.width,n=this.viewportWidth/this.viewportHeight;s<r?s=r*n:r=s/n,this.dummyCamra.setViewplaneSize(s,r);for(let a=0;a<i;a++)this.renderSplineScene(e,this.dummyCamra)}renderSplineScene(e,t,{sceneHelpers:i=void 0,sceneHelpersOnTop:r=void 0,overrideTransmission:s=void 0,overrideNormal:n=void 0}={}){let a=e instanceof F0?e.activePage:e,o=a.visible;a.visible=!0;let l=a.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(a.bgColor,a.bgColor.a),a.penumbraSizeArray.forEach((u,p)=>{ke.penumbraSize.value[p]=u}),ke.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?ke.resolution.value.set(this.resolution.x,this.resolution.y):ke.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),n!==void 0?(ke.normalRenderTarget.value=n,ke.normalRenderTargetDepth.value=Rw):l.needsNormal()&&(this.createNormalRenderTarget(),ke.normalRenderTarget.value=this.normalRenderTarget.texture,ke.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(l,a,t));let h=a.data.ao,d=h.occlusion;d&&(this.createAORenderTarget(),ke.aoRenderTarget.value=this.aoRenderTarget.texture),ke.aoEnabled.value=d,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,a.aoColor,a.fog!==null,a.backupFog.near,a.backupFog.far,h.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let c=!1;if(s!==void 0)ke.transmissionRenderTarget.value=s,ke.transmissionRenderTargetDepth.value=Rw,this.pipeline.setTransmissionPassEnabled(!1);else{let u=l.needsTransmission();u&&(this.transmissionRenderTarget===void 0&&(c=!0),this.createTransmissionRenderTarget(),ke.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,ke.aspectRatio.value=Aj(this.viewportWidth,this.viewportHeight),ke.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(u)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=a,this.pipeline.camera=t,c&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==a.postprocessing&&(this.pipeline.updatePostprocessing(a.postprocessing),!i&&!r&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),a.overrideMaterial=l.wireframeState?ov:null,this.pipeline.render(),ke.frameIndex.value=(ke.frameIndex.value+1)%16,t instanceof Yi&&t.copyHistory(),a.visible=o}renderFromSceneForSceneTransitionPass(e,t,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let r=this.pipeline.sceneTransitionPass.uniforms;r.uDPR.value=window.devicePixelRatio,r.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},lM=class extends Mc(eO){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Ec(this.object,lM.geometryHelper,e,t)}},hM=class extends Mc($L){constructor(e,t=15,i=6710886){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Ec(this.object,hM.geometryHelper,e,t)}},nv=class extends Mc(JL){constructor(e,t=6710886){super(e,t),this.object=e,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Ec(this.object,nv.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=nv._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},cM=nv;cM._vector=new M;function qH(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}var dM=class extends O0(RL,lM){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new xu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof xu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&qH(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}},zw=new M,Nw=new M,Uw=new it,uM=class extends O0(IL,cM){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=nt.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new xu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof xu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Nw.setFromMatrixPosition(this.matrixWorld),Uw.setFromRotationMatrix(this.matrixWorld),zw.copy(this.up).applyQuaternion(Uw).negate().multiplyScalar(this.distance),this.target.position.copy(Nw).add(zw),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},ra=class extends g0(Jn){constructor(e,t){super(),this.data=t,this.bgColor=new ar(1,1,1,1),this.fog=null,this.backupFog=new sS(16777215,.1,2e3),this.fogUseBGColor=!1,this.isActive=!1,this.aoColor=new je,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Yi(Vl,{...hc.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new PL(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=qi(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof ql)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&GH(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=qi(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=qi(e.aoColor,t))}updateByOp(e,t,i,r){super.updateByOp(e,t,i,r);let s=t;zr(e.path,["fog"])?this.updateFog(s.fog,i.shared):zr(e.path,["ao"])?this.updateAo(s.ao,i.shared):zr(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):zr(e.path,["shadow"])&&this.updateShadow(s.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(qi(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof dM&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize,e+=1),i instanceof uM&&i.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=i.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;ut.is(s)&&(s.visible||n?.object.data.visible)&&((Jr(s)||$g(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),av(s,e,t,!0)),i(s))}};return i(this),t}},XH=class extends O0(OL,hM){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let s=new M(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new M(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),a=new Kt(s,n),o=new bu(a,new je(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof bu){let i=this.shadow.camera,r=new M(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new M(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);t.box.set(r,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},YH=class extends or{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?A0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},z0=class extends or{constructor(e,t,i){super(e,t,i),this._shapeId=null,this._context=i}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,t;if(e.type==="Custom"){let r=e.shapeId;if(r!==this._shapeId&&this.detachShape(),r){this._shapeId=r;let s=this._context.scene.find(r);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let r;switch(e.type){case"Rectangle":r=u2;break;case"Ellipse":r=_0;break;case"Polygon":r=d2;break;case"Star":r=p2;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=r.create({parameters:e}).userData.shape}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build(),this.attachedSurfaceCloners.forEach(r=>r.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?A0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},dl=class extends Cc(Xo,Sp){constructor(e,t,i){super(),t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,i)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let i=t.scene.data.objects.get(e.component);if(i){let r,s;for(let n of Yn.rootOverrideProps)e[n]===void 0?(r===void 0&&(r={...e}),r[n]=i.data[n]):(s===void 0&&(s={}),s[n]=e[n],r===void 0&&(r={...e}),r[n]=$n.apply(i.data[n],e[n]));return this.overrideData=s,r}else return{...Xi.defaultData,...e,...vn(Xi.defaultData,Yn.rootOverrideProps)}}updateByOp(e,t,i,r){let s;if(this.isInstanceRoot&&!r){if(t=this.transformAssignData(t,i),e.type===0&&e.path.length===0&&this.component)for(let n of Yn.rootOverrideProps)n in e.props&&e.props[n]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[n]=this.component.data[n]);else if(e.type===0&&e.path.length>0&&Yn.rootOverrideProps.includes(e.path[0])){let n=e.path[0];s===void 0&&(s={...e,path:[],props:{[n]:t[n]}})}}super.updateByOp(s??e,t,i,r)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let i=e.scene.find(t.component)??null,r=!1;if(i!==this.oldComponent){if(this.oldComponent){let s=0;for(let n of this.children)if(ut.is(n))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),N0(n),s+=1;else break;this.children.splice(0,s)}r=!0}if(i){let s={};pM(e,[this.uuid],t.overrides,this,i,i,0,r,s);for(let n of this.children)if(ut.is(n)){let a=n.data;a.type==="Empty"&&a.animations&&n.traverseEntity(o=>{if(o instanceof or&&o.isSkinnedMesh){let l=o.dataPatched;if(l.bones&&l.boneInverses){let h=l.bones.map(u=>e.scene.find(s[u])),d=l.boneInverses.map(u=>new fe().fromArray(u)),c=new Pv(h,d);o.bind(c,o.bindMatrix)}}else o.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function N0(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let i of e.children)ut.is(i)&&N0(i)}}function Fw(e,t,i,r){return e.component===t&&r0(e.identity,r)?e.overrideData===i?2:1:0}function pM(e,t,i,r,s,n,a,o,l){if(a>50)return!1;if(r.component!==s){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}s.instances.push(r),r.component=s}s instanceof dl&&s.isInstanceRoot&&s.expandInstanceChildren(e);let h=0;for(let d of s.children)if(ut.is(d)){let c=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],u=ku.resolve(i,c,1);u!=null&&!(u instanceof di)&&(Object.setPrototypeOf(u,di.prototype),console.error("wrong prototype"));let p=null,f;if(!o){let g=r.children[h];if(p=ut.is(g)?g:null,p!==null){let m=Fw(p,d,u,c);f=m>=1?p.stateSelection:void 0,m!==2&&(p=null)}if(p===null&&(p=e.scene.findInstance(c)??null,p!==null)){let m=Fw(p,d,u,c);if(f=m>=1?p.stateSelection:void 0,m!==2)p=null;else{let v=p.parent.children.indexOf(p);p.parent.children.splice(v,1),r.children.splice(h,0,p),p.parent===r?v<=h&&console.error("not possible"):(p.parent=r,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),e.pendingDeletes.delete(p))}}}if(p===null){let g=u?$n.apply(d.data,u):d.data;Za.is(g.type)&&(g={...g,type:"Empty"}),p=Qn.createEntity(c,g,e),p.overrideData=u,r.add(p),r.children.splice(r.children.length-1,1),r.children.splice(h,0,p),p.updateState(p.data,e),f&&p.changeSelectedState(f,e),e.scene.registerInstanceAndSetUuid(p)}if(p.isBone){let g=p.identity[p.identity.length-1];l[g]=p.uuid}h+=1,pM(e,t,i,p,d,n,a+1,o,l)}if(!o){let d=h;for(;;){let c=r.children[h];if(ut.is(c))e.pendingDeletes.add(c);else break;h+=1}r.children.splice(d,h-d)}return!0}var QH=class extends Cc(nS,Sp){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}};function ZH(e,t,i){let r;return t.geometry.type==="TextGeometry"?new eM(e,t,i):(t.geometry.type==="SubdivGeometry"?r=new mc(e,t,i):t.geometry.type==="PathGeometry"?r=new z0(e,t,i):t.geometry.type==="VectorGeometry"?r=new YH(e,t,i):t.geometry.type==="BooleanGeometry"?r=new Cl(e,t,i):r=new or(e,t,i),r)}function U0(e,t,i){return t.type==="Mesh"?ZH(e,t,i):t.type==="Empty"?new Ku(e,t):t.type==="Bone"?new QH(e,t):t.type==="Page"?new ra(e,t):t.type==="PointLight"?new XH(e,t,i):t.type==="SpotLight"?new uM(e,t,i):t.type==="DirectionalLight"?new dM(e,t,i):t.type==="Component"||t.type==="Instance"?new dl(e,t,i):Za.is(t.type)?new Yi(e,t):(console.error(t),new Ku(e,t))}Qn.createEntity=U0;function KH(e,t,i){let r=U0(e.identity,t,i),s=e.children,n=e.attachedPaths,a=e.parent,o=e.component,l=e.instances,h=e.overrideData,d=e.uuid,c=e.stateSelection;e.dispose();for(let u of Object.keys(e))delete e[u];Object.setPrototypeOf(e,Object.getPrototypeOf(r));for(let u of Object.keys(r))e[u]=r[u];e.children=[...e.children,...s],e.attachedPaths=n,e.parent=a,e.component=o,e.instances=l,e.uuid=d,e.overrideData=h,e.updateState(e.data,i),c&&e.changeSelectedState(c,i),e.resetBBoxNeedsUpdate()}Qn.changeEntityProptotype=KH;Qn.Cloner=is;function JH(e,t,i,r){e.updateByOp(t,i,r,!1)}function kw(e,t){let i=!1,r=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline");return s.length>0&&(e.layers.set(8),r.length>0&&e.layers.enable(3),i=!0,L0(e),I0(e)),r.length===0&&s.length===0&&e.layers.set(0),e instanceof ql&&e.needsAO&&e.layers.enable(5),i}function jw(e,t){if(!t.layers)return!1;let i=!1,r=t.getLayersOfType("transmission").filter(n=>n.data.visible),s=t.getLayersOfType("outline").filter(n=>n.data.visible);return r.length>0&&(e.layers.set(3),s.length>0&&e.layers.enable(8),i=!0),r.length===0&&s.length===0&&e.layers.set(0),e.needsAO&&e.layers.enable(5),i}function $H(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof ql)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)kw(i,i.material[r])&&(t=!0);else kw(i,i.material)&&(t=!0)}),t}function e9(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof ql)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)jw(i,i.material[r])&&(t=!0);else jw(i,i.material)&&(t=!0)}),t}var t9=new SS,i9=new fe,r9=new Il;function av(e,t,i,r=!1){let s=e.cloner;if(s)for(let n of s.children){let a=i9.copy(n.matrixWorld).invert(),o=r9.copy(t.ray).applyMatrix4(a),l=e.matrixWorld;o.applyMatrix4(l);let h=t9;h.set(o.origin,o.direction),h.near=t.near,h.far=t.far;let d=h.intersectObject(e,!1);d.length>0&&i.push({...d[0],object:r?n:e})}}var s9=class{constructor(){this._constraints=new Map}setConstraint(e,t){t===null?this._constraints.delete(e):this._constraints.set(e,t)}removeDependencies(e){this._constraints.delete(e)}applyConstraints(e){let t=new Set;this._constraints.forEach((i,r)=>{let s=[r,i],n=i;for(;this._constraints.has(n);)n=this._constraints.get(n),t.has(n)||s.push(n);for(let a=s.length-2;a>=0;a--)if(!t.has(s[a])){let o=e.find(s[a]);o?o.applyPathSnapping(e):console.warn(`missing entity ${s[a]}`),t.add(s[a])}})}findDependency(e,t){let i=e;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===t)return!0;return!1}},ov=new xc;ov.wireframe=!0;var Gw=new M,F0=class extends Jn{constructor(e,t){super(),this.data=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new s9,this.errorPage=new ra("fdasfa",{...Ml.defaultData,name:""}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=e9(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=$H(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof ra&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let n=r.children.indexOf(s);i.splice(0,0,n)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>EF(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Vl)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(),r.resetBBoxNeedsUpdate(),Jr(r)&&mn(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),mn(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Jr(i)&&(i.freeBooleanPointer(),r instanceof Cl&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof z0&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid)}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let n=e.localIndex;s.children.splice(n,0,s.children.pop()),Jr(i)&&(i.invalidateUpstreamBooleanData(),mn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Cl&&r.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof ra&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:n}=t.props;t={...t,props:n},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{JH(s,t,i,{scene:this,shared:r}),s instanceof or&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}init(e,t){this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(i=>{mn(i)&&i.recomputeBoolean(),i instanceof Yi&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ut.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{ut.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,n,a){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=Du(l.data,h=>{let d=h.events.data(a.id),c=l.goUp(n);if(c){let u=[...aA(c.identity),e].join("-"),p=this.entityIdentityToEntity[u];if(p){let f=p.uuid,g=Ls.zoom(d,t);g[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,n){e.forEach(a=>{a.data.type==="Transition"?this.relativeizeInner(a.data.object,[...t,a.id],"object",i,r,s,n):a.data.type==="Animation"&&this.relativeizeInner(a.data.object,[...t,a.id],"object",i,r,s,n)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof dl&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(n=>{n.data=Du(n.data,a=>{n.isInstanceRoot||(a.events.delete(r.id),s=!0)}).data}),s===!1)for(let n of Bg.list)this.rewriteActions(r.data.gameActions[n],["gameActions",n],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof dl&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(n=>{i.addClip(n)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),N0(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof dl&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)ut.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let n of s.children){let a=n.cloner;if(ut.is(n)&&!n.raycastLock&&(n.visible||a?.object.data.visible))if(t===!0&&n.isInstanceRoot){let o=[];if(e.intersectObject(n,!0,o),o.length){let l=o[0];l.object=n,l.point.applyMatrix4(l.object.matrixWorld);let h=n.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Jr(n)||$g(n)&&this.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,i),av(n,e,i)),r(n)}};return r(this),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;ut.is(s)&&(s.visible||n?.object.data.visible)&&((Jr(s)||$g(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),av(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)ut.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)ut.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)ut.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)fc.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)ut.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,n){let a={scene:this,shared:n},o=U0(e,t,a);return o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,n)),o.updateState(t,a),o instanceof or&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{if(l instanceof or&&l.isSkinnedMesh){let h=l.dataPatched;if(h.bones&&h.boneInverses){let d=h.bones.map(p=>this.find(p)),c=h.boneInverses.map(p=>new fe().fromArray(p)),u=new Pv(d,c);l.bind(u,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:n,recursive:a}=e[r],o=this.find(n),l=a?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new Kt;return i.setFromPoints(t),i.getCenter(Gw),Gw}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof lr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof aa&&e(t.material[i]);else t.material instanceof aa&&e(t.material)})}updateCanvasSize(e,t,i=!1){this.activeCamera.setViewplaneSize(e,t,i)}},su=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},n9=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return o9(Math.atan2(r,i))},a9=(e,t,i)=>{let r={x:0,y:0};return i=lv(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},lv=e=>e*(Math.PI/180),o9=e=>e*(180/Math.PI),l9=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,fm=new Map,Vw=e=>{fm.has(e)&&clearTimeout(fm.get(e)),fm.set(e,setTimeout(e,100))},$u=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},Hw=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},fM=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),Ww=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},hv=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},k0=(e,t,i)=>{let r=mM(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let n="";for(let a=0,o=t.length;a<o;a+=1)n+=t[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},h9=(e,t)=>{let i=mM(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},mM=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},mm=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},c9=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},cv=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},d9=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(gM="ontouchstart"in window,vM=!!window.PointerEvent,yM=!!window.MSPointerEvent);var gM,vM,yM,Sh={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Ko,gc={};vM?Ko=Sh.pointer:yM?Ko=Sh.MSPointer:gM?(Ko=Sh.touch,gc=Sh.mouse):Ko=Sh.mouse;function io(){}io.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};io.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};io.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(a){a.call(i,{type:s,target:i},t)})};io.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=c9(t.options,e))};io.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},$u(e,Ko[t],i._domHandlers_[t]),gc[t]&&$u(e,gc[t],i._domHandlers_[t]),i};io.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},Hw(e,Ko[t],i._domHandlers_[t]),gc[t]&&Hw(e,gc[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var j0=io;function fi(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=fi.id,fi.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}fi.prototype=new j0;fi.constructor=fi;fi.id=0;fi.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};fi.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=h9("borderRadius","50%"),i=k0("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},mm(r.el,i),this.options.shape==="circle"&&mm(r.back,t),mm(r.front,t),this.applyStyles(r),this};fi.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};fi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};fi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};fi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};fi.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};fi.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};fi.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=k0("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};fi.prototype.restCallback=function(){var e=this,t={};t.front=k0("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};fi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};fi.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,n,a;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?n="left":n="right"),e.lockX||(t>0?a="up":a="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:n,y:a,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+n,e),h.y||this.trigger("plain:"+a,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var u9=fi;function Zt(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=Zt.id,Zt.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Zt.prototype=new j0;Zt.constructor=Zt;Zt.id=0;Zt.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};Zt.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};Zt.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};Zt.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},n=i.options,a={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-a.x,y:e.y-a.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",n.zone.appendChild(o);var l=o.getBoundingClientRect();n.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new u9(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:t,position:e,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(hv(h.ui.el,s),hv(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};Zt.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};Zt.prototype.bindNipple=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};Zt.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=e.force||e.pressure||e.webkitForce||0;n!==s&&(t.trigger("pressure",n),r.trigger("pressure "+t.identifier+":pressure",n),s=n)}.bind(r),100)};Zt.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=fM(e),t.updateBox();var s=function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var o=[e[0]];o.identifier=a,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))};return cv(e,s),t.manager.bindDocument(),!1};Zt.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),n=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,a);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),n>0&&t.pressureFn(e,d,d.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=su(a,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};Zt.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};Zt.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.scroll;if(!l9(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=su(l,s.position),d=n9(l,s.position),c=lv(d),u=h/o,p={distance:h,position:l},f,g;if(s.options.shape==="circle"?(f=Math.min(h,o),g=a9(s.position,f,d)):(g=d9(l,s.position,o),f=su(g,s.position)),i.follow){if(h>o){let x=l.x-g.x,b=l.y-g.y;s.position.x+=x,s.position.y+=b,s.el.style.top=s.position.y-(t.box.top+n.y)+"px",s.el.style.left=s.position.x-(t.box.left+n.x)+"px",h=su(l,s.position)}}else l=g,h=f;var m=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:m,y:v},i.dataOnly||hv(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:u,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:c,degree:d},vector:{x:m/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:lv(180-d),degree:180-d},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};Zt.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[n.id]=n.identifier))};Zt.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};Zt.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var p9=Zt;function _i(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=Ww(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(n){n.forEach(function(a){s=a.el.getBoundingClientRect(),a.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;$u(window,"resize",function(){Vw(i)});var r=function(){t.scroll=Ww()};return $u(window,"scroll",function(){Vw(r)}),t.collections}_i.prototype=new j0;_i.constructor=_i;_i.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};_i.prototype.create=function(e){return this.createCollection(e)};_i.prototype.createCollection=function(e){var t=this,i=new p9(t,e);return t.bindCollection(i),t.collections.push(i),i};_i.prototype.bindCollection=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};_i.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};_i.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};_i.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};_i.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};_i.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};_i.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};_i.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};_i.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=fM(t);var n=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},a=function(o){r=i.getIdentifier(o),cv(i.collections,n.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return cv(t,a),!1};_i.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};_i.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var f9=_i,qw=new f9,m9={create:function(e){return qw.create(e)},factory:qw},xM=new Map,qh=new Map,za=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:n,delay:a,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Nh({src:l,volume:n,delay:a,loop:o}),qh.has(i.uuid)?qh.get(i.uuid).push(this):qh.set(i.uuid,[this]),xM.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},dv=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=xM.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=qh.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...qh.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Xh=class{constructor(e,t,i,r){if(this.data=t,t.interaction==="play")this.interaction=new za(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new dv(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof za?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof za?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof za&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},g9="text/plain",v9="us-ascii",Xw=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),y9=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:n}=i.groups,a=r.split(";");n=t?"":n;let o=!1;a[a.length-1]==="base64"&&(a.pop(),o=!0);let l=(a.shift()||"").toLowerCase(),h=[...a.map(d=>{let[c,u=""]=d.split("=").map(p=>p.trim());return c==="charset"&&(u=u.toLowerCase(),u===v9)?"":`${c}${u?`=${u}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==g9)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${n?`#${n}`:""}`};function x9(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return y9(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let n=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,o="";for(;;){let h=n.exec(r.pathname);if(!h)break;let d=h[0],c=h.index,u=r.pathname.slice(a,c);o+=u.replace(/\/{2,}/g,"/"),o+=d,a=c+d.length}let l=r.pathname.slice(a,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let n=r.pathname.split("/"),a=n[n.length-1];Xw(a,t.removeDirectoryIndex)&&(n=n.slice(0,-1),r.pathname=n.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let n of[...r.searchParams.keys()])Xw(n,t.removeQueryParameters)&&r.searchParams.delete(n);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var b9=class{constructor({url:e,context:t},i){if(this.eventManager=i,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:x9(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){nA?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.eventManager.controlsManager.orbitControls?.onPointerUp(Ve[0]),CF())}},bM=class{constructor(e,t,i){this.data=e,this.page=t,this.eventManager=i,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=r=>{this.timeoutIdQueue.shift();let s=this.page.scene.find(r);if(s===void 0)return;let n=this.controlsManager.sharedGameControlGlobals.rapierWorld,a=n?s.dataPatched.physics?.fusedBody:!0;if(s.cloner){for(let o of s.cloner.children)a?(o.playModeVisible=!1,o.rigidBody&&s.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),n.removeRigidBody(o.rigidBody),o.rigidBody=void 0),o.bvhGeometry&&(o.bvhGeometry=void 0)):this.clone===void 0||this.clone===o?(o.playModeVisible=!1,o.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),n.removeRigidBody(o.rigidBody),o.rigidBody=void 0)):o.playModeVisible===void 0&&(o.playModeVisible=!0);(a||this.clone===void 0||this.clone===!1)&&(s.visible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0))}else s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0),s.visible=!1;n===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.rigidBody!==void 0),this.eventManager.requestRender()},this.objects=[...e.objects],this.controlsManager=i.controlsManager}dispatch(e){this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},w9=class{constructor(e,t,i){this.page=e,this.eventManager=i,this.sharedAssets=t}dispatch(){K0(this.page,this.sharedAssets,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender()}},wM={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},G0={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},_9=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],ep={CSS:{},springs:{}};function rs(e,t,i){return Math.min(Math.max(e,t),i)}function Yh(e,t){return e.indexOf(t)>-1}function gm(e,t){return e.apply(null,t)}var We={arr:function(e){return Array.isArray(e)},obj:function(e){return Yh(Object.prototype.toString.call(e),"Object")},pth:function(e){return We.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||We.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return We.hex(e)||We.rgb(e)||We.hsl(e)},key:function(e){return!wM.hasOwnProperty(e)&&!G0.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function _M(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function SM(e,t){var i=_M(e),r=rs(We.und(i[0])?1:i[0],.1,100),s=rs(We.und(i[1])?100:i[1],.1,100),n=rs(We.und(i[2])?10:i[2],.1,100),a=rs(We.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=n/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,d=1,c=l<1?(l*o+-a)/h:-a+o;function u(f){var g=t?t*f/1e3:f;return l<1?g=Math.exp(-g*l*o)*(d*Math.cos(h*g)+c*Math.sin(h*g)):g=(d+c*g)*Math.exp(-g*o),f===0||f===1?f:1-g}function p(){var f=ep.springs[e];if(f)return f;for(var g=1/6,m=0,v=0;;)if(m+=g,u(m)===1){if(v++,v>=16)break}else v=0;var y=m*g*1e3;return ep.springs[e]=y,y}return t?u:p}function S9(e){return e===void 0&&(e=10),function(t){return Math.ceil(rs(t,1e-6,1)*e)*(1/e)}}var A9=function(){var e=11,t=1/(e-1);function i(d,c){return 1-3*c+3*d}function r(d,c){return 3*c-6*d}function s(d){return 3*d}function n(d,c,u){return((i(c,u)*d+r(c,u))*d+s(c))*d}function a(d,c,u){return 3*i(c,u)*d*d+2*r(c,u)*d+s(c)}function o(d,c,u,p,f){var g,m,v=0;do m=c+(u-c)/2,g=n(m,p,f)-d,g>0?u=m:c=m;while(Math.abs(g)>1e-7&&++v<10);return m}function l(d,c,u,p){for(var f=0;f<4;++f){var g=a(c,u,p);if(g===0)return c;var m=n(c,u,p)-d;c-=m/g}return c}function h(d,c,u,p){if(!(0<=d&&d<=1&&0<=u&&u<=1))return;var f=new Float32Array(e);if(d!==c||u!==p)for(var g=0;g<e;++g)f[g]=n(g*t,d,u);function m(v){for(var y=0,x=1,b=e-1;x!==b&&f[x]<=v;++x)y+=t;--x;var _=(v-f[x])/(f[x+1]-f[x]),A=y+_*t,S=a(A,d,u);return S>=.001?l(v,A,d,u):S===0?A:o(v,y,y+t,d,u)}return function(v){return d===c&&u===p||v===0||v===1?v:n(m(v),c,p)}}return h}(),AM=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,n=4;r<((s=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var n=rs(r,1,10),a=rs(s,.1,2);return function(o){return o===0||o===1?o:-n*Math.pow(2,10*(o-1))*Math.sin((o-1-a/(Math.PI*2)*Math.asin(1/n))*(Math.PI*2)/a)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(n){return Math.pow(n,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(n,a){return function(o){return 1-s(n,a)(1-o)}},e["easeInOut"+r]=function(n,a){return function(o){return o<.5?s(n,a)(o*2)/2:1-s(n,a)(o*-2+2)/2}}}),e}();function V0(e,t){if(We.fnc(e))return e;var i=e.split("(")[0],r=AM[i],s=_M(e);switch(i){case"spring":return SM(e,t);case"cubicBezier":return gm(A9,s);case"steps":return gm(S9,s);default:return gm(r,s)}}function MM(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Mp(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],n=0;n<i;n++)if(n in e){var a=e[n];t.call(r,a,n,e)&&s.push(a)}return s}function Ep(e){return e.reduce(function(t,i){return t.concat(We.arr(i)?Ep(i):i)},[])}function Yw(e){return We.arr(e)?e:(We.str(e)&&(e=MM(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function H0(e,t){return e.some(function(i){return i===t})}function W0(e){var t={};for(var i in e)t[i]=e[i];return t}function uv(e,t){var i=W0(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Cp(e,t){var i=W0(e);for(var r in t)i[r]=We.und(e[r])?t[r]:e[r];return i}function M9(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function E9(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,d){return l+l+h+h+d+d}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),n=parseInt(r[2],16),a=parseInt(r[3],16);return"rgba("+s+","+n+","+a+",1)"}function C9(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,n=t[4]||1;function a(u,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(p-u)*6*f:f<1/2?p:f<2/3?u+(p-u)*(2/3-f)*6:u}var o,l,h;if(r==0)o=l=h=s;else{var d=s<.5?s*(1+r):s+r-s*r,c=2*s-d;o=a(c,d,i+1/3),l=a(c,d,i),h=a(c,d,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+n+")"}function T9(e){if(We.rgb(e))return M9(e);if(We.hex(e))return E9(e);if(We.hsl(e))return C9(e)}function xn(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function P9(e){if(Yh(e,"translate")||e==="perspective")return"px";if(Yh(e,"rotate")||Yh(e,"skew"))return"deg"}function pv(e,t){return We.fnc(e)?e(t.target,t.id,t.total):e}function Is(e,t){return e.getAttribute(t)}function q0(e,t,i){var r=xn(t);if(H0([i,"deg","rad","turn"],r))return t;var s=ep.CSS[t+i];if(!We.und(s))return s;var n=100,a=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(a),a.style.position="absolute",a.style.width=n+i;var l=n/a.offsetWidth;o.removeChild(a);var h=l*parseFloat(t);return ep.CSS[t+i]=h,h}function EM(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?q0(e,s,i):s}}function X0(e,t){if(We.dom(e)&&!We.inp(e)&&(Is(e,t)||We.svg(e)&&e[t]))return"attribute";if(We.dom(e)&&H0(_9,t))return"transform";if(We.dom(e)&&t!=="transform"&&EM(e,t))return"css";if(e[t]!=null)return"object"}function CM(e){if(We.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function D9(e,t,i,r){var s=Yh(t,"scale")?1:0+P9(t),n=CM(e).get(t)||s;return i&&(i.transforms.list.set(t,n),i.transforms.last=t),r?q0(e,n,r):n}function Y0(e,t,i,r){switch(X0(e,t)){case"transform":return D9(e,t,r,i);case"css":return EM(e,t,i);case"attribute":return Is(e,t);default:return e[t]||0}}function Q0(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=xn(e)||0,s=parseFloat(t),n=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+n+r;case"-":return s-n+r;case"*":return s*n+r}}function TM(e,t){if(We.col(e))return T9(e);if(/\s/g.test(e))return e;var i=xn(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Z0(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function I9(e){return Math.PI*2*Is(e,"r")}function L9(e){return Is(e,"width")*2+Is(e,"height")*2}function O9(e){return Z0({x:Is(e,"x1"),y:Is(e,"y1")},{x:Is(e,"x2"),y:Is(e,"y2")})}function PM(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var n=t.getItem(s);s>0&&(i+=Z0(r,n)),r=n}return i}function B9(e){var t=e.points;return PM(e)+Z0(t.getItem(t.numberOfItems-1),t.getItem(0))}function DM(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return I9(e);case"rect":return L9(e);case"line":return O9(e);case"polyline":return PM(e);case"polygon":return B9(e)}}function R9(e){var t=DM(e);return e.setAttribute("stroke-dasharray",t),t}function z9(e){for(var t=e.parentNode;We.svg(t)&&We.svg(t.parentNode);)t=t.parentNode;return t}function IM(e,t){var i=t||{},r=i.el||z9(e),s=r.getBoundingClientRect(),n=Is(r,"viewBox"),a=s.width,o=s.height,l=i.viewBox||(n?n.split(" "):[0,0,a,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a/l[2],h:o/l[3]}}function N9(e,t){var i=We.str(e)?MM(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:IM(i),totalLength:DM(i)*(r/100)}}}function U9(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=IM(e.el,e.svg),s=i(),n=i(-1),a=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(a.y-n.y,a.x-n.x)*180/Math.PI}}function Qw(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=TM(We.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:We.str(e)||t?r.split(i):[]}}function LM(e){var t=e?Ep(We.arr(e)?e.map(Yw):Yw(e)):[];return Mp(t,function(i,r,s){return s.indexOf(i)===r})}function OM(e){var t=LM(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:CM(i)}}})}function F9(e,t){var i=W0(t);if(/^spring/.test(i.easing)&&(i.duration=SM(i.easing)),We.arr(e)){var r=e.length,s=r===2&&!We.obj(e[0]);s?e={value:e}:We.fnc(t.duration)||(i.duration=t.duration/r)}var n=We.arr(e)?e:[e];return n.map(function(a,o){var l=We.obj(a)&&!We.pth(a)?a:{value:a};return We.und(l.delay)&&(l.delay=o?0:t.delay),We.und(l.endDelay)&&(l.endDelay=o===n.length-1?t.endDelay:0),l}).map(function(a){return Cp(a,i)})}function k9(e){for(var t=Mp(Ep(e.map(function(n){return Object.keys(n)})),function(n){return We.key(n)}).reduce(function(n,a){return n.indexOf(a)<0&&n.push(a),n},[]),i={},r=function(n){var a=t[n];i[a]=e.map(function(o){var l={};for(var h in o)We.key(h)?h==a&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function j9(e,t){var i=[],r=t.keyframes;r&&(t=Cp(k9(r),t));for(var s in t)We.key(s)&&i.push({name:s,tweens:F9(t[s],e)});return i}function G9(e,t){var i={};for(var r in e){var s=pv(e[r],t);We.arr(s)&&(s=s.map(function(n){return pv(n,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function V9(e,t){var i;return e.tweens.map(function(r){var s=G9(r,t),n=s.value,a=We.arr(n)?n[1]:n,o=xn(a),l=Y0(t.target,e.name,o,t),h=i?i.to.original:l,d=We.arr(n)?n[0]:h,c=xn(d)||xn(l),u=o||c;return We.und(a)&&(a=h),s.from=Qw(d,u),s.to=Qw(Q0(a,d),u),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=V0(s.easing,s.duration),s.isPath=We.pth(n),s.isColor=We.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var BM={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var n="";r.list.forEach(function(a,o){n+=o+"("+a+") "}),e.style.transform=n}}};function RM(e,t){var i=OM(e);i.forEach(function(r){for(var s in t){var n=pv(t[s],r),a=r.target,o=xn(n),l=Y0(a,s,o,r),h=o||xn(l),d=Q0(TM(n,h),l),c=X0(a,s);BM[c](a,s,d,r.transforms,!0)}})}function H9(e,t){var i=X0(e.target,t.name);if(i){var r=V9(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function W9(e,t){return Mp(Ep(e.map(function(i){return t.map(function(r){return H9(i,r)})})),function(i){return!We.und(i)})}function zM(e,t){var i=e.length,r=function(n){return n.timelineOffset?n.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0,l=n.pingPongEndDelayCorrection??0;return r(n)+a+o+l+n.duration*(n.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0;return r(n)+a+o+n.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0,l=n.pingPongEndDelayCorrection??0;return r(n)+a+o+n.duration*(n.loop??1)-n.endDelay-l})):t.endDelay,s}var Zw=0;function q9(e){var t=uv(wM,e),i=uv(G0,e),r=j9(i,e),s=OM(e.targets),n=W9(s,r),a=zM(n,i),o=Zw;return Zw++,Cp(t,{id:o,children:[],animatables:s,animations:n,duration:a.duration,delay:a.delay,endDelay:a.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var Fr=[],Kw=[],nu,X9=function(){function e(){nu=requestAnimationFrame(t)}function t(i){var r=Fr.length;if(r){for(var s=0;s<r;){var n=Fr[s];n.paused?(Fr.splice(s,1),r-=1):(n.tick(i),s++)}e()}else nu=cancelAnimationFrame(nu)}return e}();function Y9(e){document.hidden?(Fr.forEach(function(t){return t.pause(e.timeStamp)}),Kw=Fr.slice(0),Qt.running=Fr=[]):Kw.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Y9);function Qt(e){e===void 0&&(e={});var t=0,i=0,r=0,s,n,a=0,o=null;function l(S){var w=window.Promise&&new Promise(function(E){return o=E});return S.finished=w,w}var h=q9(e),d=l(h);function c(){var S=h.direction;S!=="alternate"&&(h.direction=S!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,n.forEach(function(w){(w.loop===1||w.loop%2===0)&&(w.reversed=h.reversed)})}function u(){h.direction="normal",h.reversed=!1,n.forEach(function(S){return S.reversed=!1})}function p(S){return h.reversed?h.duration-S:S}function f(){t=0,i=p(h.currentTime)*(1/Qt.speed)}function g(S,w,E=!1){w&&(h.reversed?w.seek(w.duration*w.loop-(S-w.timelineOffset-w.pingPongDelayCorrection),E):w.seek(S-w.timelineOffset-w.startOnceDelay-w.pingPongDelayCorrection,E))}function m(S,w=!1){if(h.reversed)for(var E=a;E--;)g(S,n[E],w);else for(var C=0;C<a;C++)g(S,n[C],w)}function v(S){var w=0,E=h.animations,C=E.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S):_(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S);w<C;){var T=E[w],D=T.animatable,P=T.tweens,L=P.length-1,R=P[L];L&&(R=Mp(P,function(Z){return S<Z.end})[0]||R);let re;h.parent?.reversed&&h.direction==="alternate"?re=rs(S-R.start-R.endDelay,0,R.duration)/R.duration:re=rs(S-R.start-R.delay,0,R.duration)/R.duration;for(var V=isNaN(re)?1:R.easing(re),k=R.to.strings,z=R.round,X=[],H=R.to.numbers.length,G=void 0,N=0;N<H;N++){var q=void 0;let Z,ue;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(Z=R.to.numbers[N],ue=R.from.numbers[N]||0):(ue=R.to.numbers[N],Z=R.from.numbers[N]||0):_(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(Z=R.to.numbers[N],ue=R.from.numbers[N]||0):(ue=R.to.numbers[N],Z=R.from.numbers[N]||0),R.isPath?q=U9(R.value,V*ue):q=Z+V*(ue-Z),z&&(R.isColor&&N>2||(q=Math.round(q*z)/z)),X.push(q)}var j=k.length;if(!j)G=X[0];else{G=k[0];for(var W=0;W<j;W++){var U=k[W],ie=k[W+1],Q=X[W];isNaN(Q)||(ie?G+=Q+ie:G+=Q+" ")}}BM[T.type](D.target,T.property,G,D.transforms),T.currentValue=G,w++}}function y(S){h[S]&&!h.passThrough&&h[S](h)}function x(){h.remaining&&h.remaining!==!0&&h.remaining--}let b={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function _(S,w,E,C,T){return b[S<<4|w<<3|E<<2|C<<1|T]}function A(S,w=!1){var E=h.duration;let C=h.delay,T=E-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(C=h.endDelay,T=E-h.delay);var D=p(S);if(h.progress=rs(D/E*100,0,100),w||(h.reversePlayback=D<h.currentTime),a&&m(D,w),!h.began&&h.currentTime>=0&&(h.began=!0,y("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,y("loopBegin")),(h.reversed||D>=0)&&D<=C&&h.currentTime!==0&&(v(0),y("change")),(D>=T&&h.currentTime!==E+h.pingPongDelayCorrection||!E)&&(v(E),y("change")),D>C&&D<T?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,y("changeBegin")),v(D),y("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,y("change"),a&&y("timelineChangeComplete")):h.began&&D>T&&y("changeComplete"),h.currentTime=rs(D,0,E+h.pingPongDelayCorrection),h.began&&y("update"),S>=E)if(x(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,y("loopComplete"),y("complete"),!h.passThrough&&"Promise"in window&&(o(),d=l(h)));else{a?t+=h.duration/Qt.speed:t+=h.duration;for(let P of n)P.setStartTime(0),P.remaining=P.loop;y("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():a&&u()}}return h.reset=function(){var S=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=S==="reverse",h.remaining=h.loop,n=h.children,a=n.length;for(var w=a;w--;)h.children[w].reset();(h.reversed&&h.loop!==!0||S==="alternate"&&h.loop===1)&&h.remaining++,v(h.reversed?h.duration:0)},h.setStartTime=function(S){t=S},h.set=function(S,w){return RM(S,w),h},h.tick=function(S){r=S,t||(t=r),A((r+(i-t))*Qt.speed)},h.seek=function(S,w=!1){A(S-t,w)},h.pause=function(S){h.paused=!0,a&&(s=S??performance.now())},h.play=function(S){!h.paused||(h.completed&&h.reset(),h.paused=!1,Fr.push(h),a&&s!==void 0&&(t+=(S??performance.now())-s),nu||X9())},h.reverse=function(){c(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function Jw(e,t){for(var i=t.length;i--;)H0(e,t[i].animatable.target)&&t.splice(i,1)}function Q9(e){for(var t=LM(e),i=Fr.length;i--;){var r=Fr[i],s=r.animations,n=r.children;Jw(t,s);for(var a=n.length;a--;){var o=n[a],l=o.animations;Jw(t,l),!l.length&&!o.children.length&&n.splice(a,1)}!s.length&&!n.length&&r.pause()}}function Z9(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?V0(t.easing):null,s=t.grid,n=t.axis,a=t.from||0,o=a==="first",l=a==="center",h=a==="last",d=We.arr(e),c=parseFloat(d?e[0]:e),u=d?parseFloat(e[1]):0,p=xn(d?e[1]:e)||0,f=t.start||0+(d?c:0),g=[],m=0;return function(v,y,x){if(o&&(a=0),l&&(a=(x-1)/2),h&&(a=x-1),!g.length){for(var b=0;b<x;b++){if(!s)g.push(Math.abs(a-b));else{var _=l?(s[0]-1)/2:a%s[0],A=l?(s[1]-1)/2:Math.floor(a/s[0]),S=b%s[0],w=Math.floor(b/s[0]),E=_-S,C=A-w,T=Math.sqrt(E*E+C*C);n==="x"&&(T=-E),n==="y"&&(T=-C),g.push(T)}m=Math.max.apply(Math,g)}r&&(g=g.map(function(P){return r(P/m)*m})),i==="reverse"&&(g=g.map(function(P){return n?P<0?P*-1:-P:Math.abs(m-P)}))}var D=d?(u-c)/m:c;return f+D*(Math.round(g[y]*100)/100)+p}}function K9(e){e===void 0&&(e={});var t=Qt(e);return t.duration=0,t.add=function(i,r){var s=Fr.indexOf(t),n=t.children;s>-1&&Fr.splice(s,1);function a(u){u.passThrough=!0}for(var o=0;o<n.length;o++)a(n[o]);var l=Cp(i,uv(G0,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=We.und(r)?h:Q0(r,h),a(t);var d=Qt(l);a(d),n.push(d),d.parent=t;var c=zM(n,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,d.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}Qt.version="3.2.0";Qt.speed=1;Qt.running=Fr;Qt.remove=Q9;Qt.get=Y0;Qt.set=RM;Qt.convertPx=q0;Qt.path=N9;Qt.setDashoffset=R9;Qt.stagger=Z9;Qt.timeline=K9;Qt.easing=V0;Qt.penner=AM;Qt.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var NM=Qt,$w=new M,e_=new M,t_=new it;function J9(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let n=1-s*s;if(n<=Number.EPSILON){let d=1-r;return i.w=d*e.w+r*t.w,i.x=d*e.x+r*t.x,i.y=d*e.y+r*t.y,i.z=d*e.z+r*t.z,i.normalize(),i}let a=Math.sqrt(n),o=Math.atan2(a,s),l=Math.sin((1-r)*o)/a,h=Math.sin(r*o)/a;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function Ka(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(a==null)return;let o=n??t[e],l=a;if(o!==l)return{update:h=>{let d=nt.lerp(o,l,h);s?t[e]=Math.trunc(d):t[e]=d},start:()=>{t[e]=o},end:()=>{t[e]=l}}}function UM(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=[...n??o],h=[...a];if(!(l.length!==h.length||r0(l,h)))return{update:d=>{l.forEach((c,u)=>{let p=nt.lerp(c,h[u],d);t[e][u]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[e],l)},end:()=>{Object.assign(t[e],h)}}}function i_(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new M().fromArray(s):a.clone(),l=new M().fromArray(n);if(!o.equals(l))return{update:h=>{a.lerpVectors(o,l,h)},start:()=>{a.copy(o)},end:()=>{a.copy(l)}}}function $9(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new fe().fromArray(s):a.clone(),l=new M,h=new it,d=new M;o.decompose(l,h,d);let c=new fe().fromArray(n),u=new M,p=new it,f=new M;if(c.decompose(u,p,f),!o.equals(c))return{update:g=>{t_.slerpQuaternions(h,p,g),$w.lerpVectors(l,u,g),e_.lerpVectors(d,f,g),a.compose($w,t_,e_)},start:()=>{a.compose(l,h,d)},end:()=>{a.compose(u,p,f)}}}function e7(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=n?typeof n=="string"?s.getColor(n).clone():new je().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new je().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let d=o.clone();return t[e]=d,{update:c=>{d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function ha(e,t,i,r){if(typeof t[e]=="number")return Ka(e,t,i??{},r);if(Array.isArray(t[e]))return UM(e,t,i??{},r)}function t7(e,t,i){let r=[],s=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let a=s??e.zoom,o=n;a!==o&&r.push({update:l=>{e.zoom=nt.lerp(a,o,l),e.updateProjectionMatrix()},start:()=>{e.zoom=a,e.updateProjectionMatrix()},end:()=>{e.zoom=o,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let a=Ka("targetOffset",e,t,i);a&&r.push(a)}return r}function i7(e,t,i,r){if(i.scaleBaked===void 0)return;let s=t.scaleBaked??e.data.geometry.scaleBaked,n=i.scaleBaked;if(ja.isEqual(s,n))return;let a=[];return a.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[nt.lerp(s[0],n[0],o),nt.lerp(s[1],n[1],o),nt.lerp(s[2],n[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:n},r),e.invalidateDownstreamBooleanData()}}),a}function r7(e,t,i){if(!i.extrusion)return;let r=e.extrusion,s=t.extrusion??{},n=i.extrusion,a=[];return GA.forEach(o=>{let l=ha(o,r,s,n);l&&a.push(l)}),a}function s7(e,t,i,r){let s=[];if(!("geometry"in i))return s;let n=e.geometry.userData.parameters,a="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof mc){let l=i7(e,a,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,vn(n,lb)),lb.forEach(h=>{let d=ha(h,l,a,o);d&&s.push(d)}),e instanceof z0){Object.assign(l,{extrusion:{...n.extrusion}});let h=r7(l,a,o);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()}})}return s}function n7(e,t,i,r){let s=[];if(i.intensity!==void 0){let n=Ka("intensity",e,t,i);n&&s.push(n)}if(i.color!==void 0){let n=e7("color",e,t,i,r);n&&s.push(n)}return s}function a7(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let n="materials"in t&&t.materials?t.materials:[],a=i.materials;e.material.forEach((o,l)=>{if(!a[l])return;let h=n[l]??{},d=a[l];typeof h=="string"||typeof d=="string"||s.push(...r_(o,h,d,r))})}else{if(!("material"in i&&i.material))return s;let n="material"in t&&t.material?t.material:{},a=i.material;if(typeof n=="string"||typeof a=="string")return s;s.push(...r_(e.material,n,a,r))}return s}function r_(e,t,i,r){let s=[],n=Qu(i,r)||!!t.layers&&Qu(t,r);s.push(m7(e,n));for(let a of e.layers){let o=t.layers?.data(a.uuid),l=i.layers.data(a.uuid);if(!l||!(a.visible??!0)||!(l.visible??!0))continue;let h=a.getNames().filter(d=>!FA.some(c=>d.includes(c)));for(let d of h)try{let c=a.getValue(d),u;if(d==="colors")u=p7(a,o,l,d);else if(Array.isArray(c))d==="steps"&&(u=u7(a,o,l,d));else if(typeof c=="number")u=o7(a,o,l,d);else{if(typeof c=="boolean")continue;c instanceof F?u=l7(a,o,l,d):c instanceof M?u=h7(a,o,l,d):c instanceof ar?u=d7(a,o,l,d,r):c instanceof je?u=c7(a,o,l,d,r):"isTexture"in c&&(u=f7(a,o,l,d))}u&&(Array.isArray(u)?s.push(...u):s.push(u))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${d}`,c)}}return s}function o7(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:e.getValue(r),n=i[r];if(s!==n)return{update:a=>{e.setValue(r,nt.lerp(s,n,a))},start:()=>{e.setValue(r,s)},end:()=>{e.setValue(r,n)}}}function l7(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new F().fromArray(t[r]):s.clone(),a=new F().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function h7(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new M().fromArray(t[r]):s.clone(),a=new M().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function c7(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new je().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new je().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let d=o.clone();return{update:c=>{e.getValue(r)!==d&&e.setValue(r,d),d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function d7(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new je().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new ar(a.r,a.g,a.b,a.a);if(l.equals(h))return;let d=o.clone();return{update:c=>{e.getValue(r)!==d&&e.setValue(r,d),d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function u7(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n,o=i[r];for(let l=0;l<n.length;++l){let h=a[l],d=o[l];h!==d&&s.push({update:c=>{n[l]=nt.lerp(h,d,c)},start:()=>{n[l]=h},end:()=>{n[l]=d}})}return s.length?s:void 0}function p7(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n.map(l=>l.toArray()),o=i[r];for(let l=0;l<n.length;++l){let h=[...a[l]],d=[...o[l]];Bu.isEqual(h,d)||s.push({update:c=>{n[l].fromArray(Bu.lerp(h,d,c))},start:()=>{n[l].fromArray(h)},end:()=>{n[l].fromArray(d)}})}return s.length?s:void 0}function f7(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let n=t?t[r]:s,a=i[r],o=[...n.repeat],l=[...n.offset],h=[...a.repeat],d=[...a.offset];if(!Qo.isEqual(o,h)||!Qo.isEqual(l,d))return{update:c=>{s.repeat=Qo.lerp(o,h,c),s.offset=Qo.lerp(l,d,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...d],s.updateMatrix()}}}function m7(e,t){return{update:()=>{e.transparent=t}}}var vm=new M,s_=new yi;function g7(e,t,i,r){let s=[],n,a,o,l,h,d,c={slide:(t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping).offset};if(h=Ka("slide",c,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping),h&&s.push(h),d=Ka("offset",c,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping),d&&s.push(d),!h&&!d&&(n=i_("position",e,t,i),n&&s.push(n),a=i_("scale",e,t,i),a&&s.push(a),o=v7(e,t,i,r),o&&s.push(o),l=$9("hiddenMatrix",e,t,i),l&&s.push(l)),n||a||o||l||h||d){let u=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Jr(e)&&mn(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,c))};s.push({update:u,start:u,end:u})}return s}function v7(e,t,i,r){let s=t?.rotation?t.rotation:void 0,n=i.rotation;if(!n)return;let a=s?new M().fromArray(s):new M().setFromEuler(e.rotation),o=new M().fromArray(n);if(a.equals(o))return;let l=vm.subVectors(o,a);if(r&&l.toArray().every(h=>Math.abs(h)<2*Math.PI)){let h=new it().setFromEuler(s_.setFromVector3(a)),d=new it().setFromEuler(s_.setFromVector3(o));return{update:c=>{J9(h,d,e.quaternion,c)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}else return{update:h=>{vm.lerpVectors(a,o,h),e.rotation.setFromVector3(vm)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}function y7(e,t,i){let r=[];if(!("cloner"in i)||!e.cloner)return r;let s=e.cloner,n="cloner"in t?t.cloner:{},a=i.cloner;OA.forEach(u=>{let p;u==="count"?p=Ka("count",s.parameters,n,a,!0):p=ha(u,s.parameters,n??{},a),p&&r.push(p)});let o=x7(s,n,a);o?.length&&r.push(...o);let l=b7(s,n,a);l?.length&&r.push(...l);let h=w7(s,n,a);h?.length&&r.push(...h);let d=_7(s,n,a);d?.length&&r.push(...d);let c=S7(s,n,a);return c?.length&&r.push(...c),r.length&&r.push({update:()=>{s.update()}}),r}function x7(e,t,i){if(e.parameters.type!=="radial")return;let r=t.radial,s=i.radial;if(!s)return;let n=e.parameters.radial,a=[];return BA.forEach(o=>{let l=ha(o,n,r??{},s);l&&a.push(l)}),a}function b7(e,t,i){if(e.parameters.type!=="linear")return;let r=t.linear,s=i.linear;if(!s)return;let n=[],a=e.parameters.linear;return RA.forEach(o=>{let l=ha(o,a,r??{},s);l&&n.push(l)}),n}function w7(e,t,i){if(e.parameters.type!=="grid")return;let r=t.grid,s=i.grid;if(!s)return;let n=[],a=e.parameters.grid;return zA.forEach(o=>{let l;o==="count"?l=UM(o,a,r??{},s,!0):l=ha(o,a,r??{},s),l&&n.push(l)}),n}function _7(e,t,i){if(e.parameters.type!=="toObject")return;let r=t.toObject,s=i.toObject;if(!s)return;let n=[],a=e.parameters.toObject;return NA.forEach(o=>{let l;o==="count"?l=Ka(o,a,r??{},s,!0):l=ha(o,a,r??{},s),l&&n.push(l)}),n}function S7(e,t,i){if(!e.parameters.randomness)return;let r=t.randomnessObject,s=i.randomnessObject;if(!s)return;let n=[],a=e.parameters.randomnessObject;return UA.forEach(o=>{let l=ha(o,a,r??{},s);l&&n.push(l)}),n}function n_(e,t,i,r,s){let n=[];return e.data.visible&&n.push(...g7(e,t,i,s)),e.data.visible&&n.push(...y7(e,t,i)),Jr(e)?(e instanceof or&&e.data.visible&&n.push(...s7(e,t,i,r)),e.data.visible&&n.push(...a7(e,t,i,r))):UG(e)?e.data.visible&&n.push(...n7(e,t,i,r)):NG(e)&&n.push(...t7(e,t,i)),n.length?{update:a=>{n.forEach(o=>o.update(a))},start:a=>{n.forEach(o=>o.start?.(a))},end:a=>{n.forEach(o=>o.end?.(a))}}:void 0}var a_=new M;function K0(e,t,i=!1){let r=[];e.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(a_,!0),s.rigidBody?.setAngvel(a_,!0)),!ut.is(s))return;let n=s.uuid,a=s.data;if(delete s.states,s.uuid===Vl)return;let o=!1;r.some(l=>e.scene.find(n)?.isDescendantOf(l))?o=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&r.push(n),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let l of a.states){let h={...l.data};e.data.globalPhysics.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||o)&&(l.data.position!==void 0&&delete h.position,l.data.rotation!==void 0&&delete h.rotation,l.data.hiddenMatrix!==void 0&&delete h.hiddenMatrix),s.states||(s.states={}),s.states[l.id]=Oa.patch(a,h)}M7(e.scene,s,null,t,a.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),A7(e)})}function A7(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let n=e.scene.find(s.data.object);n&&(n.visible=!1)}}})}function M7(e,t,i,r,s=!1){if(t instanceof or&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof or&&t.updateGeometryGroupsIfNeeded(),t instanceof Yi&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),t.cloner)for(let n of t.cloner.children)n.playModeVisible=void 0;t.updateVisible()}function FM(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
|
|
6237
6237
|
${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
|
|
6238
|
-
)`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:n}=e;t=`spring( ${i}, ${r}, ${s}, ${n} )`}else{let i;switch(e.easing){case 0:i=kn.linear;break;case 1:i=kn.ease;break;case 2:i=kn.easeIn;break;case 3:i=kn.easeOut;break;case 4:i=kn.easeInOut;break;default:i=kn.linear}let[r,s,n,a]=i;t=`cubicBezier( ${r}, ${s}, ${n}, ${a} )`}return{duration:e.duration,easing:t}}function kM(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var E7={type:"beginState"},C7={type:"completeState",isfromEntity:!1},o_=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let a=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"beginState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Yi&&o.dispatchEvent(E7)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let a=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"completeState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Yi&&o.dispatchEvent(C7)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=n_(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let a=au(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=au(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=au(this.object,i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...kM(r),...FM(r),change:this.onChange},this.callback=n_(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Qh=class extends Ti{constructor(e,t,i){if(super(),this.data=e,this.page=t,this.sharedAssets=i,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let r=this.page.scene.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=au(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:t=!1}={}){try{let i=kM(this.data.tweens[0].data),r=i.loop;t&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=NM.timeline({autoplay:!1,...i,...r===!0||r>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(n=>n?.changeBegan);if(this.timelineNeedsRebuild=s!==-1&&(r===!0||r>1),i.pingPongDelayCorrection&&t===!1&&(this.timelineNeedsRebuild=!0),e){let n=s===-1?0:s;for(let a=n;a<this.data.tweens.length-1;a++){let o=this.data.tweens[a],l=this.data.tweens[a+1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Yi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new o_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.delay:0)+(a===n&&!t?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let n=s===-1?this.data.tweens.length-1:s+1;for(let a=n;a>0;a--){let o=this.data.tweens[a],l=this.data.tweens[a-1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Yi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new o_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a-1]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.endDelay:0))}this.timeline.duration+=i.delay+(t?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function au(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var T7={type:"beginState"},l_={type:"completeState",isfromEntity:!1},h_={type:"requestRender"},jM=class extends Ti{constructor(e,t){super(),this.data=e,this.page=t,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new M,this.posEnd=new M,this.qStart=new it,this.qEnd=new it,this.zoomStart=1,this.zoomEnd=1,this.toCamera=this.page.scene.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=NM({targets:t,t:1,...FM(this.data),update:()=>{t.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)),this.page.activeCamera.dispatchEvent(T7));let i=this.page.activeCamera;i.position.lerpVectors(this.posStart,this.posEnd,t.t),i.quaternion.slerpQuaternions(this.qStart,this.qEnd,t.t),i.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*t.t,i.wasMovedBySwitchCameraAction=!0,i.updateMatrix(),i.updateMatrixWorld(),i.updateProjectionMatrix(),i.dispatchEvent(h_),t.t===1&&i.dispatchEvent(l_)}})}switchCamera(e){this.page.switchActiveCamera(e),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:e})}play(){this.playing||this.page.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.page.activeCamera.dispatchEvent(l_),this.page.activeCamera.dispatchEvent(h_))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},Zh=class extends Ti{constructor(e,t,i){super(),this.page=t,this.animationControls=i,this.startOnceDelay=0,this.toggleIsForward=!1;let r=e.object,s=t.scene.find(e.object);s&&Array.isArray(s.identity)&&(r=s.identity[0]),this.data={...e,object:r};let n=this.animationControls.clipIdToAction[e.clipId+"/"+r];this.duration=n?.getClip()?.duration??1;let a=n?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/a*this.duration,this.rightFrameTime=this.data.crop[1]/a*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=nt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let n=r.split("/")[1];this.threeAnimAction!==s&&n===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},GM=class{constructor(e,t,i,r){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.timeOutId=-1,this.scene=t.scene}dispatch(){this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),K0(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function Gr(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?us[e.type].includes("Audio")&&a.Audio.push(new Xh(o,l,n,r)):l.type==="Video"?us[e.type].includes("Video")&&a.Video.push(new J0(o,l,n)):l.type==="Link"?us[e.type].includes("Link")&&a.Link.push(new b9(l,s)):l.type==="Create"?us[e.type].includes("Create")&&a.Create.push(new Jh(l,i,s.controlsManager)):l.type==="Destroy"?us[e.type].includes("Destroy")&&a.Destroy.push(new bM(l,i,s)):l.type==="Reset"?us[e.type].includes("Reset")&&a.Reset.push(new w9(i,r,s)):l.type==="Transition"?us[e.type].includes("Transition")&&a.Transition.push(new Qh(l,i,r)):l.type==="SwitchCamera"?us[e.type].includes("SwitchCamera")&&a.SwitchCamera.push(new jM(l,i)):l.type==="SceneTransition"?us[e.type].includes("SceneTransition")&&a.SceneTransition.push(new GM(l,i,s,r)):l.type==="Animation"&&us[e.type].includes("Animation")&&a.Animation.push(new Zh(l,i,s.animationControls))}catch{}}),a}function Sr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof Xh||i instanceof J0||i instanceof Zh||i instanceof Qh||i instanceof Jh||i instanceof bM||i instanceof jM||i instanceof GM)&&i.dispose()})})}function P7(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var VM=new Map,Kh=new Map,ul=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=P7(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n)),a!==void 0&&(this.delay=a),Kh.has(i.uuid)?Kh.get(i.uuid).push(this):Kh.set(i.uuid,[this]),VM.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},fv=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=VM.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Kh.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Kh.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},J0=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new ul(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new fv(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof ul?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof ul?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},c_=(()=>{let e,t,i,r;function s(o){!e&&!d_()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(n)),o&&(t=o,r=o.requestRender)}function n(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,d=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,u=0;for(;u<c;){let p=h[u];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&d[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),u++):(d[p.userData.actionId]>p.userData.quantity&&d[p.userData.actionId]--,h.splice(u,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=u>0?requestAnimationFrame(n):void 0,i=u>0?o:void 0}function a(){d_()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",a),s})();function d_(){return!!document&&document.hidden}var u_=new it,D7=new M,I7=new M,Jh=class{constructor(e,t,i){this.data=e,this.page=t,this.controlsManager=i,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=nt.generateUUID(),this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=fF(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let s=new Ri(this.object);if(s.playModeVisible=!0,s.expand(),this.data.coordinateSystem!=="world"){let a=this.data.coordinateSystem,o=this.page.scene.find(a);o&&(o.updateMatrixWorldSVD(),s.hiddenMatrix.copy(o.matrixWorldRigid))}s.position.fromArray(this.data.position),s.rotation.fromArray(this.data.rotation),s.updateMatrix(),this.page.add(s);let n=this.controlsManager.sharedGameControlGlobals;n.createdObjects.push(s),n.nCreatedPerAction[this.uniqueId]===void 0?n.nCreatedPerAction[this.uniqueId]=1:n.nCreatedPerAction[this.uniqueId]++,s.updateWorldMatrix(!0,!0),s.traverseObject(this.traverseObjectCB),c_(),this.controlsManager.requestRender()},this.traverseObjectCB=s=>{s.hasNonUniformScale&&s.updateMatrixWorldSVD();let n;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(s instanceof is)if(s.objectForSample){if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(s instanceof Ri)n=s.object;else if(n=s,n.dataPatched.cloner?.hideBase)return!0}else{if(s instanceof is)return;s instanceof Ri?n=s.object:n=s}this.data.destroy==="Time"?s.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(s.userData.quantity=this.data.destroyAfterQuantity,s.userData.actionId=this.uniqueId);let a=new M().fromArray(this.data.velocity),o=n.dataPatched;if(!(o.physics.enabled==="visibility"?!o.visible:!o.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(s,n,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(s.rigidBody?.collider(0).setActiveEvents(1),s.userData.hasCollisionDestroy=!0),s.matrixWorld.decompose(D7,u_,I7),a.applyQuaternion(u_),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&s.rigidBody?.setLinvel(a.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in s.object&&this.controlsManager.addBoundsTree(s),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&(s.userData.velocity=a)),n.dataPatched.physics?.fusedBody===!0))return!0};let r=this.page.scene.find(this.data.object);if(!r)throw new Error("Missing Property");if(this.object=r,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");c_(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},HM=200,ym=.02,xm=.3,L7=65,cX=new M,p_=new M,f_=new M,O7=new M,Mi=new M,ji=new M,zn=new M,qd=new fe,bm=new fe,B7=new fe,dX=new fe,mr=new it,Js=new it,ys=new yi(0,0,0,"YXZ"),R7=new M(1,0,0),Zr=new M(0,1,0),z7=new M(0,0,1),wm=new M(1,1,1),_m=new _r,N7=1,U7=.025,F7=16e-6,m_=12,k7=20,gi=new Ur,Pr=new Kt,j7={type:"requestRender"},G7={type:"updateMatrix"},g_=Math.PI/6,mv=class extends Ti{constructor(e,t,i,r,s,n,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new fe,this.target0=new M,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=HM,this.euler0=new yi(0,0,0,"YXZ"),this.position0Cam=new M,this.quat0Cam=new it,this.scale0Cam=new M,this.hiddenMatrix0Cam=new fe,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Ur(new M(0,-40,0),new M(0,40,0)),matrix:new fe,position:new M,rotation:new it},this.euler=new yi(0,0,0,"YXZ"),this.eulerDelta=new M,this.lastPosition=new M,this.lastCameraQuaternion=new it,this.lastCameraPosition=new M,this.PI_2=Math.PI/2,this.prevMouse=new F,this.velocityTarget=new M,this.velocity=new M,this.directionXZ=new M,this.rotVelocityStick=new M,this.rotVelocityTarget=new M,this.rotVelocity=new M,this.rotDirection=new M,this.nonColliderRotOffset=new fe,this.nonColliderPosOffset=new fe,this.firstPointerId=-1,this.rot=new M,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new fe,this.objectToTarget=new M,this.objectToTarget0=new M,this.objectToCamXZ=new M,this.objectToCamXZ0=new M,this.targetToCamera=new M,this.targetToCamera0=new M,this.cameraPolarAxis0=new M,this.targetPos=new M,this.targetQuat=new it,this.lerpFactorPos=new M().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new it,this.objXZQuatInv=new it,this.objXZRotMat=new fe,this.isFirstPerson=!1,this.actions={},this.didHit=!1,this.groundVelocity=new M,this.pushedVelocity=new M,this.groundYRotation=0,this.objectRealQuat=new it,this.colliderWorldQuat=new it,this.groundNormal=new M,this.groundTilt=new it,this.groundTiltInv=new it,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new M,this.quaternion=new it,this.scale=new M,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!br&&(!Bx||Rx>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(Bx&&Rx<15.5&&!br?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?mv.isLocked=!0:mv.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let v=f.axes[m];g===0?m===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),d=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,d,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new M(0,0,-1).applyQuaternion(this.camera.quaternion),g=new M().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let m,v;Math.abs(f.y)<1e-6?(g.y=0,f.y=0,v=g.projectOnVector(f)):g.y/f.y>0?v=f.multiplyScalar(g.y/f.y):v=f.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate(),m=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(m,this.position);let y=new yi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Yi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*N7,this.speedOrbit=(i.speedRotate??100)*U7,this.mouseOrbitSensitivity=(i.speedRotate??100)*F7,this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Sl.defaultData.gravity)*m_,this.usePhysics=this.gloabalPhysics.usePhysics??Sl.defaultData.usePhysics,this.jumpPower=i.jumpPower*k7,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Vu.defaultDataThirdPerson.orientWith,this.slopeThresh=L7*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*ym/this.pixelsPerMeter,this.stepThresh=i.collider.height*xm/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*ym/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*xm/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*ym/this.pixelsPerMeter,this.stepThresh=i.collider.height*xm/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new M().fromArray(i.collider.position),u=new it().setFromEuler(new yi().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(u),this.collider.matrix.compose(c,u,wm),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new et;f.push({fi:0,data:{...Ji.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Ji.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=new P0({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new ir(YA.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new yi().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Yi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.page,i=this.sharedAssets,r=this.object;e.gameActions!==void 0&&Object.entries(e.gameActions).forEach(([s,n],a)=>{n.forEach(({id:o,data:l})=>{try{this.actions[s]===void 0&&(this.actions[s]=[]),l.type==="Transition"?this.actions[s].push(new Qh(l,t,i)):l.type==="Animation"?this.actions[s].push(new Zh(l,t,this.controlsManager.eventManager.animationControls)):l.type==="Audio"?this.actions[s].push(new Xh(o,l,r,i)):l.type==="Video"?this.actions[s].push(new J0(o,l,r)):l.type==="Create"&&this.actions[s].push(new Jh(l,t,this.controlsManager))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Sr(this.actions)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].forEach(t=>{t instanceof Qh?t.play():t instanceof Zh?t.play(this.initialAction===!1):t instanceof Jh?t.dispatchStart():t instanceof Xh&&t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].forEach(t=>{t instanceof Qh?(t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})):t instanceof Zh||(t instanceof Jh?t.dispatchStop():t instanceof Xh&&t.dispatchGameControl("stop"))})))}get colliderWorldPosition(){return Mi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,n=!1;if(this.usePhysics&&this.collisionEnabled){let o=ji.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*m_),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(n=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Mi,Js,ji),this.groundVelocity.subVectors(Mi,d.prevT),this.object.getWorldPosition(ji).add(this.collider.position).sub(Mi),this.groundYRotation=ys.setFromQuaternion(Js).y-d.prevR.y,zn.copy(ji).applyAxisAngle(Zr,this.groundYRotation),this.groundVelocity.add(zn.sub(ji)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Mi.subVectors(this.path[1],this.position),h=ji.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=O7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=ji.copy(a);o.y=0,a.set(0,a.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=Mi;this.camera.getWorldDirection(o);let l=zn.copy(Zr).multiplyScalar(o.dot(Zr));o.sub(l);let h=ji.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(ys.setFromVector3(this.rot),this.moveMode==="walk"&&(ys.x=0),a.applyEuler(ys),n&&(Js.setFromUnitVectors(Zr,this.groundNormal),a.applyQuaternion(Js)),i){let o=ys.set(0,this.vrEulerYOffset*g_,0);i.applyEuler(o),a.x+=i.x,a.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=ji;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=zn.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),d=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Mi.copy(a).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=ut.is(l)?l:l.object;if(d!==null&&this.lastHitObj!==c){let u;l instanceof Ri&&(u=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(u),c.dispatchEvent(yv));this.lastHitObj=c}if(d!==null){this.pushedVelocity.copy(h),o.copy(d.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(a);l<0&&a.addScaledVector(o,-l),a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Zr,this.euler.y-this.euler0.y);let o=ji.copy(this.objectToCamXZ).normalize(),l=zn.copy(a).multiplyScalar(r);l.y=0;let h=l.sub(Mi.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=nt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=nt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=nt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(ys.copy(t),ys.y=0):(ys.copy(this.euler),ys.y=0),this.nonColliderRotOffset.makeRotationFromEuler(ys)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*g_),mr.setFromAxisAngle(R7,this.rot.x),Js.setFromAxisAngle(Zr,this.rot.y),Js.multiply(mr),mr.setFromAxisAngle(z7,this.rot.z),Js.multiply(mr),this.quaternion.copy(Js),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=ji.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new M;for(let d=0;d<5;d++){let c=o.length(),u=zn.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&d===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let _ of p.cloner.children)if(_.rigidBody===x){b=_;break}}y.dispatch(b),p.dispatchEvent(yv)}}}let f=p_.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=f_.copy(u).multiplyScalar(l.toi).dot(f),m=l.toi;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=l.toi*(g-this.offset)/g,h.addScaledVector(u,m)),o.copy(u).multiplyScalar(c-m),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=zn.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Mi.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(mr.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=a.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),h===0&&this.checkTrigger(),this.collisionAdjustment(r/o)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);qd.lookAt(l,o,Zr).setPosition(l),qd.decompose(this.targetPos,this.targetQuat,Mi),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=nt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=nt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(G7),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&this.navMeshPathDest?.material?.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(j7),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=mr.setFromAxisAngle(Zr,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?nt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=nt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=nt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mi.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Js.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Zr.angleTo(e)*180/Math.PI<15||Zr.angleTo(e)*180/Math.PI>85?mr.identity():mr.setFromUnitVectors(Zr,e),this.groundTilt.slerp(mr,.06),this.groundTiltInv.copy(this.groundTilt).invert()}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(ut.is(o)?o:o.object)===!1)continue;let l=bm.copy(s.matrixWorld).decompose(Mi,mr,ji).compose(Mi,mr,wm).multiply(r),h=qd.copy(o.matrixWorld).invert().multiply(l);i instanceof Kt?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(_m.radius=i,_m.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(_m)),e?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(QW)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}collisionAdjustment(e){let t=f_.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=qd.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mi,mr,ji).compose(Mi,mr,wm);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;Pr.makeEmpty(),s.updateMatrixWorldSVD();let n=s.matrixWorldRigid,a=bm.copy(n).invert(),o=B7.copy(bm).multiply(i);gi.copy(this.collider.segment),gi.start.applyMatrix4(o),gi.end.applyMatrix4(o);let l=p_.copy(this.position).applyMatrix4(a);Pr.expandByPoint(gi.start),Pr.expandByPoint(gi.end),Pr.min.addScalar(-this.collider.radius),Pr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(gi.end)},intersectsBounds:h=>h.intersectsBox(Pr),intersectsTriangle:h=>{let d=Mi,c=ji,u=h.closestPointToSegment(gi,d,c);if(u<this.collider.radius){let p=this.collider.radius-u,f=c.sub(d).normalize(),g=zn.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(n).sub(this.position);t.add(m),gi.start.addScaledVector(f,p),gi.end.addScaledVector(f,p)}}})}),Pr.makeEmpty(),gi.copy(this.collider.segment),gi.start.applyMatrix4(i),gi.end.applyMatrix4(i),Pr.expandByPoint(gi.start),Pr.expandByPoint(gi.end),Pr.min.addScalar(-this.collider.radius),Pr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(gi.end)},intersectsBounds:s=>s.intersectsBox(Pr),intersectsTriangle:s=>{let n=Mi,a=ji,o=s.closestPointToSegment(gi,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),gi.start.addScaledVector(h,l),gi.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},WM=mv;WM.isLocked=!1;var V7=Pl(O_());function dn(e,t){let i=new qe;if(!e.getAttribute("position"))return i.setAttribute("position",new Le([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=_p(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Le(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var H7=new fe,W7=new fe,xs=[[0,0,0],[0,0,0],[0,0,0]];function qM(e){let t=e.elements;xs[0][0]=t[0],xs[0][1]=t[4],xs[0][2]=t[8],xs[1][0]=t[1],xs[1][1]=t[5],xs[1][2]=t[9],xs[2][0]=t[2],xs[2][1]=t[6],xs[2][2]=t[10];let{u:i,v:r}=(0,V7.SVD)(xs),s=H7.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),n=W7.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(n.transpose())}var q7=class extends SS{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new oa({color:65280,linewidth:10}),t=new M(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new M(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new M().addVectors(t,i.multiplyScalar(r)),n=new qe;return n.setFromPoints([t,s]),new fu(n,e)}},XM=e=>e instanceof Ku||e instanceof dl;function X7(e,t){return e.distance-t.distance}function YM(e,t,i){if(!(!cn(t)||!t.visible)){Jr(t)&&t.raycast(e,i);for(let r of t.children)YM(e,r,i)}}function gv(e,t,i){if(!i.some(s=>tp(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>YM(e,s,r)),r.sort(X7),r}function vv(e){let t=[];if(e.length){let i=e[0].object;cn(i)&&t.push(i);let r=i.parent;for(;r;)XM(r)&&t.push(r),r=r.parent}return t}function tp(e,t){if(Jr(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(XM(t))return QM(e,t)}function QM(e,t){if(!(!cn(t)||!t.visible)){if(Jr(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=QM(e,i);if(r)return r}}}function Y7(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}var Q7=class{constructor(e,t,i,r,s,n,a){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=n,this.isExport=a,this.raycaster=new q7,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(Y7(t,i,r),this.getCamera())}},ZM=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e[e.scroll=6]="scroll",e))(ZM||{}),An=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},$0=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],KM=e=>$0.find(([t,i])=>i===e)?.[0],Pc=e=>$0.find(([t])=>t===e)?.[1],Z7=(e,t)=>{let i=KM(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},K7=class extends An{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[KM(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of $0)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=Z7(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},J7=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Gr(t,t.actions,r,s,n,i)}disconnect(){Sr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.useToggle===!1&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},$7=class extends An{constructor(e,t){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.windowMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.onWindowMouseDown=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})},this.onWindowMouseUp=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseDown"))},this.onMouseUp=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent())},this.onMousePressRelease=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent(!0))},this.onKeyDown=s=>{this.heldKeys[s.key]||(this.handleKeyEvent(s,"KeyDown"),this.handleKeyEventHeld(s,"KeyDown",!0)),this.heldKeys[s.key]=!0},this.onKeyUp=s=>{this.handleKeyEvent(s,"KeyUp"),this.handleKeyEventHeld(s,"KeyUp",!0)},this.onKeyPressDown=s=>{this.heldKeysPress[s.key]?this.handleKeyEventHeld(s,"KeyPress"):(this.handleKeyEvent(s,"KeyPress"),this.handleKeyEventHeld(s,"KeyPress",!0)),this.heldKeysPress[s.key]=!0},this.onKeyPressUp=s=>{this.handleKeyEvent(s,"KeyPress",!0)},this.releaseHeldKey=s=>{delete this.heldKeys[s.key]},this.releaseHeldKeyPress=s=>{delete this.heldKeysPress[s.key]},this._onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Pc(s);o&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent(a)})):(o==="KeyDown"||o==="KeyUp"||o==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent()})))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let a of n){let o=this.eventsPerObjects[a];s.data.events.filter(({data:l})=>l.type===a&&l.disabled!==!0).forEach(({id:l,data:h})=>{try{let d=new J7(l,h,s,i,r,t);d.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.mode==="Window")?h.mode==="Canvas"&&this.canvasMouseEvents.push(d):o[s.uuid]?o[s.uuid].push(d):o[s.uuid]=[d]}catch{}}),o[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=gv(i,r,s);vv(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{tp(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:a}=this.eventContext;if(s){let o=gv(n,a,i);r=vv(o)}else i.forEach(o=>{tp(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},eW=new M,tW=new M,JM=class{constructor(e,t,i,r,s){this.actionsIn=Gr(e,e.inActions,i,r,s,t),this.actionsOut=Gr(e,e.outActions,i,r,s,t)}disconnect(){Sr(this.actionsIn),Sr(this.actionsOut)}},iW=class extends JM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{for(let u of this.objects)if(!u.visible)return;let h=eW.setFromMatrixPosition(this.objects[0].matrixWorld),d=tW.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(d)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let u=c==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Link.forEach(p=>p.dispatch()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.Animation.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),u.SceneTransition.forEach(p=>p.dispatch())}};let{distance:a,fromObject:o,toObject:l}=t.condition;this.distance=a;for(let h of[o,l]){if(!h)throw new Error("Missing property");let d=r.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},rW=class extends JM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(d=>d.dispatchConditional()),this.actionsOut.Video.forEach(d=>d.dispatchConditional()),this.actionsOut.Link.forEach(d=>d.dispatch()),this.actionsOut.Create.forEach(d=>d.dispatch()),this.actionsOut.Destroy.forEach(d=>d.dispatch()),this.actionsOut.Reset.forEach(d=>d.dispatch()),this.actionsIn.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(d=>d.play()),this.actionsOut.Animation.forEach(d=>d.play()),this.actionsIn.SwitchCamera.forEach(d=>d.pause()),this.actionsOut.SwitchCamera.forEach(d=>d.play()),this.actionsOut.SceneTransition.forEach(d=>d.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(d=>d.dispatchConditional()),this.actionsIn.Video.forEach(d=>d.dispatchConditional()),this.actionsIn.Link.forEach(d=>d.dispatch()),this.actionsIn.Create.forEach(d=>d.dispatch()),this.actionsIn.Destroy.forEach(d=>d.dispatch()),this.actionsIn.Reset.forEach(d=>d.dispatch()),this.actionsOut.Transition.forEach(d=>d.pause()),this.actionsOut.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(d=>d.play()),this.actionsIn.Animation.forEach(d=>d.play()),this.actionsOut.SwitchCamera.forEach(d=>d.pause()),this.actionsIn.SwitchCamera.forEach(d=>d.play()),this.actionsIn.SceneTransition.forEach(d=>d.dispatch()))};let{condition:a}=t;if(!a.object)throw new Error("Missing property");let o=r.find(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},sW=class extends An{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let o;a.condition.type==="Comparison"||(a.condition.type==="Distance"?o=new iW(n,a,s,i,r,t):a.condition.type==="State"&&(o=new rW(n,a,s,i,r,t))),o&&(this.eventsPerConditions[a.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ah=new M,Nn=new M,_a=new M,v_=new vr,nW=.01,xt=new M,li=new M,y_=new M,Na=new it,Sm=new yi,aW=new fe,Am=new bi,Lo=new M,bs=new M,Oo=.2;function Mm(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var oW=function(){let e=new fe;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&Mm(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?Mm(s.position,t.limits):t.reference==="local"&&(Na.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Na),Mm(s.position,t.limits),Na.invert(),s.position.applyQuaternion(Na),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(xt,s.quaternion,li),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof lr&&mn(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),lW=class{constructor(e,t,i,r,s,n){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Gr(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=Gr(t,t.dragDropActions.drop,i,r,s,this.object);let a=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(a.push(l),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new M().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new M().setFromMatrixPosition(o.matrixWorld),pointStart:new M,pointEnd:new M,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new M().copy(o.position),quat0:new it().copy(o.quaternion),snapped:!1,orientationMatrix:new fe,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Sr(this.actionsDrag),Sr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},hW=class extends An{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:d,pointStart:c}of o.dragItems){if(h===a[0].object||h===a[0].object.object||ut.is(h)&&h.isAncestorOf(a[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(xt,Na,li),Sm.setFromQuaternion(Na),u.prevR===void 0?(u.prevR=Sm.clone(),u.prevT=xt.clone()):(u.prevR.copy(Sm),u.prevT.copy(xt)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),d.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(Ve.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===a[0]?.object||h===a[0]?.object?.object||ut.is(h)&&h.isAncestorOf(a[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=a.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Ku)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(d=>d===h.object.uuid||n.scene.find(d).isAncestorOf(h.object.uuid))))[0]),l){let h=y_.copy(l.face.normal).applyMatrix3(Am.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){xt.copy(h).applyMatrix3(Am.setFromMatrix4(o.obj.matrixWorld).transpose());let d=o.obj;xt.x>Oo?li.x=-d.recursiveBBox.min.x:xt.x<-Oo&&(li.x=-d.recursiveBBox.max.x),xt.y>Oo?li.y=-d.recursiveBBox.min.y:xt.y<-Oo&&(li.y=-d.recursiveBBox.max.y),xt.z>Oo?li.z=-d.recursiveBBox.min.z:xt.z<-Oo&&(li.z=-d.recursiveBBox.max.z),li.applyMatrix3(Am.invert())}else li.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(li)}this.activeEvent.data.autoOrient&&(xt.set(0,1,0).cross(h),xt.length()<1e-4&&xt.set(-1,0,0).cross(h),li.crossVectors(y_,xt),o.orientationMatrix.makeBasis(xt,li,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Animation.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Audio.forEach(d=>{d.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(d=>{d.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")})),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new lW(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:n}=this.eventContext;s().getWorldDirection(Nn),Nn.negate();let a=Na.identity();switch(r==="parent"?aW.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(xt,a,li):r==="local"&&e.matrixWorld.decompose(xt,a,li),i){case"x":xt.set(1,0,0).applyQuaternion(a),Lo.copy(Nn).cross(xt),bs.copy(xt).cross(Lo);break;case"y":xt.set(0,1,0).applyQuaternion(a),Lo.copy(Nn).cross(xt),bs.copy(xt).cross(Lo);break;case"z":xt.set(0,0,1).applyQuaternion(a),Lo.copy(Nn).cross(xt),bs.copy(xt).cross(Lo);break;case"xy":bs.set(0,0,1).applyQuaternion(a);break;case"yz":bs.set(1,0,0).applyQuaternion(a);break;case"xz":bs.set(0,1,0).applyQuaternion(a);break;case"adaptive":Nn.angleTo(li.set(0,1,0))>Math.PI/6?(xt.crossVectors(li.set(0,1,0),Nn),bs.crossVectors(xt,li)):bs.set(0,1,0);break;default:bs.copy(Nn);break}_a.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:_a;if(v_.setFromNormalAndCoplanarPoint(bs,o),!!n.ray.intersectPlane(v_,t)&&(i==="x"||i==="y"||i==="z")){let l=li.subVectors(t,o).dot(xt);t.copy(o).addScaledVector(xt,l)}}updateDragItem(e,t=!1){_a.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ah.subVectors(e.fromPosition,_a).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ah.subVectors(e.obj.userData.worldPosition0,_a).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ah.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(_a).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ah.length()<nW:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&oW(e,Ah.add(_a),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Bo=new M,Em=new M,$s=new M,en=new M,x_=new vr,cW=.01,dW={type:"requestRender"},uW=function(){let e=new M,t=new M;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),b_=function(){let e=new fe;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof lr&&mn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),pW=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new M,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...dg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Gr(e,e.actions,i,r,s,t)}},fW=class extends An{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Ve.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(n=>n.data.type==="Follow"&&!n.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new pW(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,Sr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition($s),e.isReset)en.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(en);else{let{getCamera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a().getWorldDirection(Em),Em.negate(),Bo.copy(Em)):i==="xy"?Bo.set(0,0,1):i==="xz"?Bo.set(0,1,0):i==="yz"&&Bo.set(1,0,0),x_.setFromNormalAndCoplanarPoint(Bo,$s),!o.ray.intersectPlane(x_,en))return}if(!e.isReset){if(en.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)en.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(en.x=$s.x),e.data.enabledTranslation[1]===!1&&(en.y=$s.y),e.data.enabledTranslation[2]===!1&&(en.z=$s.z);let n=uW($s,en,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let a=Bo.subVectors(n,$s).divideScalar(e.currentDampingFactor);$s.add(a),t&&b_(e.object,$s),e.paused=a.length()<cW}else b_(e.object,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(dW)}},Mh=new M,Xd=new M,Eh=new fe,Ro=new it,Un=new it,Ch=new M,Th=new M,Sa=new M,tn=new M,Cm=new vr,mW=1e-6,gW={type:"requestRender"},vW={type:"changeRotation"},w_=function(){let e=new fe;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(qM(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof lr&&mn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),yW=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new it,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...ug.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},xW=class extends An{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Ve.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let n=Pc(r);n&&n==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new yW(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let n=this.onTargetChange(i),a=i.target;this.pairOfEventListeners.push([a,n]),a.addEventListener("requestRender",n)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:n,enabledRotation:a,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:d,target:c}=e;if(d.getWorldPosition(Ch),!e.isReset)if(e.target)e.target.getWorldPosition(Th);else{if(s==="custom"?(l().getWorldDirection(Xd),Xd.negate(),Cm.setFromNormalAndCoplanarPoint(Xd,Ch)):(s==="xy"?Mh.set(0,0,1):s==="xz"?Mh.set(0,1,0):s==="yz"&&Mh.set(1,0,0),Cm.setFromNormalAndCoplanarPoint(Mh,Ch)),!h.ray.intersectPlane(Cm,Th))return;r>0&&(s==="custom"||s===void 0)&&Th.addScaledVector(Xd,r)}if(e.isReset||(c?t==="target"?Sa.copy(c.up).applyMatrix4(Eh.extractRotation(c.matrixWorld)).normalize():a.some(u=>u===!1)?(i==="x"?(tn.set(0,0,1),a[2]===!1&&tn.set(0,1,0)):i==="y"?(tn.set(1,0,0),a[0]===!1&&tn.set(0,0,1)):(tn.set(0,1,0),a[1]===!1&&tn.set(1,0,0)),Sa.copy(tn).applyQuaternion(e.worldQuaternion0).normalize()):Sa.set(0,1,0):s==="custom"?Sa.set(0,1,0):Sa.copy(Mh)),e.isReset)Un.copy(e.worldQuaternion0);else if(Ch.distanceTo(Th)>n&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Un.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;bW(Eh,Th,Ch,Sa,i,tn),Un.setFromRotationMatrix(Eh),Ro.setFromUnitVectors(tn.applyQuaternion(Un),Sa),a.some(u=>u===!1)&&t!=="target"&&Un.premultiply(Ro).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Ro.setFromRotationMatrix(qM(d.matrixWorld)),Ro.slerp(Un,1/e.currentDampingFactor),w_(d,Eh.makeRotationFromQuaternion(Ro)),e.paused=8*(1-Ro.dot(Un))<mW):(w_(d,Eh.makeRotationFromQuaternion(Un)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(gW),d.dispatchEvent(vW)}},Dr=new M,oi=new M,Xt=new M;function bW(e,t,i,r,s,n){let a=e.elements;Xt.subVectors(t,i),Xt.lengthSq()===0&&(Xt.z=1),Xt.normalize(),oi.crossVectors(r,Xt),oi.lengthSq()===0&&(Math.abs(r.z)===1?Xt.x+=1e-4:Xt.z+=1e-4,Xt.normalize(),oi.crossVectors(r,Xt)),oi.normalize(),Dr.crossVectors(Xt,oi),s==="x"?n.z===1?[oi,Dr,Xt]=[Xt,oi,Dr]:(oi.negate(),[oi,Xt]=[Xt,oi]):s==="y"?n.x===1?[oi,Dr,Xt]=[Dr,Xt,oi]:(oi.negate(),[Dr,Xt]=[Xt,Dr]):n.x===1&&(oi.negate(),[oi,Dr]=[Dr,oi]),a[0]=oi.x,a[4]=Dr.x,a[8]=Xt.x,a[1]=oi.y,a[5]=Dr.y,a[9]=Xt.y,a[2]=oi.z,a[6]=Dr.z,a[10]=Xt.z}var wW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Gr(t,t.actions,r,s,n,i)}disconnect(){Sr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch())}},_W=class extends An{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Ve.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Pc(s);o&&o==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(l=>l.dispatchUserEvent(a)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let o=new wW(n,a,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),br&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),br&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let n=gv(r,s,this.objects);t=vv(n)}else this.objects.forEach(n=>{tp(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},SW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Gr(t,t.actions,r,s,n,i)}connect(){this.scrollCounter=0}disconnect(){Sr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},AW=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.object=i,this.domElement=n,this.eventManager=a,this.scrollStart=0,this.scrollEnd=0,this.actions=Gr(t,t.actions,r,s,a,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,n=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?a:l==="bottom"?a-o:a-o*.5;this.scrollStart=n-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Sr(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},MW=class extends An{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([a,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=a=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(d=>d.dispatch(o))})},this.onWheel=a=>{!this.isInview||a.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:a.deltaY}),l.forEach(h=>h.dispatch(a.deltaY))})},this.onUserEvent=({eventName:a,target:o,reverse:l})=>{if(!a||!o)return;let h=Pc(a);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(d=>{d.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:n}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!n){let h=new SW(o,l,a,i,r,t);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(h):this.wheelEventsPerObject.set(a,[h])}else{let h=new AW(o,l,a,i,r,s,t);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(h):this.scrollEventsPerObject.set(a,[h])}}}),this.intersectionObserver=new IntersectionObserver(a=>{let o=a[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},EW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.actions=Gr(t,t.actions,r,s,n,i)}disconnect(){Sr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof za?t.interaction.audioPlayer.play():t.interaction instanceof dv&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof ul?t.interaction.play(i==="autoplay"):t.interaction instanceof fv&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof za?t.interaction.audioPlayer.play():t.interaction instanceof dv&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof ul?t.interaction.play():t.interaction instanceof fv&&t.interaction.dispatch()})}},CW=class extends An{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(n=>{n.interaction instanceof za&&n.interaction.audioPlayer.play()}),s.actions.Video.forEach(n=>{let a=n.interaction.data.triggerAfter??"autoplay";n.interaction instanceof ul&&n.interaction.play(a==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let n=Pc(i);n&&n==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let n=new EW(r,s,i,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(n):this.eventsPerObject.set(i,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},TW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.actions=Gr(t,t.actions,r,s,n,i),this.target=t.target,this.useToggle=t.toggle}disconnect(){Sr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},PW="https://unpkg.com/@splinetool/runtime@0.9.423/build/",DW="https://unpkg.com/@splinetool/navmesh-wasm@0.9.423/build/",IW=`
|
|
6238
|
+
)`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:n}=e;t=`spring( ${i}, ${r}, ${s}, ${n} )`}else{let i;switch(e.easing){case 0:i=kn.linear;break;case 1:i=kn.ease;break;case 2:i=kn.easeIn;break;case 3:i=kn.easeOut;break;case 4:i=kn.easeInOut;break;default:i=kn.linear}let[r,s,n,a]=i;t=`cubicBezier( ${r}, ${s}, ${n}, ${a} )`}return{duration:e.duration,easing:t}}function kM(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var E7={type:"beginState"},C7={type:"completeState",isfromEntity:!1},o_=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let a=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"beginState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Yi&&o.dispatchEvent(E7)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let a=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"completeState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Yi&&o.dispatchEvent(C7)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=n_(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let a=au(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=au(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=au(this.object,i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...kM(r),...FM(r),change:this.onChange},this.callback=n_(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Qh=class extends Ti{constructor(e,t,i){if(super(),this.data=e,this.page=t,this.sharedAssets=i,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let r=this.page.scene.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=au(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:t=!1}={}){try{let i=kM(this.data.tweens[0].data),r=i.loop;t&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=NM.timeline({autoplay:!1,...i,...r===!0||r>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(n=>n?.changeBegan);if(this.timelineNeedsRebuild=s!==-1&&(r===!0||r>1),i.pingPongDelayCorrection&&t===!1&&(this.timelineNeedsRebuild=!0),e){let n=s===-1?0:s;for(let a=n;a<this.data.tweens.length-1;a++){let o=this.data.tweens[a],l=this.data.tweens[a+1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Yi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new o_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.delay:0)+(a===n&&!t?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let n=s===-1?this.data.tweens.length-1:s+1;for(let a=n;a>0;a--){let o=this.data.tweens[a],l=this.data.tweens[a-1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Yi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new o_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[a-1]=d,this.timeline.add(d.params,this.timeline.duration+(a===n?i.endDelay:0))}this.timeline.duration+=i.delay+(t?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function au(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var T7={type:"beginState"},l_={type:"completeState",isfromEntity:!1},h_={type:"requestRender"},jM=class extends Ti{constructor(e,t){super(),this.data=e,this.page=t,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new M,this.posEnd=new M,this.qStart=new it,this.qEnd=new it,this.zoomStart=1,this.zoomEnd=1,this.toCamera=this.page.scene.find(e.targetCamera)}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=NM({targets:t,t:1,...FM(this.data),update:()=>{t.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera)):(this.posEnd.copy(this.toCamera.position),this.qEnd.copy(this.toCamera.quaternion),this.zoomEnd=this.toCamera.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)),this.page.activeCamera.dispatchEvent(T7));let i=this.page.activeCamera;i.position.lerpVectors(this.posStart,this.posEnd,t.t),i.quaternion.slerpQuaternions(this.qStart,this.qEnd,t.t),i.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*t.t,i.wasMovedBySwitchCameraAction=!0,i.updateMatrix(),i.updateMatrixWorld(),i.updateProjectionMatrix(),i.dispatchEvent(h_),t.t===1&&i.dispatchEvent(l_)}})}switchCamera(e){this.page.switchActiveCamera(e),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:e})}play(){this.playing||this.page.activeCamera!==this.toCamera&&(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId;try{this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.toCamera)}catch(e){e instanceof Error&&console.error(e.message)}},this.data.delay*1e3))}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.toCamera)):this.switchCamera(this.fromCamera),this.page.activeCamera.dispatchEvent(l_),this.page.activeCamera.dispatchEvent(h_))},this.data.delay*1e3)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},Zh=class extends Ti{constructor(e,t,i){super(),this.page=t,this.animationControls=i,this.startOnceDelay=0,this.toggleIsForward=!1;let r=e.object,s=t.scene.find(e.object);s&&Array.isArray(s.identity)&&(r=s.identity[0]),this.data={...e,object:r};let n=this.animationControls.clipIdToAction[e.clipId+"/"+r];this.duration=n?.getClip()?.duration??1;let a=n?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/a*this.duration,this.rightFrameTime=this.data.crop[1]/a*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=nt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let n=r.split("/")[1];this.threeAnimAction!==s&&n===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},GM=class{constructor(e,t,i,r){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.timeOutId=-1,this.scene=t.scene}dispatch(){this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),K0(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function Gr(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?us[e.type].includes("Audio")&&a.Audio.push(new Xh(o,l,n,r)):l.type==="Video"?us[e.type].includes("Video")&&a.Video.push(new J0(o,l,n)):l.type==="Link"?us[e.type].includes("Link")&&a.Link.push(new b9(l,s)):l.type==="Create"?us[e.type].includes("Create")&&a.Create.push(new Jh(l,i,s.controlsManager)):l.type==="Destroy"?us[e.type].includes("Destroy")&&a.Destroy.push(new bM(l,i,s)):l.type==="Reset"?us[e.type].includes("Reset")&&a.Reset.push(new w9(i,r,s)):l.type==="Transition"?us[e.type].includes("Transition")&&a.Transition.push(new Qh(l,i,r)):l.type==="SwitchCamera"?us[e.type].includes("SwitchCamera")&&a.SwitchCamera.push(new jM(l,i)):l.type==="SceneTransition"?us[e.type].includes("SceneTransition")&&a.SceneTransition.push(new GM(l,i,s,r)):l.type==="Animation"&&us[e.type].includes("Animation")&&a.Animation.push(new Zh(l,i,s.animationControls))}catch{}}),a}function Sr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof Xh||i instanceof J0||i instanceof Zh||i instanceof Qh||i instanceof Jh||i instanceof bM||i instanceof jM||i instanceof GM)&&i.dispose()})})}function P7(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var VM=new Map,Kh=new Map,ul=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=P7(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n)),a!==void 0&&(this.delay=a),Kh.has(i.uuid)?Kh.get(i.uuid).push(this):Kh.set(i.uuid,[this]),VM.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},fv=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=VM.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Kh.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Kh.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},J0=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new ul(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new fv(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof ul?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof ul?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},c_=(()=>{let e,t,i,r;function s(o){!e&&!d_()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(n)),o&&(t=o,r=o.requestRender)}function n(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,d=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,u=0;for(;u<c;){let p=h[u];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&d[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),u++):(d[p.userData.actionId]>p.userData.quantity&&d[p.userData.actionId]--,h.splice(u,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=u>0?requestAnimationFrame(n):void 0,i=u>0?o:void 0}function a(){d_()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",a),s})();function d_(){return!!document&&document.hidden}var u_=new it,D7=new M,I7=new M,Jh=class{constructor(e,t,i){this.data=e,this.page=t,this.controlsManager=i,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=nt.generateUUID(),this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=fF(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let s=new Ri(this.object);if(s.playModeVisible=!0,s.expand(),this.data.coordinateSystem!=="world"){let a=this.data.coordinateSystem,o=this.page.scene.find(a);o&&(o.updateMatrixWorldSVD(),s.hiddenMatrix.copy(o.matrixWorldRigid))}s.position.fromArray(this.data.position),s.rotation.fromArray(this.data.rotation),s.updateMatrix(),this.page.add(s);let n=this.controlsManager.sharedGameControlGlobals;n.createdObjects.push(s),n.nCreatedPerAction[this.uniqueId]===void 0?n.nCreatedPerAction[this.uniqueId]=1:n.nCreatedPerAction[this.uniqueId]++,s.updateWorldMatrix(!0,!0),s.traverseObject(this.traverseObjectCB),c_(),this.controlsManager.requestRender()},this.traverseObjectCB=s=>{s.hasNonUniformScale&&s.updateMatrixWorldSVD();let n;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(s instanceof is)if(s.objectForSample){if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(s instanceof Ri)n=s.object;else if(n=s,n.dataPatched.cloner?.hideBase)return!0}else{if(s instanceof is)return;s instanceof Ri?n=s.object:n=s}this.data.destroy==="Time"?s.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(s.userData.quantity=this.data.destroyAfterQuantity,s.userData.actionId=this.uniqueId);let a=new M().fromArray(this.data.velocity),o=n.dataPatched;if(!(o.physics.enabled==="visibility"?!o.visible:!o.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(s,n,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(s.rigidBody?.collider(0).setActiveEvents(1),s.userData.hasCollisionDestroy=!0),s.matrixWorld.decompose(D7,u_,I7),a.applyQuaternion(u_),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&s.rigidBody?.setLinvel(a.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in s.object&&this.controlsManager.addBoundsTree(s),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&(s.userData.velocity=a)),n.dataPatched.physics?.fusedBody===!0))return!0};let r=this.page.scene.find(this.data.object);if(!r)throw new Error("Missing Property");if(this.object=r,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");c_(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},HM=200,ym=.02,xm=.3,L7=65,cX=new M,p_=new M,f_=new M,O7=new M,Mi=new M,ji=new M,zn=new M,qd=new fe,bm=new fe,B7=new fe,dX=new fe,mr=new it,Js=new it,ys=new yi(0,0,0,"YXZ"),R7=new M(1,0,0),Zr=new M(0,1,0),z7=new M(0,0,1),wm=new M(1,1,1),_m=new _r,N7=1,U7=.025,F7=16e-6,m_=12,k7=20,gi=new Ur,Pr=new Kt,j7={type:"requestRender"},G7={type:"updateMatrix"},g_=Math.PI/6,mv=class extends Ti{constructor(e,t,i,r,s,n,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new fe,this.target0=new M,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=HM,this.euler0=new yi(0,0,0,"YXZ"),this.position0Cam=new M,this.quat0Cam=new it,this.scale0Cam=new M,this.hiddenMatrix0Cam=new fe,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Ur(new M(0,-40,0),new M(0,40,0)),matrix:new fe,position:new M,rotation:new it},this.euler=new yi(0,0,0,"YXZ"),this.eulerDelta=new M,this.lastPosition=new M,this.lastCameraQuaternion=new it,this.lastCameraPosition=new M,this.PI_2=Math.PI/2,this.prevMouse=new F,this.velocityTarget=new M,this.velocity=new M,this.directionXZ=new M,this.rotVelocityStick=new M,this.rotVelocityTarget=new M,this.rotVelocity=new M,this.rotDirection=new M,this.nonColliderRotOffset=new fe,this.nonColliderPosOffset=new fe,this.firstPointerId=-1,this.rot=new M,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new fe,this.objectToTarget=new M,this.objectToTarget0=new M,this.objectToCamXZ=new M,this.objectToCamXZ0=new M,this.targetToCamera=new M,this.targetToCamera0=new M,this.cameraPolarAxis0=new M,this.targetPos=new M,this.targetQuat=new it,this.lerpFactorPos=new M().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new it,this.objXZQuatInv=new it,this.objXZRotMat=new fe,this.isFirstPerson=!1,this.actions={},this.didHit=!1,this.groundVelocity=new M,this.pushedVelocity=new M,this.groundYRotation=0,this.objectRealQuat=new it,this.colliderWorldQuat=new it,this.groundNormal=new M,this.groundTilt=new it,this.groundTiltInv=new it,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new M,this.quaternion=new it,this.scale=new M,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!br&&(!Bx||Rx>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(Bx&&Rx<15.5&&!br?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?mv.isLocked=!0:mv.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let v=f.axes[m];g===0?m===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),d=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,d,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new M(0,0,-1).applyQuaternion(this.camera.quaternion),g=new M().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let m,v;Math.abs(f.y)<1e-6?(g.y=0,f.y=0,v=g.projectOnVector(f)):g.y/f.y>0?v=f.multiplyScalar(g.y/f.y):v=f.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate(),m=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(m,this.position);let y=new yi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Yi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*N7,this.speedOrbit=(i.speedRotate??100)*U7,this.mouseOrbitSensitivity=(i.speedRotate??100)*F7,this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Sl.defaultData.gravity)*m_,this.usePhysics=this.gloabalPhysics.usePhysics??Sl.defaultData.usePhysics,this.jumpPower=i.jumpPower*k7,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Vu.defaultDataThirdPerson.orientWith,this.slopeThresh=L7*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*ym/this.pixelsPerMeter,this.stepThresh=i.collider.height*xm/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*ym/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*xm/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*ym/this.pixelsPerMeter,this.stepThresh=i.collider.height*xm/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new M().fromArray(i.collider.position),u=new it().setFromEuler(new yi().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(u),this.collider.matrix.compose(c,u,wm),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new et;f.push({fi:0,data:{...Ji.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Ji.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=new P0({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new ir(YA.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new yi().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Yi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.page,i=this.sharedAssets,r=this.object;e.gameActions!==void 0&&Object.entries(e.gameActions).forEach(([s,n],a)=>{n.forEach(({id:o,data:l})=>{try{this.actions[s]===void 0&&(this.actions[s]=[]),l.type==="Transition"?this.actions[s].push(new Qh(l,t,i)):l.type==="Animation"?this.actions[s].push(new Zh(l,t,this.controlsManager.eventManager.animationControls)):l.type==="Audio"?this.actions[s].push(new Xh(o,l,r,i)):l.type==="Video"?this.actions[s].push(new J0(o,l,r)):l.type==="Create"&&this.actions[s].push(new Jh(l,t,this.controlsManager))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Sr(this.actions)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].forEach(t=>{t instanceof Qh?t.play():t instanceof Zh?t.play(this.initialAction===!1):t instanceof Jh?t.dispatchStart():t instanceof Xh&&t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].forEach(t=>{t instanceof Qh?(t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})):t instanceof Zh||(t instanceof Jh?t.dispatchStop():t instanceof Xh&&t.dispatchGameControl("stop"))})))}get colliderWorldPosition(){return Mi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,n=!1;if(this.usePhysics&&this.collisionEnabled){let o=ji.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*m_),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(n=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(Mi,Js,ji),this.groundVelocity.subVectors(Mi,d.prevT),this.object.getWorldPosition(ji).add(this.collider.position).sub(Mi),this.groundYRotation=ys.setFromQuaternion(Js).y-d.prevR.y,zn.copy(ji).applyAxisAngle(Zr,this.groundYRotation),this.groundVelocity.add(zn.sub(ji)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Mi.subVectors(this.path[1],this.position),h=ji.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=O7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=ji.copy(a);o.y=0,a.set(0,a.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=Mi;this.camera.getWorldDirection(o);let l=zn.copy(Zr).multiplyScalar(o.dot(Zr));o.sub(l);let h=ji.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(ys.setFromVector3(this.rot),this.moveMode==="walk"&&(ys.x=0),a.applyEuler(ys),n&&(Js.setFromUnitVectors(Zr,this.groundNormal),a.applyQuaternion(Js)),i){let o=ys.set(0,this.vrEulerYOffset*g_,0);i.applyEuler(o),a.x+=i.x,a.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=ji;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=zn.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),d=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Mi.copy(a).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=ut.is(l)?l:l.object;if(d!==null&&this.lastHitObj!==c){let u;l instanceof Ri&&(u=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(u),c.dispatchEvent(yv));this.lastHitObj=c}if(d!==null){this.pushedVelocity.copy(h),o.copy(d.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(a);l<0&&a.addScaledVector(o,-l),a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Zr,this.euler.y-this.euler0.y);let o=ji.copy(this.objectToCamXZ).normalize(),l=zn.copy(a).multiplyScalar(r);l.y=0;let h=l.sub(Mi.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=nt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=nt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=nt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(ys.copy(t),ys.y=0):(ys.copy(this.euler),ys.y=0),this.nonColliderRotOffset.makeRotationFromEuler(ys)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*g_),mr.setFromAxisAngle(R7,this.rot.x),Js.setFromAxisAngle(Zr,this.rot.y),Js.multiply(mr),mr.setFromAxisAngle(z7,this.rot.z),Js.multiply(mr),this.quaternion.copy(Js),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=ji.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new M;for(let d=0;d<5;d++){let c=o.length(),u=zn.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&d===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let _ of p.cloner.children)if(_.rigidBody===x){b=_;break}}y.dispatch(b),p.dispatchEvent(yv)}}}let f=p_.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=f_.copy(u).multiplyScalar(l.toi).dot(f),m=l.toi;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=l.toi*(g-this.offset)/g,h.addScaledVector(u,m)),o.copy(u).multiplyScalar(c-m),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=zn.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Mi.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(mr.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=a.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),h===0&&this.checkTrigger(),this.collisionAdjustment(r/o)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);qd.lookAt(l,o,Zr).setPosition(l),qd.decompose(this.targetPos,this.targetQuat,Mi),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=nt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=nt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(G7),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&this.navMeshPathDest?.material?.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(j7),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=mr.setFromAxisAngle(Zr,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?nt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=nt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=nt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mi.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Js.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Zr.angleTo(e)*180/Math.PI<15||Zr.angleTo(e)*180/Math.PI>85?mr.identity():mr.setFromUnitVectors(Zr,e),this.groundTilt.slerp(mr,.06),this.groundTiltInv.copy(this.groundTilt).invert()}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(ut.is(o)?o:o.object)===!1)continue;let l=bm.copy(s.matrixWorld).decompose(Mi,mr,ji).compose(Mi,mr,wm).multiply(r),h=qd.copy(o.matrixWorld).invert().multiply(l);i instanceof Kt?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(_m.radius=i,_m.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(_m)),e?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(QW)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}collisionAdjustment(e){let t=f_.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=qd.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mi,mr,ji).compose(Mi,mr,wm);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;Pr.makeEmpty(),s.updateMatrixWorldSVD();let n=s.matrixWorldRigid,a=bm.copy(n).invert(),o=B7.copy(bm).multiply(i);gi.copy(this.collider.segment),gi.start.applyMatrix4(o),gi.end.applyMatrix4(o);let l=p_.copy(this.position).applyMatrix4(a);Pr.expandByPoint(gi.start),Pr.expandByPoint(gi.end),Pr.min.addScalar(-this.collider.radius),Pr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(gi.end)},intersectsBounds:h=>h.intersectsBox(Pr),intersectsTriangle:h=>{let d=Mi,c=ji,u=h.closestPointToSegment(gi,d,c);if(u<this.collider.radius){let p=this.collider.radius-u,f=c.sub(d).normalize(),g=zn.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(n).sub(this.position);t.add(m),gi.start.addScaledVector(f,p),gi.end.addScaledVector(f,p)}}})}),Pr.makeEmpty(),gi.copy(this.collider.segment),gi.start.applyMatrix4(i),gi.end.applyMatrix4(i),Pr.expandByPoint(gi.start),Pr.expandByPoint(gi.end),Pr.min.addScalar(-this.collider.radius),Pr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(gi.end)},intersectsBounds:s=>s.intersectsBox(Pr),intersectsTriangle:s=>{let n=Mi,a=ji,o=s.closestPointToSegment(gi,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),gi.start.addScaledVector(h,l),gi.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},WM=mv;WM.isLocked=!1;var V7=Pl(O_());function dn(e,t){let i=new qe;if(!e.getAttribute("position"))return i.setAttribute("position",new Le([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=_p(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Le(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var H7=new fe,W7=new fe,xs=[[0,0,0],[0,0,0],[0,0,0]];function qM(e){let t=e.elements;xs[0][0]=t[0],xs[0][1]=t[4],xs[0][2]=t[8],xs[1][0]=t[1],xs[1][1]=t[5],xs[1][2]=t[9],xs[2][0]=t[2],xs[2][1]=t[6],xs[2][2]=t[10];let{u:i,v:r}=(0,V7.SVD)(xs),s=H7.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),n=W7.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(n.transpose())}var q7=class extends SS{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new oa({color:65280,linewidth:10}),t=new M(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new M(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new M().addVectors(t,i.multiplyScalar(r)),n=new qe;return n.setFromPoints([t,s]),new fu(n,e)}},XM=e=>e instanceof Ku||e instanceof dl;function X7(e,t){return e.distance-t.distance}function YM(e,t,i){if(!(!cn(t)||!t.visible)){Jr(t)&&t.raycast(e,i);for(let r of t.children)YM(e,r,i)}}function gv(e,t,i){if(!i.some(s=>tp(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>YM(e,s,r)),r.sort(X7),r}function vv(e){let t=[];if(e.length){let i=e[0].object;cn(i)&&t.push(i);let r=i.parent;for(;r;)XM(r)&&t.push(r),r=r.parent}return t}function tp(e,t){if(Jr(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(XM(t))return QM(e,t)}function QM(e,t){if(!(!cn(t)||!t.visible)){if(Jr(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=QM(e,i);if(r)return r}}}function Y7(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}var Q7=class{constructor(e,t,i,r,s,n,a){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=n,this.isExport=a,this.raycaster=new q7,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(Y7(t,i,r),this.getCamera())}},ZM=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e[e.scroll=6]="scroll",e))(ZM||{}),An=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},$0=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],KM=e=>$0.find(([t,i])=>i===e)?.[0],Pc=e=>$0.find(([t])=>t===e)?.[1],Z7=(e,t)=>{let i=KM(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},K7=class extends An{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[KM(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of $0)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=Z7(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},J7=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Gr(t,t.actions,r,s,n,i)}disconnect(){Sr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.useToggle===!1&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},$7=class extends An{constructor(e,t){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.windowMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.onWindowMouseDown=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})},this.onWindowMouseUp=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseDown"))},this.onMouseUp=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent())},this.onMousePressRelease=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent(!0))},this.onKeyDown=s=>{this.heldKeys[s.key]||(this.handleKeyEvent(s,"KeyDown"),this.handleKeyEventHeld(s,"KeyDown",!0)),this.heldKeys[s.key]=!0},this.onKeyUp=s=>{this.handleKeyEvent(s,"KeyUp"),this.handleKeyEventHeld(s,"KeyUp",!0)},this.onKeyPressDown=s=>{this.heldKeysPress[s.key]?this.handleKeyEventHeld(s,"KeyPress"):(this.handleKeyEvent(s,"KeyPress"),this.handleKeyEventHeld(s,"KeyPress",!0)),this.heldKeysPress[s.key]=!0},this.onKeyPressUp=s=>{this.handleKeyEvent(s,"KeyPress",!0)},this.releaseHeldKey=s=>{delete this.heldKeys[s.key]},this.releaseHeldKeyPress=s=>{delete this.heldKeysPress[s.key]},this._onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Pc(s);o&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent(a)})):(o==="KeyDown"||o==="KeyUp"||o==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent()})))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let a of n){let o=this.eventsPerObjects[a];s.data.events.filter(({data:l})=>l.type===a&&l.disabled!==!0).forEach(({id:l,data:h})=>{try{let d=new J7(l,h,s,i,r,t);d.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.mode==="Window")?h.mode==="Canvas"&&this.canvasMouseEvents.push(d):o[s.uuid]?o[s.uuid].push(d):o[s.uuid]=[d]}catch{}}),o[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=gv(i,r,s);vv(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{tp(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:a}=this.eventContext;if(s){let o=gv(n,a,i);r=vv(o)}else i.forEach(o=>{tp(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},eW=new M,tW=new M,JM=class{constructor(e,t,i,r,s){this.actionsIn=Gr(e,e.inActions,i,r,s,t),this.actionsOut=Gr(e,e.outActions,i,r,s,t)}disconnect(){Sr(this.actionsIn),Sr(this.actionsOut)}},iW=class extends JM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{for(let u of this.objects)if(!u.visible)return;let h=eW.setFromMatrixPosition(this.objects[0].matrixWorld),d=tW.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(d)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let u=c==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Link.forEach(p=>p.dispatch()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.Animation.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),u.SceneTransition.forEach(p=>p.dispatch())}};let{distance:a,fromObject:o,toObject:l}=t.condition;this.distance=a;for(let h of[o,l]){if(!h)throw new Error("Missing property");let d=r.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},rW=class extends JM{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(d=>d.dispatchConditional()),this.actionsOut.Video.forEach(d=>d.dispatchConditional()),this.actionsOut.Link.forEach(d=>d.dispatch()),this.actionsOut.Create.forEach(d=>d.dispatch()),this.actionsOut.Destroy.forEach(d=>d.dispatch()),this.actionsOut.Reset.forEach(d=>d.dispatch()),this.actionsIn.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(d=>d.play()),this.actionsOut.Animation.forEach(d=>d.play()),this.actionsIn.SwitchCamera.forEach(d=>d.pause()),this.actionsOut.SwitchCamera.forEach(d=>d.play()),this.actionsOut.SceneTransition.forEach(d=>d.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(d=>d.dispatchConditional()),this.actionsIn.Video.forEach(d=>d.dispatchConditional()),this.actionsIn.Link.forEach(d=>d.dispatch()),this.actionsIn.Create.forEach(d=>d.dispatch()),this.actionsIn.Destroy.forEach(d=>d.dispatch()),this.actionsIn.Reset.forEach(d=>d.dispatch()),this.actionsOut.Transition.forEach(d=>d.pause()),this.actionsOut.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(d=>d.play()),this.actionsIn.Animation.forEach(d=>d.play()),this.actionsOut.SwitchCamera.forEach(d=>d.pause()),this.actionsIn.SwitchCamera.forEach(d=>d.play()),this.actionsIn.SceneTransition.forEach(d=>d.dispatch()))};let{condition:a}=t;if(!a.object)throw new Error("Missing property");let o=r.find(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},sW=class extends An{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let o;a.condition.type==="Comparison"||(a.condition.type==="Distance"?o=new iW(n,a,s,i,r,t):a.condition.type==="State"&&(o=new rW(n,a,s,i,r,t))),o&&(this.eventsPerConditions[a.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ah=new M,Nn=new M,_a=new M,v_=new vr,nW=.01,xt=new M,li=new M,y_=new M,Na=new it,Sm=new yi,aW=new fe,Am=new bi,Lo=new M,bs=new M,Oo=.2;function Mm(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var oW=function(){let e=new fe;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&Mm(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?Mm(s.position,t.limits):t.reference==="local"&&(Na.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Na),Mm(s.position,t.limits),Na.invert(),s.position.applyQuaternion(Na),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(xt,s.quaternion,li),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof lr&&mn(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),lW=class{constructor(e,t,i,r,s,n){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Gr(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=Gr(t,t.dragDropActions.drop,i,r,s,this.object);let a=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(a.push(l),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&a.push(d)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),n[l.uuid]&&n[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=a.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new M().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new M().setFromMatrixPosition(o.matrixWorld),pointStart:new M,pointEnd:new M,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new M().copy(o.position),quat0:new it().copy(o.quaternion),snapped:!1,orientationMatrix:new fe,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Sr(this.actionsDrag),Sr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},hW=class extends An{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:d,pointStart:c}of o.dragItems){if(h===a[0].object||h===a[0].object.object||ut.is(h)&&h.isAncestorOf(a[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(xt,Na,li),Sm.setFromQuaternion(Na),u.prevR===void 0?(u.prevR=Sm.clone(),u.prevT=xt.clone()):(u.prevR.copy(Sm),u.prevT.copy(xt)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),d.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(Ve.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===a[0]?.object||h===a[0]?.object?.object||ut.is(h)&&h.isAncestorOf(a[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=a.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Ku)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(d=>d===h.object.uuid||n.scene.find(d).isAncestorOf(h.object.uuid))))[0]),l){let h=y_.copy(l.face.normal).applyMatrix3(Am.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){xt.copy(h).applyMatrix3(Am.setFromMatrix4(o.obj.matrixWorld).transpose());let d=o.obj;xt.x>Oo?li.x=-d.recursiveBBox.min.x:xt.x<-Oo&&(li.x=-d.recursiveBBox.max.x),xt.y>Oo?li.y=-d.recursiveBBox.min.y:xt.y<-Oo&&(li.y=-d.recursiveBBox.max.y),xt.z>Oo?li.z=-d.recursiveBBox.min.z:xt.z<-Oo&&(li.z=-d.recursiveBBox.max.z),li.applyMatrix3(Am.invert())}else li.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(li)}this.activeEvent.data.autoOrient&&(xt.set(0,1,0).cross(h),xt.length()<1e-4&&xt.set(-1,0,0).cross(h),li.crossVectors(y_,xt),o.orientationMatrix.makeBasis(xt,li,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Animation.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Audio.forEach(d=>{d.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(d=>{d.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")})),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new lW(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:n}=this.eventContext;s().getWorldDirection(Nn),Nn.negate();let a=Na.identity();switch(r==="parent"?aW.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(xt,a,li):r==="local"&&e.matrixWorld.decompose(xt,a,li),i){case"x":xt.set(1,0,0).applyQuaternion(a),Lo.copy(Nn).cross(xt),bs.copy(xt).cross(Lo);break;case"y":xt.set(0,1,0).applyQuaternion(a),Lo.copy(Nn).cross(xt),bs.copy(xt).cross(Lo);break;case"z":xt.set(0,0,1).applyQuaternion(a),Lo.copy(Nn).cross(xt),bs.copy(xt).cross(Lo);break;case"xy":bs.set(0,0,1).applyQuaternion(a);break;case"yz":bs.set(1,0,0).applyQuaternion(a);break;case"xz":bs.set(0,1,0).applyQuaternion(a);break;case"adaptive":Nn.angleTo(li.set(0,1,0))>Math.PI/6?(xt.crossVectors(li.set(0,1,0),Nn),bs.crossVectors(xt,li)):bs.set(0,1,0);break;default:bs.copy(Nn);break}_a.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:_a;if(v_.setFromNormalAndCoplanarPoint(bs,o),!!n.ray.intersectPlane(v_,t)&&(i==="x"||i==="y"||i==="z")){let l=li.subVectors(t,o).dot(xt);t.copy(o).addScaledVector(xt,l)}}updateDragItem(e,t=!1){_a.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ah.subVectors(e.fromPosition,_a).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ah.subVectors(e.obj.userData.worldPosition0,_a).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ah.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(_a).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ah.length()<nW:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&oW(e,Ah.add(_a),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Bo=new M,Em=new M,$s=new M,en=new M,x_=new vr,cW=.01,dW={type:"requestRender"},uW=function(){let e=new M,t=new M;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),b_=function(){let e=new fe;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof lr&&mn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),pW=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new M,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...dg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Gr(e,e.actions,i,r,s,t)}},fW=class extends An{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Ve.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(n=>n.data.type==="Follow"&&!n.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new pW(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,Sr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition($s),e.isReset)en.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(en);else{let{getCamera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a().getWorldDirection(Em),Em.negate(),Bo.copy(Em)):i==="xy"?Bo.set(0,0,1):i==="xz"?Bo.set(0,1,0):i==="yz"&&Bo.set(1,0,0),x_.setFromNormalAndCoplanarPoint(Bo,$s),!o.ray.intersectPlane(x_,en))return}if(!e.isReset){if(en.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)en.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(en.x=$s.x),e.data.enabledTranslation[1]===!1&&(en.y=$s.y),e.data.enabledTranslation[2]===!1&&(en.z=$s.z);let n=uW($s,en,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let a=Bo.subVectors(n,$s).divideScalar(e.currentDampingFactor);$s.add(a),t&&b_(e.object,$s),e.paused=a.length()<cW}else b_(e.object,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(dW)}},Mh=new M,Xd=new M,Eh=new fe,Ro=new it,Un=new it,Ch=new M,Th=new M,Sa=new M,tn=new M,Cm=new vr,mW=1e-6,gW={type:"requestRender"},vW={type:"changeRotation"},w_=function(){let e=new fe;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(qM(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof lr&&mn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),yW=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new it,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...ug.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},xW=class extends An{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Ve.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let n=Pc(r);n&&n==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new yW(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let n=this.onTargetChange(i),a=i.target;this.pairOfEventListeners.push([a,n]),a.addEventListener("requestRender",n)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),br&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:n,enabledRotation:a,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:d,target:c}=e;if(d.getWorldPosition(Ch),!e.isReset)if(e.target)e.target.getWorldPosition(Th);else{if(s==="custom"?(l().getWorldDirection(Xd),Xd.negate(),Cm.setFromNormalAndCoplanarPoint(Xd,Ch)):(s==="xy"?Mh.set(0,0,1):s==="xz"?Mh.set(0,1,0):s==="yz"&&Mh.set(1,0,0),Cm.setFromNormalAndCoplanarPoint(Mh,Ch)),!h.ray.intersectPlane(Cm,Th))return;r>0&&(s==="custom"||s===void 0)&&Th.addScaledVector(Xd,r)}if(e.isReset||(c?t==="target"?Sa.copy(c.up).applyMatrix4(Eh.extractRotation(c.matrixWorld)).normalize():a.some(u=>u===!1)?(i==="x"?(tn.set(0,0,1),a[2]===!1&&tn.set(0,1,0)):i==="y"?(tn.set(1,0,0),a[0]===!1&&tn.set(0,0,1)):(tn.set(0,1,0),a[1]===!1&&tn.set(1,0,0)),Sa.copy(tn).applyQuaternion(e.worldQuaternion0).normalize()):Sa.set(0,1,0):s==="custom"?Sa.set(0,1,0):Sa.copy(Mh)),e.isReset)Un.copy(e.worldQuaternion0);else if(Ch.distanceTo(Th)>n&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Un.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;bW(Eh,Th,Ch,Sa,i,tn),Un.setFromRotationMatrix(Eh),Ro.setFromUnitVectors(tn.applyQuaternion(Un),Sa),a.some(u=>u===!1)&&t!=="target"&&Un.premultiply(Ro).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Ro.setFromRotationMatrix(qM(d.matrixWorld)),Ro.slerp(Un,1/e.currentDampingFactor),w_(d,Eh.makeRotationFromQuaternion(Ro)),e.paused=8*(1-Ro.dot(Un))<mW):(w_(d,Eh.makeRotationFromQuaternion(Un)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(gW),d.dispatchEvent(vW)}},Dr=new M,oi=new M,Xt=new M;function bW(e,t,i,r,s,n){let a=e.elements;Xt.subVectors(t,i),Xt.lengthSq()===0&&(Xt.z=1),Xt.normalize(),oi.crossVectors(r,Xt),oi.lengthSq()===0&&(Math.abs(r.z)===1?Xt.x+=1e-4:Xt.z+=1e-4,Xt.normalize(),oi.crossVectors(r,Xt)),oi.normalize(),Dr.crossVectors(Xt,oi),s==="x"?n.z===1?[oi,Dr,Xt]=[Xt,oi,Dr]:(oi.negate(),[oi,Xt]=[Xt,oi]):s==="y"?n.x===1?[oi,Dr,Xt]=[Dr,Xt,oi]:(oi.negate(),[Dr,Xt]=[Xt,Dr]):n.x===1&&(oi.negate(),[oi,Dr]=[Dr,oi]),a[0]=oi.x,a[4]=Dr.x,a[8]=Xt.x,a[1]=oi.y,a[5]=Dr.y,a[9]=Xt.y,a[2]=oi.z,a[6]=Dr.z,a[10]=Xt.z}var wW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Gr(t,t.actions,r,s,n,i)}disconnect(){Sr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch())}},_W=class extends An{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Ve.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Pc(s);o&&o==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(l=>l.dispatchUserEvent(a)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let o=new wW(n,a,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),br&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),br&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let n=gv(r,s,this.objects);t=vv(n)}else this.objects.forEach(n=>{tp(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},SW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Gr(t,t.actions,r,s,n,i)}connect(){this.scrollCounter=0}disconnect(){Sr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},AW=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.object=i,this.domElement=n,this.eventManager=a,this.scrollStart=0,this.scrollEnd=0,this.actions=Gr(t,t.actions,r,s,a,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,n=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?a:l==="bottom"?a-o:a-o*.5;this.scrollStart=n-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Sr(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},MW=class extends An{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([a,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=a=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(d=>d.dispatch(o))})},this.onWheel=a=>{!this.isInview||a.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:a.deltaY}),l.forEach(h=>h.dispatch(a.deltaY))})},this.onUserEvent=({eventName:a,target:o,reverse:l})=>{if(!a||!o)return;let h=Pc(a);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(d=>{d.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:n}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!n){let h=new SW(o,l,a,i,r,t);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(h):this.wheelEventsPerObject.set(a,[h])}else{let h=new AW(o,l,a,i,r,s,t);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(h):this.scrollEventsPerObject.set(a,[h])}}}),this.intersectionObserver=new IntersectionObserver(a=>{let o=a[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},EW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.actions=Gr(t,t.actions,r,s,n,i)}disconnect(){Sr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof za?t.interaction.audioPlayer.play():t.interaction instanceof dv&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof ul?t.interaction.play(i==="autoplay"):t.interaction instanceof fv&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof za?t.interaction.audioPlayer.play():t.interaction instanceof dv&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof ul?t.interaction.play():t.interaction instanceof fv&&t.interaction.dispatch()})}},CW=class extends An{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(n=>{n.interaction instanceof za&&n.interaction.audioPlayer.play()}),s.actions.Video.forEach(n=>{let a=n.interaction.data.triggerAfter??"autoplay";n.interaction instanceof ul&&n.interaction.play(a==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let n=Pc(i);n&&n==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let n=new EW(r,s,i,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(n):this.eventsPerObject.set(i,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},TW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.actions=Gr(t,t.actions,r,s,n,i),this.target=t.target,this.useToggle=t.toggle}disconnect(){Sr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},PW="https://unpkg.com/@splinetool/runtime@0.9.424/build/",DW="https://unpkg.com/@splinetool/navmesh-wasm@0.9.424/build/",IW=`
|
|
6239
6239
|
(async function() {
|
|
6240
6240
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
6241
6241
|
import('${PW}' + 'navmesh.js'),
|
|
@@ -6301,7 +6301,7 @@ onmessage = function(messageEvent) {
|
|
|
6301
6301
|
<path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6302
6302
|
</svg>
|
|
6303
6303
|
`),E.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),E.addEventListener("touchend",T=>T.preventDefault()),this.joysticks[f]=[void 0,g];return}let S={zone:g,mode:"static",position:b,size:m};y==="hide"&&(S.restOpacity=0);let w=m9.create(S);w.on("move",(E,C)=>{let T=this.gameControl;p==="pos"?C.force<.2?T.moveForce=0:(T.movementState.movePosZ=Math.sin(-C.angle.radian),T.movementState.movePosX=Math.cos(-C.angle.radian),C.force>1.2?T.movementState.run=1:T.movementState.run=0,C.force<.3?T.moveForce=(C.force-.2)/.1:T.moveForce=1):p==="rot"&&(C.force<.2?T.rotForce=0:(T.movementState.rotPosX=C.vector.y,T.movementState.rotPosY=-C.vector.x,C.force<.3?T.rotForce=(C.force-.2)/.1:T.rotForce=1)),this.requestRender()}),w.on("end",(E,C)=>{let T=this.gameControl;p==="pos"?(T.movementState.movePosZ=0,T.movementState.movePosX=0,T.moveForce=1):p==="rot"&&(T.movementState.rotPosX=0,T.movementState.rotPosY=0,T.rotForce=1)}),this.joysticks[f]=[w,g]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(p=>p.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new ct.World(new ct.Vector3(0,this.gravity,0)),this.events=new ct.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(a=>{let o;if(a instanceof is)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof Ri)o=a.object;else if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0;let l=o.dataPatched,h;for(let m of l.events)m.data.disabled!==!0&&m.data.type==="GameControl"&&(h=m.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;a.updateMatrixWorldSVD();let d=ip(l),c=!1,u=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let m of l.events)if(m.data.disabled!==!0){if(m.data.type==="Collision"){c=!0;let v=new TW(m.id,m.data,o,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==m.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(m.data.type==="Follow"){f=!0;let v=m.data.target;a.traverseVisible(y=>{y.userData.isFollowingObj=v})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(h!==void 0){let m=ct.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(ti,Kr,Fn),a.position0=ti.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Kr.clone(),ti.divideScalar(this.pixelsPerMeter),m.setTranslation(ti.x,ti.y,ti.z).setRotation(Kr);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(m);a.rigidBody=v;let y;h.collider.type==="sphere"?y=ct.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?y=ct.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):y=ct.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setRestitutionCombineRule(ct.CoefficientCombineRule.Average).setDensity(l.physics.density).setFriction(l.physics.friction).setRestitution(l.physics.restitution);let x=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(x.handle,o),ti.fromArray(h.collider.position).multiply(Fn.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),x.setTranslationWrtParent(ti);let b=new it().setFromEuler(new yi().setFromVector3(new M().fromArray(h.collider.rotation)));x.setRotationWrtParent(b),x.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||d||f||u||p||c?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:d,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(g&&e.push(dn(g,a.matrixWorld)),l.physics.fusedBody&&a.traverseObject((m,v)=>{if(v===0)return;let y;if(m instanceof is)if(m.objectForSample){if(m.objectForSample.dataPatched.physics.fusedBody)return;y=m.object}else return m.object.dataPatched.physics.fusedBody===!0&&m.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(m instanceof Ri)y=m.object;else if(y=m,y.dataPatched.cloner?.hideBase)return!0;let x=y.dataPatched;if(x.physics.enabled==="visibility"?!x.visible:!x.physics.enabled)return!0;let b=m.geometry;b?.getAttribute("position")!==void 0&&e.push(dn(b,m.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=Ba(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=ct.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),n=ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ct.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ct.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(n,s);for(let[a,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?(this.gameControl===null||this.needsCollisionDetection)&&this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new C_(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new fe().compose(rn.fromArray(t.data.position),Uo.setFromEuler(T_.fromArray(t.data.rotation)),D_);if(t.data.triggerZone==="box"){let s=new Kt;s.min.fromArray(t.data.size).multiplyScalar(-.5),s.max.fromArray(t.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}update(e,t,i){let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics){for(let s of this.sharedGameControlGlobals.entitiesWithTransformAnim){(s.hasNonUniformScale?s.matrixWorldRigid:s.matrixWorld).decompose(ti,Kr,Fn),Im.setFromQuaternion(Kr);let n=s;n.prevR===void 0?(n.prevR=Im.clone(),n.prevT=ti.clone()):(n.prevR.copy(Im),n.prevT.copy(ti)),s.rigidBody.setNextKinematicTranslation(ti.divideScalar(this.pixelsPerMeter)),s.rigidBody.setNextKinematicRotation(Kr)}this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),r=!this.updatePositions()&&r}return r}dispatchCollisionEvent(e,t,i){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent,s;if(t.cloner){for(let n of t.cloner.children)if(n.rigidBody===r){s=n;break}}e.dispatch(s),t.dispatchEvent(yv)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=XW.copy(e.matrixWorld).invert();e.traverseEntity((s,n)=>{if(t===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o=new C_(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),l;if(a.data.triggerZone==="box"?l=ct.ColliderDesc.cuboid(...a.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=ct.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),rn.fromArray(a.data.position),Uo.setFromEuler(T_.fromArray(a.data.rotation)),Lm.compose(rn,Uo,D_).premultiply(s.matrixWorld),i?(Lm.decompose(rn,Uo,P_),l.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED)):(Lm.premultiply(r).decompose(rn,Uo,P_),e.rigidBody.bodyType()===ct.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===ct.RigidBodyType.Fixed?l.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ct.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),rn.divideScalar(this.pixelsPerMeter),l.setTranslation(rn.x,rn.y,rn.z),l.setRotation(Uo),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}};function JW(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,n=this._loopCount,a=r===wv;if(e===0)return n===-1?s:a&&(n&1)===1?t-(s-i):s;if(r===k_){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(n===-1&&(e>=0?(n=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=t||s<i){let o=Math.floor((s-i)/(t-i));s-=(t-i)*o,n+=Math.abs(o);let l=this.repetitions-n;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a||(s=e>0?t:i,this.repetitions===1&&(s=t)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(a&&(n&1)===1)return t-(s-i)}return s}var I_=!1,$W=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&s.data.animations&&s.data.animations.forEach((n,a)=>{let o=n[0]+"/";if(Array.isArray(s.identity)?o+=s.identity[0]:o+=s.uuid,this.clipIdToAction[o])return;let l=Wm.parse(JSON.parse(n[2]));s.animations[a]=l;let h=this.mixer.clipAction(l,s);I_===!1&&(Object.getPrototypeOf(h)._updateTime=JW,I_=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new ZL(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(n=>n.uuid===e);if(!r)return;let s=this.clipIdToAction[e];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(n=>n.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=j_}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=wv)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?e/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},Om=new WeakMap,eq=class extends Rv{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new qm(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,n=>{this.decodeDracoFile(n,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(Om.has(e)){let o=Om.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,n=e.byteLength,a=this._getWorker(s,n).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),Om.set(e,{key:i,promise:a}),a}_createGeometry(e){let t=new qe;e.index&&t.setIndex(new Ye(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],s=r.name,n=r.array,a=r.itemSize;t.setAttribute(s,new Ye(n,a))}return t}_loadLibrary(e,t){let i=new qm(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let s=tq.toString(),n=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
6304
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function tq(){let e,t;onmessage=function(a){let o=a.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(d){e.onModuleLoaded=function(c){d({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(d=>{let c=d.draco,u=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,u,p,h),g=f.attributes.map(m=>m.array.buffer);f.index&&g.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},g)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(u)}});break}};function i(a,o,l,h){let d=h.attributeIDs,c=h.attributeTypes,u,p,f=o.GetEncodedGeometryType(l);if(f===a.TRIANGULAR_MESH)u=new a.Mesh,p=o.DecodeBufferToMesh(l,u);else if(f===a.POINT_CLOUD)u=new a.PointCloud,p=o.DecodeBufferToPointCloud(l,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let m in d){let v=self[c[m]],y,x;if(h.useUniqueIDs)x=d[m],y=o.GetAttributeByUniqueId(u,x);else{if(x=o.GetAttributeId(u,a[d[m]]),x===-1)continue;y=o.GetAttribute(u,x)}g.attributes.push(s(a,o,u,m,v,y))}return f===a.TRIANGULAR_MESH&&(g.index=r(a,o,u)),a.destroy(u),g}function r(a,o,l){let h=l.num_faces()*3,d=h*4,c=a._malloc(d);o.GetTrianglesUInt32Array(l,d,c);let u=new Uint32Array(a.HEAPF32.buffer,c,h).slice();return a._free(c),{array:u,itemSize:1}}function s(a,o,l,h,d,c){let u=c.num_components(),p=l.num_points()*u,f=p*d.BYTES_PER_ELEMENT,g=n(a,d),m=a._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,g,f,m);let v=new d(a.HEAPF32.buffer,m,p).slice();return a._free(m),{name:h,array:v,itemSize:u}}function n(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var Kn;function iq(){return Kn||(Kn=new eq,Kn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Kn.decoderPending}async function rq(e){if(Kn){let t={attributeIDs:Kn.defaultAttributeIDs,attributeTypes:Kn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await Kn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function sq(e,t){let[i,r]=xA(hg.deserialize(new Uint8Array(e)));qk(i);let s=[];i.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&s.push(a)}),s.length&&await iq();for(let n of s){let a=await rq(wi(n.geometry.data.draco));if(a){a.index&&(n.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};a.attributes.forEach(({name:l,array:h,itemSize:d})=>{o[l]={array:h,itemSize:d,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=o,n.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var L_=Object.keys(ZM).filter(e=>isNaN(Number(e))),nq=class{constructor(e,t,i,r){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.isEnable=!1,this._isPaused=!1,this.activateCount=0,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=s=>{(s.touches.length>1||this.preventTouchScroll)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.handlers={Spline:new K7(this.eventContext),Conditional:new sW(this.eventContext,this),Start:new CW(this.eventContext,this),Basic:new $7(this.eventContext,this),MouseHover:new _W(this.eventContext,this),Scroll:new MW(this.eventContext,this),Follow:new fW(this.eventContext,this),DragDrop:new hW(this.eventContext,this),LookAt:new xW(this.eventContext)},this.isPaused)return;let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),this.isEnable=!0,e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),L_.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){let{page:e,domElement:t}=this.eventContext;this.isEnable=!1,t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender)}),L_.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this._isPaused}pause(){this._isPaused=!0,this.deactivate()}resume(){this._isPaused=!1,this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnable;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}},aq=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new F().copy(i),this._editorSize=new F().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=oq(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function oq(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var lq=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new D0(e.shared,t),this.scene=new F0(e.scene,this.sharedAssets)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof ra&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof or&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},hq=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 cq(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 $h(e){return e instanceof mc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function dq(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof lr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof lr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!zi.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!zi.isMergable(l.material))return;n=zi.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][$h(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][$h(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][$h(r)].push(l)}),i}function uq(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 pq(e,t){let i=dq(t,e),r=uq(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(m=>{m instanceof lr&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&cq(a[m]);let g=Ba(a.slice(0,o),!1);if(g){let m;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new ir(g,l[0].material);break}default:{m=new ir(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof lr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][$h(x)]&&i[x.material.uuid][$h(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 fq=Pl(NE(),1),mq=new F;function gq(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 ey=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),(this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=mq.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=i0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new hq({x:10,y:10})),TF(e)}async load(e,t){gq(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 sq(e);this._data=i,i.version&&(0,fq.default)(i.version,"0.9.423")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Aw(i)&&Y8(),gG(i)&&W8(),cc.physicsEnabled(i.scene.objects)&&OF(),bw(i)&&iG(),UW(i)&&IF()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new lq(i);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();pq(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}Aw(i)&&this._scene.traverse(n=>{mn(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(n=>{n instanceof is&&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._requestRenderAutoMode()}),bw(i)&&ZW(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),K0(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new WH({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),i.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=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 aq(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"}if(t){let n=new Q7(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new KW(n),this._animationControls=new $W(this._scene,this._requestRenderAutoMode),this._eventManager=new nq(i.scene.publish,this._controls,this._animationControls,n),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Vl&&!(t instanceof ra)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof eE&&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 ar(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(n),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{ix.unsubscribe(e)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),PF(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}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;e.traverseAncestors(s=>{s instanceof ra&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof ra||e instanceof F0?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=ix(i,(s,n)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=n),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var Tp=window,Pp=Tp.ShadowRoot&&(Tp.ShadyCSS===void 0||Tp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ty=Symbol(),tE=new WeakMap,Dc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==ty)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(Pp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=tE.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&tE.set(i,t))}return t}toString(){return this.cssText}},iE=e=>new Dc(typeof e=="string"?e:e+"",void 0,ty),iy=(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 Dc(i,e,ty)},ry=(e,t)=>{Pp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Tp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Dp=Pp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return iE(i)})(e):e;var sy,Ip=window,rE=Ip.trustedTypes,vq=rE?rE.emptyScript:"",sE=Ip.reactiveElementPolyfillSupport,ay={toAttribute(e,t){switch(t){case Boolean:e=e?vq: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}},nE=(e,t)=>t!==e&&(t==t||e==e),ny={attribute:!0,type:String,converter:ay,reflect:!1,hasChanged:nE},Mn=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=ny){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)||ny}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(Dp(s))}else t!==void 0&&i.push(Dp(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 ry(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=ny){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:ay).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:ay;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||nE)(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){}};Mn.finalized=!0,Mn.elementProperties=new Map,Mn.elementStyles=[],Mn.shadowRootOptions={mode:"open"},sE?.({ReactiveElement:Mn}),((sy=Ip.reactiveElementVersions)!==null&&sy!==void 0?sy:Ip.reactiveElementVersions=[]).push("1.6.0");var oy,Lp=window,Yl=Lp.trustedTypes,aE=Yl?Yl.createPolicy("lit-html",{createHTML:e=>e}):void 0,ca=`lit$${(Math.random()+"").slice(9)}$`,pE="?"+ca,yq=`<${pE}>`,Ql=document,Lc=(e="")=>Ql.createComment(e),Oc=e=>e===null||typeof e!="object"&&typeof e!="function",fE=Array.isArray,xq=e=>fE(e)||typeof e?.[Symbol.iterator]=="function",Ic=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,oE=/-->/g,lE=/>/g,ro=RegExp(`>|[
|
|
6304
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function tq(){let e,t;onmessage=function(a){let o=a.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(d){e.onModuleLoaded=function(c){d({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(d=>{let c=d.draco,u=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,u,p,h),g=f.attributes.map(m=>m.array.buffer);f.index&&g.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},g)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(u)}});break}};function i(a,o,l,h){let d=h.attributeIDs,c=h.attributeTypes,u,p,f=o.GetEncodedGeometryType(l);if(f===a.TRIANGULAR_MESH)u=new a.Mesh,p=o.DecodeBufferToMesh(l,u);else if(f===a.POINT_CLOUD)u=new a.PointCloud,p=o.DecodeBufferToPointCloud(l,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let m in d){let v=self[c[m]],y,x;if(h.useUniqueIDs)x=d[m],y=o.GetAttributeByUniqueId(u,x);else{if(x=o.GetAttributeId(u,a[d[m]]),x===-1)continue;y=o.GetAttribute(u,x)}g.attributes.push(s(a,o,u,m,v,y))}return f===a.TRIANGULAR_MESH&&(g.index=r(a,o,u)),a.destroy(u),g}function r(a,o,l){let h=l.num_faces()*3,d=h*4,c=a._malloc(d);o.GetTrianglesUInt32Array(l,d,c);let u=new Uint32Array(a.HEAPF32.buffer,c,h).slice();return a._free(c),{array:u,itemSize:1}}function s(a,o,l,h,d,c){let u=c.num_components(),p=l.num_points()*u,f=p*d.BYTES_PER_ELEMENT,g=n(a,d),m=a._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,g,f,m);let v=new d(a.HEAPF32.buffer,m,p).slice();return a._free(m),{name:h,array:v,itemSize:u}}function n(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var Kn;function iq(){return Kn||(Kn=new eq,Kn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Kn.decoderPending}async function rq(e){if(Kn){let t={attributeIDs:Kn.defaultAttributeIDs,attributeTypes:Kn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await Kn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function sq(e,t){let[i,r]=xA(hg.deserialize(new Uint8Array(e)));qk(i);let s=[];i.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&s.push(a)}),s.length&&await iq();for(let n of s){let a=await rq(wi(n.geometry.data.draco));if(a){a.index&&(n.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};a.attributes.forEach(({name:l,array:h,itemSize:d})=>{o[l]={array:h,itemSize:d,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=o,n.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var L_=Object.keys(ZM).filter(e=>isNaN(Number(e))),nq=class{constructor(e,t,i,r){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.isEnabled=!1,this.activateCount=0,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=s=>{(s.touches.length>1||this.preventTouchScroll)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.handlers={Spline:new K7(this.eventContext),Conditional:new sW(this.eventContext,this),Start:new CW(this.eventContext,this),Basic:new $7(this.eventContext,this),MouseHover:new _W(this.eventContext,this),Scroll:new MW(this.eventContext,this),Follow:new fW(this.eventContext,this),DragDrop:new hW(this.eventContext,this),LookAt:new xW(this.eventContext)};let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),L_.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender)}),L_.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}},aq=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new F().copy(i),this._editorSize=new F().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=oq(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function oq(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var lq=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new D0(e.shared,t),this.scene=new F0(e.scene,this.sharedAssets)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof ra&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof or&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},hq=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 cq(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 $h(e){return e instanceof mc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function dq(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof lr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof lr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!zi.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!zi.isMergable(l.material))return;n=zi.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][$h(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][$h(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][$h(r)].push(l)}),i}function uq(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 pq(e,t){let i=dq(t,e),r=uq(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(m=>{m instanceof lr&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&cq(a[m]);let g=Ba(a.slice(0,o),!1);if(g){let m;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new ir(g,l[0].material);break}default:{m=new ir(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof lr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][$h(x)]&&i[x.material.uuid][$h(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 fq=Pl(NE(),1),mq=new F;function gq(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 ey=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=mq.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=i0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new hq({x:10,y:10})),TF(e)}async load(e,t){gq(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 sq(e);this._data=i,i.version&&(0,fq.default)(i.version,"0.9.424")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Aw(i)&&Y8(),gG(i)&&W8(),cc.physicsEnabled(i.scene.objects)&&OF(),bw(i)&&iG(),UW(i)&&IF()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new lq(i);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let n=performance.now();pq(i,r.scene);let a=performance.now();console.log("Merged geometries in ",a-n," ms")}Aw(i)&&this._scene.traverse(n=>{mn(n)&&n.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(n=>{n instanceof is&&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._requestRenderAutoMode()}),bw(i)&&ZW(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),K0(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new WH({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),i.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.blueNoiseTextureData),this._frameView)this._frameView.setCamera(this._camera);else{let n=Object.values(i.frames)[0];n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=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 aq(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"}if(t){let n=new Q7(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0);this._scene.updateMatrixWorld(!0),this._controls=new KW(n),this._animationControls=new $W(this._scene,this._requestRenderAutoMode),this._eventManager=new nq(i.scene.publish,this._controls,this._animationControls,n),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),this._renderer.setAnimationLoop(this.render)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Vl&&!(t instanceof ra)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof eE&&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 ar(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(n),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{ix.unsubscribe(e)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),PF(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}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;e.traverseAncestors(s=>{s instanceof ra&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof ra||e instanceof F0?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=ix(i,(s,n)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=n),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var Tp=window,Pp=Tp.ShadowRoot&&(Tp.ShadyCSS===void 0||Tp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ty=Symbol(),tE=new WeakMap,Dc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==ty)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(Pp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=tE.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&tE.set(i,t))}return t}toString(){return this.cssText}},iE=e=>new Dc(typeof e=="string"?e:e+"",void 0,ty),iy=(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 Dc(i,e,ty)},ry=(e,t)=>{Pp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Tp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Dp=Pp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return iE(i)})(e):e;var sy,Ip=window,rE=Ip.trustedTypes,vq=rE?rE.emptyScript:"",sE=Ip.reactiveElementPolyfillSupport,ay={toAttribute(e,t){switch(t){case Boolean:e=e?vq: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}},nE=(e,t)=>t!==e&&(t==t||e==e),ny={attribute:!0,type:String,converter:ay,reflect:!1,hasChanged:nE},Mn=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=ny){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)||ny}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(Dp(s))}else t!==void 0&&i.push(Dp(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 ry(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=ny){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:ay).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:ay;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||nE)(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){}};Mn.finalized=!0,Mn.elementProperties=new Map,Mn.elementStyles=[],Mn.shadowRootOptions={mode:"open"},sE?.({ReactiveElement:Mn}),((sy=Ip.reactiveElementVersions)!==null&&sy!==void 0?sy:Ip.reactiveElementVersions=[]).push("1.6.0");var oy,Lp=window,Yl=Lp.trustedTypes,aE=Yl?Yl.createPolicy("lit-html",{createHTML:e=>e}):void 0,ca=`lit$${(Math.random()+"").slice(9)}$`,pE="?"+ca,yq=`<${pE}>`,Ql=document,Lc=(e="")=>Ql.createComment(e),Oc=e=>e===null||typeof e!="object"&&typeof e!="function",fE=Array.isArray,xq=e=>fE(e)||typeof e?.[Symbol.iterator]=="function",Ic=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,oE=/-->/g,lE=/>/g,ro=RegExp(`>|[
|
|
6305
6305
|
\f\r](?:([^\\s"'>=/]+)([
|
|
6306
6306
|
\f\r]*=[
|
|
6307
6307
|
\f\r]*(?:[^
|